Skip to content

perf(codegen): a truthiness test asks a loop region for no Number lane - #11856

Merged
proggeramlug merged 2 commits into
mainfrom
regfix-region-truthiness
Oct 3, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
regfix-region-truthiness

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the #10495 own3 regression that #11795 introduced.

Cause

#11795 admits a loop region whose Number reads (R) fall on non-identity lanes and tests their values on every guard. Both of the region's R collectors counted a value that is only tested for truthiness as a Number operand: number_operand_reads, and the accumulator value flow region_number_flow_reads. In a += (o.$L ? 1 : 0) + (o.$d ? 1 : 0) + … they requested R for o.$L, a string. The learned word carried the value test, which failed on every iteration, so the loop paid the guard and then the generic path (227 to 246 instructions per op).

Fix

A conditional's test and a ! operand are not Number operands. The conditional's arms are still values. Both collectors skip the test and the ! operand.

Results (instructions per op)

row morning main this PR
#10495 own3 227 246 227

Real workloads (n=5, median instructions:u; main = 5b06d69)

workload main instr this PR delta full GCs main/PR RSS KB main/PR binary bytes main/PR
tsc (transpile x3) 184,902,302,770 184,880,958,985 -0.01% 244/244 323,052/324,368 182,782,336/182,782,336
zod x5000 19,831,886,486 19,826,300,154 -0.03% 0/0 59,396/58,828 24,440,056/24,440,056
qs parse_nested 32,985,522,956 32,986,164,020 +0.00% 0/0 60,144/60,372 27,301,072/27,288,720
commander parse_argv 8,912,561,402 8,912,263,665 -0.00% 0/0 57,528/56,448 34,203,080/34,203,080

Outputs are identical to main's in every run.

Verification

  • New codegen test a_truthiness_test_requests_no_number_lane: R mask 0 and no value test for h += o.x ? 1 : 0 and h += !o.x ? 1 : 0. Control: h += n ? o.x : 0 still requests R.
  • perry-codegen (all) passed. Gap suite (1254 files) compared with main: 0 regressions. fmt: clean.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef4b2508-c306-4465-897e-d4254195b115
📥 Commits

Reviewing files that changed from the base of the PR and between 07e50b1 and 2a61df7.

📒 Files selected for processing (4)
  • changelog.d/PENDING-regfix-region-truthiness.md
  • crates/perry-codegen/src/collectors/ptr_shape_numeric.rs
  • crates/perry-codegen/src/expr/region_loop_tests.rs
  • crates/perry-codegen/src/stmt/region_loop/plan.rs
 _______________________________________
< Goodbye, 3-hour code review sessions. >
 ---------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@proggeramlug
proggeramlug merged commit 986505a into main Oct 3, 2026
23 of 24 checks passed
@proggeramlug
proggeramlug deleted the regfix-region-truthiness branch October 3, 2026 23:51
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