Re: [PATCH RFC 0/3] zram: avoid copying spanning LZ4 objects before decompression

From: Sergey Senozhatsky

Date: Tue Nov 24 2026 - 02:33:12 EST


On (26/11/24 14:56), Xueyuan Chen wrote:
> > LZ4_decompress_safe_split() isn't actually very well optimized. While
> > it avoids the copy of the source data into a contiguous buffer, it
> > copies every match and literal run with a variable-length memcpy(),
> > which on most data is a very slow way to implement LZ decompression.
> >
> > I suspect it looked good on your synthetic benchmark (pseudorandom data
> > followed by 0's) only because that tended to generate 1 very long
> > literal run and 1 very long match. Whereas normal data would have lots
> > of interleaved literal runs and matches of much shorter lengths where an
> > external memcpy() call does very poorly; that is why the existing LZ4
> > decompression code does not do it that way.
> >
> > To some extent the literal run and match copy performance is fixable
> > with a better implementation. However, having to handle two different
> > source buffers still introduces overhead that cannot go away.
> >
> > So I feel this approach is probably not worth it. If you'd like to
> > continue to explore it, it would need to be tested on different data and
> > would need to be properly optimized.
> >
> > - Eric
> >
> Hi Eric,
>
> I reran the benchmark on arm64 with pages from an Android phone's
> zram export. Optimizing short match copies cut cycles per spanning
> read by 22–27% compared with the RFC decoder.
>
> I also tried restoring the LZ4 short-sequence fast path within each
> input fragment. That version was still slower than the existing
> copy-and-decompress path in all 28 paired runs. Swap-in took about
> 6.6–6.8% longer with one worker and 3.8% longer with eight workers.
>
> I'll drop this RFC. Thanks for pointing me toward the short-copy
> overhead and the workload issue.

Oh, I see, thanks for the update.