You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: obs-graphics: lzw_decode (output stack) is 18 % slower than the C #2504
The Rust LZW decoder of #2466 (obs_graphics::lzw, swapped in the hybrid libobs since #2471) is slower than the C through lzw_decode, the output stack:
port_comparison, M1 Max, one 1920×1080 frame
Rust
C
lzw_decode_map (full-width frame)
10.41 ms
10.16 ms (+2.5 %)
lzw_decode until the end of the data (output stack)
10.50 ms
8.86 ms (+18.5 %)
#2466 measured only lzw_decode_map. libnsgif uses lzw_decode for every interlaced or clipped frame (the complex path of the frame decode). PR #2503 (#2501) found the gap: the interlaced 1080p frame decode is 17 % slower, and the LZW stack decode is most of that.
Cause
From a profile of the Rust stack decode:
Decoder::write matches on the writer (stack or colour map) for every value; the C passes its writer as a separate inline function.
Every value reads its table entry and writes the stack through a bounds-checked index, although codes are at most 12 bits and stack positions below 4096.
Input::read_code is about a quarter of the time: its fast path reads three bytes with three bounds-checked reads.
Plan
One PR: a port_comparison bench for lzw_decode first (lzw/decode_stack_1080p), then the fix in obs-graphics, with Tier 1 (render::lzw) and Tier 3 (render::lzw_parity) unchanged as the proof that results do not change.
Activity
vpacher commentedon Oct 26, 2026
Claiming: #2504
Plan as in the description: one PR, the
lzw_decodebench first, then the fix; Tier 1 and Tier 3 unchanged.obs-graphics: Speed up the LZW decoder's stack decode (obs-rust#2504) (…