| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
By passing `const int thread_pool_size = 0` to `CreateDefaultPlatform` we allow v8 to choose sensible defaults based on the currently online processors.
|
I have no real opinion on whether this is better or worse but for background, the reason I chose 4 is that:
(4 + 4 technically actually overcommits because of the main thread but a little overcommit seems like a decent trade-off vs. under-utilization.) One glorious day we'll be able to service libuv and V8 from a single thread pool but until then, we need to strike a balance that doesn't starve one or the other. Aside, the way to benchmark this is to:
Those combined will overload both thread pools to the point that they need to queue up work items and then it's a matter of measuring throughput and latency. Aside aside, as a stop-gap measure we could tweak node to divide the cores between the two thread pools at start-up. |
Sorry, something went wrong.
|
How aggressive is V8 at consuming the available cores when the default is set to 0? I definitely think that we should look at benchmarking this more before making changes here. |
Sorry, something went wrong.
It varies. V8 allocates up to three threads for concurrent sweeping; any remaining threads are used for concurrent recompilation and on-stack replacement. It depends on the performance profile of the application whether those threads have work to do. |
Sorry, something went wrong.
|
Would it be possible / desirable to run benchmarks across machines with variable numbers of cores and use that to determine a more algorithmic way of determining the reasonable defaults? |
Sorry, something went wrong.
|
Here's one idea: rather than guessing at this, perhaps add a CLI flag to allow the default to be overridden? e.g. node --v8-default-thread-pool-size=0. The flag would likely not be used extensively so we could just add it to the man page but omit it from the node --help output. Having it would allow someone to go through and experiment with benchmarks using different values to figure out what is optimum. |
Sorry, something went wrong.
Sounds like a good idea, however I don’t like having undocumented features. Another approach could be to have an --advanced-options flag, much like we currently have for --v8-options and include --v8-default-thread-pool-size=0 under that? |
Sorry, something went wrong.
|
That's certainly a possibility but not sure it's ideal until we have more than one flag that would fall under that kind of category. Adding it to the --help output would be fine. |
Sorry, something went wrong.
Ok, I am working on this at the moment. |
Sorry, something went wrong.
Based on the conversation in nodejs#4243 this implements a way to increase and decrease the size of the thread pool used in v8. Currently v8 restricts the thread pool size to `kMaxThreadPoolSize` which at this commit is (4). So it is only possible to decrease the thread pool size at the time of this commit. However with changes upstream this could change at a later date. If set to 0 then v8 would choose an appropriate size of the thread pool based on the number of online processors.
Based on the conversation in #4243 this implements a way to increase and decrease the size of the thread pool used in v8. Currently v8 restricts the thread pool size to `kMaxThreadPoolSize` which at this commit is (4). So it is only possible to decrease the thread pool size at the time of this commit. However with changes upstream this could change at a later date. If set to 0 then v8 would choose an appropriate size of the thread pool based on the number of online processors. PR-URL: #4344 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Based on the conversation in #4243 this implements a way to increase and decrease the size of the thread pool used in v8. Currently v8 restricts the thread pool size to `kMaxThreadPoolSize` which at this commit is (4). So it is only possible to decrease the thread pool size at the time of this commit. However with changes upstream this could change at a later date. If set to 0 then v8 would choose an appropriate size of the thread pool based on the number of online processors. PR-URL: #4344 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Based on the conversation in #4243 this implements a way to increase and decrease the size of the thread pool used in v8. Currently v8 restricts the thread pool size to `kMaxThreadPoolSize` which at this commit is (4). So it is only possible to decrease the thread pool size at the time of this commit. However with changes upstream this could change at a later date. If set to 0 then v8 would choose an appropriate size of the thread pool based on the number of online processors. PR-URL: #4344 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
|
Is this PR still being worked on? ping @tangxinfa |
Sorry, something went wrong.
|
It's been subsumed by PR #4344. I'll close this one. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
By passing const int thread_pool_size = 0 to CreateDefaultPlatform
we allow v8 to choose sensible defaults based on the currently online
processors.
Benchmarking on my local machine saw no performance regressions; however it is dual core and hyper-threaded and would of used the same thread count as previously - I assume that this will benefit machines with more online processors; however I am curious if this would affect machines with only one core.