GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: use thread defaults provided by v8::platform by tomgco · Pull Request #4243 · nodejs/node

Conversation

@tomgco

@tomgco tomgco commented Dec 11, 2015

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tomgco
src: use thread defaults provided by v8::platform
ac6bb44
By passing `const int thread_pool_size = 0` to `CreateDefaultPlatform`
we allow v8 to choose sensible defaults based on the currently online
processors.
@r-52 r-52 added the c++ Issues and PRs that require attention from people who are familiar with C++. label Dec 11, 2015
@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Dec 11, 2015
@bnoordhuis

bnoordhuis commented Dec 11, 2015

Copy link
Copy Markdown
Member

I have no real opinion on whether this is better or worse but for background, the reason I chose 4 is that:

  1. I guesstimated that the average machine has 8 cores, and
  2. libuv's thread pool is also 4 threads big by default.

(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:

  1. Have a lot of functions that get promoted to the optimized tier around the same time, and
  2. Execute a decent number of (asynchronous) file-based operations, like writing numerous small chunks to a bunch of on-disk files.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Dec 11, 2015

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Dec 11, 2015

Copy link
Copy Markdown
Member

How aggressive is V8 at consuming the available cores when the default is set to 0?

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Dec 11, 2015

Copy link
Copy Markdown
Member

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Dec 12, 2015

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tomgco

tomgco commented Dec 12, 2015

Copy link
Copy Markdown
Contributor Author

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.

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Dec 16, 2015

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tomgco

tomgco commented Dec 18, 2015

Copy link
Copy Markdown
Contributor Author

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.

Ok, I am working on this at the moment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tomgco tomgco mentioned this pull request Dec 18, 2015
src: override v8 thread defaults using cli options #4344
Closed
@Trott
Trott force-pushed the master branch from 1e896a6 to 082cc8d Compare December 27, 2015 02:01
tomgco added a commit to tomgco/node that referenced this pull request Mar 22, 2016
@tomgco
src: override v8 thread defaults using cli options
010d2e4
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.
jasnell pushed a commit that referenced this pull request Mar 22, 2016
@tomgco @jasnell
src: override v8 thread defaults using cli options
03e07d3
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 <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 30, 2016
@tomgco @evanlucas
src: override v8 thread defaults using cli options
3f6fbaf
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 <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
@tomgco @evanlucas
src: override v8 thread defaults using cli options
0d0c57f
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 <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@estliberitas
estliberitas force-pushed the master branch 2 times, most recently from 7da4fd4 to c7066fb Compare April 26, 2016 05:22
@fhinkel

fhinkel commented Aug 19, 2016

Copy link
Copy Markdown
Contributor

Is this PR still being worked on?

ping @tangxinfa

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Aug 19, 2016

Copy link
Copy Markdown
Member

It's been subsumed by PR #4344. I'll close this one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis bnoordhuis closed this Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@tomgco @bnoordhuis @jasnell @fhinkel @mscdex @r-52
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.