This PR replaces the `bitvec`-based reader in `rlgr::decode` with a new `BitReader` that uses a u64 accumulator to buffer up to 64 bits. The new implementation improves performance by refilling the accumulator with up to eight bytes per bounds check and serving reads of up to 32 bits directly from the accumulator. The new bit reader is covered by an extensive test suite. ## Performance results * RLGR1 entropy decoding: 1.97x faster * RLGR3 entropy decoding: 2.17x faster * Single-tile decoding: 1.6x - 3.7x faster depending on the resolution --------- Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com> Co-authored-by: Marc-André Moreau <mamoreau@devolutions.net> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1.0 KiB
RFX decoder optimizations
This note tracks performance work on the RemoteFX (RFX) tile decode path in ironrdp-graphics.
Each optimization records what changed and how much it is faster.
Optimizations
RLGR bit reader (#2150)
What changed:
the bitvec-based reader in rlgr::decode is replaced by BitReader, which buffers up to 64 bits in a u64 accumulator.
The decoder now uses skip_leading and read instead of slice splitting.
Why it is faster:
refilling takes one bounds check for up to eight bytes, and any read of 32 bits or fewer is served from the accumulator.
Run lengths of zeros and ones come from leading_zeros on the whole word instead of a per-bit scan.
Measured result: RLGR1 and RLGR3 entropy decoding run 1.97x and 2.17x faster, and single-tile decode is 1.6x to 3.7x faster.
Rejected approaches
TBD. Record ideas that were tried and did not help, with the measured effect.
Running the benchmarks
# Native target
cargo xtask bench rfx-decode
# WASM target
cargo xtask bench rfx-decode-wasm --simd