Skip to contentSkip to conversation

cp file /dev/zero <-> cache [was Re: increasing page size]

DISCUSSION Rik van Riel 3 participants 11 messages Jul 9, 1998 – Jul 20, 1998 1 message not in the archive Memory management

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 11 lines · Stephen C. Tweedie
Quoted 2 lines · Benjamin C.R. LaHaise

Right. I'd rather see a multi-level lru like policy (ie on each cache hit it gets moved up one level in the cache, with the lru'd pages from a given

There's a fundamentally nice property about the multi-level cache which we _cannot_ easily emulate with page aging, and that is the ability to avoid aging any hot pages at all while we are just consuming cold pages. For example, a large "find|xargs grep" can be satisfied without staling any of the existing hot cached pages.

Then I'd better incorporate a design for this in the zone allocator (we could add this to the page_struct, but in the zone_struct we can make a nice bitmap of it).

OTOH, is it really _that_ much different from an aging scheme with an initial age of 1?

Rik.

+-------------------------------------------------------------------+
| Linux memory management tour guide.        [email protected] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#2 lore raw

Hi,

Quoted 10 lines · Rik van Riel
Quoted 5 lines · Stephen C. Tweedie

There's a fundamentally nice property about the multi-level cache which we _cannot_ easily emulate with page aging, and that is the ability to avoid aging any hot pages at all while we are just consuming cold pages.

Then I'd better incorporate a design for this in the zone allocator (we could add this to the page_struct, but in the zone_struct we can make a nice bitmap of it).

It's nothing to do with the allocator per se; it's really a different solution to a different problem. That helps, actually, as it means we're not forced to stick with one allocator if we want to use such a scheme.

Quoted 2 lines

OTOH, is it really _that_ much different from an aging scheme with an initial age of 1?

Yes, it is: the aging scheme pretty much forces us to age all pages on an equal basis, so a lot of transient pages hitting the cache has the side effect of prematurely aging and evicting a lot of existing, potentially far more valuable pages. A multilevel cache is pretty much essential if you're going to let any cached data survive a grep flood. Whether you _want_ that, or whether you'd rather just let the cache drain and repopulate it after the IO has calmed, is a different question; there are situations where one or other decision might be best, so it's not a guaranteed win. But the multilevel cache does have some nice properties which aren't so easy to get with page aging. It also tends to be faster at finding pages to evict, since we don't require multiple passes to flush the transient page queue.

--Stephen.
--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#3 lore raw
Quoted 9 lines · Stephen C. Tweedie

potentially far more valuable pages. A multilevel cache is pretty much essential if you're going to let any cached data survive a grep flood. Whether you _want_ that, or whether you'd rather just let the cache drain and repopulate it after the IO has calmed, is a different question; there are situations where one or other decision might be best, so it's not a guaranteed win. But the multilevel cache does have some nice properties which aren't so easy to get with page aging. It also tends to be faster at finding pages to evict, since we don't require multiple passes to flush the transient page queue.

Let's go with those nice properties. Especially the last one (quicker at finding pages) is essential in preventing memory fragmentation (a 'lazy' list can be used to prevent pressure on the few last 'free' zones from building).

Rik.

+-------------------------------------------------------------------+
| Linux memory management tour guide.        [email protected] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#4 lore raw
In reply to a message not in the archive
Quoted 5 lines · Stephen C. Tweedie

There's a fundamentally nice property about the multi-level cache which we _cannot_ easily emulate with page aging, and that is the ability to avoid aging any hot pages at all while we are just consuming cold pages. For example, a large "find|xargs grep" can be satisfied without staling any of the existing hot cached pages.

Thinking over this design, I wonder how many levels we'll need for normal operation, and how many pages are allowed in each level.

I'd think we'll want 4 levels, with each 'lower' level having 30% to 70% more pages than the level above. This should be enough to cater to the needs of both rc5des-like programs and multi-megabyte tiled image processing.

Then again, I could be completely wrong :) Anyone?

Rik.

+-------------------------------------------------------------------+
| Linux memory management tour guide.        [email protected] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#5 lore raw

Hi,

Quoted 7 lines · Rik van Riel

I'd think we'll want 4 levels, with each 'lower' level having 30% to 70% more pages than the level above. This should be enough to cater to the needs of both rc5des-like programs and multi-megabyte tiled image processing.

Then again, I could be completely wrong :) Anyone?

Maybe, maybe not --- we'd have to try it. However, I'm always a bit dubious about being overly clever about this kind of stuff, and two level may well work fine. At worst, we can do ageing on the resident level and LRU on the transient, and let the aging take care of it.

Personally, I think just a two-level LRU ought to be adequat. Yes, I
know this implies getting rid of some of the page ageing from 2.1 again, but frankly, that code seems to be more painful than it's worth. The "solution" of calling shrink_mmap multiple times just makes the algorithm hideously expensive to execute.

--Stephen

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#6 lore raw
Quoted 11 lines · Stephen C. Tweedie
Quoted 2 lines · Rik van Riel

I'd think we'll want 4 levels, with each 'lower'
level having 30% to 70% more pages than the level

Personally, I think just a two-level LRU ought to be adequat. Yes, I
know this implies getting rid of some of the page ageing from 2.1 again, but frankly, that code seems to be more painful than it's worth. The "solution" of calling shrink_mmap multiple times just makes the algorithm hideously expensive to execute.

This could be adequat, but then we will want to maintain an active:inactive ratio of 1:2, in order to get a somewhat realistic aging effect on the LRU inactive pages.

Or maybe we want to do a 3-level thingy, inactive in LRU order and active and hyperactive (wired?) with aging. Then we only promote pages to the highest level when they've reached the highest age in the active level.
(OK, this is probably _far_ too complex, but I'm just exploring some wild ideas here in the hope of triggering some ingenious idea)

Rik.

+-------------------------------------------------------------------+
| Linux memory management tour guide.        [email protected] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#8 lore raw
In reply to Stephen C. Tweedie
Quoted 5 lines · Stephen C. Tweedie

Personally, I think just a two-level LRU ought to be adequat. Yes, I
know this implies getting rid of some of the page ageing from 2.1 again, but frankly, that code seems to be more painful than it's worth. The "solution" of calling shrink_mmap multiple times just makes the algorithm hideously expensive to execute.

Hmmm, is that a hint that I should sit down and work on the code tomorrow whilst recovering? =)

-ben

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#7 lore raw
In reply to Rik van Riel

Hi,

Quoted 13 lines · Rik van Riel
Quoted 11 lines · Stephen C. Tweedie
Quoted 2 lines · Rik van Riel

I'd think we'll want 4 levels, with each 'lower'
level having 30% to 70% more pages than the level

Personally, I think just a two-level LRU ought to be adequat. Yes, I
know this implies getting rid of some of the page ageing from 2.1 again, but frankly, that code seems to be more painful than it's worth. The "solution" of calling shrink_mmap multiple times just makes the algorithm hideously expensive to execute.

Quoted 3 lines

This could be adequat, but then we will want to maintain an active:inactive ratio of 1:2, in order to get a somewhat realistic aging effect on the LRU inactive pages.

Aging is not a good thing in the cache, in general. We _want_ to be able to empty the cache at short notice. LRU works for that. The existing physical scan is definitely suboptimal without ageing, but that doesn't mean that aging is the right answer. (I tried doing buffer ageing in the original kswap. It sucked.)

Quoted 2 lines

Or maybe we want to do a 3-level thingy, inactive in LRU order and active and hyperactive (wired?) with aging.

If we have more than 2 levels, then we definitely don't want ageing:
just let migration of pages between the levels do the ageing for us.

--Stephen
--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#9 lore raw
In reply to Benjamin C.R. LaHaise

Hi,

Quoted 9 lines · Benjamin C.R. LaHaise
Quoted 5 lines · Stephen C. Tweedie

Personally, I think just a two-level LRU ought to be adequat. Yes, I
know this implies getting rid of some of the page ageing from 2.1 again, but frankly, that code seems to be more painful than it's worth. The "solution" of calling shrink_mmap multiple times just makes the algorithm hideously expensive to execute.

Hmmm, is that a hint that I should sit down and work on the code tomorrow whilst recovering? =)

I'm working on it right now. Currently, the VM is so bad that it is seriously getting in the way of my job. Just trying to fix some odd swapper bugs is impossible to test because I can't set up a ramdisk for swap and do in-memory tests that way: things thrash incredibly. The algorithms for aggressive cache pruning rely on fractions of nr_physpages, and that simply doesn't work if you have large numbers of pages dedicated to non-swappable things such as ramdisk, bigphysarea DMA buffers or network buffers.

Rik, unfortunately I think we're just going to have to back out your cache page ageing. I've just done that on my local test box and the results are *incredible*: it is going much more than an order of magnitude faster on many things. Fragmentation also seems drastically
improved: I've been doing builds of defrag in a 6MB box which were impossible beforehand due to NFS stalls.

