From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>, gao xu <gaoxu2@honor.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Minchan Kim <minchan@kernel.org>, Jens Axboe <axboe@kernel.dk>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"surenb@google.com" <surenb@google.com>,
zhouxiaolong <zhouxiaolong9@honor.com>
Subject: Re: [PATCH v2] zram: Optimize LZ4 dictionary compression performance
Date: Fri, 13 Mar 2026 12:00:30 +0900 [thread overview]
Message-ID: <abN9hhmE2hG2Cyl0@google.com> (raw)
In-Reply-To: <698181478c9c4b10aa21b4a847bdc706@honor.com>
On (26/03/13 02:41), gao xu wrote:
> Calling `LZ4_loadDict()` repeatedly in Zram causes significant overhead
> due to its internal dictionary pre-processing. This commit introduces a
> template stream mechanism to pre-process the dictionary only once when
> the dictionary is initially set or modified. It then efficiently copies
> this state for subsequent compressions.
>
> Verification Test Items:
> Test Platform: android16-6.12
> 1. Collect Anonymous Page Dataset
> 1) Apply the following patch:
> static bool zram_meta_alloc(struct zram *zram, u64 disksize)
> if (!huge_class_size)
> - huge_class_size = zs_huge_class_size(zram->mem_pool);
> + huge_class_size = 0;
> 2)Install multiple apps and monkey testing until SwapFree is close to 0.
> 3)Execute the following command to export data:
> dd if=/dev/block/zram0 of=/data/samples/zram_dump.img bs=4K
>
> 2. Train Dictionary
> Since LZ4 does not have a dedicated dictionary training tool, the zstd
> tool can be used for training[1]. The command is as follows:
> zstd --train /data/samples/* --split=4096 --maxdict=64KB -o /vendor/etc/dict_data
>
> 3. Test Code
> adb shell "dd if=/data/samples/zram_dump.img of=/dev/test_pattern bs=4096 count=131072 conv=fsync"
> adb shell "swapoff /dev/block/zram0"
> adb shell "echo 1 > /sys/block/zram0/reset"
> adb shell "echo lz4 > /sys/block/zram0/comp_algorithm"
> adb shell "echo dict=/vendor/etc/dict_data > /sys/block/zram0/algorithm_params"
> adb shell "echo 6G > /sys/block/zram0/disksize"
> echo "Start Compression"
> adb shell "taskset 80 dd if=/dev/test_pattern of=/dev/block/zram0 bs=4096 count=131072 conv=fsync"
> echo.
> echo "Start Decompression"
> adb shell "taskset 80 dd if=/dev/block/zram0 of=/dev/output_result bs=4096 count=131072 conv=fsync"
> echo "mm_stat:"
> adb shell "cat /sys/block/zram0/mm_stat"
> echo.
> Note: To ensure stable test results, it is best to lock the CPU frequency
> before executing the test.
>
> LZ4 supports dictionaries up to 64KB. Below are the test results for
> compression rates at various dictionary sizes:
> dict_size base patch
> 4 KB 156M/s 219M/s
> 8 KB 136M/s 217M/s
> 16KB 98M/s 214M/s
> 32KB 66M/s 225M/s
> 64KB 38M/s 224M/s
>
> When an LZ4 compression dictionary is enabled, compression speed is
> negatively impacted by the dictionary's size; larger dictionaries result
> in slower compression. This patch eliminates the influence of dictionary
> size on compression speed, ensuring consistent performance regardless of
> dictionary scale.
>
> [1] https://github.com/lz4/lz4?tab=readme-ov-file
>
> Signed-off-by: gao xu <gaoxu2@honor.com>
Acked-by: Sergey Senozhatsky <senozhatsky@chromium.org>
prev parent reply other threads:[~2026-03-13 3:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 2:41 [PATCH v2] zram: Optimize LZ4 dictionary compression performance gao xu
2026-03-13 3:00 ` Sergey Senozhatsky [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=abN9hhmE2hG2Cyl0@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=gaoxu2@honor.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=surenb@google.com \
--cc=zhouxiaolong9@honor.com \
/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