Exploring Swap on FreeBSD

Should I enable swap today:

I no longer see any use

what do you say ?


It is difficult to provide general advice. On FreeBSD-based appliances, such as embedded routers or NAS devices, it is quite common to see swap disabled. Such systems may not have any disks suitable for swapping[4], or their designers may not have been willing to accept potential application latency caused by faults on paged-out memory. In versions of FreeBSD before 11.0, the page daemon was responsible both for freeing clean inactive pages and laundering dirty inactive pages, so large amounts of paging activity could delay reclamation of memory and trigger freezes.

Source:
 
The article is very technical and from a systems perspective.

To offer a language perspective:

Not offering the system any paging space can influence what kind of applications might slow down. That is because readonly mapped pages (such as C/C++ code segments) can just be dropped from memory and are never paged out. Read/write pages such as from interpreted languages and VM languges (java etc) require moving to swapspace to get them out.

Now imagine you run a mix of C and Java code on a system with no paging space and memory pressure. The system is forced to drop readonly pages at a higher rate since it has no way of getting the Java code pages out. So C/C++ code might slow down disproportionally, and as we know your base operating system is written in it.

Or in other words: you force the system to keep read-write pages in no matter how useless they are, while you are causing an increased stirring of dropping and re-reading of readonly pages, no matter how often they are used.
 
If you have a swap partition, simply add a line like this to /etc/fstab:
/dev/ada0p2.eli none swap sw 0 0

I'm not getting into the discussion about swap/no swap, but having been using FreeBSD for quite a while, I still configure swap. Maybe not as much as the old recommendations based on size of RAM, but given the size of current storage devices, swap size is in the noise. A system with a 256G storage device, a 2G swap partition is 1%.

Your system, your workload, your call, but my opinion is "configure some swap space, in the range of 2-4G which is not very much on a system with N-TB storage".
 
after various tests

I now achieve peak values at 13.2 via LAN SMB copy

after customized smb server and aslr delete
Without using anything, my FreeBSD 13.2 120 MB Ram (SSHD, SMBD, min mix)
 

Attachments

  • 11111.JPG
    11111.JPG
    125.5 KB · Views: 63
Back
Top