Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Nov 2018 09:51:25 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Stefan Blachmann <sblachmann@gmail.com>
Cc:        Cy Schubert <Cy.Schubert@cschubert.com>, Rebecca Cran <rebecca@bluestop.org>, freebsd-hackers Hackers <freebsd-hackers@freebsd.org>, Mark Johnston <markj@freebsd.org>, Ian Lepore <ian@freebsd.org>, Wojciech Puchar <wojtek@puchar.net>
Subject:   Re: 13-CURRENT: several GB swap being used despite plenty of free RAM
Message-ID:  <E31D5020-157F-4033-85B4-BA3B5681A4D4@yahoo.com>
In-Reply-To: <CACc-My33oRg7eqjfDuEQU51inyydc66Hx%2B-DysqmdKyyMVVJsA@mail.gmail.com>
References:  <freebsd-hackers@freebsd.org> <F5ACF6D0-DBD7-416F-9AAC-7709771FE545@yahoo.com> <201811180154.wAI1smhg049214@slippy.cwsent.com> <CACc-My33oRg7eqjfDuEQU51inyydc66Hx%2B-DysqmdKyyMVVJsA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2018-Nov-18, at 04:11, Stefan Blachmann <sblachmann@gmail.com> wrote:

> The inconveniences that the new swapping strategy causes are a regular
> topic in the FreeBSD forums.
> 
> Desktop users complain about lagginess, server users complain of long
> delays because server processes intended to be kept in memory for
> quick response times got swapped out and need to be swapped in again,
> resulting in outrageously poor server performance in spite of plenty
> of unused memory.

I've no clue of the variations in workloads involved for
various folks, but I only see swapping/paging once free
memory is low in my UFS based contexts. (I've not used
ZFS in a long time.) I do not see free RAM decreasing
without known, expected use of the RAM. Mostly I've had
to learn how late it may be before pages for cached
information explicitly moves back to free, no matter if
that involves paging/swapping out or not.

As I understand what Mark Johnston reported, he said that there is
no preemptive paging/swapping:

"FreeBSD will only ever swap when there is a free page shortage"

Moving between Active and Inactive does not of itself involve
paging/swapping. So that part of his description is a different
issue.

So the issue may trace back to why there ends up being a prior
free RAM shortage and/or when pages are moved back to RAM after
such a shortage.

I believe my report above is consistent with what Mark
Johnston reported about the modern algorithm(s) involved.

> Turning off swap completely, as Cy Schubert suggests, is strongly
> discouraged in the forums, as it can lead to kernel panicking because
> of being unable to swap out in critical kernel memory shortage
> situations, leading to the risk of  very serious filesystem
> corruption.
> 
> However, Cy Schubert is probably right when stating that the new
> swapping strategy resembles the 1960s-1980s industry's main swapping
> strategy.

Important parts of "new" way seems to have been in place since after
4.4BSD (so BSD 5.0 and later) . . .

The book "The Design and Implementation of the FreeBSD Operating System"
(2nd edition) states (page labeled 296):

QUOTE:
The FreeBSD swap-out daemon will not select a runnable processes to swap
out. So, if the set of runnable processes do not fit in memory, the
machine will effectively deadlock. Current machines have enough memory
that this condition usually does not arise. If it does, FreeBSD avoids
deadlock by killing the largest process. If the condition begins to arise
in normal operation, the 4.4BSD algorithm will need to be restored.
END QUOTE.

(I've not found vm.pageout_oom_seq in the book. It is for controlling
how much effort is put into freeing RAM before kills start, and so,
indirectly, the elapsed time that happens before those kills start.)

I'm not sure what specific changes that are newer might be under
discussion.

> The bad thing is now, that nowadays memory is no longer scarce and
> people can dimension their memory such that under normal circumstances
> there will never be any need to swap.

My typical use is apparently not normal. I'd agree with that.

> So I guess the unwillingness of the developer team to add an option
> like "NoPreemptiveSwapping", which disables swapping out as long as
> there is free physical memory available, is of psychological nature.

Unsure how to interpret this given:

"FreeBSD will only ever swap when there is a free page shortage"

> Lacking such an option, there is still the possibility to use rctl to
> disable swapping for particular users, processes, jails etc to
> mitigate the problems caused by the new swapping strategy to some
> degree.

Whatever is going on for this, it seems a more technical identification
of what it is would be needed in order to get to the right context.
(It may be non-trivial to identify.)

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E31D5020-157F-4033-85B4-BA3B5681A4D4>