perf: optimize strategy selection and Teddy 2-byte fingerprint#61
Merged
perf: optimize strategy selection and Teddy 2-byte fingerprint#61
Conversation
Phase 1: Version pattern optimization - Move DigitPrefilter check before tiny NFA fallback (line 776) - Reject single-byte inner literals for digit-lead patterns - Patterns like \d+\.\d+\.\d+ now use DigitPrefilter instead of ReverseInner - Expected improvement: version pattern 12x -> 2x slower vs Rust Phase 2: Teddy 2-byte fingerprint - Change default fingerprint length from 1 to 2 bytes - Implement teddySlimSSSE3_2 assembly function (~150 LOC) - Reduces false positives by ~90% (from ~25% to <0.5%) - Expected improvement: literal_alt pattern 39x -> 5x slower vs Rust Files modified: - meta/strategy.go: reorder DigitPrefilter check - prefilter/teddy.go: change default to 2-byte fingerprint - prefilter/teddy_ssse3_amd64.go: add dispatch for case 2 - prefilter/teddy_ssse3_amd64.s: implement teddySlimSSSE3_2 - prefilter/teddy_test.go: update test expectation
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
isDigitLeadPattern()helper for pattern classificationPerformance Impact
Trade-off Analysis
The IP pattern regression is an acceptable trade-off:
Technical Details
Teddy 2-byte Fingerprint
Changed default from 1-byte to 2-byte fingerprint in
prefilter/teddy.go:Strategy Reorder
Moved
DigitPrefiltercheck before tiny NFA fallback inmeta/strategy.go:.) for digit patternsTest Plan