Skip to content

feat(embed): one-shot functions, build-time sizes, honest footprint ceilings - #134

Merged
MagicalTux merged 1 commit into
masterfrom
embed-footprint
Oct 3, 2026
Merged

MagicalTux merged 1 commit into
masterfrom
embed-footprint

Conversation

@MagicalTux

Copy link
Copy Markdown
Member

Summary

  • One-shot functions in deflate / zlib / gzip (embed build): decompress(input, output) (output slice is the history window: no window, no state, ~1.3 KiB stack), decompressed_len(input, max_len), compress(input, table, output) with a caller table of any size.
  • Build-time sizes: WindowedDecoder<WINDOW> and BlockEncoder<BLOCK, TABLE>; Decoder / Encoder are aliases at the defaults, so existing code is unchanged.
  • Smaller streaming codecs: the decoder compiles out other containers' states; the encoder uses a 32-bit bit buffer and no longer links memclr8 / __aeabi_llsl.
  • Footprint check fixed: stack.py stopped at the frame-pointer add and missed subw, under-reporting decoder stack (88 vs 328 bytes). Ceilings re-set from correct figures, new configurations added.

Sizes (thumbv7em, opt-level z, LTO) vs minizlib

minizlib code / stack compcol code / stack
gzip decompress 2436 / 1372 2240 / 1336
zlib decompress 2164 / 1352 2036 / 1328
raw decompress 1932 / 1344 1846 / 1328
gzip / zlib / raw compress 1028 / 940 / 804 952 / 898 / 748 (stack 116–124 vs 144–152)
zlib / raw streaming decode 3946 / 3554 3804 / 3206
gzip streaming decode 3566 3768
gzip streaming encode 1538 1718

Test plan

  • Differential test against minizlib: byte-identical compressed output (one-shot and BlockEncoder at many sizes); identical accept/reject on ~64k valid/corrupt/random streams
  • cargo test --features all, cargo test --all-features, embed-only tests (12 new)
  • clippy (all CI configs), docs with -D warnings, no_std + thumbv7em builds
  • tools/footprint/check.sh, tools/embed-crosscheck.sh

🤖 Generated with Claude Code

…eilings

- `decompress`, `decompressed_len` and `compress` in `deflate`, `zlib` and
  `gzip` (embed build): slice to slice, the output as the history window,
  no state kept. Smaller than minizlib's equivalents in code and stack.
- `WindowedDecoder<WINDOW>` and `BlockEncoder<BLOCK, TABLE>`: the streaming
  codecs' sizes picked at build time; `Decoder` and `Encoder` are aliases
  at the default sizes, so existing code is unchanged.
- The streaming decoder leaves out the states of the other containers, and
  decodes discarded output through a scrap of stack rather than a per-byte
  branch; the encoder writes through a 32-bit bit buffer and no longer
  links `memclr` or 64-bit shifts.
- tools/footprint/stack.py missed what a prologue reserves after setting up
  the frame pointer, and `subw`: the decoders' stack was under-reported
  (88 bytes vs 328 measured). Ceilings are now set from correct figures, and
  cover the new configurations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MagicalTux
MagicalTux merged commit f384027 into master Oct 3, 2026
48 checks passed
@MagicalTux
MagicalTux deleted the embed-footprint branch October 3, 2026 08:45
@MagicalTux MagicalTux mentioned this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant