swapfile question

John Levine johnl at iecc.com
Sat May 12 16:46:15 UTC 2018


In article <CAFuo_fxUspphdS3eiX99gzkesDxuZw+VbxHbfZj7phEPvr-C_w at mail.gmail.com> you write:
>On Sat, May 12, 2018 at 6:51 AM, tech-lists <tech-lists at zyxst.net> wrote:
>> Hi,
>>
>> In a SSD/amd64/ufs2/freebsd-11 context, which is faster:
>>
>> 1. swap as a partition on the ssd
>> 2. swap as a file on the ssd
>>
>> If one is faster than the other, why? To what extent?

A partition is faster since using a swap file requires looking up
block numbers using inodes and indirect blocks.  In the worst case the
difference could be 2:1, a block number lookup for every page,
typically not that bad but it's always slower.

I agree that in general it's better to set up your system so it
doesn't need to swap but you always want enough swap to avoid strange
program failures when malloc() calls fail.  (They're supposed to
recover but I can assure you, they often don't.)

I have an application that answers network queries from a mysql
database.  The database is largish, several hundred megabytes, but
only changes a few times a day.  I rewrote my application so it slurps
the whole database into a perl table and answers queries from that.
The perl table is bigger than the VM's physical memory so it's mostly
swapped out, but using the VM system for disk I/O is faster in this
application than calling out to mysql.

-- 
Regards,
John Levine, johnl at iecc.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly


More information about the freebsd-questions mailing list