-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature Request: Support Worker Threads using Sharp #1558
Comments
Hello, sharp uses nan's Having said that I'd be happy to accept a PR that does this as long as it remains fairly simple and has tests. The lzo example does not appear to use libuv worker threads where sharp does so may not be a complete enough example. The "context-aware addon carries with it the responsibility of carefully managing global static data" warning of https://nodejs.org/api/addons.html#addons_context_aware_addons is relevant here too. |
Is it worth still using nan or shifting to N-API? |
Please see #1282 for N-API. |
FYI for how iltorb does it: https://github.com/MayhemYDG/iltorb/blob/master/src/iltorb.cc#L7-L19 |
There's a discussion about adding this logic to nan at nodejs/nan#844 |
+1. I am still suffering from some non-heap leakage at heroku for over a year now. EDIT: |
I can user sharp in Worker Threads (sharp:v0.22.1,node:v10.15.3). |
Commit 946d3c8 makes the switch to use the new I've flagged this as experimental in the changelog as although both sharp and libvips are very much thread-aware, this probably requires testing at scale before use in production. |
sharp v0.23.0 is now available. |
Hi, My current solution is to spawn more Node.js process, but threads would be lighter. I don't want to bug my user to set |
@MarcusCemes worker threads all share the same thread pool, you can't much about it. You could try to use N workers, and in each worker set sharp concurrency to 1, but I don't think the performance would be better. |
canvas does not support being loaded in worker threads due to it being a native dependency that was not written using a thread-compatible API. sharp, on the other hand, is thread-aware: lovell/sharp#1558.
canvas does not support being loaded in worker threads due to it being a native dependency that was not written using a thread-compatible API. sharp, on the other hand, is thread-aware: lovell/sharp#1558.
@lovell While I have read how Sharp itself would not benefit from worker threads in #1297, I am using Sharp alongside some CPU-intensive JS programming that certainly would benefit from being in a worker thread.
nodejs/node#21481 explains the issue, and at the bottom is a reference to how it was solved in node-lzo
The text was updated successfully, but these errors were encountered: