5 ms·
I think there are two related questions that aren't strictly "swap". To discuss the question, you need to generalize beyond "swap" to all file-backed pages. Und
by jeffbee 3y ago
I think there are two related questions that aren't strictly "swap". To discuss the question, you need to generalize beyond "swap" to all file-backed pages. Under pressure to reclaim space the kernel might evict any page that is backed by a file, but people who want to "disable swap" don't want this either. So if you are against swap you need to make sure that anything that came from a file including your programs and libraries are locked into memory and can't be evicted for reclaim.
The other related issue is whether mmap is obsolete. It is, but most application authors haven't gotten the message yet. Extending your address space over a bunch of files and making the kernel figure it out doesn't work optimally on modern hardware.
- deleted 3y ago[deleted]
- jauntywundrkind 3y agoIs there anything on this assertion that map is obsolete to dive into? That's a bold & very different claim.
- jeffbee 3y agoIf you are just trying to get along and make your program work, there's nothing morally wrong with mmap, but it is far from optimal and optimality is where the interesting discussions happen. Making the kernel deal with your magic page tables, and asking it to infer what to evict, what to read ahead of time are not the best approach. The page fault cost did not matter much when they invented mmap, back when disk accesses took tens of milliseconds. Today it matters a great deal. Using `fio` on my system, mmap is the slowest way to access the SSD.