ZXC

High-performance lossless compression, built for ultra-fast decode

Star


ZXC: High-Performance Asymmetric Lossless Compression

ZXC 1.0.3. Generated from docs/WHITEPAPER.md; corrections are welcome as pull requests. If ZXC is useful to you, a star on GitHub helps others find it ( 544 so far).

Version: 1.0.3 Date: November 2026 Author: Bertrand Lebonnois


1. Executive Summary#

Software delivery pipelines such as mobile gaming, embedded systems and firmware over-the-air updates produce data once, on x86 build servers, and consume it millions of times on energy-constrained ARM devices.

LZ4 and its peers are symmetric: they spend as little on compression as on decompression, which wastes the one-time encoding budget. ZXC is an asymmetric lossless codec: a slow encoder shapes the stream so that the decoder runs as fast as the hardware allows. At its default level it decodes 1.5x to 2.2x faster than LZ4 on ARM and 1.28x to 1.53x on x86, with smaller output (46.65 % against 47.32 % on Silesia).

2. The Efficiency Gap#

Symmetric speed suits real-time logs or RAM swapping. For asset distribution it is wasted twice: the cycles saved on the build server benefit nobody, and every slow decode on a phone keeps the CPU awake longer, costing battery and heat.

3. Design#

ZXC moves the work to the encoder. Heavy analysis at build time produces a layout that suits the instruction pipelining and branch prediction of modern CPUs, ARMv8 first.

ZXC is a pure LZ byte codec: LZ77 matching plus entropy coding, with no type-aware or numeric block. Numeric and columnar data (timestamps, IDs, float columns) compress best behind a reversible pre-filter such as delta or byte-shuffle, applied before compression and inverted after. ZXC keeps such transforms out of the format on purpose: the caller knows the element type and owns the filter. See Compressing Numeric Data in EXAMPLES.md.

4. Core Algorithms#

4.1 LZ77 Engine#

A hash table with chaining finds matches in a 64 KB window (16-bit offsets), whatever the block size. Levels 3 to 5 match lazily: a match is deferred when a better one starts at the next byte. Levels 6 and 7 replace lazy matching with a price-based optimal parser (§5.4).

4.2 SIMD and Hardware Hashing#

4.3 Entropy Coding#

Huffman decoding with the PivCo level-ordered layout#

Entropy decoding is the hot path of the high-compression levels, and classical Huffman decoding is a serial bit chain: a codeword's length must be known before the next one's position is. Interleaving N streams caps the parallelism at N and keeps a load-shift-mask chain per symbol. Format v7 replaced the layout with PivCo-Huffman (PIVoted COding, level-ordered Huffman). The layout and its merge-based decode are from Żukowski 2026; the implementation here is independent.

On the post-LZ literal sections of silesia.tar at level 7 it decodes 77 % faster than the tuned 4-stream classic decoder it replaced, at byte-identical ratio. The scalar fallback is about 4x slower than the SIMD kernels; embedded targets usually stay on levels 1 to 5, which carry no entropy sections.

Selection. Section encodings are chosen by pricing every candidate (RAW, RLE, Huffman, shared-table Huffman) with J = compressed_size + premium(level) × decoded_bytes and keeping the minimum: a Lagrangian trade of bytes against decode time. Below ULTRA the premium reproduces the historical margin of about 3 %; at level 7 it drops to about 1.6 % for entropy and 0.4 % for RLE, so the encoder buys ratio with decode cycles, which is the level-7 contract.