I'm going to do a bit more experimenting to see if we can keep some of the good ageing behaviour by doing proper LRU in the cache, but otherwise I think the cache ageing has either got to go or to be drastically altered.

--Stephen
--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#10 lore raw
Quoted 8 lines · Stephen C. Tweedie

I'm working on it right now. Currently, the VM is so bad that it is seriously getting in the way of my job. Just trying to fix some odd swapper bugs is impossible to test because I can't set up a ramdisk for swap and do in-memory tests that way: things thrash incredibly. The algorithms for aggressive cache pruning rely on fractions of nr_physpages, and that simply doesn't work if you have large numbers of pages dedicated to non-swappable things such as ramdisk, bigphysarea DMA buffers or network buffers.

This means we'll have to substract those pages before determining the used percentage.

Quoted 3 lines

Rik, unfortunately I think we're just going to have to back out your cache page ageing. I've just done that on my local test box and the results are *incredible*:

OK, I don't see much problems with that, except that the aging helps a _lot_ with readahead. For the rest, it's not much more than a kludge anyway ;(

We really ought to do better than that anyway. I'll give you guys the URL of the Digital Unix manuals on this... (they have some _very_ nice mechanisms for this)

Quoted 4 lines

I'm going to do a bit more experimenting to see if we can keep some of the good ageing behaviour by doing proper LRU in the cache, but otherwise I think the cache ageing has either got to go or to be drastically altered.

A 2-level LRU on the page cache would be _very_ nice, but probably just as desastrous wrt. fragmentation as aging...

Rik.

+-------------------------------------------------------------------+
| Linux memory management tour guide.        [email protected] |
| Scouting Vries cubscout leader.      http://www.phys.uu.nl/~riel/ |
+-------------------------------------------------------------------+

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]

#11 lore raw

Hi,

Quoted 10 lines · Rik van Riel
Quoted 8 lines · Stephen C. Tweedie

I'm working on it right now. Currently, the VM is so bad that it is seriously getting in the way of my job. Just trying to fix some odd swapper bugs is impossible to test because I can't set up a ramdisk for swap and do in-memory tests that way: things thrash incredibly. The algorithms for aggressive cache pruning rely on fractions of nr_physpages, and that simply doesn't work if you have large numbers of pages dedicated to non-swappable things such as ramdisk, bigphysarea DMA buffers or network buffers.

Quoted 2 lines

This means we'll have to substract those pages before determining the used percentage.

Sure, but that's just admitting that the system is so inherently incapable of balancing itself that we have to place fixed limits on the cache size, and I'm not sure that's a good thing.

Quoted 7 lines
Quoted 3 lines

Rik, unfortunately I think we're just going to have to back out your cache page ageing. I've just done that on my local test box and the results are *incredible*:

OK, I don't see much problems with that, except that the aging helps a _lot_ with readahead. For the rest, it's not much more than a kludge anyway ;(

This is something we need to sort out. From my benchmarks so far, the one thing that's certain is that you were benchmarking something different from me when you found the ageing speedups. That's not good, because it implies that neither mechanism is doing the Right Thing. What sort of circumstances were you seeing big performance improvements in for your original page ageing code? That might help us to identify what the core improvement in the ageing is, so that we don't lose too much if we start changing the scheme again.

Quoted 3 lines

We really ought to do better than that anyway. I'll give you guys the URL of the Digital Unix manuals on this... (they have some _very_ nice mechanisms for this)

OK, thanks!

Quoted 3 lines

A 2-level LRU on the page cache would be _very_ nice, but probably just as desastrous wrt. fragmentation as aging...

Actually, fragmentation is not the big issue wrt ageing. The page ageing code is simply keeping the cache too large; the time it takes to age the cache means that far too much is getting swapped out, and on low memory machine the cache grows too large altogether.

This means that there may be several ways forward. A multi-level LRU would not necessarily be any worse for fragmentation. Keeping a (low) ceiling on the page age in the cache might also be a way forward, allowing us to give a priority boost to readahead pages, but letting us then cap the age once the pages are read to prevent them from staying too long in the cache.

I'm also experimenting right now with a number of new zoneing and ageing mechanisms which may address the fragmentation issue. As far as page ageing is concerned, it's really just the overall cache size, and the self-tuning of the cache size, which are my main concerns at the moment.

--Stephen

--
This is a majordomo managed list. To unsubscribe, send a message with the body 'unsubscribe linux-mm me@address' to: [email protected]