Repository navigation
perf: add optional o200k SIMD masks - #45
Merged
Merged
Conversation
Benchmark report✅ All base and PR correctness gates passed. Compared Cells marked
Pretokenizer pattern scanMedian scan time over paired samples (5.0 MiB per corpus);
Optional SIMD pattern scan
Median scan time over paired samples (5.0 MiB per corpus). The optional backend applies to ASCII-led GPT-2, r50k, and cl100k inputs; Chinese rows are scalar controls.
Peak RSS
|
clouds56
marked this pull request as ready for review
August 31, 2026 11:46
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
simdfeature behind the existing NEON/AVX2 backendsImplementation
Pattern::O200know selects a dedicated pure-ASCII SIMD boundary scheme. Itmodels the o200k-only parts of the PAT expression:
camelCasecan'tandx'll'dThe scheme is deliberately conservative. It only activates for an ASCII first
64-byte window and only caches ends through byte 60. Unicode, short inputs, and
right-edge ambiguity remain on the existing scalar scanner. The public iterator
and the scalar result are unchanged.
O200k uses a separate NEON/AVX2 classification pass because its grammar needs
strict-uppercase and slash masks. GPT-2/r50k/cl100k keep their existing mask
set and therefore pay no extra classification cost.
Local benchmark
Apple M2 / Rust 1.97, 5 MiB fixture, nine paired samples:
Both builds passed the direct
fancy-regexcorrectness gate. The Englishtoken-stream fingerprint was identical (1,233,584 pretokens); Chinese remains
a scalar control because its first window is non-ASCII.
The benchmark-comment renderer now includes o200k. Its trusted PR comment is
rendered from
master, so this PR's bot comment will not list o200k until thechange lands; the benchmark job's candidate preview does.
Validation
cargo test --all --features "cli simd" --verbosecargo test -p ffbpe-pat --features simd --verbosecargo check -p ffbpe-pat --features simd --target x86_64-apple-darwinnode --test .github/scripts/update-benchmark-comment.test.cjsbash .github/scripts/validate-benchmark-reports.test.shuv run --no-sync mkdocs build --strictrustfmt --checkfor changed PAT sources--features simd5 MiB, nine-sample PAT scan reports