perf(atomsplit): fuse o200k letter case-split + 32-wide ASCII classify#2201
Open
ArthurZucker wants to merge 2 commits into
Open
perf(atomsplit): fuse o200k letter case-split + 32-wide ASCII classify#2201ArthurZucker wants to merge 2 commits into
ArthurZucker wants to merge 2 commits into
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
ArthurZucker
force-pushed
the
perf/o200k-classify
branch
from
July 15, 2026 16:58
5c18f87 to
4ca03be
Compare
o200k: fold the per-run `letter_end` scan into the case-split so each
`[\p{L}\p{M}]+` run is walked once instead of twice, unroll phase-A/B
16 tags per chunk like `run_end`, and resolve the give-back last-C by a
backward hop (no per-char tracking). Byte-exact (o200k_parity); FSM
-21% to -41% across corpora (Thai -41%, Russian -39%, Chinese -34%),
so every corpus now beats logos on the full pipeline.
classify: widen the ASCII fast path to 32 bytes (one bounds check + one
`vmaxvq` covers two 16-byte stores) in place; the multibyte path is
untouched. English classify +45%, French/Russian +10-14% (text is
~half ASCII), no multibyte regression.
ArthurZucker
force-pushed
the
perf/o200k-classify
branch
from
July 15, 2026 17:06
4ca03be to
8e8b75e
Compare
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.
Two byte-exact perf changes to
atomsplit, both isolated to the scalar o200k FSM and the NEON classify kernel. No behavioural change —o200k_parityand the classify SIMD-vs-scalar parity tests pass, 0 warnings.1. o200k letter case-split: one pass instead of two
fsm_o200kwalked every[\p{L}\p{M}]+run twice —letter_end()to find the run end, thenemit_o200k_letters/o200k_letter_matchre-scanned the same bytes for the case split. Since the tags already carry exact case (UpperLetter/LowerLetter/caseless), the run end can be discovered inline during the case split:letter_endinto the phase-A[UC]*/ phase-B[LC]+scans (each stops at a non-member = run end);get_unchecked, same shape asrun_end(a 16-wide scan already skips cont spans wholesale — a 48-wide variant was measured and lost);FSM throughput (ns/byte, min-of-7, byte-exact ✓ vs onig):
Every corpus now beats logos on the full (classify + fsm) pipeline; the previous Chinese/Thai ties are gone.
2. classify: 32-wide ASCII fast path
The NEON kernel loads 32 bytes to produce 16 tags (it needs the
b1/b2lookahead), so non-ASCII bytes were effectively loaded twice. The ASCII fast path now peeks 32 bytes at once — one bounds check + onevmaxvqreduction covers two 16-byte stores — done in place. The multibyte body is completely untouched (same code, same comments). Real text is ~half ASCII (spaces / digits / punctuation), so this fires constantly.classify throughput (ns/byte, byte-exact ✓ vs
classify_scalar):No regression on non-ASCII scripts. (A full 32-wide multibyte driver was prototyped too — it gains Chinese +17% but regresses 2-byte scripts −8 to −14%, so only the clean ASCII-widening is kept.)