Live data from Hacker News

Linux Performance: Why You Should Almost Always Add Swap Space

haydenjames.io

81–90 of 120 posts

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#81
post #75

Earlier quoted context omitted.

2010. I've been following the industry since I left, and I promise you neither the physics of FN flash nor the manufacturing process has fundamentally changed since then. Nor have the true endurance numbers substantially improved. If anything the situation is worse now with smaller device dimensions. The only thing standing between your collection of cat gifs and oblivion is the flash controller making intelligent gu…

Sorry, but you must not be "following the industry" very well. SSDs have lifespans measured in years of constant use. If you think it isn't the case, you need to go back and learn more about those devices you claim to know so much about.

I'm afraid we're misunderstanding each other here. You're talking about the fully-integrated SSD. Not my area of expertise. I'm talking about the endurance of the flash cell transistors. Nobody's claiming significantly higher endurance for the transistors themselves -- what's improved is the stuff on top of them. SSD controllers have gotten better at not trashing any given cell with repeated program / erase cycles. If you measure endurance of modern SSDs versus seven years ago, sure, you'll see better endurance, but that's becasue there's better logic on top, not because the cell transistors are any better than they were.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#82
post #67
post #23

This is dangerous advice. At least on Ubuntu 16.04 with stock kernel running due to memory pressure into swap kills the systems. Basically everything times out and you can only hard-reboot. Without swap you have an OOM at least something you can recover from. If you need swap just add a little like 1-4gb - because if you have spinning disks 64gb swap won't help you at all because every request to swap is magnitudes m…

Sorry, but this is just patently not true. See this list of many reasons why you're incorrect - https://news.ycombinator.com/item?id=15952447

Thanks for the list of resources--I've been struggling to find good information about whether to use swap.

A friendly suggestion: you obviously care a lot about this, and want to bring people around to your point of view. I think you'd be more effective at that, if you wrote this up as a blog post, or a github gist. Cite the relevant information from those links (or leave some of them as further reading). As it stands, there are 16 links, and I'm anticipating slogging through them, with no idea what I'm getting out of it.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#83
post #66

Earlier quoted context omitted.

What is the rule for setting swap size, or can I use just swap file just like on win/mac? (I heard it will disable hibernation then)

The basic rule is `RAM + 2GB` I usually peak at 34GB, unless I have reason (like needing/wanting to enable full hibernation) to use 66GB, 130GB, etc.

what if if you increase your RAM after installing the system?

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#84
post #67

Earlier quoted context omitted.

Sorry, but this is just patently not true. See this list of many reasons why you're incorrect - https://news.ycombinator.com/item?id=15952447

Thanks for the list of resources--I've been struggling to find good information about whether to use swap. A friendly suggestion: you obviously care a lot about this, and want to bring people around to your point of view. I think you'd be more effective at that, if you wrote this up as a blog post, or a github gist. Cite the relevant information from those links (or leave some of them as further reading). As it stand…

> with no idea what I'm getting out of it.

Not a whole lot. I've looked at them and they are for the most part outdated, do not make the case for 'some swap' or are simply fluff to make the list look more impressive.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#85

Swap engineering is definitely way more complicated than the article lets on. What people often don't realise is that Linux distinguishes between dirty and clean memory, with dirty memory not reflected in swap, and clean memory already stored somewhere on disc, and program code is counted as clean memory that just happens to live somewhere other than swap . Therefore, under memory pressure (especially if you set swap…

> Therefore, under memory pressure (especially if you set swappiness to zero), you will be preferentially swapping out your program code (because it is always clean) in preference to your program data.

Regarding systems with near 100% utilization, wouldn't it be a better advice to pin all executable code to memory via tmpfs (at system level) or mlockall() (application level)?

Encountered this case on some heavily-loaded batch data processing workers: at some point, client programs would slow down and generate random disk I/O (which in turn is detected by monitoring and throttled). Turned out, processes would go through major page faults at random moments in time, when their executable code pages are discarded from memory and subsequently re-read from disk.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#86

I always see people caring way to much about the amount of swap space used and not enough about the swap activity going on. It isn't the amount of swap space that slows a system down but actual swapping in/out of memory pages. In vmstat you want to pay attention to the "si" and "so" columns and in your alerting/graphing you want to keep track of the values "pswpin" and "pswpout" in /proc/vmstat. If these are almost a…

That sounds like a bug worthy of reporting.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#87

What do the people that use cloud instances that don't have local disks do? You definitely don't want swap to be on EBS...

Allocate 20+% more memory that you could ever need. Use cgroups, lxc, systemd to constrain applications and containers to specific amounts of memory, cpu, etc. Properly engineered systems will have enough memory for everything else under the hood beyond the application. VM and container abstraction does not negate the requirement to calculate this.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#88

I always see people caring way to much about the amount of swap space used and not enough about the swap activity going on. It isn't the amount of swap space that slows a system down but actual swapping in/out of memory pages. In vmstat you want to pay attention to the "si" and "so" columns and in your alerting/graphing you want to keep track of the values "pswpin" and "pswpout" in /proc/vmstat. If these are almost a…

Ensure Transparent Huge Pages are disabled. There is a known bug/leak. The only fix is to set to madvise or disable it all together.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#89
post #66

Earlier quoted context omitted.

The basic rule is `RAM + 2GB` I usually peak at 34GB, unless I have reason (like needing/wanting to enable full hibernation) to use 66GB, 130GB, etc.

what if if you increase your RAM after installing the system?

It's a circular argument that people get into because they have the incorrect kernel settings. Even if you have 4TB of ram, someone will say to add more memory on disk. It just means the system is not configured correctly. I have 30k servers and not a single one of them has swap.

Re: Linux Performance: Why You Should Almost Always Add Swap Space

#90
post #39

Nowadays linux has this thing called zram disk. It compresses data in memory on the fly. I think general swapping advice would serve most people better if they always add swap on zram first, before swap on ssd or hdd. The difference is that getting data in and out of zram is so fast that you can actually use it as a tier of a slower ram, transparently compressed.

zram is cool, but still considered experimental. Even zswap is still fairly young. I have used both on my own systems. zswap is much easier to conifg.
Post reply on HN