Swap Prefetch Arguments

There's an article about Linux swapping and a proposed kernel patch over at Still waiting for swap prefetch that attracted a fair pile of comments at the time it was written. I don't know what caused me to trip over it today, but it did make me think about a few things.

First, the concept is simple enough: if stuff has been swapped because there wasn't room in RAM, but now there is because some program just exited, maybe the stuff that was swapped should be brought back now instead of waiting until it is actually needed.

Before you get too hot and heavy over this, you should know that you'll find bright people on both sides of the issue but at the end of the day this proposed change is still not in the Linux kernel. The LWN article suggests that this is due to well warranted conservatism:


There is a reason for this. Device drivers either work or they do not, but the virtual memory subsystem behaves a little differently for every workload which is put to it. Tweaking the heuristics which drive memory management is a difficult process; a change which makes one workload run better can, unpredictably, destroy performance somewhere else. And that "somewhere else" might not surface until some large financial institution somewhere tries to deploy a new kernel release. The core kernel maintainers have seen this sort of thing happen often enough to become quite conservative with memory management changes. Without convincing evidence that the change makes things better (or at least does no harm) in all situations, it will be hard to get a significant change merged.

That makes perfect sense to me. Ideally, there'd never be any need for this anyway: you'd always have enough RAM to run everything you need. In practice, well, we always try to push a little harder. There's some merit to the argument that says "if you have spare memory, the machine is under utilized" - though of course that's more true in a business setting than on our personal desktops.

Actually, for personal desktops, anticipating swap needs could be done by following our mouse cursor - if I move out of one window and stop moving over another, that's a pretty good indication I'm going to click there, right? So if that program's data is currently in swap, hey, start bringing it back..

You could carry it farther by tracking my eye focus.. I'll surely move my glance toward the application I want even before I start moving the mouse - our anticipatory swap fetcher could bring in a few bytes just based on that.. and if the operating system were really smart, it would have an extensive database of my behavioral habits anyway. A smart OS would know that I'll be spending so much time in a command line window, so much time in a browser, but now and then I'll be switching over to email.. and that smart OS would swap those things only as a last resort. The Windows XP that I run under virtualization can probably be swapped out the minute I move my mouse off it - the OS would know that I'm unlikely to come back again for a while at least.

Well, none of that exists now, but it certainly could..



Got something to add? Send me email.





(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> swap prefetching argument still continues




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





Software engineering is the part of computer science which is too difficult for the computer scientist. (Friedrich Bauer)

The errors which arise from the absence of facts are far more numerous and more durable than those which result from unsound reasoning respecting true data. (Charles Babbage)








This post tagged: