Skip to content

[codex] Inline Uint8Array access for const local lengths#5341

Merged
proggeramlug merged 2 commits into
codex/perry-performance-cycle-20260617-16from
codex/perry-performance-cycle-20260617-18
Jun 18, 2026
Merged

[codex] Inline Uint8Array access for const local lengths#5341
proggeramlug merged 2 commits into
codex/perry-performance-cycle-20260617-16from
codex/perry-performance-cycle-20260617-18

Conversation

@andrewtdiz

Copy link
Copy Markdown
Contributor

Summary

  • Teach the noalias buffer fact collector to remember prior immutable numeric length locals.
  • Allow const buf = new Uint8Array(SIZE) when SIZE is an immutable finite integer length to register a native-owned Uint8Array view.
  • Reuse the existing bounded-loop proof so buf[i] lowers to inline byte load/store instead of js_uint8array_get/set, with collector and IR regression coverage.

Verification

  • cargo fmt --check
  • git diff --check
  • cargo test -p perry-codegen collectors::hir_facts -- --nocapture (9 passed)
  • cargo test -p perry-codegen --test native_proof_buffer_views -- --nocapture (22 passed)
  • cargo test -p perry-codegen --test native_proof_regressions -- --nocapture (45 passed)
  • cargo build --release -p perry
  • target/release/perry compile benchmarks/suite/bench_buffer_readwrite.ts -o /tmp/perry-cycle18-final-bench_buffer_readwrite --trace llvm
  • IR evidence from /tmp/perry_llvm_272534_1781722418994040407_0.ll: hot path contains store i8 and load i8; no matched call i32 @js_uint8array_get or call void @js_uint8array_set.

Benchmark

bench_buffer_readwrite, checksum 12749385600 for all runs:

  • Baseline /tmp/perry-cycle18-baseline-bench_buffer_readwrite: 836, 824, 817, 864, 832 ms; avg 834.6 ms.
  • Final /tmp/perry-cycle18-final-bench_buffer_readwrite: 94, 86, 76, 99, 76 ms; avg 86.2 ms.
  • Speedup: 9.7x, about 89.7% lower runtime.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e908f242-2e7f-465c-ba83-3d804891a9ac

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/perry-performance-cycle-20260617-18

Comment @coderabbitai help to get the list of available commands and usage tips.

@proggeramlug proggeramlug marked this pull request as ready for review June 18, 2026 05:40
@proggeramlug proggeramlug reopened this Jun 18, 2026
Base automatically changed from codex/perry-performance-cycle-20260617-17 to codex/perry-performance-cycle-20260617-16 June 18, 2026 11:13
@proggeramlug proggeramlug merged commit 7433964 into codex/perry-performance-cycle-20260617-16 Jun 18, 2026
3 checks passed
@proggeramlug proggeramlug deleted the codex/perry-performance-cycle-20260617-18 branch June 18, 2026 11:13
proggeramlug added a commit that referenced this pull request Jun 18, 2026
…al inits (salvage andrewtdiz #5341/#5367) (#5401)

* Inline Uint8Array access for const local lengths

* Skip pure unused scalar literal initializers

---------

Co-authored-by: Andrew DiZenzo <andrewdizenzojhu@gmail.com>
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