Skip to content

docs: explain vm pool worker recycling cost - #10855

Merged
sheremet-va merged 3 commits into
mainfrom
docs/vm-pool-worker-recycling
Aug 4, 2026
Merged

sheremet-va merged 3 commits into
mainfrom
docs/vm-pool-worker-recycling

Conversation

@sheremet-va

Copy link
Copy Markdown
Member

Documents why worker recycling is expensive in the vmThreads pool and cheap in vmForks, and expands vmMemoryLimit with the trade-off between a low and a high limit.

Background: profiling a large jsdom suite (zammad, 638 files) showed that when workers hit the default vmMemoryLimit (total memory / maxWorkers), vmThreads pays a full garbage collection over the dying worker's heap inside the shared process. Thread stack samples showed 5-6 workers blocked in Isolate::Deinit -> MarkCompact for 15+ seconds each while the process-shared V8 background threads were saturated with marking work, starving live workers. vmForks recycles by process exit, which the kernel reclaims in O(1); the same suite ran 130s on vmForks vs 235s on vmThreads. Raising the limit so recycling never happens made both pools slower, so recycling is necessary and the difference between the pools is the cost per recycle.

Also corrects the documented vmMemoryLimit default: it is 1 / maxWorkers, not 1 / CPU Cores.

@netlify

netlify Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 95b665f
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a71ec7a4f3b0f00082fca2c
😎 Deploy Preview https://deploy-preview-10855--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread docs/config/pool.md Resolved
@sheremet-va

Copy link
Copy Markdown
Member Author

Very relevant observation I found when working on vmThreads/vmForks difference on a large suite (~600 test files)

macarie
macarie previously approved these changes Jul 31, 2026
Comment thread docs/config/vmmemorylimit.md Resolved
Co-authored-by: Raul Macarie <raul@macarie.me>
@sheremet-va
sheremet-va merged commit 96e40fe into main Aug 4, 2026
13 checks passed
@sheremet-va
sheremet-va deleted the docs/vm-pool-worker-recycling branch August 4, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants