Earlier quoted context omitted.
Anonymous memory and files have different access patterns. Files are frequently read sequentially and only once, so there is no need to keep them in memory. When files are read, cached memory pages are put into inactive file LRU first and promoted to active LRU only on the second access.
It is possible to unify things behind a single mechanism, yet apply different policies to different instances of this mechanism depending on circumstances and heuristics. We do not need almost entirely disjoint paging systems in the Linux kernel to notice that some kinds of memory have access patterns different from other kinds of memory. Instead of guessing based on whether someone used MAP_ANONYMOUS, we should obse…
Origin of the rule that swap size should be 2x of the physical memory
71–78 of 78 posts
Re: Origin of the rule that swap size should be 2x of the physical memory
#72Curious, 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
#73Earlier quoted context omitted.
Zero. My office workstation has 48 GB of RAM, my home computer has 64 (I went a bit overboard). I have very bad memories of swap thrashing and the computer becoming totally unresponsive until I forced a reset; if I manage to fill up so much RAM, I very much prefer the offending process to die instead of killing the whole computer.
I'm not an expert, but aren't you just reducing the choice of what pages can be offloaded from RAM? Without swap space, only file-backed pages can be written out to reclaim RAM for other uses (including caching). With swap space, rarely used anonymous memory can be written out as well. Swap space is not just for overcommitting memory (in fact, I suspect nowadays it rarely ever is), but also for improving performance…
Re: Origin of the rule that swap size should be 2x of the physical memory
#74Earlier quoted context omitted.
What kind of workload do you run that consumes 20 GB of swap???
Chrome and Slack. :-(
Re: Origin of the rule that swap size should be 2x of the physical memory
#75Earlier quoted context omitted.
On systems with 32/64/128 GB of ram, I'll typically have a 1GB or 2GB swap. Just so that the system can page out here and there to run optimally. Depending on the system, swap is typically either empty or just has a couple hundred MB kicking around.
On what OS are you using these settings? I found that Windows will refuse to allocate more virtual memory when the commit charge hit the max RAM size even if there is plenty of physical memory left to use. I have 64 GiB of RAM and programs would start to crash at only 25 GiB of physical memory usage in some workloads because of high commit charge. I had to re-enable a 64 GiB SWAP file again just to be able to actuall…
Linux. I also don't typically run any individual workload that would consume all system ram. Not loading a giant scientific model into memory all at once for fast processing or anything like that, so mileage will certainly vary based on requirements.
Re: Origin of the rule that swap size should be 2x of the physical memory
#76Early BSD VM pre-allocated swap backing for every anonymous page — you couldn't allocate virtual memory without a swap slot reserved for it, even if the page was never paged out. When 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…
Re: Origin of the rule that swap size should be 2x of the physical memory
#77Earlier quoted context omitted.
You guys are getting Linux to hibernate!?
I managed to get mine to wake up from sleep, haven't recovered enough to attempt hibernation yet.
Re: Origin of the rule that swap size should be 2x of the physical memory
#78Curious, How much swap have you personally allocated on your personal setup?
Zero. My office workstation has 48 GB of RAM, my home computer has 64 (I went a bit overboard). I have very bad memories of swap thrashing and the computer becoming totally unresponsive until I forced a reset; if I manage to fill up so much RAM, I very much prefer the offending process to die instead of killing the whole computer.