4 ms·
Why is reading the data back from swap be slower at all -- much less "DRAMATICALLY" so -- than saving the data to disk and reading it back?
by saurik 1y ago
Why is reading the data back from swap be slower at all -- much less "DRAMATICALLY" so -- than saving the data to disk and reading it back?
- cwillu 1y agoBecause swapping back in happens 4kb at a time
- cycomanic 1y agoWhy?
- worthless-trash 1y agoBecause of page size. Its treated like any other page.
- mnw21cam 1y agoIt's also because a filesystem is much more likely to have consecutive parts of a file stored consecutively on disc, whereas swap is going to just randomly scatter 4kB blocks everywhere, so you'll be dealing with random access read speed instead of throughput read speed.
- blueflow 1y agoValid argument with FAT on spinning rust, invalid with ext4 on ssd. ext4 is extent-based so the fragmentation overhead doesn't happen.
- Suzuran 1y agoThe swap partition does not have a filesystem, it is a linear list of blocks.
- deleted 1y ago[deleted]
- blueflow 1y agoNeither i nor parent said that. Confusion?
- ars 1y agoYou wrote your comment like it was a rebuttal of the person above you, but the text supports what they said: A filesystem is faster than swap for this. What was your intent?
- deleted 1y ago[deleted]
- cwillu 1y agoext4 is irrelevant to what happens when a file is backed by swap; even with swapfiles, the mm subsystem more or less goes behind the back of the filesystem to access the disk corresponding to the swapfile. The overhead of making (size-of-read / 4kb) requests (potentially stalling the reading process for every page) is relevant even on an ssd; there are costs to random access beyond moving a disk head and waiting for a platter to spin into position, and those costs are still relevant with solid-state storage.