Skip to content

[codex] Speed up numeric array guard cache hits#5309

Closed
andrewtdiz wants to merge 3 commits into
codex/perry-numeric-array-direct-fastpathfrom
codex/perry-numeric-array-guard-precheck
Closed

[codex] Speed up numeric array guard cache hits#5309
andrewtdiz wants to merge 3 commits into
codex/perry-numeric-array-direct-fastpathfrom
codex/perry-numeric-array-guard-precheck

Conversation

@andrewtdiz

Copy link
Copy Markdown
Contributor

Stacked on #5307.

Summary

  • Add a pre-classification numeric-array observation builder for get/set guard-cache hits.
  • Skip full classify_array work on exact monomorphic numeric-array guard-cache hits.
  • Preserve the existing full classify and guard_observe fallback for miss, stale, mismatch, nonnumeric, and layout-mismatch paths.
  • Add a runtime test that compares fast observations against the existing classifier, and log the benchmark cycle.

Benchmark Impact

Baseline: #5307 / 6a01499d4f.

  • Matrix direct median: 1239ms -> 398ms, 67.9% faster, checksum 41079519680.
  • Matrix quick: 1228ms -> 407ms, 66.9% faster.
  • Nested compare: 662ms -> 225ms, 66.0% faster.
  • Perf direct: 4.49B -> 1.44B cycles; 16.74B -> 7.03B instructions; 3.09B -> 1.57B branches.
  • Trace: get/set guard pass counts unchanged, with 0 get/set failures.

Validation

  • cargo fmt --check
  • git diff --check
  • cargo test -p perry-runtime typed_feedback_numeric_array
  • cargo test -p perry-runtime typed_feedback
  • cargo test -p perry-codegen --test typed_feedback
  • cargo test -p perry-codegen --test typed_shape_descriptors
  • PERRY_BIN=target/release/perry python3 tests/test_typed_feedback_runtime_evidence.py
  • tests/test_benchmark_output_verifier.sh
  • cargo build --release
  • benchmarks/quick.sh
  • benchmarks/compare.sh --quick --runs 3 --warn-only --json-out /tmp/perry-guard-precheck-final2.json
  • Direct matrix compile/run/trace/perf commands are recorded in PERF_RUN_LOG.md.

@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: 2ae8e77e-fcc5-4f07-aaae-f7d2c0b13bf3

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-numeric-array-guard-precheck

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

@andrewtdiz andrewtdiz force-pushed the codex/perry-numeric-array-guard-precheck branch from 713a7b6 to 9667292 Compare June 17, 2026 06:19
@proggeramlug proggeramlug force-pushed the codex/perry-array-guard-cache-fastpath branch from 6a01499 to 6b54bf6 Compare June 17, 2026 13:38
@proggeramlug proggeramlug force-pushed the codex/perry-numeric-array-guard-precheck branch from 9667292 to 9bacb98 Compare June 17, 2026 13:38
@proggeramlug proggeramlug force-pushed the codex/perry-array-guard-cache-fastpath branch from 6b54bf6 to 0f46886 Compare June 17, 2026 13:47
@proggeramlug proggeramlug force-pushed the codex/perry-numeric-array-guard-precheck branch from 9bacb98 to 8a6db40 Compare June 17, 2026 13:47
@proggeramlug proggeramlug force-pushed the codex/perry-array-guard-cache-fastpath branch from 0f46886 to 3b00735 Compare June 17, 2026 13:58
@proggeramlug proggeramlug force-pushed the codex/perry-numeric-array-guard-precheck branch from 8a6db40 to 2095f68 Compare June 17, 2026 13:58
@proggeramlug proggeramlug marked this pull request as ready for review June 18, 2026 05:41
@proggeramlug proggeramlug force-pushed the codex/perry-array-guard-cache-fastpath branch from 3b00735 to 83aa967 Compare June 18, 2026 06:36
@proggeramlug proggeramlug force-pushed the codex/perry-numeric-array-guard-precheck branch from 2095f68 to 7f98910 Compare June 18, 2026 06:36
@proggeramlug proggeramlug reopened this Jun 18, 2026
Base automatically changed from codex/perry-array-guard-cache-fastpath to codex/perry-numeric-array-direct-fastpath June 18, 2026 17:54
@proggeramlug

Copy link
Copy Markdown
Contributor

Closing as superseded. Since this codex stack was cut, main advanced 52+ commits and independently evolved the same hot codegen/runtime paths. This PR is one link in a 13-deep linear stack that conflicts with diverged, correctness-sensitive codegen and was never reviewed; landing it would mean rebasing the whole stack. Per-PR judgement was done before closing.

Specific: main already uses direct-mapped inline caches on the hot object paths (crates/perry-runtime/src/object/mod.rs:1098, alloc.rs:362, field_get_set.rs:5193). The typed-feedback array-guard cache variant here is the only arguably net-new piece, but it's entangled with main's diverged typed_feedback.rs and unreviewed — better re-proposed fresh against current main if it still measures as a win.

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