Live data from Hacker News

Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

linuxatemyram.com

41–50 of 74 posts

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#41
post #19
post #15

Earlier quoted context omitted.

Windows started doing disk caching with Vista and users certainly noticed and complained in much the same way.

Windows didn't start doing disk caching with Vista. Perhaps it used memory more aggressively, or changed the way it did the accounting, but it certainly didn't start doing disk caching just with Vista, as anyone who remembers the difference in performance of DOS before and after running SMARTDRV will attest.

2000/XP was always extremely aggressive about allocating memory for cache. It would very often swap stuff out to increase available cache, which made the apps you did not use for just a few seconds completely unresponsive.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#42
post #30

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.

> 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.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#43
post #42

Earlier 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.

> "twice the RAM is the recommended size of your swap file"

Don't listen the parrots that repeat something that ceases to be true at least 10 years ago. Swap used to be a useful hack, it is not anymore.

> as if I'm going to wait for even 200MB of swap to fill up before flipping out and killing the offending process

Well said ;-)

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#44
post #42

Earlier 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.

Hibernation requires a large swap space, doesn't it? Last I knew it did, perhaps you can compress it now.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#45
post #30

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.

> 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?

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#46
post #30

This 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…

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.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#47
post #42

Earlier quoted context omitted.

"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.

Hibernation requires a large swap space, doesn't it? Last I knew it did, perhaps you can compress it now.

Yes, and it may seem a merely semantic difference, but there's still a difference between "swap space" and "hibernation backing". One I'm willing to wait for while it fills, the other, I am not. The kernel may not distinguish, but I do. When I don't care about hibernation I just remove it.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#48
post #45

Earlier 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?

You're probably never going to hit the swap for a good reason. You might hit it if you do a mistake (resizing an image by 5000% and not 500%), in which case you will suffer if you let your gigabytes of swap get filled), or if you have specific needs (video editing, and still...).

Keeping a swap partition in a 2011 computer is 1. a waste of disk space, 2. an unecessary matter of worries (2-1. may leak some infos, even if your other partitions are encrypted, if your computer is stolen, 2-2. a source of potential bugs).

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#49
post #41
post #19

Earlier quoted context omitted.

Windows didn't start doing disk caching with Vista. Perhaps it used memory more aggressively, or changed the way it did the accounting, but it certainly didn't start doing disk caching just with Vista, as anyone who remembers the difference in performance of DOS before and after running SMARTDRV will attest.

2000/XP was always extremely aggressive about allocating memory for cache. It would very often swap stuff out to increase available cache, which made the apps you did not use for just a few seconds completely unresponsive.

Specifically, minimized applications got their working set trimmed. You could see this in Task Manager: it's Memory Usage column was actually Working Set (I think they're more explicitly labelled these days) and it frequently went from many MB down to a few KB once you minimized the app. Working set is the set of pages, currently in memory, that the app has used "recently", and are thus less likely to be paged to disk. Shrinking the WS makes pages more likely to be paged out.

Re: Tired of explaining Linux's seemingly obtuse memory usage to confused newbies?

#50
post #37
post #26

This paragraph: 'But what do you call memory that is both used for something and available for applications? You would call that "free", but Linux calls it "used".' is IMO the best way I've ever seen of explaining the issue. It also reveals the solution: call it free! It is free, after all. Nobody cares about how much free ram is cache unless they are doing something really specific, in which case they should be pass…

Or just rename "free" to "wasted". I usually tell people the free number indicates how much RAM they paid for but aren't using.

It is admittedly difficult to re-learn what you know about computers, and what Windows has taught people (including myself) is that RAM usage must be below ~75% for optimal performance. It has been my experience that paging becomes much more blocking above that.
Post reply on HN