Re: measuring swap partition speed

From: void <void_at_f-m.fm>
Date: Thu, 21 Dec 2023 15:50:52 UTC
On Wed, Dec 20, 2023 at 07:48:14PM -0800, Mark Millard wrote:

># swapoff /dev/label/growfs_swap
># dd if=/dev/urandom of=/dev/da0s2b bs=8k count=250000 conv=sync status=progress
>^C478830592 bytes (479 MB, 457 MiB) transferred 22.001s, 22 MB/s
>60557+0 records in
>60556+0 records out
>496074752 bytes transferred in 22.790754 secs (21766491 bytes/sec)

22MB/s is usable, I think. In my context, I'd be satisfied with that.
My context differs from yours slightly in that yours is SSD and mine
is spinning rust.

This is unusable:
# dd if=/dev/urandom of=/dev/da0p4 bs=8k count=250000 conv=sync status=progress
^C11862016 bytes (12 MB, 11 MiB) transferred 40.063s, 296 kB/s   

because it's way too slow. Swap never gets fully reclaimed,
thrashing happens, loads of other followon effects happen. 

The same partition formatted as ufs reports 113 MB/s. Multiple swap partitions
have been tested, then converted to ufs. Results are the same.

There are no reported errors in smartctl. Long smartctl tests run monthly.

5 Reallocated_Sector_Ct   PO--CK   100   100   050    -    0
9 Power_On_Hours          -O--CK   001   001   000    -    48992
196 Reallocated_Event_Count -O--CK   100   100   000    -    0
197 Current_Pending_Sector  -O--CK   100   100   000    -    0
198 Offline_Uncorrectable   ----CK   100   100   000    -    0

I can't find any hardware problem here. Possible workarounds, bearing in mind 
I'm not versant in C so it's not like I can fix this myself in code:

1. swap as swapfile and not partition [a]
2. swap as nfs [b]
3. swapoff & swapon script running every minute [c]
4. just turn all swap off and reboot after crashing (undesirable)
5. use another OS that doesn't have this problem

[a] not tried yet, and i hope it works. Legacy info suggests swap as partition is usually
     faster than filesystem-based swap. But the reverse might be the case here.

[b] also not tried. This, I imagine, would be filesystem only (I'm unsure a zfs volume can
     be exported to look like a mountable partition to the client)

[c] https://github.com/Freaky/swapflush.git - usually works but maybe i need to run it every 
     minute instead of every five mins. For testing, this script was disabled.

Any additional suggestions on how to overcome this problem gratefully received.

--