Summary
CompressionLevel::Best currently triggers unimplemented!(). Level 11 uses binary tree with lazy matching — highest compression ratio in the current enum.
Analysis
C reference implementation (zstd level 11)
- Strategy:
ZSTD_btlazy2 (binary tree + lazy2)
- Parameters:
windowLog=24, chainLog=25, hashLog=24, searchLog=7, minMatch=3, targetLength=128
- Key file:
lib/compress/zstd_lazy.c (ZSTD_insertDUBT1, ZSTD_DUBT_findBestMatch)
Algorithm
- Binary search tree — sorted by suffix content for O(log n) match finding
- DUBT (Doubly-Unsorted Binary Tree) — insertion marks entries as sorted/unsorted (
ZSTD_DUBT_UNSORTED_MARK = 1)
- Common-length optimization —
commonLengthSmaller/Larger to skip already-compared bytes during tree traversal
- Lazy2 on top — same 2-step look-ahead as level 7 but with btree match finder instead of hash chains
What needs to be implemented
- Binary tree data structure — left/right pointers in chain table, sorted insertion
- DUBT insertion —
insertDUBT1 equivalent with sorted/unsorted mark handling
- Tree search —
ZSTD_DUBT_findBestMatch with common-length caching
- Integration with lazy2 — same lazy evaluation but better matches from btree
Acceptance criteria
Dependencies
Time estimate
4d
Blocked by
Summary
CompressionLevel::Bestcurrently triggersunimplemented!(). Level 11 uses binary tree with lazy matching — highest compression ratio in the current enum.Analysis
C reference implementation (zstd level 11)
ZSTD_btlazy2(binary tree + lazy2)windowLog=24, chainLog=25, hashLog=24, searchLog=7, minMatch=3, targetLength=128lib/compress/zstd_lazy.c(ZSTD_insertDUBT1, ZSTD_DUBT_findBestMatch)Algorithm
ZSTD_DUBT_UNSORTED_MARK = 1)commonLengthSmaller/Largerto skip already-compared bytes during tree traversalWhat needs to be implemented
insertDUBT1equivalent with sorted/unsorted mark handlingZSTD_DUBT_findBestMatchwith common-length cachingAcceptance criteria
CompressionLevel::Bestno longer panicsDependencies
Time estimate
4d
Blocked by