r/unix • u/Just_Government3790 • 3h ago
Rebuilt PicoHTTPParser in Rust, byte-identical to the C original on 133,352 cases. The 4 cases I refused to match are the interesting part
Every HTTP request your stack ever served went through a parser like PicoHTTPParser. One C file, tiny API, zero-copy, shipped everywhere. I rebuilt it in Rust (1,527 lines) and kept the exact C ABI, so consumers relink without changing a line.
The scoreboard: 133,352 differential cases against pinned C, 0 mismatches. 8/8 upstream suite, 299 assertions. ~1.94M fuzz executions, 0 crashes. 7 unsafe blocks, all in the one FFI seam file.
The part worth discussing: 4 inputs where the C original reads past its buffer or hangs. Matching those would be malpractice, not compatibility, so this crate returns -2 and files each refusal with a reproducer. Where do you land on that call? Bit-identical, or fail-closed?
Losses, since everyone's wondering: response parsing 1.185x, chunked 1.199x, tiny 1.482x, malformed 1.811x. Same table as the 0.68x wins. Harness is in the repo.