Skip to content

svga v0.1.2

Choose a tag to compare

@WendellXY WendellXY released this 19 Sep 07:26
· 2 commits to main since this release

A performance release. No API or behaviour changes.

Faster typed decoding

Decoding the typed Movie is about a third faster: 148 µs → 98 µs per file, averaged over 233 real-world files on an Apple M2 Max. Whole-file parsing (inflate + Document + Movie) goes from 599 µs to 550 µs.

  • Varints take a single-byte fast path, which covers tags and most lengths, and field iteration is inlined.
  • The per-frame decoders fill one local value in place instead of rebuilding it for every field.

How it compares with libsvga

Measured against libsvga 0.2.7 with its own svga_phase_bench, same files, best of 10 interleaved rounds:

per file inflate parse
svga 0.1.2 (pure Rust, miniz_oxide) 429 µs 106 µs (Document + Movie)
libsvga, Apple libz 330 µs 97 µs (protobuf), +55 µs for its minimal owned model
libsvga, portable Zig inflate 1079 µs 99 µs

Inflate dominates on every side. On large files svga parses faster because image bytes are borrowed from the payload rather than copied (164 µs vs 318 µs on a 2.6 MB file), and peak memory per parse is lower (0.76 MB vs 0.96–2.2 MB).

Also

  • The crate now declares #![forbid(unsafe_code)]. It never contained any.