首页 > AI前沿 > Show HN: misa77 – Up to 3x faster decompression than zstd, with better ratios

Show HN: misa77 – Up to 3x faster decompression than zstd, with better ratios

Hacker News 2026-12-03 16:07 25 阅读 查看原文
misa77 (0.9.0) misa77 is an LZ-based compressor that targets the write-once, read-many niche. In particular, it aims to satisfy the following criteria: Extremely high decompression throughput (single-threaded and in-memory). Good compression ratios relative to decode throughput. For reference, misa77 levels that correspond to LZ4 and zstd-class ratios decode roughly 2 times faster than their counterparts. Constant memory use during compression, regardless of input size. Slow compression is the obvious tradeoff that we make to achieve the above. Decompression is guaranteed to be safe in the case of corrupt/malicious input (i.e. the decompressor terminates gracefully, and does not access out-of-bounds memory or engage in any other UB) . Benchmarks A terse summary of misa77's performance would be that relative to its competitors (LZ4 class codecs for levels 1 to 6, and zstd/brotli/xz for levels 11 to 13), it encodes somewhat slower, gets similar ratios, but decodes much faster. Some results on specific corpora follow. For more detailed and cross-platform results, see BENCHMARKS.md. The benchmarks below were run on the following setup: CPU: Intel(R) Core(TM) i7-14650HX (@2.2 GHz) (Intel Turbo disabled). Single threaded, pinned to a single performance core. CPU governor set to performance, uncore frequency pinned at its maximum. The benchmarking harness used was lzbench. misa77 has also been merged into TurboBench, and the results below can be reproduced through both harnesses. Silesia Corpus This corpus can be found here. It contains 12 files, totaling 212 MB, covering text, source code, databases, executables, and medical images. It is the standard (albeit outdated) corpus for comparing general-purpose compressors. The takeaway is that levels 3-6 dominate LZ4 (and other codecs in this class) on decode speed. Level 6 in particular gets smaller ratios and decodes ~2x faster (...and encodes much slower). Levels 11-13 get ratios similar to those of zstd's levels 11 to 22, while decoding about 2.5 to 3 times faster. Note: lzbench lists misa77 as two codecs, as its levels are not contiguous. misa77 is levels 1 to 6 and misa77ec is levels 11 to 13. Game Asset Corpus There's no standard corpus for this, so I unwrapped the archives of some games (14 games, using 12 different engines), and put together a corpus containing the following data types: textures (33 %), geometry (15 %), levels (14 %), engine packages (13 %), other raster data (10 %), text and tables (9 %) and animation (6 %). It's about 263 MB, and games usually compress data in small independent blocks, so I've included results at 256 KiB and 64 KiB block framings. The takeaways are quite similar to those for silesia, except that levels 12 and 13 get better ratios than zstd here. Also, the relative placement of codecs here is not that sensitive to blocked framing (although their absolute ratios do worsen as block size reduces). Levels TLDR: I recommend using one of levels 3, 11, 12, or 13 depending on your requirements. misa77 is really two classes of compressors bundled into one library: Levels 1-6 involve simple LZ compression with no entropy coding or preprocessing. Competitors here would be LZ4, LZSSE, Lizard, etc. Levels 11-13 involve LZ compression along with possible use of entropy coding, delta coding, and some other tricks. Competitors here would be zstd, brotli, etc. Within a class, levels are ordered by compression effort. For most shapes of data, encode time increases and ratio decreases with increasing level (within a class), but decompression throughput is not similarly monotonic. Ratio is as measured on silesia.tar in the Intel run. The Encode/Decode vs L3 columns are throughput relative to level 3, from the same run. Levels 1 to 5 emit the light format, level 6 emits the heavy format and levels 11 to 13 emit the entropy format (see docs/format.md). Encoder memory is the compressor's own working state (disjoint from the caller's input and output buffers). Levels 5 and above need less for inputs smaller than their internal block or window (level 13 uses about 11 MB for a 64 KB input and 52 MB for a 1 MB input, and level 11 about 4 MB and 30 MB). Decompression needs no working memory at levels 1 to 6, and the decoder for levels 11 to 13 allocates 1.4 MB of scratch space per call. Requirements For the library: A C++20 compiler (both GCC and Clang are fine). CMake >= 3.20. A little-endian 64-bit system. For the CLI: The misa CLI needs POSIX (Linux, macOS). Note: On x86-64, AVX2/SSE2 are selected at runtime. ARM has a NEON path. On x86-64 and ARM64 with GCC or Clang, the decoders use hand-written assembly kernels (you can pass -DMISA77_ASM=OFF to use the C++ decoders instead, but I strongly recommend not doing this). Building cmake -B build -DCMAKE_BUILD_TYPE=Release cmake --build build This produces the misa CLI at build/misa. For a binary tuned to the machine you'll run it on, add -DMISA77_MARCH=native (I recommend this). To run the round-trip test: ctest --test-dir build Note: if you build the library with your own build system on x86-64 instead of the CMakeLists.txt from this repo, ensure the following two things. src/isa/target_sse2.cpp (or target_portable.cpp) must come before src/isa/target_avx2.cpp on the link line or in the archive. LTO must stay off for the library. Library Usage The build produces a static library (CMake target misa77::misa77) with a small C++ API in misa77/misa77.h. The easiest integration is a git submodule (or CMake FetchContent) plus: add_subdirectory(misa77) target_link_libraries(your_app PRIVATE misa77::misa77) Alternatively, install it (cmake --install build --prefix ) and use: find_package(misa77 REQUIRED) target_link_libraries(your_app PRIVATE misa77::misa77) Pass -DMISA77_BUILD_CLI=OFF if you only want the library. Sample usage: #include #include // compress (pick a level with misa77::config(N) where N is a valid level, default is 3), returns 0 on failure misa77::config cfg; std::vector compressed(misa77::compress_bound(input_size, cfg)); uint64_t csize = misa77::compress(input, input_size, compressed.data(), compressed.size(), cfg); compressed.resize(csize); // decompress, returns original_size on success uint64_t original_size = misa77::decompressed_size(compressed.data()); std::vector output(misa77::decompressed_buffer_bound(original_size)); // returns 0 on invalid input uint64_t written = misa77::decompress(compressed.data(), csize, output.data(), output.size()); Two things to keep in mind: You must size the destination buffers with compress_bound / decompressed_buffer_bound, passing compress_bound the same config you compress with (the bound depends on the level's format). The size you pass to misa77::decompress must be the exact size of the compressed stream (what compress returned), and not the size of the buffer holding it. The experimental modes are declared in misa77/experimental.h, with usage documented in comments (these keep changing frequently so I don't wanna "formally" document them here just yet). You probably shouldn't be using them anyway. CLI Usage misa is a single, dependency-free binary with two file-based subcommands, and a benchmark mode. It operates on single files only (there's no directory or pipe support, so tar first if you need those). misa compress FILE # -> FILE.misa77 misa decompress FILE.misa77 # -> FILE misa compress takes -l N / --level N to pick the compression level (default is 3). Everywhere, -o PATH sets the output path and -f overwrites without asking. misa compress -l 12 enwik8 # enwik8 -> enwik8.misa77 misa decompress enwik8.misa77 -f # back to enwik8 misa bench FILE compresses and decompresses a file in memory, and prints the sizes and throughput of each level (nothing is written to disk). -l N or -l A:B restricts it to one level or a range of levels, and -t SECONDS sets how long decompression is timed for at each level (default 3). Compression is timed over a single pass (as it's quite slow anyway), and decompression over the fastest of multiple passes. $ misa bench -l 1:3 silesia.tar 1#silesia.tar : 211957760 -> 99075595 ( 46.74%), 233 MB/s, 4399 MB/s 2#silesia.tar : 211957760 -> 93849014 ( 44.28%), 169 MB/s, 5000 MB/s 3#silesia.tar : 211957760 -> 90281695 ( 42.59%), 71.7 MB/s, 5684 MB/s Documentation The underlying stream formats (used by the library functions) and the container format for .misa77 files (produced by the CLI) can be found in docs/. Status misa77's format may change unexpectedly as it's still v0.x.y. It's been through local fuzzing with ASan/UBSan, broader hardening is ongoing. Note: misa77 has evolved out of a less polished endeavour to learn performance engineering, and its history can be found in this archived repository. Acknowledgement Inspiration has been taken from: LZ4 lizard zstd xz / LZMA libdeflate m77rip Various people on encode.su Lastly, the following models helped a lot with every step of the process, including independently suggesting ideas/techniques that I wouldn't have thought of. Without their assistance, development would have been far slower, and I would likely not have explored all the paths that I did end up exploring (some of which were productive and some of which weren't). Claude Opus 4.8 Claude Fable 5 Claude Opus 5 Claude Opus 5.5 Claude Fable 5.2 License MIT (see LICENSE).