Say what the multibyte block kernel changed, and where it still loses

The 100 MB numbers replace the 10 MB ones, because 10 MB was measuring
process startup as much as the decoder. Characters in dense CJK now beat
the clone by 2.5x; words and longest line still lose to it by a quarter,
which the divergences section says out loud instead of leaving the reader
to find it. The -c and -m rows join the head-to-head table: no stream is
opened for a count that is a file size.
This commit is contained in:
2026-11-15 13:51:33 -05:00
parent 3194a21aec
commit a2fef6ce5c
2 changed files with 43 additions and 26 deletions
+15 -9
View File
@@ -149,13 +149,16 @@ bite with them.
| `-L`, 11 GB | 1.29 s | **0.56 s** |
| 1050 × 1 MiB, `-lwc` | 145 ms | **45 ms** |
| 1050 × 1 MiB, `-L` | 1.23 s | **66 ms** |
| 1050 × 1 MiB, `-c` | 3.7 ms | **2.1 ms** |
| 1050 × 1 MiB, `-m` | 30.8 ms | **2.7 ms** |
Same files, same machine, both binaries racing the clock back to back.
Read the last row twice: on a thousand small files we are eighteen times
Read the `-L` row twice: on a thousand small files we are eighteen times
faster at the one thing it used to win, because the width kernel now
computes a whole 64-byte block's line widths with prefix sums and one
packed subtract, and a long file list is spread over the cores instead of
counted one file at a time.
counted one file at a time. The `-c` and `-m` rows are the other half of
that: a count that is a file size never opens the file.
Rust is the femboy language of systems programming: spotless hygiene,
elaborate safety equipment, and a firm opinion about how you should be
@@ -176,13 +179,16 @@ whether it holds one line or sixty. That isn't a language feature. It's
maths their kernel doesn't do, and ours does.
The same goes for the locale. Their "decode only around the high bytes"
instinct was right, so the UTF-8 path now splits the mapping into chunks
that decode independently and hands every ASCII stretch to the byte
kernels. 10 MB of lightly thé'd text under `en_US.UTF-8`: **1.6 ms**,
against their 2.8 ms and GNU's 30 ms. Dense CJK is the one place they
still edge us on `-w` and `-m`, because they carry their own width table
and we call `wcwidth` so the counts match GNU exactly. We are five times
ahead of GNU there and we will take the trade.
instinct was right, so the UTF-8 path splits the mapping into chunks that
decode independently, hands every ASCII stretch to the byte kernels, and
counts dense CJK a 64-byte block at a time from masks rather than a
character at a time. 100 MB of lightly thé'd text under `en_US.UTF-8`:
**5.5 ms**, against their 6.2 and GNU's 224. On dense CJK characters we
are 7.6 ms against their 18.7; on CJK words and longest line they still
have us by a quarter, because they keep a width table and trust the
encoding where we validate and call `wcwidth` to match GNU exactly. We
will take a quarter of a loss on two flags of one alphabet for exact
counts on all of them.
## What it does