zstd
zstd copied to clipboard
Optimal huff depth speed improvements
TLDR
This PR is a followup to a previous PR that, for high compression levels, brute force tests all valid Huffman table depths and chooses the optimal based on minimizing encoded + header size. This PR introduces some speed optimizations that could (potentially) allow this feature to be used at lower compression levels.
Note: This does cause us to lose a bit in terms of compression ratio, but offers a significant speed improvement. This could mean that we want more fine-grained depth modes
, but that could be overkill.
Benchmarking
I benchmarked on an Intel(R) Xeon(R) Gold 6138 CPU @ 2.00GHz machine with core isolation and turbo disabled. I measured compression time and compression ratio for silesia.tar (212M), compiling with clang15. I experimented with various combinations of compression level and chunk size. I ran each scenario 5 times and chose the maximum speed value.
Speed-Optimized Optimal Log vs. No Optimal Log
In the following tables, ctrl
uses the original huffman log method with no speed or compression optimizations, and test
uses the speed-optimized huffman log method.
Default block size
![Screen Shot 2022-10-27 at 4 44 42 PM](https://user-images.githubusercontent.com/48103643/198394271-3c532d44-94a0-4663-aad0-5e9b0a6d611a.png)
-B1KB
![Screen Shot 2022-10-27 at 4 45 05 PM](https://user-images.githubusercontent.com/48103643/198394335-c066bdbc-dfa0-458d-8b40-9024852de707.png)
-B16KB
![Screen Shot 2022-10-27 at 4 45 25 PM](https://user-images.githubusercontent.com/48103643/198394386-e9cca96e-91b9-46fd-88b9-dbb78d3e6b8b.png)
Speed-Optimized Optimal Log vs. Brute Force Optimal Log
In the following tables, ctrl
uses the brute force optimal log method, and test
uses the speed-optimized optimal log method.
Default block size
![Screen Shot 2022-10-27 at 10 37 30 PM](https://user-images.githubusercontent.com/48103643/198473484-466ee1b9-aefc-400c-86d6-5ee4bdc3e120.png)
-B1KB
![Screen Shot 2022-10-27 at 10 39 48 PM](https://user-images.githubusercontent.com/48103643/198474730-136b2df8-a81c-480d-b9a7-25d0412c8e6e.png)
-B16KB
![Screen Shot 2022-10-27 at 10 38 29 PM](https://user-images.githubusercontent.com/48103643/198473987-39471161-ba8f-490b-855d-219a800de803.png)