Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Nov 2016 10:31:28 +0100
From:      Gary Jennejohn <gljennjohn@gmail.com>
To:        freebsd-arch@freebsd.org
Subject:   Re: PQ_LAUNDRY
Message-ID:  <20161105103128.78197d36@ernst.home>
In-Reply-To: <20161103182916.GA31178@wkstn-mjohnston.west.isilon.com>
References:  <20161103182916.GA31178@wkstn-mjohnston.west.isilon.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 3 Nov 2016 11:29:16 -0700
Mark Johnston <markj@FreeBSD.org> wrote:

> Hi,
> 
> Alan and I have been working on a branch at user/alc/PQ_LAUNDRY in svn.
> It reworks the mechanism and policy used for dirty page laundering.
> 
> Currently, the inactive queue is used to store pages eligible for
> reclamation by the pagedaemon. It contains both clean and dirty pages.
> Dirty pages must be laundered before they may be reclaimed; that is,
> they must either be written to swap, or to persistent storage (i.e., a
> filesystem). Because laundering a page is an expensive operation, the
> pagedaemon will perform at most a small number of launderings in a
> first-pass scan of the inactive queue.
> 
> The PQ_LAUNDRY branch adds a new page queue, PQ_LAUNDRY, to store dirty
> pages that have passed once through the inactive queue. A dedicated
> thread is responsible for both deciding when to launder pages, and
> actually laundering them. The new policy uses the relative sizes of the
> inactive and laundry queues to determine whether to launder pages at a
> given point. This leads to more intelligent swapping behaviour in
> general, since the laundry thread will avoid swapping when the marginal
> benefit of doing so is low. Without a dedicated queue for dirty pages,
> the pagedaemon doesn't have the information to determine whether
> swapping provides any utility to the system. Thus, the current policy
> often results in small but steadily increasing amounts of swap usage
> when the system is under memory pressure, even when the inactive queue
> consists mostly of clean pages. PQ_LAUNDRY addresses this, and
> incidentally also helps pave the way for some future VM improvements by
> removing the last source of object-cached clean pages (PG_CACHE pages).
> 
> Some more details and the diff for PQ_LAUNDRY can be viewed here:
> https://reviews.freebsd.org/D8302
> 
> We would like to commit it next week. Any additional comments, review,
> or testing would be welcome.
>

In my use case, which is moving multi-gigabyte video files from
one file system to another, this seems to swap more than the
previous code did.  Moving such large files with the previous
code seemed to recycle Inact more quickly and IIRC only a few 10s
of MB were swapped out.  In my test this morning 125MB were
swapped out and Inact was not recycled as quickly.  The overall
size of the files moved was about the same in the two tests.

This code doesn't even come close to the behavior we had about 2
years ago.  I could move 100s of GB and never see a single bye
get swapped because Inact was very quickly recycled in multi-GB
chunks, frequently the approx. 6GB of Inact would be recycled in
a (to the human eye) single transfer to Free.

In any case, the new code doesn't break anything.

-- 
Gary Jennejohn



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161105103128.78197d36>