public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Some thoughts about cache and swap
@ 2004-06-05 14:40 Lasse Kärkkäinen / Tronic
  2004-06-05 23:37 ` Rik van Riel
  0 siblings, 1 reply; 13+ messages in thread
From: Lasse Kärkkäinen / Tronic @ 2004-06-05 14:40 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]

One thing where most current cache/swap implementations seem to fail 
miserably is when user - for some reason - processes large amounts of 
data. This may be as simple as listening large MP3 collection for few 
hours (having very large working set, and pushing everything else out of 
RAM, replacing that with cached songs).

Incidentally, in such cases, swapping the content is usually complete 
waste, as it is unlikely that the same data is needed again, or if it 
actually is required, the speed may not be any kind of issue.

In order to make better use of the limited cache space, the following 
methods could be used:

1. highly preferable to cache small files only
  * big seek latency of disk/net access, small RAM usage of caching
  * applications with long loading times usually use big number of tiny
    files => caching those makes response times a lot better
  * higher probability of getting more hits (per consumed cache space)

1.1. if caching large files anyway
  * try to detect access type (sequential, highly spatial or random)
  * only cache the hottest parts of the file

2. only cache files where I/O is the bottle neck
  * if applications typically don't need the data faster, having it in
    cache isn't very useful either
  * detecting whether I/O is a limiting factor is difficult

Additionally, for machines with oversized RAM (like nearly all 
desktop/server computers):

3. never (or only rarely) swap out applications for more cache
  * eventually it will be restored to RAM and the user will notice
    major trashing with long delays, and blame the OS
  * applications only take small portion of the RAM and using that
    as extra cache makes only small difference in cache performance
  * if application or its data has been loaded to memory, there normally
    is a reason for that (i.e. the data needs to be accessed quickly)

3.1. memory leaks are exception (but maybe fixing the bug would be 
correct solution instead of obscuring the problem by swapping it out)

Definition of large file changes over time, as technology evolves
  * size of RAM (and thus the available cache space)
  * reading one megaoctet or doing single seek on modern HDD each consume
    roughly the same time - about 13 ms (notice how evil seeking is!)

- Tronic -


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-06-16 14:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-05 14:40 Some thoughts about cache and swap Lasse Kärkkäinen / Tronic
2004-06-05 23:37 ` Rik van Riel
2004-06-06  7:08   ` John Bradford
2004-06-06  8:38     ` Christian Borntraeger
2004-06-09 18:13       ` Matt Mackall
2004-06-09 19:32         ` John Bradford
2004-06-09 19:32           ` Rik van Riel
2004-06-11 14:07             ` Jörn Engel
2004-06-12  1:50               ` Rik van Riel
2004-06-09 19:45       ` Bill Davidsen
2004-06-09 19:43     ` Bill Davidsen
2004-06-10  7:47       ` Buddy Lumpkin
2004-06-16 14:15       ` jlnance

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox