Repository navigation
Tags
Tags
libexpr: adaptively absorb comparably-sized overlays instead of stack… …ing layers The shouldLayer path previously always stacked a new thin layer per `//`-merge. A run of similarly-sized overlays (e.g. a module-system-style accumulation) grew the chain by one layer each time, making a later full iteration (attrNames, etc.) pay for walking the whole chain via the k-way merge instead of a flat array. Bindings::tryAbsorb folds a new overlay into the existing top layer's own attrs when they're comparably sized (within absorbRatio, 2x either way), instead of stacking. This bounds chain depth logarithmically rather than linearly in the number of merges, with no fixed depth cutoff. absorbRatio=4 was measured first: on real workloads it cost roughly double the memory of absorbRatio=2 for only a marginally bigger CPU win on synthetic chain-heavy benchmarks, so 2 is what's used here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PreviousNext