Skip to content

Commit 09c3895

Browse files
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

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
]
88

99
[workspace.package]
10-
version = "0.1.27"
10+
version = "0.1.28"
1111
edition = "2024"
1212
license = "MIT OR Apache-2.0"
1313
publish = false

crates/nexide/src/dispatch/dispatcher.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ async fn run_worker(
275275
.with_cjs(resolver)
276276
.with_cjs_root(ROOT_PARENT)
277277
.with_fs(crate::ops::FsHandle::real(vec![project_root]))
278-
.with_process(ProcessConfig::builder(Arc::new(OsEnv)).build());
278+
.with_process(ProcessConfig::builder(Arc::new(OsEnv)).build())
279+
.with_heap_limit(crate::effective_heap_limit());
279280

280281
let mut engine = match V8Engine::boot_with(&entrypoint, ctx).await {
281282
Ok(engine) => {

0 commit comments

Comments
 (0)