Choosing an Archive Format: Ratio, Speed and Compatibility

Choosing an Archive Format: Ratio, Speed and Compatibility
Technical Specifications & Compatibility
Deflate Window 32 KB LZ77 sliding window, fixed by the format
Dictionary Size 64 MB with LZMA2 at 7-Zip -mx=9, allocated in RAM to decode
Zstandard Window 8 MB window at level 19 (windowLog 23)
Solid Mode on by default in 7-Zip and RAR; -ms=off disables it
Header Encryption 7z -mhe=on; RAR -hp; ZIP leaves the central directory readable
Table of Contents

A 40 GB folder leaves your machine as one file and has to arrive usable. The container you choose settles three things at once: how much smaller the transfer gets, how long the sender waits, and whether the recipient needs to install anything before opening it. Those three pull against each other, and the best ratio is rarely the right default. The useful question is which content type is inside.

Three algorithms, three strategies

DEFLATE is the oldest and most widely deployed. It finds repeated strings inside a 32 KB sliding window and encodes them with Huffman codes. The window is fixed by the format, so a match forty kilobytes back cannot be referenced at all. Hence the plateau: fast and unencumbered, not dense.

LZMA2 replaces the fixed window with a dictionary the encoder chooses, 64 MB at the maximum 7-Zip preset, and codes literals with a range coder instead of Huffman tables. A binary-tree match finder searches the whole dictionary while an optimal parser weighs each match against its encoding cost. Compression is slow; decompression only replays decisions.

Zstandard aims at the middle. It combines finite state entropy with Huffman coding over a configurable window, at levels 1 to 22. At low levels it matches DEFLATE at several times the speed; at level 19 it approaches LZMA2 ratios with a fast decoder. The price is a format less universally installed than ZIP.

Solid blocks trade access time for ratio

7-Zip and RAR compress groups of files as one continuous stream, called a solid block. A function name repeated across forty source files is stored once instead of forty times. That is where most of the advantage over ZIP comes from on code and logs.

The cost appears at extraction. Because the block is one stream, reaching a file near the end means decoding everything before it; a solid archive of thirty thousand small files can take minutes to produce one 4 KB text. Damage behaves the same way: a flipped byte invalidates the rest of the block. ZIP stores entries independently, which suits archives read selectively. In 7-Zip, -ms=off disables solid mode at some cost in ratio.

A solid archive is all-or-nothing. If the recipient needs one file today and the rest next month, that decision was made by whoever built it.

Dictionaries cost memory, not disk

The dictionary size sits in the archive header, and the decoder allocates it before producing a byte. A 7z built with -mx=9 declares a 64 MB dictionary, so extraction needs that much free RAM per decoding thread. On a 512 MB virtual server or an older phone, a large archive can fail with Can't allocate required memory before any file appears.

Compression needs more than decompression: the match finder keeps hash tables and a binary tree over the dictionary, often several times its size. Zstandard declares a window instead of a dictionary, 8 MB at level 19, and DEFLATE never exceeds 32 KB. If you distribute to unknown hardware, dictionary size is a compatibility parameter, not a detail.

Content typeZIP (DEFLATE -6)7Z (LZMA2 -mx=9)Zstandard (-19)
Plain text, logs, CSV3.5-4.5x5-7x4.5-6x
Source code, XML, JSON3-4x5-6.5x4-5.5x
Executables, disk images2-2.5x2.5-3.5x2.5-3x
JPEG, PNG, MP4, MP31.00-1.02x1.00-1.03x1.00x

Ratios are original over archive size, as orders of magnitude only.

Algorithm and levelCompressionDecompression
DEFLATE -630-60 MB/s200-400 MB/s
LZMA2 -mx=91-3 MB/s50-100 MB/s
Zstandard -193-8 MB/s500+ MB/s
Zstandard -3300+ MB/s1+ GB/s

Single-core figures; real throughput depends on the content.

Content that is already compressed

Compression removes redundancy. A JPEG has passed through discrete cosine transform, quantisation and Huffman coding, so its bytes are close to uniformly distributed. An MP4 carrying H.264 has been through CABAC. A general-purpose compressor looking for repeated strings finds almost nothing, and spends CPU proving it. A one-gigabyte video typically shrinks by under two percent.

The correct move is store mode: zip -0, or 7z a -m0=Copy. You keep the packaging benefit, one file with one checksum and a single transfer, without pretending the payload will shrink. PNG is the borderline case: it already contains DEFLATE streams.

Recompression changes the hash

A ZIP is not a canonical representation of its contents. Besides the file bytes it stores names, timestamps, a method per entry, extra fields and a central directory whose offsets depend on ordering. Rebuild the same folder with another tool and both the bytes and the SHA-256 change, even though every extracted file is identical.

This matters when you publish a checksum. The hash must describe the exact artifact you distribute; rebuild the archive afterwards and verification fails for reasons unrelated to corruption. Two policies work: hash the final archive once and never touch it, or publish per-file hashes and verify the extracted tree. The checksum verifier computes both locally.

Header encryption and the file-name leak

Traditional ZIP encryption protects file data and nothing else. The central directory stays in clear text, so anyone holding the archive can list names, sizes and the directory tree without the password. That listing is often the sensitive part. A name such as redundancies-q1-2026.xlsx or client-oncology-records.zip discloses the subject even when the bytes are unreadable.

7-Zip's -mhe=on and WinRAR's -hp encrypt the header itself, so the archive presents no listing until the passphrase is correct. The side effect is diagnostic: some tools answer Cannot open file as archive, since an encrypted header is indistinguishable from a damaged one. AES-256 with heavy key derivation is strong; a reused five-word passphrase is not.

  1. Classify the payload before choosing: text and code reward LZMA2, media does not.
  2. Test the ratio on a representative sample rather than the full 40 GB.
  3. Build the final archive once, with the dictionary the recipient can afford to decode.
  4. Compute SHA-256 on the file you will actually upload, not on the folder.
  5. Publish that hash, and say which dictionary size the archive needs.

None of this replaces verification. Pick the container by content, build it once, and hash the bytes you send. If extraction still fails, the guide to repairing corrupted archives explains what a CRC error leaves recoverable.

Troubleshooting Common Issues

Error / Issue Technical Cause Step-by-Step Fix
Cannot open file as archive Encrypted 7z header. Without the passphrase the file table cannot be read, so the file does not look like an archive at all. Open it in 7-Zip or WinRAR and enter the password; the listing appears only after the header decrypts.
ERROR: Can't allocate required memory! The LZMA2 dictionary declared in the header exceeds free RAM, common on small virtual servers and older phones. Extract on a machine with more memory, or ask for an archive rebuilt with a smaller dictionary such as -md=16m.
CRC failed in file.ext The block decompressed but its stored CRC32 does not match, usually a truncated or bit-flipped transfer. Download the archive again and compare its SHA-256 with the published value before extracting.
Data Error in 'file.ext'. File is broken Damage inside a solid block. Every entry after the bad offset in that block becomes unreachable. Use the RAR recovery record if one was embedded, or re-transfer the archive; extracting neighbours will not recover it.

Frequently Asked Questions

Is 7z always smaller than zip?

No. On text, source code and logs LZMA2 usually wins by a wide margin. On JPEG, MP4 or already-optimised PNG the gap falls to a few percent, and zip finishes far sooner.

Why does extracting one file from a 7z take so long?

Solid blocks are compressed as a single stream. Reaching a file in the middle forces the decoder to process every byte before it, even though the other entries are discarded.

Does renaming files inside an archive change its hash?

Yes. Names, timestamps and entry order are part of the byte stream. Any rewrite produces a different SHA-256 even when the extracted payload is identical.

Can I compress a video to speed up an upload?

Rarely. H.264 and HEVC output is already entropy-coded, so a general compressor typically recovers under two percent while spending minutes of CPU. Store it instead.

Related Technical Guides