Skip to content

perf: share boxed closure capture layouts by function - #11177

Closed
proggeramlug wants to merge 2 commits into
mainfrom
perf/closure-box-layout
Closed

proggeramlug wants to merge 2 commits into
mainfrom
perf/closure-box-layout

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Closure creation currently stores a per-instance list of boxed capture slots and repeats lifetime bookkeeping for every slot. This change emits a constant bitmap for each compiled function and registers all its boxed captures in one call. Runtime instances retain only a weak owner address; marking, cloning, relocation and death pruning read the cells from the closure payload.

Per-box reference counts remain necessary for frame/async release. The old setter remains available for dynamic runtime callers, with a fallback to exact edges when a shared-layout closure is modified. Fresh boxed closures also use the existing bulk capture initializer.

Validation:

  • 71 runtime box/closure tests and 24 compiler tests passed (release lowering, wide bitmap emission, and GC call effects).
  • Fresh compiler plus runtime/stdlib static archives: the new wide/async fixture and two existing capture regressions match Node 26.5.1.
  • Forced evacuation plus verification: the new fixture matches Node; three copying minors ran, with 5,514 objects copied in the first.
  • Formatting, file-size, address-classification, GC root-holder, Node-version consistency, and root-dominance self-checks passed.

No version bump. This removes the per-closure edge-list allocation/storage on generated paths; no end-to-end performance percentage is claimed.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 55 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 701a1b5e-279c-4df2-aade-767dca93da9c

📥 Commits

Reviewing files that changed from the base of the PR and between c7d0963 and c41b000.

📒 Files selected for processing (17)
  • changelog.d/11177-closure-box-layout.md
  • crates/perry-codegen/src/expr/closure.rs
  • crates/perry-codegen/src/expr/mod.rs
  • crates/perry-codegen/src/gc_call_effects.rs
  • crates/perry-codegen/src/root_reload.rs
  • crates/perry-codegen/src/runtime_decls/strings.rs
  • crates/perry-codegen/src/stmt/boxed_frame_release_tests.rs
  • crates/perry-codegen/tests/native_proof_regressions.rs
  • crates/perry-codegen/tests/release_boxes_lowering.rs
  • crates/perry-runtime/src/box.rs
  • crates/perry-runtime/src/closure/alloc.rs
  • crates/perry-runtime/src/closure/box_captures.rs
  • crates/perry-runtime/src/closure/box_layout.rs
  • crates/perry-runtime/src/closure/mod.rs
  • scripts/check_runtime_symbols.sh
  • scripts/gc_root_dominance_check.py
  • test-files/test_gap_closure_shared_box_layout.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Merge queue: neither red on this run is yours.

No action needed unless the re-run fails again. If you're about to push anyway, that also clears the custody failure.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Superseded by the scope-context implementation from #11179, already landed on main in e6b897e . Closing the obsolete predecessor as directed by the merge-queue runbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant