Swap on SSD

Frank Leonhardt frank2 at fjl.co.uk
Wed Feb 7 15:18:25 UTC 2018

On 2018-02-05 20:08, John R. Levine wrote:
> In article <24BAEBB4-FAA7-47C8-A6FC-32839063666F at kreme.com>, LuKreme
> <kremels at kreme.com> wrote:
>> On Feb 5, 2018, at 09:13, Frank Leonhardt <frank2 at fjl.co.uk> wrote:
>>> FreeBSD doesn't actually swap these days; uses demand paging. This 
>>> means that blocks of RAM that are hardly ever used can get
>> copied to disk. This may include some stuff that's only accessed a few 
>> times a year, but would otherwise be occupying precious
>> RAM that would be much more useful as a disk cache. That said, FreeBSD 
>> tends not to page out except as a last resort - probably a
>> mistake but I can't prove it.

> On one of my BSD cloud virtual machines I have a server process that
> slurps in about a gigabyte of stuff into a very large perl table, then
> sits there and answers queries from that table.  The system swaps like
> crazy for a few seconds while it's loading up the table, then quiets
> down and reads a few pages a second from the swap as the queries come
> in. That's about the worst case, and only becasue I'm a cheapskate and
> don't want to pay for a larger VM where everything would fit in RAM.

On a VM you have no idea whether anything is on disk or in RAM - chances 
are in this case your swap partition is in the hypervisor's disk cache.


There seems to be some confusion on this list about swapping and paging. 
Swapping is old hat. Basically when doing a context swap you wrote a 
non-running process to a swap area to free up RAM space. We don't do 
that anymore - we use demand paged virtual memory. All processes 
potentially remain resident, but some of their memory map may be paged 
out to disk to free up RAM. If the process tries to access such a page 
the MMU interrupts the kernel, which loads in the missing page and uses 
the MMU to put it back in the process space at the right location before 
returning control.

I'm not being pedantic here - the difference between swapped and paged 
systems is very significant if you're optimising disk/RAM usage.

Swap areas have been replaced by page areas on disk, but the name stuck. 
A bit like core store - I haven't used core store since the 1980's but 
we still have "core dumps". Youngsters in the office look at me oddly 
when I use terms like core and DASD...

More information about the freebsd-questions mailing list