Repository navigation
Heap: make minEdenToOldGenerationRatio a JSC option - #332
Conversation
The 1/3 constant in Heap::updateAllocationLimits() schedules a full collection after an eden GC whenever remainingHeapSize / maxHeapSize falls below it. Since maxHeapSize = growthFactor * live and remainingHeapSize is approximately (growthFactor - 1) * live in steady state, this bounds the effective heap growth factor below at 1 / (1 - ratio) = 1.5. Any growth factor under 1.5 promotes every eden GC to full. Exposing it as Options::minEdenToOldGenerationRatio() (same 1/3 default, no behavior change) lets embedders tune the growth factors below 1.5 without inducing full-GC thrash.
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
Comment |
There was a problem hiding this comment.
LGTM — mechanical hoist of a hardcoded constant into a JSC option with an identical default.
What was reviewed:
- Confirmed the new
Options::minEdenToOldGenerationRatio()default (1.0 / 3.0) matches the removed local, so default behavior is unchanged. - Option entry follows the same
v(Double, ..., Normal, ...)pattern as the adjacent heap-growth options inOptionsList.h. - No other references to
minEdenToOldGenerationRatioin the tree; the single call site inHeap::updateAllocationLimits()is the only consumer.
Extended reasoning...
Overview
This PR replaces a hardcoded local constant double minEdenToOldGenerationRatio = 1.0 / 3.0 in Heap::updateAllocationLimits() with a new JSC runtime option Options::minEdenToOldGenerationRatio(). The option is registered in OptionsList.h alongside the other heap-growth tuning knobs (smallHeapGrowthFactor, heapGrowthMaxIncrease, etc.) with the same 1.0 / 3.0 default and a descriptive help string. Two files, three effective lines changed.
Security risks
None. This is a GC scheduling heuristic threshold. The option uses Normal availability, consistent with every neighboring heap-tuning option, and is only settable via the standard JSC_* env / Options:: mechanism before VM finalization. Misconfiguration could only affect GC frequency (perf/RSS), not memory safety or isolation.
Level of scrutiny
Low. This is a textbook constant-to-option hoist with an unchanged default — a pattern used hundreds of times in this exact macro list. The comparison at the call site (edenToOldGenerationRatio < Options::minEdenToOldGenerationRatio()) is semantically identical to the removed code when the option is left at its default. There is no new control flow, no type change, and Options::foo() accessors are trivially inlined reads from the frozen OptionsStorage.
Other factors
- Grep confirms the only two occurrences of
minEdenToOldGenerationRatioare the definition and the single use site — no stale references. - The PR description includes a clear derivation of why the constant matters and benchmark data motivating configurability, but the code change itself does not alter any default.
- The upstream WebKit CODEOWNERS lists
@WebKit/jsc-reviewersfor all ofSource/JavaScriptCore; that is inherited upstream config and applies to essentially every change in this fork, so it is not treated as a per-PR gate here. - No prior reviewer comments to address; the only timeline entry is a CodeRabbit rate-limit notice.
Preview Builds
|
…pdated recommendations With minEdenToOldGenerationRatio exposed (oven-sh/WebKit#332), ratio=0.2 moves the thrash floor from growth-factor 1.5 to 1.25, enabling heapGrowthMaxIncrease=0.5 / smallHeapGrowthFactor=1.5 safely. tsc peak RSS: 1035 MB (current) -> 800 MB (-23%) at +3% wall. Servers: RSS unchanged, no thrash.
|
@claude now that this is merged and the release artifacts have had time to build, please open a PR in oven-sh/bun that bumps |
Adds Options::minEdenToOldGenerationRatio. The default is unchanged so this is behavior-preserving; assigning a non-default value can come separately.
The
1.0 / 3.0constant inHeap::updateAllocationLimits()schedules a full collection after an eden GC wheneverremainingHeapSize / maxHeapSizefalls below it.Since
maxHeapSize = growthFactor * liveandremainingHeapSize ≈ (growthFactor - 1) * livein steady state, the condition reduces to(growthFactor - 1) / growthFactor < ratio, i.e.growthFactor < 1 / (1 - ratio). At the currentratio = 1/3this is 1.5: any proportional heap growth factor below 1.5 promotes every eden GC to a full GC.This makes it an
Options::minEdenToOldGenerationRatio()with the same1.0 / 3.0default, so behavior is unchanged. Lowering it (e.g. to 0.2) drops the growth-factor floor to 1.25, which lets embedders run tighterheapGrowthMaxIncrease/smallHeapGrowthFactorvalues without thrash.Measured on Bun 1.4.0 release, linux-x64, across tsc 5.9,
next build --webpack, and express/fastify/elysia/node:http under load:The cliff between 1.5 and 1.75 is this constant. Full writeup and harness at bench/heap-growth/REPORT.md.