Joint nudge (levels 6 and 7). Before pricing, a DP pass relaxes the fitted code lengths toward flatter trees whenever the modeled PivCo decode saving outweighs the size cost, with the same premium. The result stays a canonical, Kraft-exact code. Idea by Dougall Johnson (pivco-huffman issue #20).

Prefix Varint#

Overflow values use a prefix varint: the number of leading 1 bits in the first byte gives the total length, so the decoder knows the width before reading further, with no continuation bit per byte and no serial dependency as in VByte. An N-byte varint carries 7N payload bits.

Prefix (Binary) Total Bytes Data Bits (1st Byte) Total Data Bits Range (Value < X)
0xxxxxxx 1 7 7 128
10xxxxxx 2 6 14 (6+8) 16,384
110xxxxx 3 5 21 (5+8+8) 2,097,152 (2 MiB)

A varint encodes LL - MASK or ML - MASK, both bounded by ZXC_BLOCK_SIZE_MAX = 2 MiB, so every legitimate varint fits in 3 bytes. A first byte of 0xE0 or more is out of spec: encoders never emit it and decoders reject it, which caps the varint surface at the block size limit and removes integer overflow from downstream bounds arithmetic. Longer prefixes are reserved for a format version that raises the limit.

Example: Encoding value 300 (binary: 100101100):

Value 300 > 127 and < 16383 -> Uses 2-byte format (Prefix '10').

Step 1: Low 6 bits
300 & 0x3F = 44 (0x2C, binary 101100)
Byte 1 = Prefix '10' | 101100 = 10101100 (0xAC)

Step 2: Remaining high bits
300 >> 6 = 4 (0x04, binary 00000100)
Byte 2 = 0x04

Result: 0xAC 0x04

Decoding Verification:
Byte 1 (0xAC) & 0x3F = 44
Byte 2 (0x04) << 6   = 256
Total = 256 + 44 = 300

5. Format Design#

FORMAT.md specifies every byte of the wire format, with worked hexdumps and public conformance vectors. This section explains the choices behind it and the encoder and decoder pipelines, which the specification leaves open.

5.1 Two Block Layouts#

A data block is RAW (stored), SPL or PAK (FORMAT.md § 5). Levels 1 and 2 emit PAK, levels 3 to 7 emit SPL, and either falls back to RAW when the coded form would not shrink the data.

Key Differences: SPL vs PAK

Feature SPL (Split streams) PAK (Packed sequences)
Sections 4 (Lit, Tokens, Offsets, Extras) 3 (Lit, Sequences, Extras)
Sequence Format 1-byte token + separate offset Packed 32-bit word
LL/ML Bits 4 bits each (overflow at 15) 8 bits each (overflow at 255)
Memory Access Multiple stream pointers Single aligned 4-byte reads
Decoder Speed Fast Fastest (optimized for ARM/x86)
RLE Support Yes (literals) No
Huffman Literals Yes (level ≥ 6, ≥ 139 lits) No
Parser Lazy (≤ L5), Optimal DP (L6-L7) Lazy
Best For General data, good compression Maximum decode throughput

Why a packed word: one aligned read per sequence removes the pointer chasing between token and offset streams, uses the cache better and lets the decoder unroll 4x.

5.2 Descriptor Economy#

An SPL block writes a section size only when its header cannot already imply it (FORMAT.md § 5.2); a PAK block writes none at all (FORMAT.md § 5.3). N Literals and N Sequences are on the wire anyway, so RAW literal and token sections need no descriptor, and the offset stream never does, its width being a header field. That leaves the two entropy-coded sizes and the extras, recoverable as the residue because they come last. The saving is 24 to 32 bytes per block against the earlier fixed table, about 2 % of a 4 KB block.

Design Note: a new encoding costs a new enc_* value and, if its size becomes unimplied, one more u32 descriptor gated on that value, plus a format version bump. The bump is the intended mechanism, not a pool of reserved bytes.

A mandatory footer closes each frame (FORMAT.md § 8): an 8-byte archive digest when checksums are on, then the source size and the compressed frame size on the fewest bytes that hold them, and a last byte giving their two lengths.

The sizes cost what they hold: 5 bytes for a small frame, 9 for a few hundred MB, against a fixed 16. A sequential decoder knows both values when it reaches the footer, derives the one valid encoding and compares it byte for byte. Read from the last byte, the compressed size locates the frame's header without any other field, which is what lets frames be concatenated (FORMAT.md § 2.1).

The digest is an ordered fold of every block's checksum: a whole-archive identity that a full decode verifies and zxc -t reports, and that a seekable range read, which never sees every block, does not check. Per-block integrity does not depend on it: each checksum is seeded with the block's position (§5.5), so a block out of place fails on its own. The digest adds what that cannot see, a block replaced by a valid one at the same position.

5.4 Block Codecs#

SPL (levels 3 to 7)#

Encoding:

  1. Parse: hash-chain LZ77 over a 64 KB window. Levels 3 to 5 match lazily. Levels 6 and 7 run a forward dynamic program: dp[p] holds the cheapest encoding of src[0..p), each step emits a literal or any sub-length of the longest match at p, with static prices (literal ≈ 9 bits, match ≈ 24 bits plus varint extras), and backtracking from dp[N] yields the optimal sequence. A long-match guard skips re-search inside a match, keeping the parse O(N) on repetitive data.
  2. Streams: each sequence splits into a literal run, a token (LitLen << 4) | MatchLen, an offset and, for lengths of 15 or more, a prefix varint in the extras. Offsets take 1 byte when none exceeds 255 (enc_off = 1), 2 bytes otherwise.
  3. Literal coding: RLE and, from level 6 with at least 139 literals, a length-limited Huffman code (L = 8 at level 6, L = 11 at level 7) nudged toward a flat tree and written in the PivCo layout (§4.3). Level 7 codes the tokens the same way (enc_tok = 2). With a dictionary carrying a shared literal table (§5.7), a fourth candidate reuses the dictionary's code lengths without the 128-byte header (enc_lit = 3); a block holding a literal the table does not cover falls back to its own table. The Lagrangian of §4.3 keeps the cheapest candidate, so no choice is a regression.
  4. Serialization: sections are concatenated behind a descriptor for each coded one (§5.2), with zero padding when fewer than 32 bytes follow the literal section.

Decoding:

  1. Sections: sizes come from the header, descriptors are read for the coded sections only, the extras take the residue. A block with fewer than 32 bytes behind its literals is rejected.
  2. Literals: RAW is a view into the source; RLE expands in one pass; PivCo decodes by the SIMD merges of §4.3, with the shared-table variant using code lengths validated once, when the dictionary was attached.
  3. Tokens (level 7): a Huffman-coded token stream is decoded into scratch by a dedicated specialization of the block decoder, so the RAW-token path keeps its exact code shape.
  4. Main loop: reads the three streams together and copies with 16-byte literal loads and 32-byte match stores, overlapping matches going through dedicated overlapped-copy primitives. A safe zone at the end of the buffer switches to a bounds-checked loop, so the main loop runs without bounds checks.

PAK (levels 1 and 2)#

Encoding: the same parser with lazy matching and step skipping, then one 32-bit word per sequence (literal length, match length minus 5, 16-bit offset), raw literals, and a varint in the extras for lengths of 255 or more. No descriptor is written: every size follows from the header (FORMAT.md § 5.3).

Decoding: one aligned read per sequence. With enough output margin the loop handles 4 sequences per iteration, pre-read into registers and copied with 32-byte SIMD stores. Offsets are validated only until the output, plus any dictionary prefix, exceeds 65536 bytes: past that point no 16-bit offset can reach below the buffer. Overlapping matches (offset below 32) take the same special path as SPL.

5.5 Data Integrity#

Each block may carry a 32-bit checksum of its decompressed bytes. The question answered is "are the bytes handed back the ones that went in", not "is the payload intact".

The algorithm field selects the hash; only rapidhash (0) is defined, its 64-bit result folded to 32 bits. rapidhash is based on wyhash and was developed by Nicolas De Carli.

5.6 Seekable Archives#

An optional seek table (a SEK block before the footer, FORMAT.md § 5.5) gives O(1) random access. It holds groups of 64 blocks, a u64 anchor and one u32 size per block, about 4.1 bytes per block. A block is found by one division (block_index = offset / block_size), then one bounded read from its group's anchor, with nothing of the table kept in memory. Groups are bounds-checked when loaded and each block header must agree with its entry, so a damaged entry costs only its group. The table is not authenticated: only the position-seeded block checksums bind a block to its index.

5.7 Pre-Trained Dictionaries#

Blocks are encoded independently, so a small block (4 KB to 128 KB) has little match history of its own. A pre-trained dictionary supplies it.

6. System Architecture (Threading)#

A producer-consumer pipeline keeps every core busy.

Compression: the main thread slices the input into fixed-size chunks (a power of 2 from 4 KB to 2 MB, 512 KB by default) and submits them to a lock-free ring buffer. Workers compress chunks independently, each in its own zxc_cctx_t, into thread-local buffers. A writer thread restores the original order on output.

Decompression: the main thread scans block headers for boundaries and sizes. On a regular file, workers read their own payloads with positioned reads and small blocks travel in batches; on a pipe, stdio feeds one block per job. Workers decode into pre-allocated buffers, using wild copies (16- and 32-byte SIMD stores) whenever the output margin allows, and blocks are committed in order.

7. Performance Analysis (Benchmarks)#

Methodology. lzbench 2.4.1 (by inikep) built with MOREFLAGS="-march=native", 512 KB blocks, checksums off, one thread, on silesia.tar (202 MB). The three Google Cloud instances run one thread per core (SMT disabled on the x86 C4D and C2D instances).

Cycles per byte are frequency / decompression speed, at the base frequency (the performance-core frequency for the M3); lower is better. Throughput over a link is the speed-up over sending the data uncompressed, min(Decode, Bandwidth × 100 / Ratio) / Bandwidth, with each codec family at its best level for that bandwidth (Figure D), one decoding thread, transfer and decoding overlapped, and compression time left out as it is paid once; higher is better.

Figure A: Pareto Frontier — Compression Ratio vs. Decompression Speed (across 4 CPUs)

Pareto Frontier — Compression Ratio vs Decompression Speed

Figure A': Compression Ratio vs. Compression Speed (across 4 CPUs)

Compression Ratio vs Compression Speed

7.1 Client ARM64 Summary (Apple Silicon M3)#

Compressor Decompression Speed (Ratio vs LZ4) Compressed Size (Index LZ4=100) (Lower is Better)
zxc 1.0.0 -1 2.97x 130.51
zxc 1.0.0 -2 2.52x 113.81
zxc 1.0.0 -3 2.23x 98.58
zxc 1.0.0 -4 2.02x 91.78
zxc 1.0.0 -5 1.87x 86.29
zxc 1.0.0 -6 1.58x 76.67
zxc 1.0.0 -7 1.17x 69.92
lz4 1.11.0 --fast -17 1.26x 130.81
lz4 1.11.0 (Ref) 1.00x 100.00
lz4hc 1.11.0 -9 0.94x 77.65
lzav 7.1 -1 0.86x 82.90
snappy 1.3.1 0.69x 101.11
zstd 1.5.7 --fast --1 0.56x 86.66
zstd 1.5.7 -1 0.40x 72.98
zstd 1.5.7 -3 0.38x 65.94
zlib 1.4 -1 0.09x 77.03

Decompression Efficiency (Cycles per Byte @ 4.05 GHz)

Compressor Cycles/Byte Performance vs memcpy (*)
memcpy 0.095 1.00x (baseline)
zxc 1.0.0 -1 0.277 2.9x
zxc 1.0.0 -2 0.326 3.4x
zxc 1.0.0 -3 0.368 3.9x
zxc 1.0.0 -4 0.406 4.3x
zxc 1.0.0 -5 0.440 4.6x
zxc 1.0.0 -6 0.521 5.5x
zxc 1.0.0 -7 0.702 7.4x
lz4 1.11.0 0.820 8.7x
lz4 1.11.0 --fast -17 0.649 6.8x
lz4hc 1.11.0 -9 0.875 9.2x
lzav 7.1 -1 0.949 10.0x
zstd 1.5.7 -1 2.055 21.7x
zstd 1.5.7 --fast --1 1.458 15.4x
zstd 1.5.7 -3 2.158 22.8x
snappy 1.3.1 1.182 12.5x
zlib 1.4 -1 9.020 95.1x

Throughput over a link

Link bandwidth ZXC LZ4 / LZ4HC Zstandard
125 MB/s (1 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 3.21x (zstd -3)
1.25 GB/s (10 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 2.21x (zstd --fast --1)
3 GB/s 2.59x (zxc -6) 1.65x (lz4) 0.93x (zstd --fast --1)
7 GB/s (NVMe) 1.77x (zxc -2) 0.89x (lz4 --fast -17) 0.40x (zstd --fast --1)

Reading: on Apple M3, the ratio of zstd -3 leads below 621 MB/s. Above that a ZXC level delivers the most data: -7 up to 1.91 GB/s, then the faster levels in turn, up to 14.6 GB/s, where one decoding thread falls behind the link and compression stops paying (6.24 GB/s for LZ4). No LZ4 or LZ4HC level is ahead of the best ZXC level at any bandwidth.

7.2 Cloud Server Summary (ARM64 / Google Axion Neoverse-V2)#

Compressor Decompression Speed (Ratio vs LZ4) Compressed Size (Index LZ4=100) (Lower is Better)
zxc 1.0.0 -1 2.18x 130.51
zxc 1.0.0 -2 1.80x 113.81
zxc 1.0.0 -3 1.51x 98.58
zxc 1.0.0 -4 1.40x 91.78
zxc 1.0.0 -5 1.30x 86.29
zxc 1.0.0 -6 1.14x 76.67
zxc 1.0.0 -7 0.82x 69.92
lz4 1.11.0 --fast -17 1.20x 130.81
lz4 1.11.0 (Ref) 1.00x 100.00
lz4hc 1.11.0 -9 0.90x 77.65
lzav 7.1 -1 0.68x 82.90
snappy 1.3.1 0.53x 101.11
zstd 1.5.7 --fast --1 0.53x 86.66
zstd 1.5.7 -1 0.38x 72.98
zstd 1.5.7 -3 0.35x 65.94
zlib 1.4 -1 0.09x 77.03

Decompression Efficiency (Cycles per Byte @ 2.6 GHz)

Compressor Cycles/Byte Performance vs memcpy (*)
memcpy 0.110 1.00x (baseline)
zxc 1.0.0 -1 0.277 2.5x
zxc 1.0.0 -2 0.335 3.0x
zxc 1.0.0 -3 0.401 3.6x
zxc 1.0.0 -4 0.430 3.9x
zxc 1.0.0 -5 0.463 4.2x
zxc 1.0.0 -6 0.532 4.8x
zxc 1.0.0 -7 0.735 6.7x
lz4 1.11.0 0.604 5.5x
lz4 1.11.0 --fast -17 0.504 4.6x
lz4hc 1.11.0 -9 0.671 6.1x
lzav 7.1 -1 0.889 8.1x
zstd 1.5.7 -1 1.583 14.4x
zstd 1.5.7 --fast --1 1.138 10.3x
zstd 1.5.7 -3 1.708 15.5x
snappy 1.3.1 1.134 10.3x
zlib 1.4 -1 6.684 60.7x

Throughput over a link

Link bandwidth ZXC LZ4 / LZ4HC Zstandard
125 MB/s (1 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 3.21x (zstd -3)
1.25 GB/s (10 GbE) 2.83x (zxc -7) 2.72x (lz4hc -9) 1.83x (zstd --fast --1)
3 GB/s 2.14x (zxc -3) 1.62x (lz4 --fast -17) 0.76x (zstd --fast --1)
7 GB/s (NVMe) 1.34x (zxc -1) 0.74x (lz4 --fast -17) 0.33x (zstd --fast --1)

Reading: on Google Axion, the ratio of zstd -3 leads below 504 MB/s. Above that a ZXC level delivers the most data: -7 up to 1.17 GB/s, then the faster levels in turn, up to 9.39 GB/s, where one decoding thread falls behind the link and compression stops paying (5.16 GB/s for LZ4). No LZ4 or LZ4HC level is ahead of the best ZXC level at any bandwidth.

7.3 Build Server Summary (x86_64 / AMD EPYC 9B45, Zen 5)#

Compressor Decompression Speed (Ratio vs LZ4) Compressed Size (Index LZ4=100) (Lower is Better)
zxc 1.0.0 -1 2.14x 130.51
zxc 1.0.0 -2 1.90x 113.81
zxc 1.0.0 -3 1.53x 98.58
zxc 1.0.0 -4 1.38x 91.78
zxc 1.0.0 -5 1.29x 86.29
zxc 1.0.0 -6 1.11x 76.67
zxc 1.0.0 -7 0.86x 69.92
lz4 1.11.0 --fast -17 1.12x 130.81
lz4 1.11.0 (Ref) 1.00x 100.00
lz4hc 1.11.0 -9 0.97x 77.65
lzav 7.1 -1 0.68x 82.90
snappy 1.3.1 0.43x 101.21
zstd 1.5.7 --fast --1 0.45x 86.66
zstd 1.5.7 -1 0.35x 72.98
zstd 1.5.7 -3 0.32x 65.94
zlib 1.4 -1 0.07x 77.03

Decompression Efficiency (Cycles per Byte @ 2.1 GHz)

Compressor Cycles/Byte Performance vs memcpy (*)
memcpy 0.075 1.00x (baseline)
zxc 1.0.0 -1 0.180 2.4x
zxc 1.0.0 -2 0.203 2.7x
zxc 1.0.0 -3 0.251 3.4x
zxc 1.0.0 -4 0.279 3.7x
zxc 1.0.0 -5 0.298 4.0x
zxc 1.0.0 -6 0.347 4.7x
zxc 1.0.0 -7 0.447 6.0x
lz4 1.11.0 0.386 5.2x
lz4 1.11.0 --fast -17 0.344 4.6x
lz4hc 1.11.0 -9 0.398 5.3x
lzav 7.1 -1 0.570 7.6x
zstd 1.5.7 -1 1.114 15.0x
zstd 1.5.7 --fast --1 0.865 11.6x
zstd 1.5.7 -3 1.218 16.3x
snappy 1.3.1 0.891 12.0x
zlib 1.4 -1 5.330 71.5x

Throughput over a link

Link bandwidth ZXC LZ4 / LZ4HC Zstandard
125 MB/s (1 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 3.21x (zstd -3)
1.25 GB/s (10 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 1.94x (zstd --fast --1)
3 GB/s 2.35x (zxc -5) 1.81x (lz4) 0.81x (zstd --fast --1)
7 GB/s (NVMe) 1.62x (zxc -1) 0.87x (lz4 --fast -17) 0.35x (zstd --fast --1)

Reading: on AMD EPYC 9B45, the ratio of zstd -3 leads below 570 MB/s. Above that a ZXC level delivers the most data: -7 up to 1.56 GB/s, then the faster levels in turn, up to 11.6 GB/s, where one decoding thread falls behind the link and compression stops paying (6.10 GB/s for LZ4). No LZ4 or LZ4HC level is ahead of the best ZXC level at any bandwidth.

7.4 Production Server Summary (x86_64 / AMD EPYC 7B13, Zen 3)#

Compressor Decompression Speed (Ratio vs LZ4) Compressed Size (Index LZ4=100) (Lower is Better)
zxc 1.0.0 -1 1.99x 130.51
zxc 1.0.0 -2 1.65x 113.81
zxc 1.0.0 -3 1.28x 98.58
zxc 1.0.0 -4 1.21x 91.78
zxc 1.0.0 -5 1.16x 86.29
zxc 1.0.0 -6 1.05x 76.67
zxc 1.0.0 -7 0.77x 69.92
lz4 1.11.0 --fast -17 1.21x 130.81
lz4 1.11.0 (Ref) 1.00x 100.00
lz4hc 1.11.0 -9 0.96x 77.65
lzav 7.1 -1 0.74x 82.90
snappy 1.3.1 0.45x 101.21
zstd 1.5.7 --fast --1 0.43x 86.66
zstd 1.5.7 -1 0.32x 72.98
zstd 1.5.7 -3 0.29x 65.94
zlib 1.4 -1 0.09x 77.03

Decompression Efficiency (Cycles per Byte @ 2.2 GHz)

Compressor Cycles/Byte Performance vs memcpy (*)
memcpy 0.090 1.00x (baseline)
zxc 1.0.0 -1 0.269 3.0x
zxc 1.0.0 -2 0.324 3.6x
zxc 1.0.0 -3 0.419 4.7x
zxc 1.0.0 -4 0.444 4.9x
zxc 1.0.0 -5 0.459 5.1x
zxc 1.0.0 -6 0.511 5.7x
zxc 1.0.0 -7 0.698 7.8x
lz4 1.11.0 0.535 5.9x
lz4 1.11.0 --fast -17 0.443 4.9x
lz4hc 1.11.0 -9 0.558 6.2x
lzav 7.1 -1 0.727 8.1x
zstd 1.5.7 -1 1.645 18.3x
zstd 1.5.7 --fast --1 1.237 13.7x
zstd 1.5.7 -3 1.823 20.2x
snappy 1.3.1 1.197 13.3x
zlib 1.4 -1 6.197 68.8x

Throughput over a link

Link bandwidth ZXC LZ4 / LZ4HC Zstandard
125 MB/s (1 GbE) 3.02x (zxc -7) 2.72x (lz4hc -9) 3.21x (zstd -3)
1.25 GB/s (10 GbE) 2.76x (zxc -6) 2.72x (lz4hc -9) 1.42x (zstd --fast --1)
3 GB/s 1.86x (zxc -2) 1.62x (lz4 --fast -17) 0.59x (zstd --fast --1)
7 GB/s (NVMe) 1.17x (zxc -1) 0.71x (lz4 --fast -17) 0.25x (zstd --fast --1)

Reading: on AMD EPYC 7B13, the ratio of zstd -3 leads below 399 MB/s. Above that a ZXC level delivers the most data: -7 up to 1.04 GB/s, then the faster levels in turn, up to 8.18 GB/s, where one decoding thread falls behind the link and compression stops paying (4.97 GB/s for LZ4). No LZ4 or LZ4HC level is ahead of the best ZXC level at any bandwidth.

7.5 Benchmarks Results#

Figure C: Decompression Efficiency: Cycles Per Byte Comparison

Benchmark Cycles Per Byte

Figure D: Throughput over a link — Speed-up over an Uncompressed Transfer, by Link Bandwidth

Speed-up over an uncompressed transfer by link bandwidth

7.5.1 ARM64 Architecture (Apple Silicon M3)#

Compressor name Compression Decompress. Compr. size Ratio Filename
memcpy 42707 MB/s 42720 MB/s 211947520 100.00 1 files
zxc 1.0.0 -1 982 MB/s 14646 MB/s 130896288 61.76 1 files
zxc 1.0.0 -2 652 MB/s 12422 MB/s 114152506 53.86 1 files
zxc 1.0.0 -3 290 MB/s 11006 MB/s 98875304 46.65 1 files
zxc 1.0.0 -4 211 MB/s 9974 MB/s 92052403 43.43 1 files
zxc 1.0.0 -5 127 MB/s 9210 MB/s 86544351 40.83 1 files
zxc 1.0.0 -6 16.6 MB/s 7780 MB/s 76900560 36.28 1 files
zxc 1.0.0 -7 11.2 MB/s 5773 MB/s 70129881 33.09 1 files
lz4 1.11.0 873 MB/s 4937 MB/s 100297438 47.32 1 files
lz4 1.11.0 --fast -17 1468 MB/s 6237 MB/s 131194546 61.90 1 files
lz4hc 1.11.0 -9 51.4 MB/s 4629 MB/s 77884448 36.75 1 files
lzav 7.1 -1 773 MB/s 4268 MB/s 83147688 39.23 1 files
snappy 1.3.1 722 MB/s 3427 MB/s 101415443 47.85 1 files
zstd 1.5.7 --fast --1 808 MB/s 2778 MB/s 86916294 41.01 1 files
zstd 1.5.7 -1 714 MB/s 1971 MB/s 73193704 34.53 1 files
zstd 1.5.7 -3 441 MB/s 1877 MB/s 66133500 31.20 1 files
zlib 1.4 -1 165 MB/s 449 MB/s 77259029 36.45 1 files

7.5.2 ARM64 Architecture (Google Axion Neoverse-V2)#

Compressor name Compression Decompress. Compr. size Ratio Filename
memcpy 23695 MB/s 23595 MB/s 211947520 100.00 1 files
zxc 1.0.0 -1 883 MB/s 9394 MB/s 130896288 61.76 1 files
zxc 1.0.0 -2 592 MB/s 7764 MB/s 114152506 53.86 1 files
zxc 1.0.0 -3 256 MB/s 6489 MB/s 98875304 46.65 1 files
zxc 1.0.0 -4 185 MB/s 6043 MB/s 92052403 43.43 1 files
zxc 1.0.0 -5 109 MB/s 5614 MB/s 86544351 40.83 1 files
zxc 1.0.0 -6 13.4 MB/s 4891 MB/s 76900560 36.28 1 files
zxc 1.0.0 -7 8.76 MB/s 3539 MB/s 70129881 33.09 1 files
lz4 1.11.0 748 MB/s 4305 MB/s 100297438 47.32 1 files
lz4 1.11.0 --fast -17 1305 MB/s 5158 MB/s 131194546 61.90 1 files
lz4hc 1.11.0 -9 42.6 MB/s 3875 MB/s 77884448 36.75 1 files
lzav 7.1 -1 642 MB/s 2925 MB/s 83147688 39.23 1 files
snappy 1.3.1 567 MB/s 2292 MB/s 101415443 47.85 1 files
zstd 1.5.7 --fast --1 603 MB/s 2284 MB/s 86916294 41.01 1 files
zstd 1.5.7 -1 523 MB/s 1642 MB/s 73193704 34.53 1 files
zstd 1.5.7 -3 325 MB/s 1522 MB/s 66133500 31.20 1 files
zlib 1.4 -1 115 MB/s 389 MB/s 77259029 36.45 1 files

7.5.3 x86_64 Architecture (AMD EPYC 9B45)#

Compressor name Compression Decompress. Compr. size Ratio Filename
memcpy 28162 MB/s 28183 MB/s 211947520 100.00 1 files
zxc 1.0.0 -1 873 MB/s 11639 MB/s 130896288 61.76 1 files
zxc 1.0.0 -2 588 MB/s 10363 MB/s 114152506 53.86 1 files
zxc 1.0.0 -3 253 MB/s 8352 MB/s 98875304 46.65 1 files
zxc 1.0.0 -4 184 MB/s 7535 MB/s 92052403 43.43 1 files
zxc 1.0.0 -5 110 MB/s 7038 MB/s 86544351 40.83 1 files
zxc 1.0.0 -6 15.3 MB/s 6051 MB/s 76900560 36.28 1 files
zxc 1.0.0 -7 10.2 MB/s 4702 MB/s 70129881 33.09 1 files
lz4 1.11.0 800 MB/s 5445 MB/s 100297438 47.32 1 files
lz4 1.11.0 --fast -17 1321 MB/s 6100 MB/s 131194546 61.90 1 files
lz4hc 1.11.0 -9 42.8 MB/s 5274 MB/s 77884448 36.75 1 files
lzav 7.1 -1 724 MB/s 3687 MB/s 83147688 39.23 1 files
snappy 1.3.1 564 MB/s 2356 MB/s 101512076 47.89 1 files
zstd 1.5.7 --fast --1 662 MB/s 2429 MB/s 86916294 41.01 1 files
zstd 1.5.7 -1 605 MB/s 1885 MB/s 73193704 34.53 1 files
zstd 1.5.7 -3 369 MB/s 1724 MB/s 66133500 31.20 1 files
zlib 1.4 -1 135 MB/s 394 MB/s 77259029 36.45 1 files

7.5.4 x86_64 Architecture (AMD EPYC 7B13, Zen 3)#

Compressor name Compression Decompress. Compr. size Ratio Filename
memcpy 24517 MB/s 24440 MB/s 211947520 100.00 1 files
zxc 1.0.0 -1 733 MB/s 8175 MB/s 130896288 61.76 1 files
zxc 1.0.0 -2 485 MB/s 6796 MB/s 114152506 53.86 1 files
zxc 1.0.0 -3 215 MB/s 5255 MB/s 98875304 46.65 1 files
zxc 1.0.0 -4 159 MB/s 4959 MB/s 92052403 43.43 1 files
zxc 1.0.0 -5 93.6 MB/s 4788 MB/s 86544351 40.83 1 files
zxc 1.0.0 -6 11.9 MB/s 4303 MB/s 76900560 36.28 1 files
zxc 1.0.0 -7 8.02 MB/s 3153 MB/s 70129881 33.09 1 files
lz4 1.11.0 675 MB/s 4115 MB/s 100297438 47.32 1 files
lz4 1.11.0 --fast -17 1153 MB/s 4968 MB/s 131194546 61.90 1 files
lz4hc 1.11.0 -9 35.2 MB/s 3944 MB/s 77884448 36.75 1 files
lzav 7.1 -1 509 MB/s 3027 MB/s 83147688 39.23 1 files
snappy 1.3.1 508 MB/s 1838 MB/s 101512076 47.89 1 files
zstd 1.5.7 --fast --1 486 MB/s 1779 MB/s 86916294 41.01 1 files
zstd 1.5.7 -1 442 MB/s 1337 MB/s 73193704 34.53 1 files
zstd 1.5.7 -3 233 MB/s 1207 MB/s 66133500 31.20 1 files
zlib 1.4 -1 106 MB/s 355 MB/s 77259029 36.45 1 files

7.6 Memory Usage per Compression Context#

Block Size Levels -1 to -5 Levels -6 and -7
256 KB ~1.04 MB ~3.07 MB
512 KB (default) ~1.79 MB ~5.85 MB
2 MB (max) ~6.29 MB ~22.54 MB

Levels -1 to -5 share one layout (hash, chain, sequence and literal buffers) that scales linearly with block size. Levels -6 and -7 add the optimal parser's scratch, about 3x more, allocated lazily. zxc_estimate_cctx_size(block_size, level) gives the exact figure for any combination.

Guideline: the default 512 KB block keeps a context under 6 MB even at levels -6 and -7. For streaming, embedded or memory-constrained use, take -B 256K or smaller and levels -1 to -5; keep -6 and -7 for offline encoding where RAM per thread is plentiful.

7.7 In-Place Decompression#

Integrators that hold the whole archive in RAM (firmware unpackers, asset loaders, FOTA payloads) can decode inside one buffer: the archive is placed flush-right in a buffer of zxc_decompress_inplace_bound(...) bytes and zxc_decompress_inplace() decodes left to right into the same memory.

The margin is exact. A block payload never expands (the encoder falls back to RAW), but each block adds its framing, so on incompressible input the compressed stream runs nblocks × framing bytes longer than the output. A margin of one block plus that framing plus the decoder's wild-copy tail (block_size + nblocks × (header + optional checksum) + EOF block + optional seek table + footer + ZXC_DECOMPRESS_TAIL_PAD) keeps every block's output behind its compressed start. The bound comes from the header and footer without decoding. The decoder also caps each block's output by the input still unread and rejects an archive that would overrun it (ZXC_ERROR_CORRUPT_DATA) or a buffer too small for it (ZXC_ERROR_DST_TOO_SMALL), never corrupting memory.

Peak decode memory drops from compressed + decompressed to decompressed + about 1 %, as with the in-place modes of LZ4 and Zstandard. It is a library capability for embedded integration; the CLI's block-at-a-time decode is already memory-bounded. Dictionary archives are supported through the context's own bounce buffer.

8. Choosing a Level#

9. Conclusion#

ZXC moves the cost of compression to the build pipeline, where it is paid once, and gives the decoder a layout built for modern CPUs. The result is faster loads, lower battery drain and less heat on every device that reads the data, ARM first.