Uh oh!
There was an error while loading. Please reload this page.
src: use thread defaults provided by v8::platform - #4243
Conversation
By passing `const int thread_pool_size = 0` to `CreateDefaultPlatform` we allow v8 to choose sensible defaults based on the currently online processors.
bnoordhuis
commented
Dec 11, 2015
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. |
jasnell
commented
Dec 11, 2015
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. |
bnoordhuis
commented
Dec 11, 2015
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. |
jasnell
commented
Dec 11, 2015
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? |
jasnell
commented
Dec 12, 2015
Here's one idea: rather than guessing at this, perhaps add a CLI flag to allow the default to be overridden? e.g. |
tomgco
commented
Dec 12, 2015
Sounds like a good idea, however I don’t like having undocumented features. Another approach could be to have an |
jasnell
commented
Dec 16, 2015
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 |
tomgco
commented
Dec 18, 2015
Ok, I am working on this at the moment. |
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>
7da4fd4 to
c7066fbComparefhinkel
commented
Aug 19, 2016
Is this PR still being worked on? ping @tangxinfa |
bnoordhuis
commented
Aug 19, 2016
It's been subsumed by PR #4344. I'll close this one. |
By passing
const int thread_pool_size = 0toCreateDefaultPlatformwe 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.