ZXC is an asymmetric high-performance lossless compression library optimized for Content Delivery and Embedded Systems (Game Assets, Firmware, App Bundles). It is designed to be "Write Once, Read Many.". Unlike symmetric codecs (LZ4), ZXC trades compression speed (build-time) for maximum decompression throughput (run-time).
Key Result: ZXC outperforms LZ4 decompression by +40% on Apple Silicon and +20% on Cloud ARM (Google Axion) with better compression ratios.
Verified: ZXC has been officially merged into the lzbench master branch. You can now verify these results independently using the industry-standard benchmark suite.
Traditional codecs often force a trade-off between symmetric speed (LZ4) and archival density (Zstd).
ZXC focuses on Asymmetric Efficiency.
Designed for the "Write-Once, Read-Many" reality of software distribution, ZXC utilizes a computationally intensive encoder to generate a bitstream specifically structured to maximize decompression throughput. By performing heavy analysis upfront, the encoder produces a layout optimized for the instruction pipelining and branch prediction capabilities of modern CPUs, particularly ARMv8, effectively offloading complexity from the decoder to the encoder.
- Build Time: You generally compress only once (on CI/CD).
- Run Time: You decompress millions of times (on every user's device). ZXC respects this asymmetry.
👉 Read the Technical Whitepaper
To ensure consistent performance, benchmarks are automatically executed on every commit via GitHub Actions. We monitor metrics on both x86_64 (Linux) and ARM64 (Apple Silicon M1/M2) runners to track compression speed, decompression speed, and ratios.
(See the latest benchmark logs)
Scenario: Game Assets loading, App startup.
| Codec | Decoding Speed | Ratio vs LZ4 | Verdict |
|---|---|---|---|
| ZXC -3 (Standard) | 6,687 MB/s | Smaller (-1.6%) | 1.40x Faster than LZ4 |
| ZXC -5 (Compact) | 5,844 MB/s | Dense (-14.1%) | 2.70x Faster than Zstd fast -1 |
| LZ4 1.10 | 4,801 MB/s | Reference | Industry Standard |
Scenario: High-throughput Microservices, ARM Cloud Instances.
| Codec | Decoding Speed | Ratio vs LZ4 | Verdict |
|---|---|---|---|
| ZXC -3 (Standard) | 5,020 MB/s | Smaller (-1.6%) | 1.21x Faster than LZ4 |
| ZXC -5 (Compact) | 4,353 MB/s | Dense (-14.1%) | 2.49x Faster than Zstd fast -1 |
| LZ4 1.10 | 4,163 MB/s | Reference | Industry Standard |
Scenario: CI/CD Pipelines compatibility.
| Codec | Decoding Speed | Ratio vs LZ4 | Verdict |
|---|---|---|---|
| ZXC -3 (Standard) | 3,643 MB/s | Smaller (-1.6%) | 1.03x Faster than LZ4 |
| ZXC -5 (Compact) | 3,290 MB/s | Dense (-14.1%) | 2.09x Faster than Zstd fast -1 |
| LZ4 1.10 | 3,522 MB/s | Reference | Industry Standard |
(Benchmark Graph ARM64 : Decompression Throughput & Storage Ratio (Normalized to LZ4))

Benchmarks were conducted using lzbench (from @inikep), compiled with Clang 17.0.0 using MOREFLAGS="-march=native" on macOS Sequoia 15.7.2 (Build 24G325). The reference hardware is an Apple M2 processor (ARM64). All performance metrics reflect single-threaded execution on the standard Silesia Corpus.
| Compressor name | Compression | Decompress. | Compr. size | Ratio | Filename |
|---|---|---|---|---|---|
| memcpy | 52773 MB/s | 52216 MB/s | 211938580 | 100.00 | 12 files |
| zxc 0.3.0 -1 | 721 MB/s | 8724 MB/s | 131013961 | 61.82 | 12 files |
| zxc 0.3.0 -2 | 479 MB/s | 8165 MB/s | 124873774 | 58.92 | 12 files |
| zxc 0.3.0 -3 | 211 MB/s | 6687 MB/s | 99293477 | 46.85 | 12 files |
| zxc 0.3.0 -4 | 190 MB/s | 6302 MB/s | 93417296 | 44.08 | 12 files |
| zxc 0.3.0 -5 | 79.6 MB/s | 5844 MB/s | 86695943 | 40.91 | 12 files |
| lz4 1.10.0 | 816 MB/s | 4801 MB/s | 100880147 | 47.60 | 12 files |
| lz4 1.10.0 --fast -17 | 1342 MB/s | 5650 MB/s | 131723524 | 62.15 | 12 files |
| lz4hc 1.10.0 -12 | 14.1 MB/s | 4541 MB/s | 77262399 | 36.46 | 12 files |
| zstd 1.5.7 -1 | 645 MB/s | 1623 MB/s | 73229468 | 34.55 | 12 files |
| zstd 1.5.7 --fast --1 | 721 MB/s | 2164 MB/s | 86932028 | 41.02 | 12 files |
| snappy 1.2.2 | 883 MB/s | 3264 MB/s | 101352257 | 47.82 | 12 files |
Benchmarks were conducted using lzbench (from @inikep), compiled with GCC 12.2.0 using MOREFLAGS="-march=native" on Linux 64-bits Debian GNU/Linux 12 (bookworm). The reference hardware is a Google Neoverse-V2 processor (ARM64). All performance metrics reflect single-threaded execution on the standard Silesia Corpus.
| Compressor name | Compression | Decompress. | Compr. size | Ratio | Filename |
|---|---|---|---|---|---|
| memcpy | 22939 MB/s | 22987 MB/s | 211938580 | 100.00 | 12 files |
| zxc 0.3.0 -1 | 677 MB/s | 6659 MB/s | 131013961 | 61.82 | 12 files |
| zxc 0.3.0 -2 | 425 MB/s | 6305 MB/s | 124873774 | 58.92 | 12 files |
| zxc 0.3.0 -3 | 200 MB/s | 5020 MB/s | 99293477 | 46.85 | 12 files |
| zxc 0.3.0 -4 | 173 MB/s | 4746 MB/s | 93417296 | 44.08 | 12 files |
| zxc 0.3.0 -5 | 71.3 MB/s | 4353 MB/s | 86695943 | 40.91 | 12 files |
| lz4 1.10.0 | 740 MB/s | 4163 MB/s | 100880147 | 47.60 | 12 files |
| lz4 1.10.0 --fast -17 | 1279 MB/s | 4837 MB/s | 131723524 | 62.15 | 12 files |
| lz4hc 1.10.0 -12 | 12.5 MB/s | 3775 MB/s | 77262399 | 36.46 | 12 files |
| zstd 1.5.7 -1 | 520 MB/s | 1347 MB/s | 73229468 | 34.55 | 12 files |
| zstd 1.5.7 --fast --1 | 604 MB/s | 1747 MB/s | 86932028 | 41.02 | 12 files |
| snappy 1.2.2 | 751 MB/s | 1831 MB/s | 101352257 | 47.82 | 12 files |
Benchmarks were conducted using lzbench (from @inikep), compiled with GCC 13.3.0 using MOREFLAGS="-march=native" on Linux 64-bits Ubuntu 24.04. The reference hardware is an AMD EPYC 7763 processor (x86_64). All performance metrics reflect single-threaded execution on the standard Silesia Corpus.
| Compressor name | Compression | Decompress. | Compr. size | Ratio | Filename |
|---|---|---|---|---|---|
| memcpy | 19181 MB/s | 19182 MB/s | 211938580 | 100.00 | 12 files |
| zxc 0.3.0 -1 | 536 MB/s | 4900 MB/s | 131013961 | 61.82 | 12 files |
| zxc 0.3.0 -2 | 340 MB/s | 4582 MB/s | 124873774 | 58.92 | 12 files |
| zxc 0.3.0 -3 | 146 MB/s | 3643 MB/s | 99293477 | 46.85 | 12 files |
| zxc 0.3.0 -4 | 129 MB/s | 3436 MB/s | 93417296 | 44.08 | 12 files |
| zxc 0.3.0 -5 | 54.4 MB/s | 3290 MB/s | 86695943 | 40.91 | 12 files |
| lz4 1.10.0 | 594 MB/s | 3522 MB/s | 100880147 | 47.60 | 12 files |
| lz4 1.10.0 --fast -17 | 1034 MB/s | 4097 MB/s | 131723524 | 62.15 | 12 files |
| lz4hc 1.10.0 -12 | 11.2 MB/s | 3450 MB/s | 77262399 | 36.46 | 12 files |
| zstd 1.5.7 -1 | 410 MB/s | 1198 MB/s | 73229468 | 34.55 | 12 files |
| zstd 1.5.7 --fast --1 | 451 MB/s | 1574 MB/s | 86932028 | 41.02 | 12 files |
| snappy 1.2.2 | 609 MB/s | 1589 MB/s | 101464727 | 47.87 | 12 files |
- Go to the Releases page.
- Download the binary matching your architecture:
zxc-macos-arm64for Apple Silicon.zxc-linux-aarch64for ARM-based Linux servers.zxc-linux-x86_64for standard Linux servers.zxc-windows-x86_64.exefor Windows servers.
- Make the binary executable:
chmod +x zxc-* mv zxc-* zxc
Requirements: CMake (3.10+), C Compiler (Clang/GCC C11), Make/Ninja.
git clone https://github.com/hellobertrand/zxc.git
cd zxc
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
# Binary usage:
./zxc --help- Level 2 or 3 (Fast): Optimized for real-time assets (Gaming, UI). ~40% faster loading than LZ4 with comparable compression (Level 3).
- Level 4 (Balanced): A strong middle-ground offering efficient compression speed and a ratio superior to LZ4.
- Level 5 (Compact): The best choice for Embedded, Firmware, or Archival. Better compression than LZ4 and significantly faster decoding than Zstd.
The CLI is perfect for benchmarking or manually compressing assets.
# Basic Compression (Level 3 is default)
zxc -z input_file output_file
# High Compression (Level 5)
zxc -z -5 input_file output_file
# -z for compression can be omitted
zxc input_file output_file
# as well as output file; it will be automatically assigned to input_file.xc
zxc input_file
# Decompression
zxc -d compressed_file output_file
# Benchmark Mode (Testing speed on your machine)
zxc -b input_fileZXC provides a fully thread-safe (stateless) and binding-friendly API, utilizing caller-allocated buffers with explicit bounds. Integration is straightforward: simply include zxc.h and link against lzxc_lib.
Ideal for small assets or simple integrations. Ready for highly concurrent environments (Go routines, Node.js workers, Python threads).
#include "zxc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
// Original data to compress
const char* original = "Hello, ZXC! This is a sample text for compression.";
size_t original_size = strlen(original) + 1; // Include null terminator
// Step 1: Calculate maximum compressed size
size_t max_compressed_size = zxc_compress_bound(original_size);
// Step 2: Allocate buffers
void* compressed = malloc(max_compressed_size);
void* decompressed = malloc(original_size);
if (!compressed || !decompressed) {
fprintf(stderr, "Memory allocation failed\n");
free(compressed);
free(decompressed);
return 1;
}
// Step 3: Compress data (Level 3, checksum enabled)
size_t compressed_size = zxc_compress(
original, // Source buffer
original_size, // Source size
compressed, // Destination buffer
max_compressed_size,// Destination capacity
ZXC_LEVEL_DEFAULT, // Compression level
1 // Enable checksum
);
if (compressed_size == 0) {
fprintf(stderr, "Compression failed\n");
free(compressed);
free(decompressed);
return 1;
}
printf("Original size: %zu bytes\n", original_size);
printf("Compressed size: %zu bytes (%.1f%% ratio)\n",
compressed_size, 100.0 * compressed_size / original_size);
// Step 4: Decompress data (checksum verification enabled)
size_t decompressed_size = zxc_decompress(
compressed, // Source buffer
compressed_size, // Source size
decompressed, // Destination buffer
original_size, // Destination capacity
1 // Verify checksum
);
if (decompressed_size == 0) {
fprintf(stderr, "Decompression failed\n");
free(compressed);
free(decompressed);
return 1;
}
// Step 5: Verify integrity
if (decompressed_size == original_size &&
memcmp(original, decompressed, original_size) == 0) {
printf("Success! Data integrity verified.\n");
printf("Decompressed: %s\n", (char*)decompressed);
} else {
fprintf(stderr, "Data mismatch after decompression\n");
}
// Cleanup
free(compressed);
free(decompressed);
return 0;
}For large files, use the streaming API to process data in parallel chunks. Here's a complete example demonstrating parallel file compression and decompression using the streaming API:
#include "zxc.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argc != 4) {
fprintf(stderr, "Usage: %s <input_file> <compressed_file> <output_file>\n", argv[0]);
return 1;
}
const char* input_path = argv[1];
const char* compressed_path = argv[2];
const char* output_path = argv[3];
// Step 1: Compress the input file using multi-threaded streaming
printf("Compressing '%s' to '%s'...\n", input_path, compressed_path);
FILE* f_in = fopen(input_path, "rb");
if (!f_in) {
fprintf(stderr, "Error: Cannot open input file '%s'\n", input_path);
return 1;
}
FILE* f_out = fopen(compressed_path, "wb");
if (!f_out) {
fprintf(stderr, "Error: Cannot create output file '%s'\n", compressed_path);
fclose(f_in);
return 1;
}
// Compress with auto-detected threads (0), level 3, checksum enabled
int64_t compressed_bytes = zxc_stream_compress(f_in, f_out, 0, ZXC_LEVEL_DEFAULT, 1);
fclose(f_in);
fclose(f_out);
if (compressed_bytes < 0) {
fprintf(stderr, "Compression failed\n");
return 1;
}
printf("Compression complete: %lld bytes written\n", (long long)compressed_bytes);
// Step 2: Decompress the file back using multi-threaded streaming
printf("\nDecompressing '%s' to '%s'...\n", compressed_path, output_path);
FILE* f_compressed = fopen(compressed_path, "rb");
if (!f_compressed) {
fprintf(stderr, "Error: Cannot open compressed file '%s'\n", compressed_path);
return 1;
}
FILE* f_decompressed = fopen(output_path, "wb");
if (!f_decompressed) {
fprintf(stderr, "Error: Cannot create output file '%s'\n", output_path);
fclose(f_compressed);
return 1;
}
// Decompress with auto-detected threads (0), checksum verification enabled
int64_t decompressed_bytes = zxc_stream_decompress(f_compressed, f_decompressed, 0, 1);
fclose(f_compressed);
fclose(f_decompressed);
if (decompressed_bytes < 0) {
fprintf(stderr, "Decompression failed\n");
return 1;
}
printf("Decompression complete: %lld bytes written\n", (long long)decompressed_bytes);
printf("\nSuccess! Verify the output file matches the original.\n");
return 0;
}Compilation:
gcc -o stream_example stream_example.c -I include -L build -lzxc_lib -lpthread -lmUsage:
./stream_example large_file.bin compressed.xc decompressed.binThis example demonstrates:
- Multi-threaded parallel processing (auto-detects CPU cores)
- Checksum validation for data integrity
- Error handling for file operations
- Progress tracking via return values
The streaming multi-threaded API in the previous example is just the default provided driver.
However, ZXC is written in a "sans-IO" style that separates compute from I/O and multitasking.
This allows you to write your own driver in any language of your choice, and use the native I/O
and multitasking capabilities of your language.
You will need only to include the extra public header zxc_sans_io.h, and implement
your own behavior based on zxc_driver.c.
| Language | Repository |
|---|---|
| Go | https://github.com/meysam81/go-zxc |
- Continuous Fuzzing: Integrated with local ClusterFuzzLite suites.
- Static Analysis: Checked with CPPChecker & Clang Static Analyzer.
- Dynamic Analysis: Validated with Valgrind and ASan/UBSan in CI pipelines.
- Safe API: Explicit buffer capacity is required for all operations.
ZXC Codec Copyright © 2025, Bertrand Lebonnois. Licensed under the BSD 3-Clause License. See LICENSE for details.
Third-Party Components:
- xxHash by Yann Collet (BSD 2-Clause) - Used for high-speed checksums.