[Apologies for a highly technical post. If you don't know much about operating systems and aren't an Apple user, this post may not be for you.]

I've was having some performance problems on my Mac under Lion of late -- VMWare became unusable, for example, and apps would beach ball under all sorts of circumstances (say, when spotlight started indexing or when time machine kicked off).

A buddy of mine got me thinking about this a lot more strongly when he told me he was having similar problems but that he could temporarily cure them by running "purge", which nukes the buffer cache.

I did a little research using tools like vm_stat etc, and it appears that, under many circumstances, Lion seems to throw data pages (aka anonymous pages) into the swap files on disk in order to bring in more buffer cache pages, even when it should probably be preferring to leave them in RAM. Stuff like time machine would read lots of disk pages into RAM and, in the process, kick out lots of data pages and applications would hang when they needed those data pages until they could be brought back in from the swap files.

So, to test this, I took a fairly radical step and disabled page outs of anonymous memory entirely by nuking dynamic_pager, and since then, everything on my machine has performed remarkably well -- no more trouble with beach balls of death, no more trouble with things like iChat suddenly hanging, VMWare is usable again, etc.

(FYI, I turned off dynamic_pager with:

launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

followed by a reboot. You can turn it on again with

launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

)

So running this way is probably not the best of ideas -- if you run out of memory the system will have no ability to keep things going by pushing data pages out to disk -- but this seems to indicate to me that there is something very wrong with the way the latest VM subsystems on OS X are deciding which pages to keep in RAM.
Shared publiclyView activity