Honor the documented checksum-disable flag

perfloop-oss/lz4 · Uncatalogued performance

https://perfloop.ai/t/oss/case_1hekg0g6vs

Verdict

VALIDATED BY A DIFFERENT CHANGE · settled 2026-11-22 · merged as pierrec/lz4#302

What happened: The check fails before this change and passes with it.

Hypothesis

The compression checksum switch does the opposite of its documented purpose. Help and README say that -sc disables the stream checksum, but providing it enables the checksum and omitting it disables the checksum. This is an option-contract repair, not a security or measured speed claim. Use of either polarity by real callers and the performance cost of changing the default remain unknown.

At revision 8bbd9778866f036e932a403b46c656ed75cebbfd, Compress registers the false-by-default streamChecksum variable with help text `disable stream checksum` at cmd/lz4c/compress.go:36-37. The shared option setup passes that value directly to lz4.ChecksumOption at line 79. The resolved v4.1.33 codec documents ChecksumOption as an enable/disable setting with default true and sets its content-checksum bit directly from the boolean. README.md:40-41 repeats the disabling contract. This shared setup affects named files, stdin, and benchmark configuration; the proof fixture's named-file scenario is not the scope boundary.

Receipt call_c77c571874f24e84818067aac60fcf64, output:1, runs `go test -count=1 -run '^TestHuntCompressSCDisablesStreamChecksum$' .` in cmd/lz4c. The provisional test compresses one small regular input with -sc, -c=1, and -size=64K using the real codec. It verifies that the actual frame round-trips, then compares it with a fully finalized frame made using identical options and ChecksumOption(false). The test fails with `-sc must match ChecksumOption(false): got finalized frame 41 bytes, want 37 bytes`. Exit status 1 is the intended option-contract assertion failure. The current output is valid; it has the opposite checksum configuration. The fixture and exact-byte comparator are provisional proof methods.

The Case proof target is the documented switch polarity and corresponding default across the shared configuration path, with valid output in both states. The smallest next check is to make the exact -sc assertion pass, then verify the checksum-enabled default. Correcting this observable behavior requires compatibility and release-note consideration even though the runtime mapping itself is small; no maintainer acceptance of that change is assumed.

The existing checksum-truncation control in cmd/lz4c/main_test.go:229 onward uses -sc to prepare a checksum-bearing frame. That is a real fixture dependency on current behavior, not an explicit decision overriding the flag documentation. Retain its truncated-checksum error coverage when adapting it to the corrected polarity. The fixture arrived in the merged https://github.com/pierrec/lz4/pull/297, whose deciding implementation concerns output truncation and input aliases, not this flag contract. The actual implementation in https://github.com/pierrec/lz4/pull/293 changes active Writer.ReadFrom composition and leaves this option mapping untouched. README.md:76-81 names GitHub issues and pull requests as the contribution venue; no separate review archive was identified. Older owner history is unavailable in the shallow checkout.

Change to test: Make -sc disable the stream checksum and its absence retain the codec's checksum-enabled default, consistently across Compress modes. Account for the observable polarity change in compatibility notes and update dependent fixtures without losing checksum-error coverage.

Where it lives

perfloop-oss/lz4

Evidence

The check fails before this change and passes with it: `For stdin and single named-file compression, lz4c help describes -sc as enabling the stream checksum: frames omit it by default and include it with -sc, and both forms decode to the original input.`

Checks: 2 of 2 passed. Verification: no defect found.

Timeline