Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 2020 14:27:24 -0500
From:      John Johnstone <>
Subject:   Re: questions about swap (partition and file)
Message-ID:  <>
In-Reply-To: <>
References:  <> <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On 2/11/20 11:21 AM, tech-lists wrote:
> Hi,
> On Tue, Feb 11, 2020 at 04:55:25PM +0100, Polytropon wrote:
>> 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.
> But given there's no overhead, then why on the face of it is it slower 
> than a
> swapfile?

It is the memory management part of an OS that writes and reads memory 
areas to swap space.  It does so directly without using dd or going 
through the OS file system handling.  So whatever testing you are doing 
to try to benchmark the performance of things cannot be compared to what 
the OS does when it is using swap space.

Also file system caching can dramatically change the performance numbers 
that will be reported when doing file I/O.  Maybe you are just measuring 
130MB/s of I/O writes generated by dd that are going to the write cache 
before they are written to disk.  If that's the case you're just 
measuring the speed of I/Os hitting memory and not the disk.  Powerfail 
your system 0.5 seconds into your test and then check and see if you 
actually got 65MB of data written to your disk.

If you are seeing 17MB/s of writes going directly to a partition there 
will be no caching involved.  Although that also is not exactly what the 
OS does it will be a much closer comparison to the OS swap I/O.

John J.

Want to link to this message? Use this URL: <>