Conversation
The V8 platform currently creates the configured worker threads and a dedicated libuv loop for delayed tasks during Node.js bootstrap, then waits for those workers to become ready. Short-lived processes often never post background work, so this wastes startup time and RSS. Start workers as tasks are posted, up to the configured pool size, and create the delayed-task loop only when a delayed task is first scheduled. NumberOfWorkerThreads() now reports the configured size instead of the number of already-started threads (which previously included the scheduler thread). Assisted-by: Cursor Grok 4.6 Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
Member
Author
|
Closing: A/B numbers show no startup, RSS, or thread-count win. V8 still starts the platform workers and delayed-task loop during isolate init. Will look for a change that actually moves those metrics. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This stops
NodePlatformfrom creating the V8 worker pool and the delayed-task libuv loop during bootstrap, then blocking until those workers are ready.Workers are started as tasks are posted, up to
--v8-pool-size. The delayed-task loop is started only when a delayed worker task is first scheduled.NumberOfWorkerThreads()now returns the configured pool size. It previously returnedstarted threads, which included the scheduler thread.V8 still posts compile and GC jobs during isolate initialization (
OptimizingCompileTaskExecutor, concurrent baseline/maglev, scavenger,MemoryPool::PostDelayedReleaseTask). A defaultnode -eprocess therefore still ends up with 4node-V8Workerthreads plusDelayedTaskSchedulerWorker. The libuv FS/DNS/crypto pool (UV_THREADPOOL_SIZE) is unchanged.Benchmarks
A/B on the same machine, same
configureflags (--ninja --without-intl --without-npm --without-node-snapshot --without-node-code-cache --v8-disable-temporal-support). Onlysrc/node_platform.{cc,h}differs. Snapshot-less startup is slower than a production build; the comparison is relative.benchmark/misc/startup-core.js(ops/sec, higher is better)empty.mjsmode=processn=30semicolon.jsmode=processn=30require-builtins.jsmode=processn=30Wall-clock spawn (n=40, warmup=5, lower is better)
benchmark/fixtures/empty.mjstest/fixtures/semicolon.jsnode -e ''Threads and RSS after user JS starts (
/proc/self/status)node-MainThread, 4×node-V8Worker,DelayedTaskSchedulerWorker,SignalInspectorStartup and RSS are within noise. Steady-state thread count is unchanged because V8 posts platform jobs during isolate init. The remaining effects are: no constructor barrier, on-demand creation for embedders that do not immediately initialize an isolate, and a correct worker-count for
CreateJob.Tests
cctest --gtest_filter=PlatformTest.Lazy*passedtest/parallel/test-v8-platform-lazy-workers.jspassedtest/parallel/test-v8-flag-pool-size-0.jspassed