perf(runtime): gate dynamic-index collection probes by GcHeader (#7865) - #7880
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDynamic index reads and writes use receiver GC metadata to select Map or Set registry probes. Raw-I64 receivers undergo managed-membership validation before header access. Tests verify array bypass, registry selection, and rejection of unmapped receivers. ChangesDynamic index dispatch
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DynIndex
participant GCMetadata
participant CollectionRegistry
DynIndex->>GCMetadata: Validate receiver and read GC tag
GCMetadata-->>DynIndex: Receiver GC tag and flags
DynIndex->>CollectionRegistry: Probe matching Map or Set registry
CollectionRegistry-->>DynIndex: Confirm collection ownership
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry-runtime/src/value/dyn_index.rs`:
- Around line 594-597: Move the raw-pointer validity check in js_dyn_index_set
ahead of the receiver_gc_tag call, rejecting unmapped legacy raw-I64 addresses
before any GC-header read. Preserve the existing collection-tag handling after
validation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 675fd78a-2e66-443b-9a1f-53c4703e05d4
📒 Files selected for processing (3)
changelog.d/7880-dyn-index-header-gates.mdcrates/perry-runtime/src/value/dyn_index.rscrates/perry-runtime/src/value/dyn_index_collection_tag_tests.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/perry-runtime/src/value/dyn_index_collection_tag_tests.rs`:
- Around line 61-81: Extend the test-only instrumentation in receiver_gc_tag
with a GC-header-read counter, incrementing it only when the header is actually
accessed. Update unmapped_legacy_raw_i64_is_rejected_before_the_gc_header_read
to invoke both js_dyn_index_get and js_dyn_index_set, while retaining the
probes() assertion and asserting the new counter remains zero after each
dispatch.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 75b630d8-7cac-4301-8723-64b0001702f3
📒 Files selected for processing (2)
crates/perry-runtime/src/value/dyn_index.rscrates/perry-runtime/src/value/dyn_index_collection_tag_tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/perry-runtime/src/value/dyn_index.rs
Summary
Reproduction
With both collection registries armed, the regression test failed before the implementation because three plain-array dynamic index operations moved the Map/Set probe counts from
(0, 0)to(3, 3). It passes with both counters unchanged after the header gate.Validation
RUST_TEST_THREADS=1 cargo test -p perry-runtime --lib: 2,127 passed, 4 ignored, 0 failedPerformance
Quiet M1 mini, lock held, alternating A/B order:
bench/interp.ts, 7 pairs and 3 executions per cell: baseline 3.32 s wall / 3.30 s user; fix 3.31 s / 3.29 s (about -0.3%, within noise)This PR claims the structurally eliminated registry lookups and regression coverage, not a measurable wall-clock speedup.
Closes #7865
Summary by CodeRabbit
Bug Fixes
Tests
Documentation