Repository navigation
3
strnlen is a slot of the table now, no longer memchr through the table in derived.c: memchr's blocks for the NUL, the offset for the answer (n when there is none), and past the two blocks in line a kernel of its own, strnlen_large, made of memchr_large's blocks. struct str_table has 22 slots where it had 20, so a loader that counts them, as pizdos's does, must count 22. strncat, strlcat and strndup call the slot; strlcpy and strpbrk choose by a select, not by a branch the programs' calls mispredict.
Zen 5 runs evex512. evex512r differed from it in memset alone, rep stosb for every size, and on the programs' own calls it lost on 18 of 20 and tied on 2; it goes, with the STR_FSRS bit and the cpuid leaves only it read. For Broadwell the small copies and fills of sse2, sse42 and avx2 test their size classes in rising order, one taken branch at most; avx2's memset stores up to 256 bytes itself; and avx2's fills from 8 MiB on are non-temporal stores closed by an sfence.
The compiler builds the library for pizdos's wasm2o as well (--abi wasm2o, ./build libstr_wasm2o): the convention of the code wasm2o compiles, for its loader to link. That build found a bug: a function whose stack addresses escape made a tail call, and str_host's struct on the stack was overwritten; such a call is no longer a tail call. A vector operation's address now folds into its memory operand (eight functions lose an instruction or two), and the compiler emits non-temporal vector stores and sfence.
The lab measures real programs too: dev/lab/pizdos.py runs pizdos's compiler compiling itself, its decoders and CPython with this library linked in, counts their cycles, and records their calls as traces for kbench. The workload has the derived functions in its mix and 1% of its copies and fills on a power-law tail from 4 KiB to 8 MiB, as the programs make them. README's table is on it: 0.65, 0.81 and 0.96 of glibc's time on Zen 5, Skylake-SP and Broadwell. A call costs more there than in release 2's workload, so the two tables do not compare.
The proof chain ran entirely on this release's code: every function in every configuration (116 of 116), and the derived functions by the contracts of the slots they call, all of them but memmem and strstr, which are tested. New are the proofs of strnlen and its kernel, non-temporal stores and sfence in the symbolic machine, and a proof of evex's fill_large of its own. The first runs found two gaps in the specs, closed now: strnlen's lacked the obligation that the answer is n itself when there is no NUL, and strnlen_large's let its from wrap below s. The chain had three faults of its own: the nodes were not sent common.h, --dist swept the hosts' answer cache, and the prover's threads overflowed the 128 KiB stacks of the hosts' musl. strnlen_large in avx2 and in evex has one solver query each that takes 34 and 48 minutes, past the chain's default limit of 30 (-Dproof_timeout); both were proved with a limit of two hours.
Validation: on an AVX-512 host, the C test on every configuration and 176 one-slot mixes, the compiler's self-check, the decoder round-trip and the wasm2o contract; line and branch coverage 100% (1596 of 1596 lines, 1418 of 1418 branches); the whole proof chain, 262 nodes, proved; CI green with gcc and clang.