fix: keep main green after the #9302/#9303/#9307 batch - #9313
Merged
Conversation
added 5 commits
August 31, 2026 19:35
…clone
17_loop_data_dependent: 475 ms -> 219 ms against node's 220 ms on an idle
Mac mini -- parity, from 2.16x. Sums bit-identical across 100M data-dependent
float recurrence steps.
sum = sum * x[i & 63] + x[(i * 7) & 63] // rejected
sum = sum * x[i & 63] // admitted
The discriminator was the accumulator's static numeric proof. `+` can be
concatenation, so the dense tier's per-statement proof demands both operands
numeric; a reassigned accumulator has no such proof, because its own writes
read the guarded array, whose element proof only exists once the guard has
run. A chicken-and-egg that `*` never faces -- multiplication needs only the
weaker inert fact. Confirmed by instrumenting the two conjuncts of the dense
LocalSet arm: the failing one is the proof, on exactly the fixtures whose
accumulator writes contain a plain-array read.
The matcher now peels the accumulator: when the proof fails on the LocalSet
target of a self-accumulating write, it retries with the target treated as
numeric BY CONTRACT, records it pending, and then verifies every pending
local with the same collector the lowering runs
(`collect_numeric_accumulators`), rejecting the whole dense match with its
own named trace reasons (`accumulator_needs_single_array`,
`accumulator_not_provable`) if the two disagree -- so the clone can never
contain a dynamic `+` under facts that forbid one.
The contract is enforced at run time twice over: the clone's entry emits a
genuine-double tag check on the accumulator, and the dense entry guard
validates the whole masked window hole-free. A string-seeded accumulator and
a string element both route to the slow copy and produce node's
concatenation, verified under PERRY_GC_FORCE_EVACUATE.
Supporting changes:
* `accumulator_rhs_is_numeric` accepts masked static-window reads of the
tracked array (`masked_reads_validated`), sound because the dense guard
validated the window union hole-free. Fixing that exposed a match-arm
reachability bug: `_ if offset_reads_inlined` was a guarded catch-all, so
ANY arm placed after it was unreachable whenever the flag was set -- the
first version of this change sat exactly there and verified as a no-op.
The two tests are now one combined catch-all.
* `emit_range_loop_accumulator_admission` admits a masked-only single array
(counter-bearing arrays keep priority; multiple arrays still decline).
* `MaskedWindowArrayFact` carries `numeric_accumulators` so `is_numeric_expr`
sees admitted accumulators while the clone lowers -- without this the add
inside the clone would stay dynamic, which is a collecting call under facts
that assume none (the #9259 cascade shape). Mirrors the string-window
fact's field (#9160).
perry-codegen lib 1378/0; packed-loop integration suite 59/0 across 11 files;
3 new regression tests (admission + node-identical result, string-seeded
accumulator, string element), each under forced evacuation.
Claude-Session: https://claude.ai/code/session_01Pcq6j6y57TdKSR2Zx2D187
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThe codegen now admits validated numeric accumulators in dense masked-window clones. It records these locals for lowering and rejects unproven cases. Runtime regression tests move into external modules, with additional formatting-only and changelog updates. ChangesDense masked-read accumulator
Runtime test extraction
File-size and formatting follow-up
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RangeLoopMatcher
participant DenseBodyCollector
participant NumericAccumulatorCollector
participant MaskedWindowArrayFact
RangeLoopMatcher->>DenseBodyCollector: collect pending accumulator locals
DenseBodyCollector->>NumericAccumulatorCollector: verify pending locals
NumericAccumulatorCollector-->>RangeLoopMatcher: accept or reject dense match
RangeLoopMatcher->>MaskedWindowArrayFact: record numeric_accumulators
✨ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the batch merged today. Three things, all validated together as one build before the batch went in:
#9303's masked-reads commit. #9303 was stacked on #9294; once #9294 merged, the PR branch conflicted against
main. The remaining delta is carried here as its original commit, so authorship is preserved.Two files back under the 2000-line cap.
ic_miss.rs(1965 onmain) andarray/tests.rs(1980) were each within ~35 lines of the gate, and #9302 and #9307 tipped them to 2035 and 2003. The C3C PIC test module and theArray.prototypemethod-discriminator tests move to sibling files, following the existingtests_strict_dense.rsconvention. No behaviour change.The dead arm after the combined accumulator catch-all. #9303 adds a combined
_ =>arm but leaves the_ => falseit supersedes, making it an unreachable pattern:With
-D warningsthat's a build failure. Removing it is the fix #9308 correctly identified.Also carries a
cargo fmtpass — #9302 landed with formatting rustfmt reformats, socargo fmt --checkis red onmainas of now.Validation:
perry-codegen+perry-hir+perry-transform(74 suites) andperry-runtime(8 suites) both green underRUST_TEST_THREADS=1, plus all four PRs' own integration tests (issue_9287_overflow_slot_ic,numeric_range_add_resume,dense_accumulator_masked_reads,issue_9253_affine_range_index— 16 tests). Release build clean with no new warnings; all nine lint ratchets pass.Summary by CodeRabbit
Performance Improvements
Bug Fixes
Tests
Maintenance