LWN.net Logo

Another reason to distinguish anonymous vs page cache

Another reason to distinguish anonymous vs page cache

Posted Mar 23, 2007 20:15 UTC (Fri) by giraffedata (subscriber, #1954)
Parent article: Toward improved page replacement

The article mentions one reason to favor page cache pages over anonymous ones: that a page cache page is more likely to exist somewhere else already so stealing the page frame doesn't require writing out the page presently in it.

There's another reason that I think is even more important: programs have traditionally been written to assume that I/O is slow and memory access is fast. It's an idea that is perhaps outdated in the face of modern virtual memory and file caching, not to mention mmap, but still a program that reads something from a file and thinks it will access it again soon is likely to keep it in an anonymous virtual memory buffer. Sophisticated programs even "page" between virtual memory and a file based on the program's knowledge of what will be needed soonest.

So giving priority to anonymous pages, which back virtual memory, is a way to take advantage of extra information the program has about what data is most important.


(Log in to post comments)

Another reason to distinguish anonymous vs page cache

Posted Mar 28, 2007 17:17 UTC (Wed) by liljencrantz (subscriber, #28458) [Link]

Sure, some programs choose to implement their own file caches internally. That is a _bad_ thing, as the operating system can share the page cache between all running software, meaning that all programs that access the same file will benefit from the cache, and that if multiple instances of the program is run, they will not create multiple copies of the same cache.

Also, you would be surprised how little it turns out that applications know about their own memory usage. The kernel is usually _much_ better at guseeing what pages will be used next based on a simple LRU rule. That is why modern processors have a really fast L1 cache instead of a tiny on-processor memory that the programmer has manual control of.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds