-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: add option to set cpu affinity of mainthread #44459
base: main
Are you sure you want to change the base?
src: add option to set cpu affinity of mainthread #44459
Conversation
Add runtime option '--set-mainthread-cpu-affinity' to pin the mainthread to the current running cpu before entering event loop. This feature is implemented on Linux OS currently. Enabling this option will benefit node.js applications running on heavy-workload system and can increase performance for several node.js benchmarks, ex., several cases in benchmark/vm/ improved by 40%.
I feel like something like this should be implemented by libuv instead and then node can call out to the libuv API for setting this sort of thing. |
@mscdex The main thread is not created by libuv API, and it might be better to keep this simple feature in node instead of libuv. |
libuv is generally where the platform-specific bits get abstracted away, allowing node to escape ifdef hell. Changing the affinity should work cross-platform whether we're changing it for a |
Since CPU affinities are inherited across threads, and this affects the main thread on startup, this seems like it's just adding the functionality of |
|
@qdaoming-intel If that’s the concern, then I’d also recommend putting a cross-platform API for this into libuv, and then maybe even just exposing it as a regular JS API in Node.js? |
@addaleax @mscdex One question about modifying libuv code: |
@qdaoming-intel The process starts by submitting a PR to the libuv repo. |
Add runtime option '--set-mainthread-cpu-affinity' to pin the
mainthread to the current running cpu before entering event loop.
This feature is implemented on Linux OS currently.
Enabling this option will benefit node.js applications running on
heavy-workload system and can increase performance for several
node.js benchmarks, ex., several cases in benchmark/vm/ improved
by 40%.