by CoconutPilot · 8y ago · 0 comments
In the Pentium 1 era EDO RAM maxed out at 256MB/s and hard disk xfer was 10MB/s. Common RAM size was 16MB.
In today's era DDR4 maxes out at 32GB/s and hard disk xfer is 500 MB/s. Common RAM size is 16GB.
RAM xfer rate has grown is 320x. RAM capacity has grown 100x. Disk xfer rate has grown 50x.
Swap is no longer a useful tool.
Swap has a lot less purpose in a world without memory leaks and extraneous functions. But in practice it's quite good at getting several gigabytes of unnecessary data out of the way, so ram can be used properly.
Swap, well-used, should only take up a few percent of the drive's bandwidth.
You can't detect a priori whether data is "unused." If you guess wrong a few times in a row, you get the familiar pattern where your Linux box is unresponsive to everything and needs to be bounced.
If you could detect whether data is rarely used, swap still isn't necessary. Applications can mmap() a file and use that region for "rarely used data" if such is known in advance.
Extraneous functions should be backed by the executable in the common case. In the JIT case, they probably won't be JITted anyway.
I still think the OOM killer is less intrusive than swapping to disk. It kills some, but not all, of the processes on the machine get killed. The system pretty reliably comes back to life in less time than it takes a human to diagnose the problem and bounce the system. As a bonus, no human needs to get involved.
They could, but that's a lot like just making swap be manual.
> Extraneous functions should be backed by the executable in the common case.
I don't mean the code itself, I mean all the data it builds up for something that isn't needed.
Sure. Isn't that a good thing? Rarely-used data can be swapped out to storage allocated for the purpose, as you desire, and too-large working sets don't have to hose the machine.
> I don't mean the code itself, I mean all the data it builds up for something that isn't needed.
I guess I don't often run programs that waste large amounts of memory for no reason. Either my working set fits or it's too large, and swap only matters if it's too large.
Is Java the typical beneficiary here?
When dealing with swap, continuous transfer rate of the hard disk is not the relevant metric; seek time is.
In my experience, when the system starts needing to read a lot of pages back in from swap, it tends to do so in more or less random order. It reads a small amount of data, then it seeks to a new position, then reads another, and so on.
(I also find the argument unconvincing for a separate reason: I think hard drives are somewhat obsolete. Even my home system has flash instead of swap. And flash has a massively better seek time.)
One of those times was on a 512MB RAM VPS, where I needed to compile something - you don't want a 512MB VPS to do a lot of compilation, but in that one instance, I was very glad I could easily just make a swap file and get on with it. The other time was on my laptop with 8 GB of RAM.
Also, even ignoring the times where swap makes possible a task which would otherwise have been impossible, you flat out ignored the content of the article. Did you even read it? If you have a long running task which allocates a lot of memory, then proceeds to only very rarely use that memory (or maybe it only needs that memory when it shuts down, or just forgot to free that memory), swap allows the system to swap out that memory and instead do something useful with it, like caching files or not killing processes. It doesn't matter that the disk is slower than RAM, if the swapped-out memory is rarely or never accessed.
hard disk xfer is 500 MB/s
You need better disks. The one in the laptop I'm typing this on can do 2GB/s, which greatly weakens your comparison.A better statistic to use is how many IOPS the disk can handle.
not sure even they could pull off those speeds with random reads, though.