Skip to content

Merge train 182: #10205 - #10206

Merged
proggeramlug merged 3 commits into
mainfrom
train182
Sep 13, 2026
Merged

proggeramlug merged 3 commits into
mainfrom
train182

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Merge train 182: lands #10205 (JS-level regex searches on non-ASCII strings resume from the previous call's position, via a per-thread heap generation; part of #10164 and #10165) at head d04e162ba1, plus the workspace version bump to 0.5.1555.

Both PR commits were cherry-picked onto 5d3bf85f9 without conflicts. main has not moved since the PR's base, so the tree before the bump is byte-identical to the PR head, and the PR head's validation applies unchanged.

Validation on that tree (perrymaster, Linux x86_64, --locked):

  • cargo fmt --all -- --check
  • cargo check -p perry-runtime --no-default-features --features full --lib (regex feature off): 0 warnings
  • cargo check -p perry-runtime --lib --tests: no warnings outside the known global_this_webassembly.rs dead code
  • cargo test -p perry-runtime --lib -- --test-threads=1: 3724 passed, 1 failed. The failure is native_stack::tests::stack_top_respects_custom_thread_stack_sizes, red on main.
  • cargo clippy -p perry-runtime --lib --tests: identical to train 181
  • scripts/run_lint_gates.sh script tier: 76 of 77 pass. The failure is public benchmark evidence freshness, identical on main.
  • check_changeset_fragment.sh PerryTS/perry 10205: pass

Re-checked on this branch after the bump: cargo metadata --locked, fmt, gc_runtime_root_holders.py, check_file_size.sh.

The PR has the tests, the 13 fault injections (all fail as required) and the measurements. The non-ASCII exec loop at 40,000 records drops from 28.5 s to 314 ms, and matchAll from 26.9 s to 463 ms. ASCII per-call cost rises by 27–55 instructions (0.1–0.2 %).

https://claude.ai/code/session_01Da12JXeG5XuVBma5yWp5C9

Summary by CodeRabbit

  • Performance

    • Improved JavaScript regular expression loops over non-ASCII text, preventing repeated searches from becoming quadratic.
    • exec() and matchAll() can now resume searches more efficiently across calls.
  • Bug Fixes

    • Corrected regex position reuse when strings are moved or replaced during garbage collection, ensuring searches start from the correct location.
  • Documentation

    • Updated the documented release version to 0.5.1555.
    • Added changelog coverage for the regex performance improvement.

Ralph Küpper added 3 commits September 13, 2026 14:07
…revious call's position (#10164)

A JavaScript exec/test/search/matchAll step binds its subject afresh on
every call, so on a non-ASCII (WTF-8) string each search paid a seek from
the nearer end and a loop over one string did quadratic work. A per-thread
four-entry table now remembers where the last such search stopped and hands
that position to the next search on the same string.

"The same string" is decided without a traced edge or per-object state:
the concealed address, the byte and UTF-16 lengths, and a new per-thread
heap generation must all match. The generation advances on entry and exit
of a HeapChange scope around every event that frees or moves heap memory
(copying minor, cycle Sweep and Reclaim steps, minor-prelude evacuation
with a nested compaction scope, in-place promotion, gc_realloc, the
synchronous sweep). Debug builds assert at every primitive that makes
object memory reusable or evacuates a young object that a scope is open.
RegExpHeader is unchanged (56 bytes); ASCII strings never consult the
table.

Tests: one per event kind asserting the generation advanced and the kind's
own scope opened; a funnel assertion that can say no; linearity of a
JS-level non-ASCII loop with and without positions; a moved string; and a
different same-layout string at a freed string's address.

Claude-Session: https://claude.ai/code/session_01Da12JXeG5XuVBma5yWp5C9
@proggeramlug
proggeramlug merged commit 0956673 into main Sep 13, 2026
18 of 20 checks passed
@proggeramlug
proggeramlug deleted the train182 branch September 13, 2026 14:08
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e299e82e-3a07-4837-a426-576e3b08e2c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5d3bf85 and 6eb609e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (28)
  • CLAUDE.md
  • Cargo.toml
  • changelog.d/10205-regex-cross-call-position.md
  • crates/perry-runtime/src/arena/promote.rs
  • crates/perry-runtime/src/arena/reset.rs
  • crates/perry-runtime/src/arena/tests.rs
  • crates/perry-runtime/src/gc/copying.rs
  • crates/perry-runtime/src/gc/cycle.rs
  • crates/perry-runtime/src/gc/heap_generation.rs
  • crates/perry-runtime/src/gc/malloc.rs
  • crates/perry-runtime/src/gc/mod.rs
  • crates/perry-runtime/src/gc/old_free.rs
  • crates/perry-runtime/src/gc/oldgen.rs
  • crates/perry-runtime/src/gc/tests/alloc.rs
  • crates/perry-runtime/src/gc/tests/debt_pacer.rs
  • crates/perry-runtime/src/gc/tests/evacuation.rs
  • crates/perry-runtime/src/gc/tests/heap_generation.rs
  • crates/perry-runtime/src/gc/tests/incremental_sweep_reclaim.rs
  • crates/perry-runtime/src/gc/tests/mod.rs
  • crates/perry-runtime/src/gc/tests/oldgen.rs
  • crates/perry-runtime/src/gc/tests/promote_in_place.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots/perex_position_hint.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots/perex_reuse.rs
  • crates/perry-runtime/src/regex.rs
  • crates/perry-runtime/src/regex/perex_api.rs
  • crates/perry-runtime/src/regex/perex_position_hint.rs
  • scripts/gc_runtime_root_holders.json

📝 Walkthrough

Walkthrough

Changes

Regex position reuse and heap identity

Layer / File(s) Summary
Heap-generation contract
crates/perry-runtime/src/gc/heap_generation.rs, crates/perry-runtime/src/gc/mod.rs
Adds per-thread heap generations, scoped HeapChange tracking, event kinds, and debug assertions.
GC change instrumentation
crates/perry-runtime/src/arena/*, crates/perry-runtime/src/gc/{copying.rs,cycle.rs,malloc.rs,old_free.rs,oldgen.rs}
GC paths now open or validate heap-change scopes for memory movement, reclamation, sweeping, promotion, compaction, and reallocation.
Heap-generation validation
crates/perry-runtime/src/arena/tests.rs, crates/perry-runtime/src/gc/tests/*
Tests cover generation advancement, event counts, scope assertions, and the instrumented GC paths.
Regex position hint flow
crates/perry-runtime/src/regex.rs, crates/perry-runtime/src/regex/perex_api.rs, crates/perry-runtime/src/regex/perex_position_hint.rs
Adds a four-entry per-thread hint cache and uses validated string identities to look up and record regex search positions.
Regex validation and release support
crates/perry-runtime/src/gc/tests/runtime_roots/*, scripts/gc_runtime_root_holders.json, changelog.d/10205-regex-cross-call-position.md, Cargo.toml, CLAUDE.md
Tests verify linear loops and reject stale hints after movement or address reuse. Release metadata, changelog text, and runtime-root records are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant JavaScript
  participant RegexExecution
  participant PositionHint
  participant GarbageCollector
  JavaScript->>RegexExecution: execute repeated non-ASCII search
  RegexExecution->>PositionHint: look up string identity
  PositionHint-->>RegexExecution: return prior position when valid
  RegexExecution->>GarbageCollector: continue with possible collection
  GarbageCollector->>PositionHint: invalidate identity through generation change
  RegexExecution->>PositionHint: record post-search position
Loading

Suggested reviewers: jdalton

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch train182

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.

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