Does the LZ4 multithreaded scaling advantage hold beyond level -1?

Short answer: yes, at every level tested. After one build-script fix uncovered by this experiment, the optimized LZ4 binary beats stock LZ4 v1.10.0's built-in multithreading at all compression levels (-1, -3, -6, -9) and all multithreaded thread counts (8, 16, 32, and even 64 = 2× oversubscription), while producing byte-identical output.

Setup. Pristine upstream lz4 v1.10.0 (commit 0774d05, plain make) vs the optimized build (parallel chunk reads + PGO/LTO/native flags). Workload: lz4 -<level> -T<threads> -c silesia8.tar > /dev/null on a 1.7 GB corpus (8× silesia.tar) held in RAM (tmpfs), interleaved best-of-3 wall-clock runs on an idle 2× Xeon (16 physical cores / 32 hardware threads). Level -1 is LZ4's fast mode; levels -3/-6/-9 use the high-compression (HC) engine.

1 · Compression throughput: stock vs optimized (MB/s, best-of-3)

LevelThreadsStock lz4 -T#OptimizedAdvantage Stock scaling vs its own T1Optimized scaling
-1 (fast) 1426.6419.30.98× (noise)1.0×1.0×
81,614.93,028.01.88×3.8×7.2×
161,583.33,670.32.32×3.7×8.8×
321,519.43,810.52.51×3.6×9.1×
641,473.23,785.02.57×3.5×9.0×
-3 (HC) 181.387.21.07×1.0×1.0×
8612.8668.11.09×7.5×7.7×
161,057.81,276.91.21×13.0×14.6×
321,293.41,638.31.27×15.9×18.8×
641,213.81,477.11.22×14.9×16.9×
-6 (HC) 149.553.01.07×1.0×1.0×
8384.7414.21.08×7.8×7.8×
16730.9798.01.09×14.8×15.1×
32929.61,068.51.15×18.8×20.2×
64883.61,021.51.16×17.9×19.3×
-9 (HC) 131.934.01.07×1.0×1.0×
8246.5263.61.07×7.7×7.8×
16474.2506.31.07×14.9×14.9×
32626.9684.01.09×19.7×20.1×
64609.1678.31.11×19.1×19.9×

2 · Throughput at 32 threads, level by level

MB/s (T32) 1000 2000 3000 4000 1,519 3,811 level -1 2.51× 1,293 1,638 level -3 1.27× 930 1,069 level -6 1.15× 627 684 level -9 1.09× stock v1.10.0 optimized
Compression throughput at 32 threads, silesia×8 in tmpfs, best-of-3. The advantage is largest at -1 (I/O-loop-bound) and stays positive through -9 (compute-bound).

3 · Scaling curves: where stock stalls and where it doesn't

level -1 (fast) — MB/s 2000 4000 18163264 3,811 1,519 (stalls at T8) level -9 (HC) — MB/s 350 700 18163264 684 627 stock v1.10.0 optimized
At level -1 stock is limited by its serial read→checksum→dispatch loop (scaling stalls at ~3.8×); the optimized parallel-read path reaches 9.1×. At level -9 compression itself is the bottleneck, so both scale to ~20× on 16 cores + hyperthreading — and the optimized build still wins on raw throughput.

4 · A finding this experiment uncovered (and fixed)

The first run showed the optimized binary losing ~5–6% to stock at HC levels, even single-threaded. To separate code from compiler flags, the optimized sources were rebuilt with plain make (identical flags to stock): that build won at every level (-3 T32: 1.19×, -6 T32: 1.09×, -9 T32: 1.03×, -9 T1: exact parity) — proving the deficit came from the build, not the code. Root cause: the PGO (profile-guided optimization) stage trained only on level-1 runs, so the compiler optimized the fast path at the HC path's expense. Fix (commit 032f1c0): build-optimized.sh now trains levels 1, 3 and 9. After retraining, the HC levels flipped from −6% to +7% single-threaded and +7–27% multithreaded, with level -1 unregressed.

5 · Honesty checks

Reproduce

git clone https://github.com/lz4/lz4 lz4-stock && git -C lz4-stock checkout 0774d05 && make -C lz4-stock -j
cd ~/LZ4-ks && ./build-optimized.sh                      # now trains PGO on levels 1, 3, 9
for i in $(seq 8); do cat ~/LZ4-ks-bench/silesia.tar >> /dev/shm/silesia8.tar; done
for L in 1 3 6 9; do for T in 8 16 32 64; do
  /usr/bin/time -f "stock -$L -T$T: %e s" ./lz4-stock/lz4 -$L -T$T -c /dev/shm/silesia8.tar > /dev/null
  /usr/bin/time -f "ours  -$L -T$T: %e s" ~/LZ4-ks/lz4   -$L -T$T -c /dev/shm/silesia8.tar > /dev/null
done; done

Raw measurement record: ~/LZ4-ks/OPTIMIZATION-RESULTS.md (Round 7, commit 032f1c0). Machine: 2× Intel Xeon 2.80 GHz, 16 physical cores / 32 hardware threads, lz4 v1.10.0 sources at upstream commit 0774d05.