From: Lasse Collin <lasse.collin@tukaani.org>
To: Paul Menzel <pmenzel@molgen.mpg.de>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/xz: Decode LZMA with local range decoder and dictionary state
Date: Sat, 14 Nov 2026 19:43:37 +0200 [thread overview]
Message-ID: <20261114194337.0197caa7.lasse.collin@tukaani.org> (raw)
In-Reply-To: <20261113115937.188894-1-pmenzel@molgen.mpg.de>
On 2026-11-13 Paul Menzel wrote:
> lzma_main() and the functions it calls access the range decoder and
> the dictionary through s->rc and s->dict. Every decoded bit stores to
> a uint16_t probability, and every decoded byte stores to dict.buf, and
> the kernel builds with -fno-strict-aliasing. So the compiler has to
> assume that these stores modify *s, and reloads and stores rc.range,
> rc.code, rc.in_pos, dict.pos, dict.full, … around each of them.
>
> Copy both structures to local variables at the start of lzma_main()
> and write them back at the end, and force inlining of the helpers that
> take their address, so that the compiler can keep them in registers.
I tested quickly, but I cannot comment properly yet, sorry. I hope I can
some day next week.
> liblzma’s LZMA decoder does the same [1]: lzma_decode() works on a
> local copy of the dictionary, and rc_to_local() makes a local copy of
> the range decoder.
It was done when GCC 3.3 and 3.4 were still in common use. Maybe
aliasing is one reason why it helped. Maybe it was that variables on
stack can be accessed directly via the stack pointer, which could have
mattered on register-starved 32-bit x86. I haven't checked how big
difference it makes in liblzma nowadays.
> liblzma has copied the range decoder since the first commit of the xz
> repository in 2007 [2], and the dictionary since a restructuring in
> 2008 [3], first released in xz 4.999.5alpha.
History about non-kernel code isn't needed in the commit message.
In late 2023 or very early 2024, I wrote some compact x86-64 inline
assembly for XZ Embedded, but I never polished and released it. I try to
finish it.
Thanks!
--
Lasse Collin
prev parent reply other threads:[~2026-11-14 17:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 11:59 Paul Menzel
2026-11-14 17:43 ` Lasse Collin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261114194337.0197caa7.lasse.collin@tukaani.org \
--to=lasse.collin@tukaani.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmenzel@molgen.mpg.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®