Re: [PATCH v4 0/8] Batched zswap_store() framework with compression batching
From: Kanchana P. Sridhar
Date: Tue Nov 24 2026 - 18:46:17 EST
On Tue, Nov 24, 2026 at 12:29 PM Yosry Ahmed <yosry@xxxxxxxxxx> wrote:
>
> On Fri, Nov 20, 2026 at 03:16:32PM -0800, Nhat Pham wrote:
[...]
> > Have you tried perf-ing the store path to see what was the overhead
> > source (before and after this optimization)? I'm curious.
>
> So I was able to reproduce the usemem30 sys/wall time improvements here
> on a Sapphire Rapids machine (both in a VM and on baremetal), and I
> threw my LLM at perf-ing to figure out what the overhead was. It's
> important to note that the sys/wall time improvement I observed was on
> the free phase, the write phase / throughput (which involves zswap
> store) didn't show much of a change.
>
> Batching made more consecutive pages that compress to the same zsmalloc
> class more likely to land in the same zspage, so the freeing path gets
> faster as the zspage and metadata are hot in the cache, which alleviates
> contention on the class lock.
This is a real performance gain with batching, correct?
>
> I think the memory allocated by usemem all compresses to the same class
> size, which makes holding the class lock in the freeing path a
> bottleneck. I confirmed this by a hacky patch to shard the class lock
> into 32 locks, which caused the same usemem improvements and the series
> doesn't improve performance anymore on top of that change.
I think we all agree that vm-scalability/usemem is a
microbenchmark/standard. I am not sure I understand the value of these
"hacks", when my patch-series posts data with the standard mm-unstable
and my patch series with a standard usemem microbenchmark.
>
> I also tried usemem with Silesia to get realistic compression data
> (similar to Kanchana's testing on previous versions), and didn't see
> similar improvements (because the compressed pages get distributed
> across multiple classes). I also tried a kernel build and the munmap
> microbenchmark in [1] (which Sergey quoted in [2]), which also didn't
> show improvements.
>
> That got me curious tho, and I had my LLM explore other optimizations to
> the freeing path. I think we can get similar improvements in usemem
> as well as the munmap microbenchmark [1] by batching zswap entries
> freeing. We can batch both the zsmalloc object freeing as well as the
> LRU deletion. I am still looking into it and I might send out patches.
>
> But I think this series doesn't really move the needle on realistic
> workloads, as I previously mentioned.
Your statements and hypothesis based on the kernel hacks don't explain
why I see 6.56% additional Sys time savings with compress batching
over the gains observed with store batching alone. I am not sure how
to interpret your statement above without your posting any data.
Did you get a chance to see the usemem/ZSTD data with/without compress
batching that I posted in [1], and my analysis of the breakdown
between performance gains from store batching vs. compress batching in
[2]?
As per the data I posted, compress batching of PMD THP with ZSTD
yields an additional 6.56% Sys time savings and additional 1.12%
Throughput improvement over zswap store batching. Combined zswap store
+ compress batching yields 13.87% Sys time reduction and 3.85%
Throughput increase over mm-unstable. I think this clearly
demonstrates performance benefits to a well established
microbenchmark, run at scale, using upstream kernel git trees and my
patch series.
I would appreciate comments from Nhat, Johannes and Andrew on these
posted gains/analysis:
[1]: https://lore.kernel.org/all/20261120041906.5785-2-kanchanapsridhar2026@xxxxxxxxx/T/#m33e586ec89ed46790da284e7a2f6d99b50c9f935
[2]: https://lore.kernel.org/all/20261120041906.5785-2-kanchanapsridhar2026@xxxxxxxxx/T/#m51d7d13809d508a9116904c01bf3c94fdf2981dc
An independent replication of the gains posted by me in this
patch-series, using standard mm-unstable and vm-scalability/usemem
would also be very useful.
Thanks,
Kanchana
> Regarding the bpftrace
> measurements, I couldn't reproduce them. I think one factor is that
> probing both zswap_store() and zswap_compress() makes the zswap_store()
> numbers different based on how many zswap_compress() calls we make
> (which are less with batching) due to the overhead of the probe itself.
> When I trace zswap_store() without zswap_compress(), I don't see
> meaningful changes in latency.
>
> [1] https://lore.kernel.org/linux-mm/20261016120927.3191690-1-hongfengchen@xxxxxxxxxx/
> [2] https://lore.kernel.org/linux-mm/20261123054746.2579253-1-senozhatsky@xxxxxxxxxxxx/