Skip site navigation (1)Skip section navigation (2)
Date:      12 May 2018 12:46:13 -0400
From:      "John Levine" <johnl@iecc.com>
To:        freebsd-questions@freebsd.org
Cc:        gobble.wa@gmail.com
Subject:   Re: swapfile question
Message-ID:  <20180512164613.AD3372675650@ary.qy>
In-Reply-To: <CAFuo_fxUspphdS3eiX99gzkesDxuZw%2BVbxHbfZj7phEPvr-C_w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <CAFuo_fxUspphdS3eiX99gzkesDxuZw+VbxHbfZj7phEPvr-C_w@mail.gmail.com> you write:
>On Sat, May 12, 2018 at 6:51 AM, tech-lists <tech-lists@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@iecc.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180512164613.AD3372675650>