Re: Swap, ZFS & ARC

From: Warner Losh <imp_at_bsdimp.com>
Date: Thu, 02 Feb 2023 16:49:39 UTC
On Thu, Feb 2, 2023 at 7:42 AM Eugene Grosbein <eugen@grosbein.net> wrote:

> 02.02.2023 21:28, jbo@insane.engineer wrote:
> > Hello folks,
> >
> > Based on a discussion on the forums not so long ago I tried to figure
> out how swap usage on a ZFS system plays together with ARC. However, I
> could find very little to no information on this which leads me to believe
> that there is some "core concept" I might be oblivious to.
> >
> > The main question is basically this: Your system starts to swap out data
> from RAM to your swap partition.
> > This swap data on disk ultimately resides somewhere in a ZFS pool.
>
> I prefer not doing this. That is, all my systems have swap partition
> outside of ZFS pool.
>

I agree. Don't swap to anything but a raw partition if you have any way
possible to avoid it. Swapping to anything ZFS provides is a bad idea
because ZFS has to do memory allocations to do the I/O, which might not be
possible when heavily swapping on a memory constrained system. If it can't
allocate memory to do the swapping, it can't release the dirty memory that
is being swapped out, possibly leading to deadlock.

I actively avoid it unless there's no alternative, just like I actively
avoid swapping to a file in a filesystem like UFS if I can avoid it too...

Warner