Compression Benchmark: ZIP vs 7-Zip (LZMA2) vs zstd

When optimizing deployment pipelines and storage for .NET applications, choosing the right compression algorithm can significantly impact both storage costs and deployment speed. I recently conducted a comprehensive benchmark comparing three popular compression methods: ZIP, 7-Zip with LZMA2, and Facebook’s Zstandard (zstd) algorithm.

Test Dataset

The benchmark used real-world .NET application data consisting of dotnet publish output files from our backend services. The dataset included:

  • Size: 5.4GB of uncompressed data
  • Content: Mixed self-contained and framework-dependent publish outputs. A lot of duplicates files.
  • Structure: Multiple directories with typical .NET deployment artifacts
  • Test Focus: Compression only (decompression speeds not measured)

This represents a realistic scenario for developers working with .NET application deployments, CI/CD pipelines, and artifact storage.

Benchmark Results

ZIP Compression

  • Time: 5 minutes
  • Compressed size: 1.8GB
  • Compression ratio: 67% size reduction

The standard ZIP format provided decent compression with reasonable speed, serving as our baseline for comparison.

7-Zip (LZMA2)

I tested two different configurations of 7-Zip’s LZMA2 algorithm:

PresetBlockTimeCompressed SizeCompression Ratio
StandardSolid7,5 min1,2GB78%
Ultra64MB10,5 min0,88GB84%

Zstandard (zstd)

Zstandard was tested across multiple compression levels, both with and without dictionaries:

PresetDictionaryTimeCompressed SizeCompression Ratio
19No34,5 min1,38GB74%
16Yes14,5 min1,49GB72%
12Yes3 min1,55GB71%
6Yes1 min1,61GB70%
3Yes0,5 min1,7GB69%

Key Findings

Compression Efficiency

7-Zip emerged as the clear winner for maximum compression ratio. The Ultra preset achieved an impressive 84% size reduction, nearly halving the storage requirements compared to ZIP. This was a surprise for me, I expected zstd to be better in every aspect, but it turned out that in the case of many identical source files (dll, cs, etc.), the result can be surprising.

Speed vs Ratio Balance

Zstandard offers the best speed-to-compression ratio. While it doesn’t achieve 7-Zip’s compression levels, zstd preset 6 with dictionary compression provides 70% size reduction in just 1 minute – making it 7-10 times faster than 7-Zip for similar results.

Diminishing Returns in zstd

Higher zstd presets (16, 19) dramatically increase compression time while providing only marginal improvements in file size. The sweet spot appears to be presets 3-6 for most practical applications.

Decompression Performance

While not measured in this benchmark, it’s worth noting that zstd typically provides 10x faster decompression than 7-Zip, with decompression speed remaining consistent regardless of the compression level used. This makes zstd particularly attractive for scenarios where files are compressed once but decompressed frequently.

Practical Recommendations

I would choose 7-Zip (LZMA2) when:

  • Storage cost is critical (cloud storage, long-term archival)
  • Compression time is not a constraint (overnight builds, batch processing)
  • Maximum compression ratio is required

I would choose Zstandard when:

  • Balanced performance is needed (CI/CD pipelines, frequent deployments)
  • Fast decompression is important (runtime package extraction, frequent access)
  • Moderate compression with good speed is acceptable

I would choose ZIP when:

  • Universal compatibility is required (cross-platform, legacy systems)
  • Simple tooling is preferred (built-in OS support, minimal dependencies)
  • Good-enough compression with standard tooling

Implementation Considerations

For .NET developers working with deployment pipelines, consider these factors:

Build Pipeline Integration: Zstandard’s speed makes it ideal for CI/CD scenarios where build time directly impacts developer productivity.

Container Images: When building Docker images, the compression choice can significantly impact both image size and push/pull times.

Package Distribution: If your application involves distributing packages that are downloaded and extracted frequently, zstd’s fast decompression becomes a significant advantage.

Conclusion

The benchmark clearly shows that there’s no one-size-fits-all solution. 7-Zip excels in storage efficiency, Zstandard provides the best balance of speed and compression, while ZIP remains the most universally compatible option.

For most .NET development scenarios involving frequent compression and decompression cycles, Zstandard with presets 3-6 offers the optimal balance, providing significant storage savings while maintaining fast operation speeds that don’t bottleneck development workflows.

The choice ultimately depends on your specific requirements.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top