4 ms·
Swap is still mostly mysterious to me (and the article is mostly over my head). My current naïve understanding is that swap is slower memory, and a disk cache i
by drsopp 2y ago
Swap is still mostly mysterious to me (and the article is mostly over my head). My current naïve understanding is that swap is slower memory, and a disk cache is faster disk. I remember back in the windows xp days moving the pagefile to a RAM disk. That significantly decreased latency (re)running programs. These days I disable swap in my 64GiB windows box and have temp files in a RAM disk mostly for security reasons.
- SunlitCat 2y agoWait? Moving the pagefile, which should cover large memory allocations (not necessarily large memory usage, just the allocation), to a Memory based disk. Well...that's interesting, to say the least!
- corysama 2y ago“moving the pagefile to a RAM disk.” is a hacky way to emulate disabling swap :P In an ideal world, swap would automagically move stuff that you are not likely use soon out of RAM even when you use poorly written programs that don’t do that explicitly. And, disk cache would automagically keep stuff in RAM that you are likely to need again soon even when using poorly written programs that don’t do that explicitly. So, ideally, they work together to max the effectiveness of you RAM.
- 22c 2y agoI think what many people forget is that applications can ask for a bunch of memory and then never do anything with it (or just do something with it once). Imagine you want to write something down, so you ask me for a notebook. Now you start writing very slowly such that I can tell you're not going to need more than one page of that notebook for quite a while. I don't want to take the notebook away from you because you're fussy and you insist on having the entire notebook to yourself, but someone else comes along also wanting to write something down. Me being the clever kernel that I am, decide to let you keep a "virtual" copy of your notebook, but really only the first page of it is "real" paper and I give the notebook to the next person who ALSO insists on having an entire notebook to write down a few words on a page. I can now have 20 people all writing in their own "virtual" 100 page notebooks, while I really only have a single 100 page notebook to go around. Only when the combined total of all needed pages REALLY hits 100 pages will I start to run into issues.
- drsopp 2y agoSurely we can do this without writing anything to disk?
- 22c 2y agoI didn't really complete the analogy. Once you hit 100 actual pages of your notebook, I could either give up completely or I can say "Hey that first page you wrote to, I noticed you haven't used it in a while... I'm just going to store that in the filing cabinet." Now again we're fine and we're even past 100 pages, but if you ever need to read the page I stored in in the filing cabinet, I'll have to swap that page out for another page, which will be time consuming and inefficient.
- DEADMINCE 2y ago> Swap is still mostly mysterious to me ... I remember back in the windows xp days I mean no disrespect, but why in 20 years haven't you just read up on or watched a video explaining swap and disk cache?
- drsopp 2y agoNone taken. I guess because I haven't really had the need to know more than I do about it. Maybe you can enlighten me. Can you explain to me why my xp installation behaved much more snappy after I moved the page file into a ram disk? Is swap really useful these days, or is the overhead too wasteful? Is it perhaps a crutch from the time it was necessary but now only lives on because of a kind of learned helplessness from programmers who don't need to care about modestly allocating memory?
- DEADMINCE 2y agoYou likely had much more ram than the average person did, right? My understanding was XP was based around the needs of the average consumer and wrote the OS in such a way as to almost mandate swapping rather than writing something smarter that could avoid swapping if the machine had more than enough ram. Because that swapping would occur regardless, there would be a performance penalty when you didn't actually need it. Pointing the swap back to ram circumvented that. I wouldn't say it's a crutch as there are still plenty of users machines and situations where ram might run out, so swapping is better than the apps crashing. But yes it's becoming increasingly obsolete.
- drsopp 2y agoThanks, makes sense.
- navjack27 2y agoPlease don't do that anymore! Windows requires a page file. Page files should not be on a ram disk. There is a hierarchy of memory. Temp files should be on a disk where they should be.