-
-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for running inside a node 10.5 worker_thread #1007
Conversation
Very cool, thanks for putting up this PR. So, this enables node-sqlite3 to be used from a native node.js thread started via the new I'm interested to hear more about what usecases you'll use this for. Also, as someone on the bleeding edge of |
Yes. This PR makes it safe to use in a multithreaded context using node's new experimental worker threads feature. It does not introduce new APIs to enable sharing of connections in serialized mode between worker threads or to reduce overhead via sqlite's shared cache feature, but perhaps this could be explored in the future. My basis for comparison is an existing worker implementation on top of If you are aware of benchmarks showing the overhead of JS worker threads vs C++ native modules with background threads, that would be very interesting though not directly relevant to the project that led to this PR. |
I'll be interested to know if that expectation is met. One thing that could negatively impact the performance, when run inside a
Got it, none that I'm aware of which is why I created mapbox/node-cpp-skel#143 |
Noticing that the only failure for this PR is unrelated (coverage build failed). So, merging now. This will likely land in v4.0.2 (when I cut it, but I don't have an ETA on that). |
Unfortunately, I didn't do my due diligence and actually test with multiple workers. When I did so, it uncovered some additional adjustments that needed to be made. It also uncovered a bug in the way node's native module support interacts with In the meantime, the performance script is available here: https://gist.github.com/rpetrich/2e49540a26e1e6e0dc2c57252b8a562c. It will require rpetrich/node-sqlite3@020a0eb and rpetrich/node@ffdc0c0 |
Thanks for the followup. I'll revert then for now until this has a chance to settle out. |
Could you inform me if the upstream bug has been resolved or not? |
Properly tracks which event loop callbacks should be dispatched on so that node doesn't busy loop on the main thread if node-sqlite3 is called from a worker.