Skip to content

perf: array forwarding compression, shared add-tree guards, packed shape guards - #8682

Merged
proggeramlug merged 1 commit into
mainfrom
merge/b8
Aug 24, 2026
Merged

perf: array forwarding compression, shared add-tree guards, packed shape guards#8682
proggeramlug merged 1 commit into
mainfrom
merge/b8

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Lands three reviewed PRs as one squash: #8674, #8675, #8676.

Why #8672 is not in this batch

All four were authored as one stack on top of #8672, so each PR head carries #8672's commit. Their contents, however, touch disjoint files, so these three are cherry-picked onto main on their own.

#8672 is held deliberately. It defines its own is_bound_native_method_closure_value, which returns true for any bound native-module export with a non-empty module name. main (via #8662) superseded that with is_bound_native_constructor_closure_value, which returns true only for an actual constructor, gated on explicit constructor metadata:

// p8672                                  // main
bound_native_callable_module_and_method   bound_native_callable_is_constructor_value(value)
  .map(|(module, _)| !module.is_empty())

Different truth sets — main's is strictly narrower. Substituting one for the other is a behavioural change at every call site, not a mechanical rename, so it needs the author's judgment rather than mine.

File-size cap

#8674 pushed array/tests.rs from 1998 to 2034 lines, over the 2000-line gate. Split the growth-forwarding group (install_array_growth_forwarding_* plus the three clean_arr_ptr chain-walk tests) into an array/forwarding_tests.rs sibling, following the existing subclass_tests pattern. Pure relocation.

Validation (on the merged result)

  • 9 ratchet gates + cargo fmt --all --check: pass
  • perry-codegen --lib: 1198 passed, 0 failed (+4)
  • perry-runtime --lib (RUST_TEST_THREADS=1): 2652 passed, 0 failed (+1)
  • Split proven non-vacuous: all 5 relocated tests verified running under array::forwarding_tests::*, crate total unchanged
  • Squashed tree verified byte-identical to the merged tree before push

No version-file changes; three changelog.d/ fragments carried through.

Summary by CodeRabbit

  • Performance Improvements

    • Improved array forwarding-chain resolution by compressing validated multi-step chains for faster indexed access.
    • Optimized numeric execution for dynamic additions involving three or more values while preserving existing behavior for non-numeric values.
    • Reduced overhead for packed direct-method checks through consolidated validation.
  • Reliability

    • Expanded validation and coverage for array growth, forwarding chains, method guards, and dynamic addition behavior.
    • Preserved safeguards against invalid forwarding targets and cycles.

…ape guards

Lands three reviewed PRs as one squash: #8674, #8675, #8676.

- #8674: compress array forwarding chains (`clean_arr_ptr` multi-hop walk).
- #8675: share numeric guards across dynamic add trees.
- #8676: pack monomorphic method shape guards.

These three were authored as a stack on top of #8672, but their contents
touch disjoint files, so they are cherry-picked onto main on their own.
#8672 is NOT included: it defines its own
`is_bound_native_method_closure_value` (true for any bound native-module
export with a non-empty module name), which #8662 superseded on main with
the strictly narrower `is_bound_native_constructor_closure_value` (gated
on explicit constructor metadata). Those predicates have different truth
sets, so the substitution is a behavioural change at every call site and
is left to the author to rebase.

Also splits `array/tests.rs`, which #8674 pushed over the 2000-line cap,
into an `array/forwarding_tests.rs` sibling. Pure relocation.

Version bump not included per maintainer policy.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ee41765-b41c-429c-9983-6daca778b580

📥 Commits

Reviewing files that changed from the base of the PR and between 81ddd46 and 40088b0.

📒 Files selected for processing (12)
  • changelog.d/8674-array-forwarding-path-compression.md
  • changelog.d/8675-dynamic-add-tree-guard.md
  • changelog.d/8676-packed-method-shape-guard.md
  • crates/perry-codegen/src/collectors/proven_this_routing_tests.rs
  • crates/perry-codegen/src/expr/binary.rs
  • crates/perry-codegen/src/expr/dynamic_add_tree_tests.rs
  • crates/perry-codegen/src/expr/mod.rs
  • crates/perry-codegen/src/lower_call/method_override.rs
  • crates/perry-runtime/src/array/forwarding_tests.rs
  • crates/perry-runtime/src/array/header.rs
  • crates/perry-runtime/src/array/mod.rs
  • crates/perry-runtime/src/array/tests.rs

📝 Walkthrough

Walkthrough

Changes

The PR adds three performance changes: array forwarding-chain compression, shared numeric guards for dynamic addition trees, and packed method-shape validation. Each change includes focused tests or updated assertions and a performance changelog entry.

Array forwarding compression

Layer / File(s) Summary
Forwarding resolution and validation
crates/perry-runtime/src/array/header.rs, crates/perry-runtime/src/array/forwarding_tests.rs, crates/perry-runtime/src/array/tests.rs, crates/perry-runtime/src/array/mod.rs, changelog.d/8674-array-forwarding-path-compression.md
clean_arr_ptr compresses validated multi-hop forwarding chains. Tests cover growth, injected headers, cycles, untracked targets, and chain compression. Existing comments and assertions describe the compressed path.

Dynamic addition tree lowering

Layer / File(s) Summary
Shared guarded addition lowering
crates/perry-codegen/src/expr/binary.rs, crates/perry-codegen/src/expr/dynamic_add_tree_tests.rs, crates/perry-codegen/src/expr/mod.rs, changelog.d/8675-dynamic-add-tree-guard.md
Dynamic + trees with at least three leaves use one shared numeric guard when safe. Tests verify floating-point fast paths, dynamic fallback calls, and direct dispatch for two-leaf trees.

Packed method-shape guards

Layer / File(s) Summary
Packed header guard validation
crates/perry-codegen/src/lower_call/method_override.rs, crates/perry-codegen/src/collectors/proven_this_routing_tests.rs, changelog.d/8676-packed-method-shape-guard.md
Method guards use masked packed header checks and packed class/ShapeId comparisons. Tests verify GC masks, little-endian field layout, and updated inline guard assertions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: thehypnoo, jdalton

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch merge/b8

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.

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