]> git.ipfire.org Git - thirdparty/haproxy.git/commit
IMPORT: slz/uslz: inline the bit reader and the huffman decoders
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Aug 2026 16:41:42 +0000 (18:41 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 12 Aug 2026 07:14:07 +0000 (09:14 +0200)
commite3c9a9c6b56ff06d6430d06ff84569f6224f56cc
tree5425c047f405fa3d32a9e42b77d8dd661b4b721e
parent8e32ba6efadcf65ba5e01e5883146eaa005dbe8a
IMPORT: slz/uslz: inline the bit reader and the huffman decoders

gethuff(), gethuff_fixed() and bit_accumulate() were all purposely marked
noinline due to tests showing a significant performance decrease and code
increase by inlining them. That's annoying because most of the arguments
they need can easily be optimized once the compiler has a full view of
them, and it's quite visible with perf top when decompressing an slz stream
that 30% of the CPU is spent in gethuff_fixed() and bit_accumulate(), and
that when decompressing a gzip stream, it's 62% in gethuff() alone!

It turns out that it's only combinations of 1 or 2 of them inlined that
ruins the performance, but inlining the 3 at once instead shrinks the
code and boosts the performance by letting the compiler keep all these
local variables in registers. As a proof, the code is now ~352 bytes
smaller, and 13 to 17% faster (respectively for slz and gzip streams).
That's one example of situations where individual changes bring nothing
good.

This is libslz upstream commit d1e73bed32b47ee43e91255126ab7fcf82a1e21b
src/uslz.c