-
Notifications
You must be signed in to change notification settings - Fork 10
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
Enhancement: pass data created in threadpool back to main JS thread in zero-copy way #69
Comments
The way to achieve both of these things is to allocation data once and move it into the
Described at mapnik/node-mapnik#531 (comment) |
Note that we ran into malloc errors related to passing buffers back to JS land in mapbox/vtcomposite#19 - it'd be great to get this set up in node-cpp-skel to avoid rewriting the strings into std::unique_ptr! |
Done in #147 |
The #67 talks about a critical optimization when passing data into the threadpool (to do work on it). The corresponding optimization that is equally important is that large data created in the threadpool needs to be efficiently passed back across the boundary from C++ to JS.
Otherwise if the data is large then this hurts performance in the
After
callback (calledHandleOkCallback
when usingNan::AsyncWorker
), which runs on the main event loop. In particular, large copies at this point can trigger expensive allocation and further slow down the main event loop.refs this code:
node-cpp-skel/src/standalone_async/hello_async.cpp
Lines 104 to 113 in 44f8d41
Proposal
Modify node-cpp-skel to return a
node::Buffer
from the threadpool usingnode::Buffer::New
.We'll need to modify the example code to make this logical: we'll need to invent a scenario where a
node::Buffer
would be appropriate. A good example of this is when passing gzip compressed data back from the threadpool.The text was updated successfully, but these errors were encountered: