-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Returning an array from thread #15
Comments
Hey Deema! Did you use https://github.com/andywer/threads.js#transferable-objects? Passing large arrays is by default very slow, since the whole array is copied when sending messages between the threads. But you can explicitly transfer the ownership of an array to the other thread when sending data to it (see link). This is much faster, but the sending thread cannot access the array anymore until the other thread gives the array ownership back. |
I forgot to ask: Are you working in a browser or a node.js setting? |
@andywer in node. In browser it does not seem to be an issue. |
Yeah, my suggested approach was also browser-related... I don't have a Node.js solution by hand right now. The best I could come up with when googling it was this: audreyt/node-webworker-threads#58 But that issue seems quite dead... |
Closing for now. This is a rather tough one. Might be easy to fix once node supports web workers (nodejs/node#13143). |
Hi @andywer!
An issue actually related with audreyt/node-webworker-threads#99.
I tried both webworker-threads and threads libs to implement multithreading in nogl-shader-output, and both packages get very slow at returning an array from threads. It takes 800ms on my laptop to return 300×300 array from the thread.
Whether something I don’t know or is there a way to speed things up?
Thank you.
The text was updated successfully, but these errors were encountered: