Tuning Linux VM swapping 324
Lank writes "Kernel developers started discussing the pros and cons of swapping to disk on the Linux Kernel mailing list. KernelTrap has coverage of the story on their homepage. Andrew Morton comments, 'My point is that decreasing the tendency of the kernel to swap stuff out is wrong. You really don't want hundreds of megabytes of BloatyApp's untouched memory floating about in the machine. Get it out on the disk, use the memory for something useful.' Personally, I just try to keep my memory usage below the physical memory in my machine, but I guess that's not always possible..."
It doesn't work that way (Score:5, Informative)
I keep my memory usage much below the total ram on the servers, but in real life, the machine still swaps. This is because even tho the machine NEVER needs more ram than is available at any given time, over a period of days, it will use more than the available ram. It caches out the old data that was used 12 hours ago.
Unless you reboot every day (as in a client machine) you will use swap on just about any machine. Using swap is not bad. Using swap for a currently running application is not so good. This isn't a bug, its a feature. Reading data from swap after it has been accessed is still faster than reading new data from the drives, especially if its a network drive.
What's wrong with many resident pages? (Score:4, Informative)
Why not? BloatyApp, if it's that bloaty is probably an object oriented program with template instantiation (or is by Micro$oft); these programs are notoriously huge, but also have notoriously poor locality of reference. The user will get better perceived response if you can keep more of BloatyApp resident.
If there's space in memory, I don't see the point of pre-emptively ejecting as many LRU pages of BloatyApp. (Of course, I haven't RTFA, but this is
Re:How fast is swapping really these days? (Score:5, Informative)
Re:God no... (Score:5, Informative)
My kernel has autoswappiness enabled so it figures out the number on its own. I'm running at 64 ATM on a 256 Meg system (ram donations accepted)
Re:God no... (Score:4, Informative)
Re:God no... (Score:2, Informative)
cat 0 >
and I have instant control as to the performance of my machine. In fact... I could even write wrappers to specific programs so that they can tune the system's swappiness to better suit them. I.E. Programs that use huge ammounts of memory, less swappy, programs with repetetive disk access more swappy... Is swappy even a word?
Re:The big issue (Score:3, Informative)
Well, you see, KDE is written in C++. GTK is C. C++ stuff does not play well with different version of the same compiler let alone different compilers or even different languages.
In theory you're only "supposed" to use either GNOME or KDE and therefore only have one set of libraries installed. In practice you often want to use applications from both systems, and end up installing them both.
The problem is political and religious as well as technical.
My vote.... (Score:4, Informative)
Re:The big issue (Score:3, Informative)
Re:How fast is swapping really these days? (Score:3, Informative)
Re:How fast is swapping really these days? (Score:3, Informative)
It has awesome memory checking, cache profiling and heap profiling.
I'm just a satisfied user, i have no relationship with the Valgrind developers.
Re:God no... (Score:5, Informative)
Then, make the following changes to the registry:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\ClearPageFileAtShutdown, set to 1. I don't shut my machine down very often, but occasionally XP will increase the size of the pagefile if it absolutely needs to depending on circumstances. This forces it back to the size you want it when you restart.
HKLM\System\CurrentControlSet\Control\FileSystem\
HKLM\System\CurrentControlSet\Control\FileSystem\
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Contr
Set to 4096 if you've got more than 32M RAM
Set to 8192 if you've got more than 64M RAM
16384, 128M
32768, 160M
65536, 256M
131072, 512M
This changes the maximum number of bytes that can be locked for I/O operations. The default is 512Kb. While the above are the recommendations, I've found stepping down one level to provide the most performance for my needs, YMMV. (For example, I have 256M, but I set my IO limit to 32768.)
HKLM\System\CurrentControlSet\Control\Session Manager\Memory Management\DisablePagingExecutive, Set to 1 to disable paging of the kernel.
There, that wasn't so hard, was it? For those who want to flame that statement, keep in mind, that the information above is easier to find than some of the tuning suggestions I've heard for Linux. I've used Linux for 10 years, and only today heard about
Re:God no... (Score:2, Informative)
Re:God no... (Score:3, Informative)
Who thinks that writing a page to disk immediately wipes the ram it came from. This is how things really do work.
The problem is whether this paged but still valid ram should be given to other processes. I would say it is a tuning thing. There is no perfect method that will be best for all situations.
Whoever modded this insightful needs to do a little reading about operating systems.
Two copies ARE kept (Score:1, Informative)
And also the other way round - if a page is paged in (into ram), it is not immediately deleted from swap, so if that page is NOT MODIFIED it doesn't need paged out again if memory is required.
XP paging registry settings (Score:2, Informative)
"DisablePagingExecutive"=dword:00000001
"LargeSystemCache"=dword:00000001
The combo will keep your kernel in RAM (DisablePagingExecutive)and enforce a minimum reserve (4MB) amount of memory for it (LargeSystemCache), although that amount can grow dynamically. The LargeSystemCache may cause "Delayed Write Failed" errors, if it does, reboot in SafeMode and undo the damage.
More goodies here, many adjustments that can affect how your sytem divides between swap, cache and currently-running-apps:
HKLM/System/CurrentControlSet/Control/Session Manager/Memory Management
"ClearPageFileAtShutdown" "DisablePagingExecutive" "IoPageLockLimit" "LargeSystemCache" "NonPagedPoolQuota" "NonPagedPoolSize" "PagedPoolQuota" "PagedPoolSize" "PagingFiles" "SecondLevelDataCache" "SystemPages" "PhysicalAddressExtension" "WriteWatch"
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Se ssion Manager\Memory Management\PrefetchParameters
"VideoInitTime" "AppLaunchMaxNumPages" "AppLaunchMaxNumSections" "AppLaunchTimerPeriod" "BootMaxNumPages" "BootMaxNumSections" "BootTimerPeriod" "MaxNumActiveTraces" "MaxNumSavedTraces" "RootDirPath" "HostingAppList" "EnablePrefetcher"
Re:God no... (Score:2, Informative)
That's 'cause "swappiness" was just added in the 2.5 series. It hasn't been around that long.
Re:Stupid Windows Kernal Swapping (Score:3, Informative)
When you have a bunch of lazy, slacker, multi-megabyte services running in the background, waiting for that once-in-a-blue-moon event that requires their help (yes, I'm talking about YOU spoolsv.exe, you 3.98MB hog!), you might as well shove them into the swap file. Windows can end up with an unGODLY amount of oversized crap just sitting aorund waiting for something to happen. Take a look at the "processes" tab on the task manager-- it's insane! I figure the NT kernel is about the same: a bunch of modular pieces, two thirds of which are used maybe once at startup and then paged out. I guess I understand why they did it-- if I had a 57MB kernel image lolling around memory, I'd look for ways to swap out some too.
Re:Stupid Windows Kernal Swapping (Score:2, Informative)
Re:God no... (Score:1, Informative)
Re:God no... (Score:2, Informative)
No swap involved (Score:2, Informative)