perf: v0.12.21 — tagged start states, zero-alloc API#155
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Benchmark ComparisonComparing Summary:
|
DFA Engine: - Tagged start states (Rust LazyStateID) — prefilter only at start state, no O(n²) - DFA multiline $ EndLine look-ahead fix (Rust determinize mod.rs:131-212) - Dead-state prefilter restart in searchEarliestMatch - isMatchWithPrefilter pfSkip off-by-one fix - Tiny NFA (< 20 states) → UseDFA routing (was UseNFA/UseBoth) Allocation: - Flat buffer FindAllIndex: 1100x fewer mallocs (203K → 182 per iter) - Local SearchState cache: atomic.Pointer, survives GC - Redundant pool round-trips eliminated in FindAll/Count New Public API (zero-alloc, Go stdlib conventions): - AllIndex/AllStringIndex: iter.Seq[[2]int] iterator (Go proposal #61902) - All/AllString: iter.Seq match content iterator - AppendAllIndex/AppendAllStringIndex: buffer-reuse (strconv.Append* pattern) Benchmarks (LangArena, 7.2 MB, 13 patterns): - Total: 163ms → 107ms (-34%) - errors: 23ms → 5.5ms with AllIndex (-76%) - vs Rust gap: 3.9x → 1.7x with AllIndex (-56%) - emails AppendAllIndex: 2.0ms vs Rust 2.6ms (faster than Rust!) - Mallocs: 203K → 182 per iter (-99.9%) - AllIndex/AppendAllIndex: 0 KB / 0 mallocs (same as Rust find_iter)
423e71f to
e147568
Compare
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.
Summary
Tagged start states (Rust
LazyStateID), zero-alloc public API, DFA correctness fixes.17 files, +749 -361 lines.
DFA Engine
$fix — EndLine look-ahead re-computationAllocation
New Public API (zero-alloc)
AllIndex/AllStringIndex—iter.Seq[[2]int]iterator (Go proposal #61902)All/AllString— match content iteratorAppendAllIndex/AppendAllStringIndex— buffer-reuse (strconv.Append*pattern)Benchmarks (LangArena, i7-1255U, same data as Rust)
emails:
AppendAllIndex2.0ms vs Rust 2.6ms — faster than Rust!Verification
go test ./...— all 9 packages passgofmt -l/golangci-lint— cleanregex-automatafind_fwd