Every case in the suite pinned LC_ALL=C, so the multibyte path - the one
whose counts go wrong quietly rather than crashing - had no contract
behind it at all. genfile grew a --utf8 mode that writes mixed CJK,
ASCII words, a tab, an ideographic space, a no-break space and a
combining accent, and the words suite now races -w, -m and -L over 300k
lines of it under en_US.UTF-8 (C.UTF-8 as a fallback), against coreutils.
The case runs the locale on both sides rather than inheriting the C pin,
because the oracle's own decoder is the reference. It prints SKIP rather
than passing when the host has no UTF-8 locale: a multibyte count cannot
be checked in a single-byte one.
The numbers for -L and for a long file list lived in a scratch harness,
so nothing in the repository would fail if either regressed. The lines
suite now races -L at 1M and 10M lines against every oracle, and ends
with 128 files holding 12.8M lines counted in one invocation, which is
where the worker pool lives.
The file-list check compares the row count and the total row's numbers
rather than the whole output: busybox and toybox pad their columns
differently, and an exact string compare would fail on their formatting
instead of on our arithmetic.
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.
-L is now the widest gap in the table rather than the one case we lost,
so the README stops pretending that "never slower" covered it and says
where the numbers came from. The Rust clone that held the record gets
its own section: what it did right, what it still wins (dense CJK, by
carrying a width table where we call wcwidth), and what it lost.
PERFORMANCE.md gets the receipts: the -L kernel ladder with one-core
throughput per kernel, the UTF-8 numbers before and after the split
decode, the thread-count rules, and the tab and CJK cases stated as
divergences instead of hidden.
Busybox wc is back in every suite, for shits and giggles. checkwc now
walks PATH and identifies each wc by its --version answer (coreutils and
fastwc respond; busybox names itself in the error it prints), so a wc
symlinked to fastwc is detected and skipped instead of silently racing
us against ourselves, and a missing coreutils is a clear configure
error. Every run now ends with the average speedup of fastwc against
coreutils and busybox, computed from the per-case ratios.
The fail-fast verdict now requires a measurable (>0ms) reference time,
so sub-millisecond cases stop flaking on startup noise, and the 100M
line monster is pinned back to the coreutils oracle instead of whatever
oracle was raced last.
Adds -L/--max-line-length (display width, tab stops every 8), the long
options --lines/--words/--chars/--bytes/--max-line-length, --files0-from
(NUL-delimited name lists), --total=auto|always|only|never, --debug
(acceleration diagnostics), and POSIXLY_CORRECT handling. Ports GNU's
column width rule (digits of the sum of regular file sizes, floor 7 for
non-regular inputs), its multibyte word/line-length semantics (-w/-m/-L
decode per character under a multibyte locale), the -c sizing heuristic
(page-aligned st_size reads a tail block), and its error texts, quoting
and exit codes.
Verified byte-identical stdout, exit codes and (normalized) stderr
against coreutils wc 9.11: 125-case parity suite and 552-case fuzz
across C, C.UTF-8, en_US.UTF-8 and POSIX locales. The benchmark contract
holds: words, lines (incl. the 100M monster) and stdin all pass with
fastwc never slower than GNU wc.
Review (5-lane) found one MAJOR: count_sliced ignored pthread_create's
return value - on EAGAIN it joined an indeterminate pthread_t and summed
an uninitialized slice, UB plus a silently wrong count. Threads are now
initialized to 0, a failed create counts its slice inline, and nt is
hard-capped at a named MAX_THREADS (the fixed jobs[8]/th[8] arrays
smash the stack past 8 threads - reproduced by QA's thread sweep).
Shipped from the measured optimization hunt:
- -w-only mode skips the newline compare/popcount entirely (the
(x-9)<5 range already covers '\n' in the whitespace mask) - a
need_lines gate threads through every kernel, the scalar reference,
the avx512 mirror, and the sliced workers.
- Thread retune: 12 threads past 32 MiB, 16 past 256 MiB (was 8) -
up to 18% on 110 MB, ~3% on 1.1 GB in QA's interleaved sweep.
- Benchmark suites pin LC_ALL=C so GNU wc -w can't silently switch to
multibyte decoding and inflate the win.
- popcount16 is guarded to x86 builds (zero-warnings on other arches);
checkwc's stray argument dropped.
Verified: selftest (kernels + sliced, now with need_lines coverage),
120-trial fuzz vs GNU (file + stdin, both locales), full test-all suite
three consecutive times, format-check and clang-tidy clean. The 1B
solo monster now lands at 3.7-6s (up to 268 Mlines/s) depending on how
warm the page cache is feeling.
Suites split into benchmarks/files/{lines,words} and
benchmarks/stdin/piping, with the monsters bolted onto the lines suite:
100M lines raced against coreutils (~2x win), 1B lines solo (~6-8s,
11 GB in one pass). Stdin redirects from regular files are now mmap'd
in count_stream, so the stdin suite wins too — up to 12.00x on words.
The ratio column now reports how many times faster fastwc is, not how
much of GNU's time it used. busybox was removed from the suite: it
stopped being a challenge and started being a participation trophy.
GNU wc's lone win — 1M lines by one millisecond on hand-tuned AVX-512
assembly — is now a historical footnote, and the README says so.
SIMD kernels (AVX-512/AVX-2/SSE2, runtime-dispatched) counting a
single pass over mmap'd files, split across cores past 8 MiB, with
exact GNU oracle parity (NBSP included, glibc's decoder fixed, the
whole -m path mirrored so counts agree at every boundary).
Result: 1ms vs 2ms at 1M lines, 8-9ms vs 22-24ms at 10M. Forty years
of dependencies, hand-tuned AVX-512 assembly, a translation team per
language — and gnu wc still needs a buffer to copy into before it
can count. We mapped the file and just counted. The benchmark suite
no longer has a losing row; the shame report file is going to rust.