Discussion:
swapfile question
(too old to reply)
tech-lists
2018-05-12 13:51:15 UTC
Permalink
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?

thanks,
--
J.
Waitman Gobble
2018-05-12 15:39:52 UTC
Permalink
Post by tech-lists
Hi,
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?
thanks,
--
J.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
Don't swap. 1 and 2 are both slower.

I use Warren Block's SSD setup and create swap file, seems to work A-OK.

http://www.wonkity.com/~wblock/docs/
--
Waitman Gobble
Los Altos California USA
650-621-0423
thor
2018-05-13 04:03:51 UTC
Permalink
Partition is faster because it does not depend on all the file
processor. But:

1) I had a setup where the swap was a md vnode on a geli partition. And
it has some troubles, I didn't investigate why. The main trouble was a
panic immediately after disk sync on shutdown. So in the future I am
going to use a separate geli partition for swap.

2) Use of lots of RAM without swap is even faster. But there are some
programs (notably compile libre office) that need lots of ram/swap per core.
Post by Waitman Gobble
Post by tech-lists
Hi,
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?
thanks,
--
J.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
Don't swap. 1 and 2 are both slower.
I use Warren Block's SSD setup and create swap file, seems to work A-OK.
http://www.wonkity.com/~wblock/docs/
RW via freebsd-questions
2018-05-14 00:22:44 UTC
Permalink
On Sat, 12 May 2018 08:39:52 -0700
Post by Waitman Gobble
I use Warren Block's SSD setup and create swap file, seems to work A-OK.
http://www.wonkity.com/~wblock/docs/
Swap files are certainly more flexible, but I think the argument about
TRIM is wrong. My understanding is that to UFS the swap activity on a
swap file is just reads and writes in the file. Short of deleting the
file I don't think you would get any trims. From that perspective swap
files are slightly worse because when you create the file with dd you
are telling the SSD that all of it holds data.
Waitman Gobble
2018-05-14 00:57:45 UTC
Permalink
On Sun, May 13, 2018 at 8:22 PM, RW via freebsd-questions
Post by RW via freebsd-questions
On Sat, 12 May 2018 08:39:52 -0700
Post by Waitman Gobble
I use Warren Block's SSD setup and create swap file, seems to work A-OK.
http://www.wonkity.com/~wblock/docs/
Swap files are certainly more flexible, but I think the argument about
TRIM is wrong. My understanding is that to UFS the swap activity on a
swap file is just reads and writes in the file. Short of deleting the
file I don't think you would get any trims. From that perspective swap
files are slightly worse because when you create the file with dd you
are telling the SSD that all of it holds data.
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
The only swap issue I have is with Firefox on FreeBSD desktop with
less than 12gb RAM. ie, 8gb machine will start paging eventually. This
could be an issue that was solved though, I think I remember people
complaining about FF. But when FF starts paging the easiest is to
reboot. Yes, it has to do with hella tabs open after a month or so. :)

FreeBSD servers are running 32gb or 64gb RAM and those have not been
paging. That i've noticed.
--
Waitman
John Levine
2018-05-12 16:46:13 UTC
Permalink
Post by tech-lists
Hi,
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, ***@iecc.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly
tech-lists
2018-05-13 08:52:52 UTC
Permalink
Thanks for all your help
--
J.
Loading...