Bug fix + 16x speedup for -w when WORD starts with string literal#123
Open
ludi317 wants to merge 2 commits intosvent:masterfrom
Open
Bug fix + 16x speedup for -w when WORD starts with string literal#123ludi317 wants to merge 2 commits intosvent:masterfrom
ludi317 wants to merge 2 commits intosvent:masterfrom
Conversation
…h \b\W or ending with \W\b Old code: $ sift "\b\W\W\W\b" $m/mist-ap/cloud | wc -l 0 New code: $ sift "\b\W\W\W\b" $m/mist-ap/cloud | wc -l 3509 Ripgrep agrees with bug fix: $ rg "\b\W\W\W\b" $m/mist-ap/cloud | wc -l 3509
…tches for WORD start with a string literal. 1. Make a first pass over the haystack by starting the search with the string literal part of the needle: WORD\b It's a more selective filter (in most cases) and delays entering the slower regex engine. [1] 2. Do a second pass with the now much smaller haystack on the complete needle: \bWORD\b [1] https://github.com/golang/go/blob/a064a4f29a97a4fc7398d1ac9d7c53c5ba0bc646/src/regexp/backtrack.go#L341 Observed 16x speedup for the following pattern and directory: sift -q "\bWaitForConnect\b" $m/mist-ap 2.60s user 0.09s system 549% cpu 0.488 total sift -w -q "WaitForConnect" $m/mist-ap 0.08s user 0.10s system 570% cpu 0.031 total
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.
No description provided.