Repository navigation
index: preserve Unicode fold classes in substring verification - #1230
Merged
keegancsmith merged 10 commits intoNov 13, 2026
Merged
Conversation
keegancsmith
requested changes
Nov 12, 2026
keegancsmith
left a comment
Member
There was a problem hiding this comment.
The fix looks right. Three things before merge:
- The ASCII fast path got slower, because the pattern byte is now case-folded on every iteration. Lowercase both bytes through a 256-byte lookup table (or only lowercase when
pb != mb). In my benchmark either one matches main's speed. Lowercasing ASCII never leaves a fold class, so k/K and s/ſ still go to the slow path correctly. - Drop the
substrBytes == nilfallback inmatchContent. Only test fixtures need it, so update them instead. - Trim the integration test: put the ſ/ς/uppercase rows into
TestCaseFoldingEqualsRunes, and keep one content case and one filename case. Keep the exhaustive fold-table test.
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
perfloop
Bot
force-pushed
the
perfloop-pr-open-8k5yx2g7jj
branch
from
November 13, 2026 01:51
e7c5d0b to
648e7b7
Compare
Contributor
Author
|
ASCII comparison uses a 256-byte lookup table, and the description contains paired ASCII and Unicode results. Unicode folding avoids redundant Latin-1 work and stops when the fold cycle wraps; the description also states its remaining costs. The original-pattern fixtures and two-case integration test remain. |
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.
Substring filters now use Unicode simple folding of the original pattern and report consumed subject bytes. This preserves
sss/ssſandσσσ/σσςmatches with equivalent extraction or retained regexps. ASCII uses a 256-byte lowercase table and byte positions. Cached lowercase buffers retain cheap extent checks after matched prefixes; BM25 grouping is unchanged.Paired Linux amd64/Go 1.27.3 medians:
Remaining complete substring-verification costs, in ns/op (base → changed; pairs):
These costs are accepted to prevent lost matches while preserving corrupt-span detection and cheap mismatch bounds. Net cost depends on unknown query mix; these checks do not measure whole-Search latency.
The native mixed-subject benchmark is in
index/case_folding_bench_test.go. Reproduction recipe:go test ./index -run '^$' -bench '^BenchmarkCaseFoldingEqualsRunes$' -benchtime=2000000x -count=1.Focused Go tests covering folding, substring/regexp search, byte spans, symbols, BM25 and corrupt-candidate bounds passed. Native tests cover two Search cases, the fold-table sweep and two cached-width bounds rows.
The separate regexp-engine fixed-width-prefix issue can still affect anchored long-s queries such as
case:no content:sss$.Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.