Compute two-sided, heap-aware budgets for the L0 / L1 / S-cache tiers.
Allocation (when the heap is known):
pool = heap × targetHeapUsage × CACHE_SHARE_OF_TARGET
sliceMin= clamp(pool × SLICE_MIN_FRACTION, SLICE_ABS_MIN, sliceConfig) // heap-relative floor
L0, L1 = their config ceilings, scaled DOWN proportionally only if
(pool − sliceMin) cannot seat both — render-proximal priority:
the S-cache floor is protected first, the chunk caches shrink.
slice = clamp(pool − L0 − L1, sliceMin, SLICE_CAP) // residual → scales UP
Param: heapLimitBytes
Override for the device heap limit (tests). When
omitted, readHeapLimitBytes is consulted.
Param: poolOverrideBytes
Explicit total cache pool (L0+L1+S-cache) in bytes,
from ?cacheBudgetMB= or the native launcher. Takes precedence over the
heap: this is how the WKWebView app / Safari (no performance.memory) still
get a real budget instead of the tiny fixed fallback. Split across tiers by
the same rule as the heap path.
Param: fallbackPoolBytes
Total pool to use when there is NO explicit override
AND no measurable heap — typically deviceClassPoolBytes. Lets WebKit
without an override still get a device-class-appropriate budget rather than
the tiny fixed sizes.
Which tiers are actually active this session. A disabled tier
gets a 0 budget and does NOT reserve any pool: e.g. ?noSliceCache frees
the S-cache floor back to the chunk caches, and disabling L0 gives its share
to the S-cache. Defaults to all enabled (identical to the pre-flag behavior).
Compute two-sided, heap-aware budgets for the L0 / L1 / S-cache tiers.
Allocation (when the heap is known): pool = heap × targetHeapUsage × CACHE_SHARE_OF_TARGET sliceMin= clamp(pool × SLICE_MIN_FRACTION, SLICE_ABS_MIN, sliceConfig) // heap-relative floor L0, L1 = their config ceilings, scaled DOWN proportionally only if (pool − sliceMin) cannot seat both — render-proximal priority: the S-cache floor is protected first, the chunk caches shrink. slice = clamp(pool − L0 − L1, sliceMin, SLICE_CAP) // residual → scales UP
Param: heapLimitBytes
Override for the device heap limit (tests). When omitted, readHeapLimitBytes is consulted.
Param: poolOverrideBytes
Explicit total cache pool (L0+L1+S-cache) in bytes, from
?cacheBudgetMB=or the native launcher. Takes precedence over the heap: this is how the WKWebView app / Safari (noperformance.memory) still get a real budget instead of the tiny fixed fallback. Split across tiers by the same rule as the heap path.Param: fallbackPoolBytes
Total pool to use when there is NO explicit override AND no measurable heap — typically deviceClassPoolBytes. Lets WebKit without an override still get a device-class-appropriate budget rather than the tiny fixed sizes.
Resolution order: explicit override → measured heap → device-class fallback → fixed config sizes (
source: 'fixed', e.g. non-browser / no device signals).Param: enabled
Which tiers are actually active this session. A disabled tier gets a 0 budget and does NOT reserve any pool: e.g.
?noSliceCachefrees the S-cache floor back to the chunk caches, and disabling L0 gives its share to the S-cache. Defaults to all enabled (identical to the pre-flag behavior).