From: Nhat Pham <nphamcs@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Yosry Ahmed <yosryahmed@google.com>,
akpm@linux-foundation.org, linux-mm@kvack.org,
kernel-team@meta.com, linux-kernel@vger.kernel.org,
flintglass@gmail.com, Chengming Zhou <chengming.zhou@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>
Subject: Re: [PATCH 1/2] zswap: implement a second chance algorithm for dynamic zswap shrinker
Date: Mon, 29 Jul 2024 23:23:01 -0700 [thread overview]
Message-ID: <CAKEwX=NsuNBijq9LEau9tM6e1r4qTbDLSfsF-f8bAcKFFx28mw@mail.gmail.com> (raw)
In-Reply-To: <20240730033929.GB2866591@cmpxchg.org>
On Mon, Jul 29, 2024 at 8:39 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> Seek is a fixed coefficient for the scan rate.
>
> We want to slow writeback when recent zswapouts dominate the zswap
> pool (expanding or thrashing), and speed it up when recent entries
> make up a small share of the pool (stagnating).
>
> This is what the second chance accomplishes.
Wow, this is something that I did not even consider. Thanks for
pointing this out, Johannes.
shrinker->seeks tuning allows you to adjust writeback pacing, as a
ratio of the pool size. When the pool is static (no/few zswpin or
zswpout), then these two are similar (on average). But with concurrent
activities (pages coming in and out), the dynamics can potentially be
different.
Second chance allows you to have different dynamics depending on
recent pool activities. The recent zswpouts will be protected by
virtue of the reference bits (and given another chance, which will be
taken if it's used again soon), and the pages concurrently zswapped in
obviously will be too, whereas the stale objects who have already been
touched by the shrinker once in the past will be evicted immediately.
IOW, all of the above activities (zswpin, zswpout, reclaim pressure)
can harmonize seamlessly to adjust the effective rate of writeback.
Without any additional heuristics (old or new), increasing seek (i.e
decreasing the writeback rate) by itself only has a static effect, and
definitely does not accomplish the aformentioned dynamic writeback
rate adjustment. Now, we can (and did try to) mimic the above behavior
somewhat with the protection size scheme: only return the unprotected
size, carefully increase it on zswpout and swpin (so that zswpouts are
not considered), carefully prevent shrinker from reclaiming into
protected area, etc.. But it's incredibly brittle - with all these
hacks, it becomes even more complicated and unintuitive than the
second chance algorithm. If it's performing well, then sure, but it's
not. Might as well do the simpler thing? :)
Besides, the problem with the haphazard aging (i.e protection
decaying) remains - at which point do we decay, and how much do we
decay? Compare this with the new second chance scheme, which gives you
a natural aging mechanism, and can elegantly adjust itself with
reclaim/memory pressure.
next prev parent reply other threads:[~2024-07-30 6:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 23:28 [PATCH 0/2] improving dynamic zswap shrinker protection scheme Nhat Pham
2024-07-25 23:28 ` [PATCH 1/2] zswap: implement a second chance algorithm for dynamic zswap shrinker Nhat Pham
2024-07-26 21:58 ` Yosry Ahmed
2024-07-29 23:07 ` Nhat Pham
2024-07-30 0:07 ` Nhat Pham
2024-07-30 3:39 ` Johannes Weiner
2024-07-30 6:23 ` Nhat Pham [this message]
2024-07-30 18:46 ` Yosry Ahmed
2024-07-30 21:40 ` Nhat Pham
2024-07-30 22:04 ` Nhat Pham
2024-07-25 23:28 ` [PATCH 2/2] zswap: increment swapin count for non-pivot swapped in pages Nhat Pham
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='CAKEwX=NsuNBijq9LEau9tM6e1r4qTbDLSfsF-f8bAcKFFx28mw@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=flintglass@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shakeel.butt@linux.dev \
--cc=yosryahmed@google.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