All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin LaHaise <bcrl@redhat.com>
To: Momchil Velikov <velco@fadata.bg>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@redhat.com>
Subject: Re: [PATCH] Scalable page cache
Date: Mon, 26 Nov 2001 13:16:42 -0500	[thread overview]
Message-ID: <20011126131641.A13955@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0111261753480.10763-100000@localhost.localdomain> <87vgfxqwd3.fsf@fadata.bg>
In-Reply-To: <87vgfxqwd3.fsf@fadata.bg>; from velco@fadata.bg on Mon, Nov 26, 2001 at 07:23:52PM +0200

On Mon, Nov 26, 2001 at 07:23:52PM +0200, Momchil Velikov wrote:
...
> Ingo> The problem with the tree is that if we have a big, eg. 16 GB pagecache,
> Ingo> then even assuming a perfectly balanced tree, it takes more than 20
> Ingo> iterations to find the page in the tree.  (which also means 20 cachelines
> Ingo> touched per tree node we pass.) Such an overhead (both algorithmic and
> Ingo> cache-footprint overhead) is absolutely out of question - and it will only
> Ingo> get worse with more RAM, which isnt a good property.
> 
> The tree is per mapping, not a single one.  Now, with 16GB cached in a
> single mapping, it'd perform poorly, indeed (though probably not 20).
...

I've looked at both splay trees and the page lock patch by Ingo & Dave, and 
personally I disagree with both approaches as they fail to address some of 
the very common cases that are actually causing the underlying problem.

First off, if we take a look at why the page cache lock is being contended 
a few obvious problems pop out immediately:

	1. potentially long hash chains are walked with the page cache
	   lock held for the entire duration of the operation
	2. multiple cache lines are touched while holding the page cache 
	   lock
	3. sequential lookups involve reaquiring the page cache lock
	4. the page cache hash is too large, virtually assuring that 
	   lookups will cause a cache miss

Neither proposed patch addresses all of these problems to the degree that 
I think is possible and would like to attempt.  What I've got in mind is 
a hybrid hash + lock + b*tree scheme, where the lock is per-bucket.  With 
that in place, each bucket would be treated like the top of a b*tree 
(I might have the name wrong, someone please correct me if what I'm 
describing has a different name), where a number of {index, page} pairs 
are stored, plus pointers to the next level of tree.  The whole thing 
would be sized at 1 cacheline per bucket and hold around 5-6 page pointers 
per bucket (64 byte cacheline size).  The lock would be a rw lock to 
allow simultaneous readers (the most common operation).

This directly helps with #1 by allowing us to avoid pulling in extra 
cache lines during the initial lookup phase since the page index # 
is already in the cache line we've retrieved (we may need a pointer 
to the address space, but the hash function can be chosen to make 
such collisions irrelevant) as well as reducing the number of cache 
lines accessed during a lookup.  Since a tree is used for the worst 
case, the length of a chain is reduced, with a very low likelyhood 
of ever exceeding 2 levels (remember, we're working on buckets in 
each level of the tree, not individual page cache entries).  Item 3 
is addressed by improving cache locality for sequential lookups.  
Item 4 can be addressed by changing the hash function to cause some 
grouping for address spaces.

I haven't coded up this idea yet, but I'll get moving on it.  If we're 
going to change the locking again, I'd like to go all the way and do 
it Right.  To this end I'd like to see some appropriate benchmarks made 
to look at the behaviour of the proposed changes under sequential access 
patterns as well as random.  Thoughts?

		-ben
-- 
Fish.

  reply	other threads:[~2001-11-26 18:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-26 12:31 [PATCH] Scalable page cache Momchil Velikov
2001-11-26 17:22 ` Ingo Molnar
2001-11-26 17:23   ` Momchil Velikov
2001-11-26 18:16     ` Benjamin LaHaise [this message]
2001-11-26 18:42       ` Rik van Riel
2001-11-26 20:29       ` Ingo Molnar
2001-11-26 18:33         ` David S. Miller
2001-11-26 19:29           ` Andrew Morton
2001-11-26 19:35             ` David S. Miller
2001-11-26 18:34         ` Benjamin LaHaise
2001-11-26 20:40       ` Ingo Molnar
2001-11-26 19:19         ` Benjamin LaHaise
2001-11-26 21:00         ` Ingo Molnar
2001-11-26 20:43       ` Daniel Phillips
2001-11-26 19:49     ` Ingo Molnar
2001-11-26 18:08       ` Christoph Hellwig
2001-11-26 20:13         ` Ingo Molnar
2001-11-26 21:09     ` Ingo Molnar
2001-11-26 19:18       ` David S. Miller
2001-11-26 19:45         ` Andrew Morton
2001-11-26 19:57           ` David S. Miller
2001-11-26 20:03             ` Andrew Morton
2001-11-26 20:37             ` Linus Torvalds
2001-11-26 21:02               ` Andrew Morton
2001-11-26 22:23                 ` Linus Torvalds
2001-11-26 22:49                   ` Jeff Garzik
2001-11-26 23:06                     ` Linus Torvalds
2001-11-26 21:10       ` Ingo Molnar
2001-11-26 17:29   ` Linus Torvalds
2001-11-26 20:03     ` Ingo Molnar
2001-11-26 18:02   ` David S. Miller
2001-11-26 18:11     ` Rik van Riel
2001-11-27  8:07     ` benchmark results: " Anton Blanchard
2001-11-26 18:52   ` [PATCH] " Daniel Phillips

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=20011126131641.A13955@redhat.com \
    --to=bcrl@redhat.com \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=velco@fadata.bg \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.