r/compression • u/Specialist_Data_5403 • 11d ago
Windowless Random-Access LZSS for Constrained Microcontrollers
Hello r/compression
I'd like to share a project that I've been working on for the last couple of months.
On microcontrollers with only a few kilobytes of Flash and SRAM, heatshrink [1] and tamp [2] are widely used for decompressing static assets. They are small, configurable, and produce good compression ratios.
However, for random-access workflows (like reading a single entry from a config table, font, or devicetree), sliding-window decoders still require allocating the full window and sequentially decoding from the start of a block. To get small-slice random access with heatshrink or tamp, you either pay that full sequential decode cost or split the asset into small independently compressed blocks (which hurts compression ratio).
==============
blaris is a windowless LZSS format/decompressor - meaning it does not allocate a sliding window at all. This lets it match (or sometimes beat) the compression ratios of high-window heatshrink and tamp configurations while keeping total SRAM usage fixed at 104–112 B regardless of lookback range or file size.
Typical LZ77/LZSS resolves matches by copying from a RAM sliding window. blaris instead resolves matches directly inside the compressed payload, following the chain of matches backward until it lands on a literal run token.
To make bidirectional traversal fast and deterministic, tokens are split into 3 streams:
Because each control byte fixes the exact number of literal bytes or distance bits consumed, the decoder can step forward and backward across all 3 streams in lockstep.
A few optimizations make this practical:
On small random-access slices (1–32 B), blaris significantly outperforms ratio-matched, block-indexed heatshrink and tamp (e.g., >500× faster on 1 B reads at ~36% ratio on a 15.2 KiB devicetree blob). For larger sequential reads, streaming decoders overtake blaris around 64–128 B slices since blaris's work scales linearly with slice length. Testing on physical ESP32-C3FN4 quad-SPI XIP Flash also showed that Flash wait states don't disproportionately penalize backward token walking (~1.30–1.33× overhead vs. zero-wait-state simulation for slices ≥ 4 B).
Memory footprints compiled with Clang (-Os) for RV32IMC (including common adapter):
GitHub repo with the C implementation, host compressor, benchmarking suite, and full results: https://github.com/lis05/blaris
[1] https://github.com/atomicobject/heatshrink
[2] https://github.com/BrianPugh/tamp
[3] https://github.com/lis05/lzmpo
AI-enhanced post.