3 ms·
All these problems you're describing are way more complicated than "just don't allocate the memory" and would involve sophisticated logic to optimize (like pred
by shawnz 4y ago
All these problems you're describing are way more complicated than "just don't allocate the memory" and would involve sophisticated logic to optimize (like predicting exactly what features are or are not going to be used by an application at start time without significantly increasing the startup latency, etc). Why not just let swap be that optimization?
- morelisp 4y agoMediocrity uber alles forever!
- shawnz 4y agoI'd argue that the fact such a simple and elegant solution as virtual memory is able to effectively cover such a wide range of use cases while eliminating the need for every application developer to duplicate their efforts is the exact opposite of "mediocre" and in fact it's the exact kind of efficiency-minded thinking that the software industry needs more of.
- lazide 4y agoBecause it’s dangerous. Are you SURE that memory never gets accessed under load? Because I’ve seen a lot of surprised sysadmins over the years.
- shawnz 4y agoSo why not address those edge cases with something like "madvise" style configuration rather than just saying application developers need to reinvent the wheel any time they do something outside the golden path?
- lazide 4y agoBecause that would require the programmer do something explicit to deal with a runtime edgecase they fundamentally don’t have the context to decide the right course of action on? Especially if it’s a library or the like? That infrequent call might be key for program stability in one context or pointless (garbage collector whatever- key in a major server program, pointless in a toy app). The moral of the story is, if under load code or data gets moved from where access is fast (RAM) to where it is slow ( even SSD and most NVMe counts here) then gets accessed when under load? It makes the problem much worse.
- shawnz 4y agoSurely if they don't have that context, then it's even less likely they'll be able to roll their own optimization to fix the issue without swap.
- lazide 4y agoWell, they could use less RAM in general (hence less likely to be applying memory pressure). But good luck. Hence why the advice for servers is turn swap off. It’s a footgun waiting to happen.
- menaerus 4y agoI don't understand the argument. Performance-wise, swap will obviously decrease the one but runtime-wise isn't it going to actually enable your application to continue running rather than crashing, albeit at much lower speeds? Once you exhaust the RAM and you run with no swap configured, what happens with your application?