Skip to content

Add KB entry 041: speeding up zstd's strongest levels and decoder at equal size - #25

Open
HenningWoydt wants to merge 1 commit into
CHSZLab:mainfrom
HenningWoydt:kb/041-zstd-optimal-parser
Open

HenningWoydt wants to merge 1 commit into
CHSZLab:mainfrom
HenningWoydt:kb/041-zstd-optimal-parser

Conversation

@HenningWoydt

Copy link
Copy Markdown

Adds knowledge-base entry 041 and its row in INDEX.md.

The entry comes from an AAE session on the reference Zstandard library. The metric was the shifted geometric mean of the compression and decompression time ratios at levels 1 and 19, with compressed size held within 0.1% of the unmodified code. The score went from 1.000 to 0.877, and level-19 compression became 1.55x faster.

Transferable lessons:

  • Price tables: precomputing per-code prices in an optimal LZ parser took 11.7% off level-19 compression.
  • Huge pages before prefetch: for a pointer-chasing match finder larger than the TLB reach, prefetching both tree children gave -1.6% before transparent huge pages and -5.8% after them. Discarded memory-latency ideas are worth retrying after a change to the memory layout or paging.
  • Split loops: splitting a loop on its predictable condition beat a branchless rewrite.
  • Size budget: raising an under-tuned cost-model constant (the per-match handicap) made output smaller and decoding faster, which paid for a faster, less exhaustive length scan.
  • Loop placement: moving the decoder's hot loop to a different offset made decompression 5-9% faster on a CPU with the JCC-erratum microcode.
  • Dead ends and traps: a branchless tree descent and lockstep walks of upcoming searches were slower; gains of about 1% measured warm did not hold in the cold one-run-per-process benchmark; running sanitizers only at the benchmarked levels let an over-read slip through.

…equal size

Per-code price tables in the optimal parser, huge pages before tree
prefetch, cross-call prefetch pipelining, a split length scan, a
recalibrated per-match handicap and JCC-aware placement of the decoder
loop. Score 1.000 -> 0.877; level-19 compression 1.55x faster.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant