Why I built axioma: A zero-allocation, division-free universal compression algorithm
Btw , here’s a fun fact: while some people build projects on 64-core monsters with 128 GB of RAM, this entire algorithm—every test and every overflow fix in codec.rs —was written, compiled, and debugged right on a smartphone screen within the Termux terminal. To be honest, it was a pretty hardcore experience, but if the code compiles and runs blazingly fast on mobile hardware, it means the…
The article discusses the challenges faced in modern data compression algorithms, particularly the memory allocation and division operations that impact performance. The author, who built the algorithm "axioma," shares how they overcame these hurdles by creating a lightweight and clean architecture. They explain how axioma is a zero-allocation, division-free universal compression algorithm that can be written, compiled, and debugged on a smartphone.
Key points include the concept of a dynamic probability manifold, where the sum of weights for 256 symbols is fixed at 4096 (2^12). This invariant allows for a multiplication and right shift operation instead of division, eliminating the need for dynamic memory allocation. The encoder uses a lazy rebalancing technique to maintain the invariant when updating symbol weights, which only requires conditional increments and bitwise operations.
Furthermore, axioma is designed to be deterministic, parallelizable, and portable, making it suitable for various applications such as hard real-time systems, kernel modules, and WASM sandboxes. It achieves compression by maintaining a uniform initial probability manifold, allowing the model to adapt online to the source distribution without compromising performance.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.