-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Consider using worker threads instead of using spawn. #61
Comments
I think worker threads were added in 11.7 actually, but maybe this can take advantage of https://github.com/josdejong/workerpool which has logic to automatically determine if worker threads are supported and use them for a worker pool or otherwise use child_process. |
after I created #81 and realized there are some breaking changes when use worker_threads, pushed bit more PR to spin up working module https://www.npmjs.com/package/webpack-loader-worker . Would be keen on upstream these changes eventually if there are interests, meanwhile publishing as user land module so anyone can give it a try. |
I wonder if this pool implementation would help? |
I forked the latest version of See malash/thread-loader-issue-61#1 It could 100% work in my Webpack projects, which means no error is emitted when bundling and the output is correct. For better performance I didn't introduce any thread pool library, but only modified the But, when I test it in my large Webpack project, which contains 5k+ modules, I cannot find any performance improvement 😢 , even the This is not a rigorous performance benchmark, and because different Webpack config / project scale / test environments may effect the test result, I advice you to try it in yourselves projects, or create a benchmark. But for now, I don't think it worths to migrate to |
I would think you would need more than 3 workers to see any real difference. |
Also do you warn up? The main problem is not in webpack, webpack is pretty fast in most of cases, babel/sass/tsc are bottlenecks in much of projects, try to remove |
Locally I do some benchmark with multi threading (tried rewrite it on |
@jsg2021 I tried 3 workers, 5 workers and more, and got same result. In fact, as the number of workers increased, the total build time may even increase. As a reference, here is a benchmark result when I enabled |
@alexander-akait Webpack 5
|
@malash Can you profile code? Maybe we can find the slowest places |
@malash The Xeon scenario is more in line with what this loader is for. High-core-count CPUs. Also, If you use more workers than your CPU has cores the perf will go down as you noticed with the i7. (Hyperthreading cores sometimes don't scale the same) The perf may also depend on how your project is arranged. Anyways, IMO, this loader is still valuable and worth improving. |
It's the new feature in node 12.x. Maybe it works in older version with some running arguments.
The text was updated successfully, but these errors were encountered: