Commit 09c3895
committed
Pin per-isolate heap limit to V8 flags
Keep per-isolate heap limits in sync with the process-wide V8 --max-old-space-size and tune heap sizing for Next.js workloads. Changes include:
- Extract compute_old_space_cap_mb(...) and add SINGLE_WORKER_HARD_OLD_SPACE_CAP_MB to compute per-isolate old-space caps with dedicated single-worker behaviour.
- Adjust adaptive_per_isolate_heap_mb bands to larger values for realistic Next.js working sets.
- Wire a process-wide EFFECTIVE_HEAP_LIMIT (OnceLock<HeapLimitConfig>) seeded in apply_v8_flags and expose effective_heap_limit() to read it.
- Resolve per-isolate HeapLimitConfig from env or computed cap via resolve_effective_heap_limit and set it as the default used when booting V8 isolates.
- Apply the heap limit to new V8 BootContext instances (with_heap_limit calls) in dispatcher and engine pump so isolate.create_params().heap_limits(...) matches the V8 flag.
- Update and add tests to assert the new cap computations and resolution behaviour.
Motivation: prevent mismatches where the V8 process flag permits a larger old-space than each isolate's hard cap, which previously caused "Reached heap limit" aborts on real Next.js workloads; and provide more appropriate sizing for dedicated single-worker pods.1 parent c393279 commit 09c3895
5 files changed
Lines changed: 268 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| |||
0 commit comments