HC4 vs BT4: 7-Zip Match Finder Efficiency Compared
This article examines the operational and performance differences between the HC4 (Hash Chain) and BT4 (Binary Tree) match finders in 7-Zip's LZMA and LZMA2 compression algorithms. By comparing compression speed, memory overhead, and final archive ratios, this guide clarifies which algorithm provides the optimal balance of efficiency for specific archiving tasks.
Understanding Match Finders in 7-Zip
During the LZMA/LZMA2 compression process, the match finder scans incoming data to identify repeated byte sequences within a sliding dictionary window. Replacing these redundant sequences with shorter references is the foundation of dictionary-based compression. The choice of match finder dictates how efficiently 7-Zip locates these duplicate strings.
HC4 (Hash Chain 4) Characteristics
HC4 organizes references to previous data strings using a combination of hash tables and linear linked lists (chains).
- Speed: HC4 is optimized for execution speed. It searches through a fixed-depth chain of recent matches, bypassing exhaustive searches to minimize processor cycles.
- Memory Consumption: Hash chains require relatively low memory overhead per dictionary entry, as each entry only needs to point to the preceding match in the chain.
- Compression Ratio: Because HC4 stops traversing the chain once a predefined limit is reached, it often misses the absolute longest match available in the dictionary. Consequently, it yields lower compression ratios compared to tree-based approaches.
BT4 (Binary Tree 4) Characteristics
BT4 utilizes a 4-byte hash table pointing to binary search trees to organize and sort dictionary matches.
- Speed: BT4 requires substantially more CPU cycles than HC4. Inserting nodes and reorganizing binary trees during every byte shift creates significant processing overhead.
- Memory Consumption: Binary trees require two child pointers per node, leading to approximately double the RAM consumption of hash chains for the match finder structure itself.
- Compression Ratio: BT4 consistently finds the optimal (longest) match across the entire dictionary window. This exhaustive matching delivers the highest possible compression ratio, making it the default match finder for 7-Zip's "Normal," "Maximum," and "Ultra" presets.
Efficiency Comparison
| Metric | HC4 (Hash Chain) | BT4 (Binary Tree) |
|---|---|---|
| Compression Speed | Fast | Moderate to Slow |
| Decompression Speed | Identical (format dependent) | Identical (format dependent) |
| RAM Usage (Compression) | Low | High |
| Compression Ratio | Moderate | Maximum |
| Default 7-Zip Preset | Fast, Fastest | Normal, Maximum, Ultra |
When to Use HC4 vs. BT4
- Choose HC4 when throughput is critical or system memory is constrained. It is ideal for real-time backups, large log file archiving on busy servers, or situations where rapid job completion outweighs squeezing out the final few percent of file size reduction.
- Choose BT4 when archival density is the priority and compression time is secondary. It is the optimal choice for distributing software packages, cold storage backups, or archiving static data that will be stored long-term and decompressed frequently.