perf(tla): memoize the interpreted-path action text splitters - #191
Merged
Conversation
`split_action_body_clauses` and `split_action_body_disjuncts` (action_ir.rs) are pure functions of their input text — the v2 layout-aware parse is deterministic and `v2_enabled()` is fixed per process — but they are re-invoked on the SAME action/clause text on every `next_states` call. During full-space exploration, and especially trace reconstruction (which re-explores the whole graph), re-running the Pratt parse + string scans per visit dominated the hot path for fairness/reconstruction specs once #189 removed the compiled-IR recompilation (gdb showed `split_action_body_clauses`/`split_top_level`/`matches_keyword_at`). Wrap each splitter as an `_uncached` inner fn behind a thread-local memoization keyed by the input string (returns a cheap `Vec<String>` clone instead of re-parsing). Thread-local, so no cross-worker contention. Result: ACP_NB_WRONG_TLC completes in ~29s (was ~143s post-#189, ~5x), same verdict (AC1 violated). Gate: diff_tlc 20/20, cargo test --release 1486 passed / 0 failed — pure memoization, no behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
split_action_body_clausesandsplit_action_body_disjuncts(action_ir.rs) are pure functions of their input text (the v2 layout-aware parse is deterministic;v2_enabled()is fixed per process), but they're re-invoked on the same action/clause text on everynext_statescall. During full-space exploration — and especially trace reconstruction, which re-explores the whole graph — re-running the Pratt parse + string scans per visit dominated the hot path for fairness/reconstruction specs once #189 removed the compiled-IR recompilation (gdb showedsplit_action_body_clauses/split_top_level/matches_keyword_at).Wrap each splitter as an
_uncachedinner fn behind a thread-local memoization keyed by the input string (returns a cheapVec<String>clone instead of re-parsing). Thread-local, so no cross-worker contention.Result
ACP_NB_WRONG_TLCcompletes in ~29s (was ~143s post-#189 — a ~5x speedup), same verdict (AC1violated).Validation
scripts/diff_tlc.sh: 20/20.cargo test --release: 1486 passed / 0 failed.Follow-up to #189 (which cached the compiled action IR in the guard path); together they remove the two dominant per-
next_statesre-work costs (recompilation + re-splitting).