Re: Path forward for Virtualized Swap?
From: Rik van Riel
Date: Wed Sep 23 2026 - 10:37:35 EST
On Tue, 2026-09-22 at 21:00 -1000, Chris Li wrote:
> On Tue, Sep 22, 2026 at 5:49 AM Rik van Riel <riel@xxxxxxxxxxx>
> wrote:
>
> >
> > However, your configuration values are not a good
> > default for my setup.
> >
> > I believe we need to set the default to something
> > that accommodates a diverse range of desktop and
> > mobile users.
>
> Act. That is why I am asking for the maximum percentage that
> represents the upper bound for an actual usage case.
>
I think the workload that can use the most zswap
is probably a build system that places its temporary
files in tmpfs, in order to cut down on SSD wear.
Those files are just sitting there most of the time,
and are not part of the working set.
I suspect for such a workload we could get away
with maybe 30-40% of memory taken by the zswap
pool, which with a 4:1 compression ratio would
correspond to 120-160% of memory zswapped.
At a more pessimistic 3:1 compression ratio,
which seems to be fairly typical, it would
be 90-120%.
> >
> > Most of those users do not know what they will need,
> > but they will know to close a few browser tabs when
> > things get slow.
>
> They don't need to know. Such a bound exists naturally. We just want
> a
> safe margin. You say such a boundary doesn't exist. I say that
> boundary exists; that is the main contention.
>
The current default in Linux is to allow the
zswap pool to take up to 20% of memory.
That results in 60-80% of memory swapped out
to zswap at most, at typical compression ratios
of between 3:1 to 4:1.
I suspect a few workloads would benefit from
having a larger zswap pool.
> I agree; I wouldn't want to configure each machine differently all
> the
> time. In my mind, swapping out that much system RAM to zswap already
> results in a very unusable system. If you haven't try that, I suggest
> you try it before suggesting a number > 100%. At 100%, it is not a
> usable system, so we don't need to make a default for that.
> Defaulting
> to 8PB or 8TB is way too much.
But we don't have a default size.
Zswap starts at size 0. The memory is only allocated
when it is needed.
The vswap data structures are the same. They get
allocated when they are needed, and freed when
they are no longer needed.
It isn't like we need to pre-allocate anything.
--
All Rights Reversed.