Repository navigation
feat: CompositeSequenceDFA 25x speedup + FindAllIndexCompact API - #84
Merged
Merged
Conversation
Add FindAllIndexCompact/FindAllStringIndexCompact methods that return [][2]int instead of [][]int, reducing allocations from N to 1 for N matches. Also fix per-match allocation in CompositeSearcher.matchAt by pre-allocating matchLengths slice. Benchmark results (1MB, 60974 matches): - FindAllIndex: 48 MB/s, 60974 allocs - FindAllIndexCompact: 51 MB/s, 9 allocs - Compact + reuse: 73 MB/s, 0 allocs Resolves performance concern in Issue #78 investigation.
Implement Rust-style DFA using NFA subset construction for patterns like \w+[0-9]+ where character classes overlap. Key improvements: - Byte class reduction: 256 bytes -> 3-8 equivalence classes - Subset construction: handles overlapping char classes correctly - Single-pass matching: no backtracking needed Benchmark results (1MB, \w+[0-9]+): Before: 42 MB/s (CompositeSearcher backtracking) After: 170 MB/s (CompositeSequenceDFA) Speedup: 4x faster vs stdlib: 12.9x faster (170 MB/s vs 13 MB/s) vs Rust: ~3x slower (170 MB/s vs 500 MB/s)
- Remove //go:nosplit (stack too large) - Add first-part skip optimization (O(1) start position check) - Implement 4-byte loop unrolling (Rust-inspired) Benchmarks (1MB input): - CompositeSearcher: 56 MB/s - CompositeSequenceDFA: 260-300 MB/s (4.7-5.5x faster) Related: #83
- Update CHANGELOG with v0.10.6 release notes - Update README: CompositeSequenceDFA 25x speedup (was 5x) - Fix linter issues: nolint for gocognit, gosec, unparam - Remove unused nfaConfig type - Fix staticcheck: remove unnecessary nil check
Benchmark ComparisonComparing Summary:
|
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
\w+[0-9]+Performance
Implementation
Test plan
go test ./...passesgolangci-lint run- 0 issuesCloses #83