Skip to content

perf(intl): Segments view — one realm record for the test proof, fixed-slot cursor fields, no duplicate pointer validation - #9917

Open
proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:perf/segview-percall
Open

perf(intl): Segments view — one realm record for the test proof, fixed-slot cursor fields, no duplicate pointer validation#9917
proggeramlug wants to merge 3 commits into
PerryTS:mainfrom
proggeramlug:perf/segview-percall

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Stacked on #9893 (perf/segview-levers @ f076656). Three runtime-only commits, written by codex from the segmenter lane's per-call read list, not yet compiled (the dev box was out of disk); gates and measurement run on perrymaster and will be appended here.

What changes, per commit

  1. 5f6a21734 — the recorded RegExp.prototype.test proof becomes one CanonicalTestSite TLS record (prototype pointer, canonical NaN-boxed closure, field index) instead of three TLS slots; both roots stay GC-visited (visit_atomic_i64_slot / visit_atomic_nanbox_u64_slot). The per-call may_have_descriptor_entry(proto, "test", true) (registry probe + key_bytes_hash + Bloom load) becomes one (*meta).accessor_key_bits load against a compile-time FNV-1a mask; object_static_prototype_known_non_meta reads the OBJECT_PROTOTYPES_NONEMPTY latch first.
  2. b94c586a7regexp_test_str_bounded no longer re-validates the regex pointer its only caller already validated.
  3. 5b7c4fa94 — the cursor's numeric fields are read through fixed slots (CursorFields, one base per entry) and _next writes slots 1–4 through a number-only store with no barrier.

Unchanged by design: with_input's per-entry re-derivation of the input (the §9a rooting contract) and utf16_len's second pass.

Why

On the current best bundle (I7-view) js_segments_view_regexp_test is 6.8 % of the thread inclusive, dominated by property loads (js_object_get_field 2.3 %, object_static_prototype 1.2 %) and TLS reads; js_object_set_field for the cursor's four integers was 1.6 %. The match itself is 0.8 %.

Tests (named; sabotage stated in each)

an_accessor_installed_after_recording_makes_the_next_call_decline, a_patched_prototype_test_declines_on_the_next_call, canonicality_proof_walks_once_per_realm_not_once_per_call, bounded_regex_test_does_not_repeat_entry_pointer_validation, cursor_position_fields_are_never_pointer_typed.

Gates

Run: rustfmt, git diff --check, scripts/gc_runtime_root_holders.py (pass), scripts/check_file_size.sh (pass). Not run (disk): cargo build --release -p perry default features, nm for the exported symbols, the runtime suite, the five tests above. Draft until they run.

Gate history

  • 5b7c4fa94 on perrymaster (archives stamped af9227369): cargo build --release -p perry rc=0; the archive feature set (--features perry-runtime/wasm-host) rc=0 with T js_regexp_test and the five view symbols present; RUST_TEST_THREADS=1 cargo test --release -p perry-runtime --lib -- --test-threads=1: 3230 passed, 0 failed, 4 ignored. Named tests green: an_accessor_installed_after_recording_makes_the_next_call_decline, a_patched_prototype_test_declines_on_the_next_call, canonicality_proof_walks_once_per_realm_not_once_per_call, bounded_regex_test_does_not_repeat_entry_pointer_validation, cursor_position_fields_are_never_pointer_typed, and the 13 view_mode_tests. Next: the I8-view relink on I7-view's cache (identity by objdump call-site counts 20/10), the probe compile, then rows vs I7-view. Stays draft until the rows are on this PR.

Measured (perrymaster, quiet box load 1.1–1.3, 5-round paired rotation vs the best bundle I7-view; both arms in the same rotation)

3300-char turn CPU: −2.4 / −5.2 / −4.0 / −3.0 / −3.3 % (faster 5/5) — I7-view 2.97–3.06 s, this arm 2.88–2.92 s. 400-char turn: 0 / 0 %. Peak RSS within ±1 %; settled after idle +6 MB at 3300, +1 MB at 400. Identity from the artefact: view call sites next/open 20/10 on both arms (the fixed-slot reads change what the runtime does inside the same entry points).
Note: the rig's absolute times drifted ≈ +33 % between the earlier I7-view rows (2.23–2.35 s) and this rotation; the pair above is inside one rotation and holds, the absolutes are under investigation (mock home growth suspected).

Rebased onto main (2026-09-07)

The base PRs this branch was stacked on landed on main via merge train #9922, so the branch was rebased onto current main: head 5b7c4fa94b73769735, replay patch-identical (only this branch's own commits remain above main). The measurements above were taken on the pre-rebase head with the same code; CI on this head is the remaining gate.

Local gates on the rebased head (macOS arm64, 2026-09-09): perry-codegen tests 1,45x passed / 0 failed; runtime lib suite one thread 3,26x passed / 0 failed / 4 ignored; cargo build --release -p perry-runtime --features wasm-host ok. Un-drafted under the local-verification rule (GitHub runners unavailable); the Linux ladder on perrymaster follows as confirmation.

https://claude.ai/code/session_011dhBmdn4vGgNibjo3oZqTo

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 361df5e7-9b4d-4f49-9c12-cb9034b71181

📥 Commits

Reviewing files that changed from the base of the PR and between 616a2cb and b737697.

📒 Files selected for processing (6)
  • crates/perry-runtime/src/intl/segments_view.rs
  • crates/perry-runtime/src/object/mod.rs
  • crates/perry-runtime/src/object/prototype_chain.rs
  • crates/perry-runtime/src/object/regex_proto_thunks.rs
  • crates/perry-runtime/src/regex.rs
  • scripts/gc_runtime_root_holders.json

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.

@jdalton jdalton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 5b7c4fa94d879a1643fdcf0da4410b561a4edf04 (2026-09-07).

The direct cursor slots and one-time UTF-8 validation rely on a clear write-once input invariant. The runtime observability change deserves a follow-up before using this to validate #9843: report_segview_counters is removed, but product builds still increment the atomics under PERRY_SEGVIEW_DIAG; only #[cfg(test)] counters() reads a subset. Compiler rewrite counts do not prove that the runtime accepted a cursor rather than declining it. Please wire a runtime summary into the existing reporting path (with accepted/declined and next counts), or remove the product-only counter work and explicitly limit the claims to compile-time admission. An end-to-end liveness assertion should check that accepted opens and nexts are nonzero.

Validation scope: source/diff inspection; I have not run this PR's build or test suite locally.

@proggeramlug
proggeramlug marked this pull request as ready for review September 7, 2026 21:06
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