r/compression • • 8h ago

IngotTS: a from-scratch Zstandard encoder/decoder in C (RFC 8878), our own level-1/level-2 parsers, within ~3% of zstd -19

I wrote a Zstandard implementation from the RFC (no reference code used) for storing training-data shards as independently decodable blocks. Output is standard zstd frames; the stock zstd -d is the oracle in the tests.

Measured (1 MiB blocks, each its own frame, zstd 1.5.7 on the same blocks): - Level 2 (optimal parse over a binary-tree match finder) vs zstd -19: repository text 1.0035x bytes, code 1.025x, generated docs 1.006x; with a 4 MiB dictionary 0.995x-1.024x. Speed 1.8-3.0 MB/s (about zstd -19 under the same load). - Level 1 vs zstd -3: code 0.940x bytes, documents 1.019x, repo text 0.950x. Speed 178 MB/s on code (Mac M4, idle); 34.8 MB/s on a Pentium 2117U. - Decoder (one core, 1 MiB blocks, G5 E5440 / Pentium 2117U): 136-599 MB/s depending on corpus, level and dictionary; at most 8% slower and up to 37% faster than the zstd CLI in my runs (G5). - Output is byte-identical across Mac clang/arm64, gcc x86-64 (golden sha256 match), and 1 vs 8 threads. - Tests: ASan/UBSan/TSan clean, libFuzzer smoke (hundreds of thousands of runs, 0 crashes), mutation testing (28/28 and 32/32 caught per stage).

Limits: it is not a new algorithm and does not beat zstd's own encoder; the gains are in the container (independent blocks with an index) and dictionaries. No parquet comparison yet (not run).

Code: https://github.com/dcherrera/Foundry/tree/main/ingot/ingotts (AGPL-3.0). I'm the author.

Background (Ingot, the weight codec IngotTS grew out of): https://teamide.dev/research/papers/ingot.pdf

0 Upvotes

0 comments sorted by