4 ms·
Windows has been fine with swap files since the age of spinning disks, so I guess using a swap file instead of a swap partition is fine. Speaking of Windows: H
by wongarsu 4y ago
Windows has been fine with swap files since the age of spinning disks, so I guess using a swap file instead of a swap partition is fine.
Speaking of Windows: How is it that Linux seems to grind to a halt when it is forced to swap, while Windows works just fine in the same scenario? Sure, on Windows a lot of swap file "use" is just bookkeeping of empty pages because Windows doesn't overcommit memory. But even if it actually swaps it stays responsive, while I've had to reboot linux boxes more than once because they stayed unresponsive after memory pressure. Does Windows have a smarter swap algorithm? Is it more proactive about swapping stuff back in once memory pressure is gone? A better scheduler that gives more precedence to "interactive" things? And most importantly: can linux implement those things too?
- hulitu 4y ago> How is it that Linux seems to grind to a halt when it is forced to swap /proc/sys/vm/swapiness or something like this. AFAIK shall be bigger than 50% to not see the behaviour that you describe.
- Manu40 4y agoAh yes, swapiness. I think Windows is set to something like ... 65% or so. Or was it 85%. I forget, but I looked into this a long time ago when I was having to suffer through having about half as much ram as was ideal for my use case scenarios on both windows and linux. I remember coming across some method to get it changed on windows as well, but I forget that method too. Or rather, I think it's some reg edit that needs doing, but I forget what/where.
- MrStonedOne 4y ago
- simoncion 4y agoBased on the explanation in the documentation <https://docs.kernel.org/admin-guide/sysctl/vm.html?highlight=swappiness#swappiness https://docs.kernel.org/admin-guide/sysctl/vm.html?highlight...>, I set 'swappiness' to 100. I figure that SSDs are fine with random IO, so swap isn't likely to be much -if at all- slower than pulling pages back in from disk.
- xani_ 4y agoWrong direction. Bumping swappiness up means OS will make it more likely to keep more pages in cache, setting it to higher value makes OS treat it more like RAM and that's usually slow and jittery
- derkades 4y agoUsing more swap may make the system faster. It means there is more room for file-backed pages in RAM, to cache read and writes. A swappiness value should be chosen based on the system IO workload and swap device performance characteristics.
- marcosdumay 4y agoWindows swap never worked well. The OS was always famous for trashing constantly, and only started to lose that fame when computers started coming with way more RAM than any sane OS could use.
- timbit42 4y ago> trashing Freudian slip?
- yellowapple 4y agoI think the correct Windows terminology would be Recycle Binning.
- phendrenad2 4y ago> The OS was always famous for trashing constantly Famous, huh? Do you have any resources or articles where I can read about this famous phenomenon?
- fragmede 4y agoThe word is thrashing. https://en.wikipedia.org/wiki/Thrashing_(computer_science) https://en.wikipedia.org/wiki/Thrashing_(computer_science) https://superuser.com/questions/32860/how-to-reduce-disk-thrashing-paging https://superuser.com/questions/32860/how-to-reduce-disk-thr... https://answers.microsoft.com/en-us/windows/forum/all/why-is-my-hard-disc-thrashing-continuously-for/4f23499a-a072-4b4f-8c7a-5037ff612ae2 https://answers.microsoft.com/en-us/windows/forum/all/why-is... https://serverfault.com/questions/74822/how-do-i-tell-if-my-windows-server-is-swapping https://serverfault.com/questions/74822/how-do-i-tell-if-my-...
- phendrenad2 4y agoThese links look like you just googled "windows thrashing" and copied the first 4 results. Did you do that? Addressing your links in order: 1. I know that the word is thrashing, I was quoting the OP. 2. The existence of someone who thinks they experienced thrashing (but didn't do any investigation to see if they were actually experiencing thrashing), 13 years ago, doesn't seem very difinotive to me. 3. Please read this page. You'll see that the first sentence is "hard drive is being continuously thrashed even when no applications are apparently running". How is the system thrashing when there are no applications running? FYI, "thrashing" does not just mean ANY frequent hard drive reads for any reason. 4. I don't know what this article has to do with the question I asked. The article title is "How do I tell if my Windows server is swapping?" which seems completely unrelated to my question about how often Windows swaps?
- xani_ 4y agoOnce you swap a lot out and you get back some free memory linux will swap it back in on demand, which means a lot of micro-lag moments once apps start accessing now-in-swap things. Linux assumes it's better to have not-used thing in swap while RAM is used for IO caching, that's why you see this behaviour, there is (AFAIK) no mechanism to go "okay, we have few gigs free, let's bring stuff from swap back". Reboot-less method is to add new LV with swap and swapoff the old one but that's more PITA than restart...
- vbezhenar 4y agoWe use servers with swap files. It works fine and does not grind to halt. Right now one server has 10/15 GB RAM utilization and 3.7/3.7GB swap utilization. It's pretty responsive.
- pixl97 4y agoEh, are you sure we're really comparing apples to apples here?, at least when it comes to server based applications. I've overloaded windows multiple times and yes I could move the mouse around and Mayne open notepad if it already cached in memory, but you could get stuck waiting for IOPS trying to do anything else for insanely long periods of time. I've not done much in this realm since NVMe SSD has been common so not sure how this behaves these days.
- teo_zero 4y ago> Windows doesn't overcommit memory So, what's the function of swap for Windows?
- kazinator 4y agoThe function of swap isn't "to overcommit"; it is to provide more virtual memory than you have physical memory. Overcommitting is a separate idea, which can be done without swap.
- teo_zero 4y agoSorry but "provide more virtual resources than you physically have" isn't another way to say "overcommit"?
- kazinator 4y agoVirutal memory provides a larger memory than available RAM, but all of it can be backed by mass storage. In that case, you have all of the storage; just not all of it is RAM. When not all of it is backed by storage, then the situation is overcommitted.
- kazinator 4y agoThe VirtualAlloc API in Windows provides explicit control over commitment. You can reserve address space using the MEM_RESERVE flag, and commit with MEM_COMMIT. These can be combined into one. Therefore, we cannot say that "Windows doesn't overcommit". Windows applications can overcommit. You don't know which ones might do that, for what purpose.