Origin of the rule that swap size should be 2x of the physical memory
retrocomputing.stackexchange.com
Origin of the rule that swap size should be 2x of the physical memory
1–10 of 78 posts
Re: Origin of the rule that swap size should be 2x of the physical memory
#2Re: Origin of the rule that swap size should be 2x of the physical memory
#3Too bad because it's an interesting question that I would also like to know the answer to.
Re: Origin of the rule that swap size should be 2x of the physical memory
#4Curious, How much swap have you personally allocated on your personal setup?
Edit: oh and I don’t have an actual personal system with swap configuration on it anymore to give my own answer anymore either.
Re: Origin of the rule that swap size should be 2x of the physical memory
#5Curious, How much swap have you personally allocated on your personal setup?
Re: Origin of the rule that swap size should be 2x of the physical memory
#6Re: Origin of the rule that swap size should be 2x of the physical memory
#7Curious, How much swap have you personally allocated on your personal setup?
Re: Origin of the rule that swap size should be 2x of the physical memory
#8Curious, How much swap have you personally allocated on your personal setup?
Re: Origin of the rule that swap size should be 2x of the physical memory
#9The OP clearly states that he wants to know the earliest origin of the rule , and the only answers he gets are people giving their own opinions on how much swap space you should have. Too bad because it's an interesting question that I would also like to know the answer to.
Re: Origin of the rule that swap size should be 2x of the physical memory
#10When a process forks, the child needed swap reservations for the parent's entire address space (before exec replaces it). A large process forking temporarily needs double its swap allocation. If your working set is roughly equal to physical RAM, fork alone gets you to 2x.
This was the practical bottleneck people actually hit. Your system had enough RAM, swap wasn't full, but fork() failed because there wasn't enough contiguous swap to reserve. 2x was the number that made fork() stop failing on a reasonably loaded system.
The later overcommit/copy-on-write changes made this less relevant, but the rule of thumb outlived the technical reason. Most people repeating "2x RAM" today are running systems where anonymous pages aren't swap-backed until actually paged out.
Today swap is no longer about extending your address space, it's about giving the kernel room to page out cold anonymous pages so that RAM can be used for disk cache.
A little swap makes the system faster even when you're nowhere near running out of memory, because the kernel can evict pages it hasn't touched in hours and use that RAM for hot file data instead.
The exception is hibernation — you need swap >= RAM for that, which is why Ubuntu's recommendations are higher than RedHat's 20% of RAM.