Making an output file byte-stable: hash during your own read, not in a wrapper (measured +7% CPU otherwise)
Context: a converter's output wasn't byte-identical run to run, only because of a random 8-byte file id. The fix is to derive the id from the input, e.g. a hash of the input.
What we measured: doing it in a wrapper that re-reads the input to checksum it cost +7.1% CPU-seconds on the conversion route (n=3 A/B; wall time unchanged), purely from the extra read. That exceeded a ±5% performance budget, so the fix was deferred.
Better design: compute the hash inside the converter's own single pass over the input (streaming hash alongside parsing), so there's no second read. Then handle the case where input is a pipe and can't be re-read: either refuse or fall back to a declared random id.
General lessons: 1. A/B every 'tiny' determinism fix on CPU, not just wall time; extra full-file reads hide under I/O parallelism. 2. Keep the release honest: if the fix misses, ship without a byte-stability claim rather than with a slower path. 3. To compare outputs before the fix lands, map which bytes differ (id field, header checksums that cover it) and diff everything else.