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: handling v8 thread pool of zero by daeyeon · Pull Request #42524 · nodejs/node

Conversation

@daeyeon

@daeyeon daeyeon commented Mar 30, 2022

Copy link
Copy Markdown
Member

Resolved: #42523

Problem:

If no platform worker exists, Node.js doesn't shut down when background
tasks scheduled exist. It keeps waiting in NodePlatform::DrainTasks.

Observation:

It seems that Node.js used V8's DefaultPlatform implementation a long
time ago, which chooses a suitable default value in case --v8-pool-size=0
is given as a command-line option. However, Node.js currently uses its
own v8::Platform implementation, NodePlatform. It seems not to have
the logic to handle the case.

I referred to #4344 to track the issue.

Sorry, something went wrong.

Uh oh!

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

bricss reacted with eyes emoji
All reactions
  • 👀 1 reaction
@daeyeon
src: handling v8 thread pool of zero
9fd2df7
fix: nodejs#42523

Problem:
If no platform worker exists, Node.js doesn't shut down when background
tasks exist. It keeps waiting in `NodePlatform::DrainTasks`.

Observation:
It seems that Node.js used to use V8's `DefaultPlatform` implementation,
which chooses a suitable default value in case that `--v8-pool-size=0`
is given as a command-line option. However, Node.js currently uses its
own v8::Platform implementation, `NodePlatform`. It doesn't have the
logic to handle the case.

I referred to nodejs#4344 to track the issue.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Mar 30, 2022
@daeyeon
doc: fix lint-md ci error
182a83f
bnoordhuis
bnoordhuis reviewed Mar 30, 2022
View reviewed changes
Comment thread src/node_platform.cc
Comment on lines +53 to +57
if (uv_cpu_info(&cpu_info, &count) == 0) {
uv_free_cpu_info(cpu_info, count);
thread_pool_size = count - 1;
}
}

@bnoordhuis bnoordhuis Mar 30, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest waiting for the upgrade to libuv 1.44 and replacing this with uv_available_parallelism(), it's specifically for use cases such as this one.

uv_cpu_info() isn't really appropriate because it doesn't know how many processors are available to the process, only how many are online.

Sorry, something went wrong.

Uh oh!

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

All reactions

@daeyeon daeyeon Mar 31, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv_available_parallelism() looks more suited to this case indeed. I'll wait for the upgrade to land.

Sorry, something went wrong.

Uh oh!

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

All reactions
@Trott
Trott force-pushed the main branch from 2d76238 to ca3ed36 Compare November 12, 2022 01:49
@daeyeon daeyeon mentioned this pull request Nov 19, 2022
src: set an appropriate thread pool size if given --v8-pool-size=0 #45513
Merged
@daeyeon daeyeon closed this Nov 21, 2022
@daeyeon
daeyeon deleted the master.node-220330.Wed-20.01 branch November 21, 2022 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis left review comments

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++. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Run worker threads with --v8-pool-size=0

Uh oh!

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

3 participants

@daeyeon @bnoordhuis @nodejs-github-bot
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.