Skip to content

The write pass's widening walks share what they found unchanged, as the parameter pass's do - #10179

Merged
matz merged 1 commit into
matz:masterfrom
amatsuda:pr/widen-walks-shared-in-write-pass
Oct 25, 2026
Merged

matz merged 1 commit into
matz:masterfrom
amatsuda:pr/widen-walks-shared-in-write-pass

Conversation

@amatsuda

@amatsuda amatsuda commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

The write pass's widening walks share what they found unchanged, as the parameter pass's do.

What happened

infer_write_container_usage follows a value of another kind pushed into a boxed local or element back to the arrays it can hold, widening them where they are built (widen_boxed_array_sources). A boxed receiver's arrays are reached through every method its calls can resolve to, and each method's values through theirs, to depth 6, so one walk fans out over the methods of a common name; the walk keeps a memo of the visits that changed nothing, but each walk from the pass opened a generation of its own (wbas_touch at depth 0), so the next store of the same scope walked the same web again.

On a Rails application, in the rounds after the optimistic ones settle (where the walk runs), the walk was 33% and 42% of two sampled fixpoint windows and the whole of a third, all of it the recursion widen_boxed_array_sources <-> widen_method_value_sources.

The fix

The pass shares the memo across its walks the way infer_param_types_ex already does (wbas_share_begin / wbas_share_step / wbas_share_end): a generation ends wherever the pass reports a change, at each node it visits, and now also as a walk begins when the pass reported a change since its last step, so no walk reads a record left before a write it has not seen. A visit skipped on the strength of the shared record is one that changed nothing in the same state, as before within a walk.

SPINEL_WBAS_SHADOW=1, which makes every skipped visit all the same and aborts if it would have widened or written, passes on the Active Support sample (C identical to the unshadowed build's) and on the related corpus tests.

Measurements

Rails application (--timing, same machine, the runs alongside each other):

master this branch
infer_write_types, 69 calls 435.1 s 144.7 s
analysis_fixpoint (31 rounds) 2,848 s 2,543 s
an_post_fixpoint 349.3 s 197.2 s
an_method_backstops 743.0 s 360.3 s
analysis 4,767 s 4,050 s

(The pass runs again in the post-fixpoint and backstops phases, which is where the rest of its time was.)

The application stops on the same deferred refusals, and its refusal output is identical line for line to master's. The Active Support sample's C is byte-identical to plain master's. 703 related corpus tests pass locally, under the shadow check as well; the gate check passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VXZndU8ST2PpoRWZ4iiejs

Summary by CodeRabbit

  • Improvements
    • Analysis is more consistent when multiple writes involve shared array data.
    • Related type and write analysis now stays synchronized across these cases.

…he parameter pass's do

infer_write_container_usage follows a value of another kind pushed into a
boxed local or element back to the arrays it can hold
(widen_boxed_array_sources), through every method its calls can resolve
to and each method's values in turn. The walk's memo of the visits that
changed nothing lasted one walk, so the next store of the same scope walked
the same web of methods again. The pass now shares the memo across its
walks the way infer_param_types_ex does: a generation ends wherever the
pass reports a change, at each node, and as a walk begins when a change was
reported since the last step. SPINEL_WBAS_SHADOW=1 passes on the related
corpus tests and on a large program.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXZndU8ST2PpoRWZ4iiejs
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f9c017a-093e-4bfc-a5a6-183cf3821b44
Commits

Reviewing files that changed from the base of the PR and between 3b44407 and 9c78805.

Files selected for processing: 1
  • src/analyze_pass.c

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The write pass now shares boxed-array-source traversal state across stores. It advances traversal generations between stores and includes changes from shared traversal in its return value. The traversal wrapper also synchronizes generations at outermost calls.

Changes: Write-pass traversal

Layer / File(s) Summary
Coordinate traversal generations
src/analyze_pass.c
The write pass shares traversal tracking across stores and returns changes accumulated by the shared traversal. The traversal wrapper advances or synchronizes generations at outermost calls. Comments describe how parameter binding and write-pass stores affect generation changes.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

Suggested reviewers: matz

Merge Risk: Minimal · up to 9c788

No actionable risk introduced by this change remains after the review. The PR is mergeable subject to normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: sharing unchanged widening-walk results in the write pass, following the parameter pass pattern. It is specific and related to the pull request.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 too large.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@matz
matz merged commit c6fa64b into matz:master Oct 25, 2026
5 checks passed
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.

2 participants