questions about swap (partition and file)

Polytropon freebsd at edvax.de
Tue Feb 11 15:56:00 UTC 2020


On Tue, 11 Feb 2020 15:50:09 +0000, tech-lists wrote:
> Which is it better to have - swapfile partition or swapfile?
> 
> I have both, on a SSD. Thing is, I can write 10x faster to the
> file than I can
> to the partition. With a 512b block size, it can write at 17MB/s
> to the
> partition, and about 120-130MB/s to the swapfile, as reported by dd.

Probably a partition is better because it saves the subsystems
accessing it to deal with the filesystem layer. A swap device
does not have a filesystem, and it's not under VFS control, so
no overhead of that kind.

However, it is possible to "emulate" a swap device with a file,
and there are probably several ways to do this (for example,
virtual node: mdconfig + swapctl, also possible as "on demand"
solution where space will only be claimed when there's an
actual need for it).



> Historically, ISTR that it was recommended to have several swap
> partitions on
> the fastest disks available, and that swapfile was slower than
> a partition
> because of something like fat translation.

It was also suggested to make the swap partition = 2 x maximum
RAM of machine... :-)



> Is this still the case nowadays?
> Is there a better way of measuring swap speed than dd?

I'm not sure. It probably depends on the swapping behaviour
implied by your actual workloads.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list