Earlier quoted context omitted.
I often just turn swap off entirely. A normal workload on my 4GB linux machine will frequently fail to fill even 2GB of buffers . At the moment my machine has still managed to fail to fill 800MB of my RAM with anything and I'm running two virtual machines and doing my usual work load. I do have a swap partition but only so I can hibernate.
Swap is mainly an emergency backing, i have nagios message me whenever swap hits x amount depending on the server, it's better than oom killer picking off processes.
Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
51–60 of 74 posts
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#52Earlier quoted context omitted.
I often just turn swap off entirely. A normal workload on my 4GB linux machine will frequently fail to fill even 2GB of buffers . At the moment my machine has still managed to fail to fill 800MB of my RAM with anything and I'm running two virtual machines and doing my usual work load. I do have a swap partition but only so I can hibernate.
> I often just turn swap off entirely. And you're smart to do so. Swap is useless for 99% of end-user systems. ChromeOS doesn't use any swap partition, for instance. As for hibernation, it's not available if you use a crypted swap, which is wise to use (at least on a laptop). As a result, I, too, disabled swap completely.
That said, if you never fill your RAM with buffers/cache, then of course swap makes no sense.
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#53Earlier quoted context omitted.
> I often just turn swap off entirely. And you're smart to do so. Swap is useless for 99% of end-user systems. ChromeOS doesn't use any swap partition, for instance. As for hibernation, it's not available if you use a crypted swap, which is wise to use (at least on a laptop). As a result, I, too, disabled swap completely.
"And you're smart to do so." Finally, that's the first comment I get, instead of someone extolling the virtues of swap and babbling warmed-over 1990s rules of thumb about "twice the RAM is the recommended size of your swap file" as if I'm going to wait for even 200MB of swap to fill up before flipping out and killing the offending process, let alone 8GB.
Those people have doubtless misunderstood the point of swap. You should have a swapfile/partition because it allows allocated but currently unused memory (from an application which keeps data hanging around which is not needed for most of it's working life, or an application which simply leaks) to be dumped to long term storage, thus freeing memory for its real use: page cache. Sweet, sweet page cache.
I'm always happy to see a few tens, even a couple of hundred MB of swap in use, because it means that some application had some unused data hanging around for so long that to leave it there would mean my machine having to read from disk more frequently, which would be Bad.
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#54Earlier quoted context omitted.
> I often just turn swap off entirely. And you're smart to do so. Swap is useless for 99% of end-user systems. ChromeOS doesn't use any swap partition, for instance. As for hibernation, it's not available if you use a crypted swap, which is wise to use (at least on a laptop). As a result, I, too, disabled swap completely.
Care to explain why this is so?
Clearly, you don't need and basically can't use an 8GB swap partition. So, how long are you willing to put up with? That will vary, but let's say 10 seconds before you're "flipping out and killing processes". That's a 200MB swap partition. But... that's only 5% of the size of your RAM! If that's the difference between a process completing or not, you've probably already lost. Or you should just kill Firefox.
On a 4GB system, the most likely reason a process is pushing you into swap is that it is in an infinite allocation loop, and all having 4GB of swap does is make your system crawl that much more before the process dies.
This is a result of RAM sizes increasing far faster than hard drive write speed has. When I had 32MB of RAM, it made sense to have some swap. I could swap out, say, 16MB of unused executable pages (bits of windows, bits of drivers I'm not using, bits of the massive Office suite I'm not using, etc) and get that much more working set, and this could happen in a reasonable time; the system choked for a couple of seconds but recovered in a stable manner. Now swapping out 16MB of executable is a joke. SSDs may change the balance, but these balances have been out of whack for a long time, I rather suspect that even with an SSD it won't be worth swap. Especially since by the time SSDs are truly common 8GBs of RAM may be entry-level because, well, why not? (Poking at Best Buy really quickly, at the $500 line you get 4GB for laptops, a little over $300 for desktops, coming down fast. I'm not sure they have anything less than 2GB now and even that is really into "don't use swap" for the average user.)
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#55It looks like gnome-system-monitor reports the "correct" amount of free RAM. I'd imagine most newbies would use that rather than popping open a terminal and typing "free," right?
You'd be surprised. Some users who use Linux consider themselves to be pretty adept, and I can easily see this problem being an issue for people who perceive themselves to be clever.
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#56It looks like gnome-system-monitor reports the "correct" amount of free RAM. I'd imagine most newbies would use that rather than popping open a terminal and typing "free," right?
You'd be surprised. Some users who use Linux consider themselves to be pretty adept, and I can easily see this problem being an issue for people who perceive themselves to be clever.
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#57Wouldn't it make more sense to just include the RAM used for disk-caching when calculating free memory? After all, the whole reason it's being used for disk-caching in the first place is that it's free! The Linuxoids that know what this even means can always explicitly look for the line that says how much memory is being used for caching...
It costs time to zero pages; disk cache pages are not zeroed. Not having a source of zero pages will add latency to large memory allocation requests. (The pages must be zeroed to avoid the security problem of snooping on data you might not have access to.)
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#58This is misleading, as the kernel will often swap out processes rather than shrink the disk cache. Its tendency to do this is controlled by the vm.swappiness parameter, which by default heavily favors swapping: http://kerneltrap.org/node/3000 Decreasing this value will favor reducing the cache size and will tend to increase responsiveness. You can set it in the /etc/sysctl.conf file. Low values (≤ 5) are especially g…
Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?
#59Whoops!
The difference between the scenario above and Linux's disk cache? Techies blame the former on the car company but the latter on the end-users.