From: "Buddy Lumpkin" <b.lumpkin@comcast.net>
To: "'John Bradford'" <john@grabjohn.com>,
"'Michael Brennan'" <mbrennan@ezrs.com>,
<linux-kernel@vger.kernel.org>
Cc: <riel@redhat.com>
Subject: RE: why swap at all?
Date: Tue, 1 Jun 2004 02:38:42 -0700 [thread overview]
Message-ID: <S264961AbUFAJhd/20040601093733Z+1483@vger.kernel.org> (raw)
In-Reply-To: <200405312029.i4VKTCZ0000596@81-2-122-30.bradfords.org.uk>
> I'm not really sure what the above was intended to demonstrate, but
> I assume that it was that having swap allowed the first grep to fill
> physical RAM with
> cache at the expense of swapping other processes, which were
> using physical RAM to disk.
> However, if 57 Mb of swap allows this, 57 Mb of extra physical RAM should
> also allow the grep to be cached, without having to swap out anything.
> Hence my comment about it not being a magical property of swap space.
> John.
Exactly! Swap will allow for room to evict anonymous pages (heap, stack,
shared memory, etc.) from memory to make room for other pages in memory.
Those pages could be file backed pages and therefore qualify as "pagecache".
When you read or write to/from a file at a given offset, the file operations
actually occur against memory.
Accessing an offset into the mapping of a file triggers a pagefault if a
page for that offset doesn't currently exist in memory. The point is, file
system I/O is actually achieved by accessing memory which triggers a major
pagefault (disk access) if the page doesn't already exist in memory. If the
page does already exist (minor fault) because the lookup of that
device,inode,offset succeeded, the already memory resident page is used
rather than incurring an I/O to disk.
This means if you grep thru the kernel tree, grep reads every line of every
file in the kernel tree trying to do pattern matching, every file in the
kernel tree is sitting in memory in it's entirety. Any subsequent reads of
those files are quite snappy since they are already memory resident (only
minor faults are incurred).
The above scenario where 57mb of swap allows for the entire kernel src tree
to be memory resident may provide tremendous value on a workstation or a
system with a small amount of disk I/O takes place, but it assumes that the
anonymous pages aren't going to be faulted right back in as soon as the
program that uses these pages becomes runnable again. It's not uncommon to
have a system where certain pages continually are paged in and out to/from
the swap device, simply because the system is very low on RAM, and
filesystem I/O is filling up physical memory at a rate that exceeds the
frequency that a process that is allocating anonymous memory becomes
runnable.
The problem is that any system doing enough constant filesystem I/O, with
enough data is eventually going to fill physical memory. This is not true
for anonymous memory. When I choose the amount of memory for a system, it is
first and foremost based on the resident set size of the application
processes. If I care about caching filesystem I/O, then all I have to do is
populate the system with enough "extra" physical RAM that files can be
cached in physical memory.
If I know in advance that filesystem I/O will eventually fill physical
memory with filesystem pages (pagecache), then why would I allow file system
I/O to force out anonymous pages on the system? Also, why wake up an
expensive algorithm (kswapd) that walks all pages in physical memory in
order to determine which pages are "Least Recently Used" on a system where
all resident set sizes of all processes add up to 100MB, and another 900MB
of physical RAM is full of filesystem backed pages?
On a server, where lots of I/O is taking place and you are willing to size
applications to fit completely within physical memory and add a little extra
for pagecache, I very much prefer the way that Solaris was modified to work
in Solaris 8 using a cyclical page cache.
The idea is "something" like this:
Filesystem backed pages are considered free memory. If you need to allocate
more anonymous memory, you just grab from (evict) the tail of a linked list
(called the cachelist) that represents the pagecache. If you update a page
or create a new page in the cachelist, then you simply move that page to the
head of the cachelist. This means there is always a small overhead in
maintaining the list, but nothing compared to the two-handed clock algorithm
that scans for pages to evict. The two-handed clock algorthim (the scanner)
is kept, but only when freemem falls to lotsfree. In Solaris 8, freemem is
the size of the cachelist + the size of free memory (pages that are not
pagecache and are free).
This way, filesystem I/O CANNOT cause the scanner to wake up and start
traversing main memory, eating up valuable CPU time. Also, anonymous pages
will not be evicted on systems due to lots of filesystem I/O.
I won't try to imply that the Solaris 8 or later VM system outperforms the
Linux VM because I haven't compared the two, but I can attest that the
Solaris 8 VM beats the pants off the Solaris 7 VM system on systems where
large amounts of filesystem I/O take place.
You don't get the supposed "benefit" of evicting anonymous memory to swap in
order to cache filesystem pages, but quite frankly on a server, I would not
want this bug ... err, ... I mean ... feature :) I would much rather size
my system such that applications fit in physical memory and if I so desire,
add a little extra for pagecache.
--Buddy
next prev parent reply other threads:[~2004-06-01 9:37 UTC|newest]
Thread overview: 146+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-31 19:34 Michael Brennan
2004-05-31 20:29 ` John Bradford
2004-05-31 22:47 ` Nick Piggin
2004-05-31 23:30 ` Bernd Eckenfels
2004-06-01 18:36 ` FabF
2004-06-01 19:02 ` Valdis.Kletnieks
2004-06-01 19:53 ` FabF
2004-06-01 20:00 ` Valdis.Kletnieks
2004-06-01 20:14 ` FabF
2004-06-01 20:22 ` Valdis.Kletnieks
2004-06-01 21:15 ` FabF
2004-06-01 21:40 ` Valdis.Kletnieks
2004-06-03 13:54 ` Bill Davidsen
2004-06-04 0:01 ` Nick Piggin
2004-06-01 23:17 ` Bernd Eckenfels
2004-06-02 5:38 ` FabF
2004-06-02 11:42 ` Con Kolivas
2004-06-02 12:22 ` John Bradford
2004-06-02 12:22 ` Con Kolivas
2004-06-02 17:06 ` FabF
2004-06-03 14:14 ` Bill Davidsen
2004-06-04 7:23 ` Buddy Lumpkin
2004-06-04 17:08 ` Bill Davidsen
2004-06-15 14:55 ` Charles Shannon Hendrix
2004-06-04 9:11 ` Catalin BOIE
2004-06-04 17:24 ` Bill Davidsen
2004-06-06 14:39 ` Rik van Riel
2004-06-02 17:59 ` Valdis.Kletnieks
2004-06-02 18:30 ` FabF
2004-06-02 23:54 ` Con Kolivas
2004-06-03 16:16 ` FabF
2004-06-03 23:56 ` Con Kolivas
2004-06-04 0:16 ` Con Kolivas
2004-06-03 14:18 ` Bill Davidsen
2004-06-03 14:27 ` Con Kolivas
2004-06-02 17:52 ` Valdis.Kletnieks
2004-06-02 3:50 ` Tim Connors
2004-06-02 17:45 ` Valdis.Kletnieks
2004-06-01 8:34 ` John Bradford
2004-06-01 8:32 ` William Lee Irwin III
2004-06-01 8:50 ` John Bradford
2004-06-01 8:54 ` William Lee Irwin III
2004-06-01 9:10 ` John Bradford
2004-06-08 1:18 ` Tim Connors
2004-06-08 5:29 ` Denis Vlasenko
2004-06-01 9:38 ` Buddy Lumpkin [this message]
2004-06-01 10:13 ` Tim Connors
2004-06-01 10:24 ` William Lee Irwin III
2004-06-01 11:19 ` Tim Connors
[not found] <fa.amhil9e.o5kt1u@ifi.uio.no>
[not found] ` <fa.kfm8lru.1l2mdp4@ifi.uio.no>
2004-06-08 15:12 ` Ray Bryant
2004-06-08 15:15 ` Ray Bryant
2004-06-09 19:24 ` Bill Davidsen
-- strict thread matches above, loose matches on Subject: below --
2004-05-27 12:31 Piszcz, Justin Michael
2004-05-27 12:41 ` William Lee Irwin III
2004-05-27 15:59 ` John Bradford
2004-05-27 16:16 ` William Lee Irwin III
2004-06-03 13:38 ` Bill Davidsen
[not found] <fa.fegqf9v.kmidof@ifi.uio.no>
[not found] ` <fa.bqpvcrs.u648jq@ifi.uio.no>
2004-05-27 11:39 ` Andy Lutomirski
2004-05-28 21:37 ` Denis Vlasenko
2004-05-28 22:28 ` Bernd Eckenfels
2004-05-29 7:31 ` Denis Vlasenko
2004-05-31 10:49 ` jlnance
2004-06-01 11:57 ` Lenar Lõhmus
2004-06-01 12:27 ` Robin Rosenberg
2004-06-01 16:49 ` jlnance
2004-06-02 18:38 ` John Hendrikx
2004-06-01 12:21 ` David B. Stevens
2004-05-27 5:37 Nick Piggin
2004-05-27 17:27 ` Buddy Lumpkin
2004-05-26 12:34 Piszcz, Justin Michael
2004-05-26 12:24 Nick Piggin
2004-05-26 13:03 ` Buddy Lumpkin
2004-05-26 13:27 ` Helge Hafting
2004-05-26 11:57 Nick Piggin
2004-05-26 12:19 ` Buddy Lumpkin
2004-05-26 11:04 Nick Piggin
2004-05-26 6:38 Anthony DiSante
2004-05-26 7:31 ` Buddy Lumpkin
2004-05-26 7:55 ` William Lee Irwin III
2004-05-26 8:30 ` Buddy Lumpkin
2004-05-26 8:44 ` Nick Piggin
2004-05-26 9:34 ` John Bradford
2004-05-26 9:48 ` Nick Piggin
2004-05-26 10:10 ` Matthias Schniedermeyer
2004-05-26 10:33 ` Nick Piggin
2004-05-26 10:58 ` Matthias Schniedermeyer
2004-05-26 11:19 ` Nick Piggin
2004-05-26 12:27 ` Matthias Schniedermeyer
2004-05-27 5:38 ` Nick Piggin
2004-05-26 12:37 ` Matthias Schniedermeyer
2004-05-26 13:06 ` Gianni Tedesco
2004-05-26 13:41 ` Matt H.
2004-05-26 13:55 ` Buddy Lumpkin
2004-05-27 5:14 ` Tom Felker
2004-05-27 6:02 ` Nick Piggin
2004-05-27 7:04 ` Bernd Eckenfels
2004-05-27 7:16 ` Oliver Neukum
2004-05-26 10:45 ` Martin Olsson
2004-05-26 11:25 ` Nick Piggin
2004-05-26 16:33 ` David Schwartz
2004-05-26 16:58 ` John Bradford
2004-05-26 23:32 ` Kyle Moffett
2004-05-27 8:05 ` John Bradford
2004-05-26 10:46 ` John Bradford
2004-05-26 11:46 ` Buddy Lumpkin
2004-05-26 11:39 ` Buddy Lumpkin
2004-05-26 9:42 ` Anthony DiSante
2004-05-26 9:58 ` Nick Piggin
2004-05-26 20:11 ` Wakko Warner
2004-05-27 5:59 ` Nick Piggin
2004-05-27 14:34 ` Wakko Warner
2004-05-26 10:40 ` Buddy Lumpkin
2004-05-26 13:15 ` Helge Hafting
2004-05-26 9:09 ` William Lee Irwin III
2004-05-26 11:38 ` Buddy Lumpkin
2004-05-26 12:12 ` Paulo Marques
2004-05-26 12:14 ` Nick Piggin
2004-05-26 12:40 ` Denis Vlasenko
2004-05-26 10:41 ` Denis Vlasenko
2004-05-26 12:07 ` Buddy Lumpkin
2004-05-26 12:06 ` Marc-Christian Petersen
2004-05-26 12:19 ` Denis Vlasenko
2004-05-26 13:48 ` Buddy Lumpkin
2004-05-26 12:33 ` Richard B. Johnson
2004-05-26 13:25 ` Buddy Lumpkin
2004-05-26 12:30 ` Rik van Riel
2004-05-26 10:44 ` Denis Vlasenko
2004-05-26 11:49 ` Buddy Lumpkin
2004-05-26 12:19 ` Rik van Riel
2004-05-26 12:55 ` Buddy Lumpkin
2004-05-26 8:27 ` Roger Luethi
2004-05-26 9:23 ` John Bradford
2004-05-26 9:30 ` Roger Luethi
2004-05-26 10:35 ` John Bradford
2004-05-26 10:37 ` Nick Piggin
2004-05-26 10:48 ` John Bradford
2004-05-26 13:01 ` Helge Hafting
2004-05-26 8:32 ` Denis Vlasenko
2004-05-26 9:00 ` Helge Hafting
2004-05-26 9:40 ` John Bradford
2004-05-26 13:06 ` Helge Hafting
2004-05-26 9:06 ` John Bradford
2004-05-26 12:31 ` Buddy Lumpkin
2004-05-26 10:02 ` Raphael Jacquot
2004-05-26 13:00 ` Satoshi Oshima
2004-05-26 13:38 ` William Lee Irwin III
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=S264961AbUFAJhd/20040601093733Z+1483@vger.kernel.org \
--to=b.lumpkin@comcast.net \
--cc=john@grabjohn.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbrennan@ezrs.com \
--cc=riel@redhat.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
all inboxes | Powered by JetHome®