Re: measuring swap partition speed

From: void <void_at_f-m.fm>
Date: Tue, 19 Dec 2023 13:23:31 UTC
On Fri, Dec 15, 2023 at 08:41:10AM -0700, Warner Losh wrote:

>benchmarking of storage. Do a random workload with a 8k write size (since
>that's the page
>size of aarch64) on one of the swap partitions when it's not in active use.

I've not got my head around benchmarks/fio yet. But I've done the following
tests which seem to show abysmal swap speed, not linked to the hardware :

# 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   
1494+0 records in
1493+0 records out
12230656 bytes transferred in 41.495178 secs (294749 bytes/sec)

# dd if=/dev/urandom of=/dev/da0p4 bs=128k count=250000 conv=sync status=progress
^C88080384 bytes (88 MB, 84 MiB) transferred 47.309s, 1862 kB/s  
674+0 records in
673+0 records out
88211456 bytes transferred in 48.677246 secs (1812170 bytes/sec)

But when the same partition is formatted as ufs:

# newfs -U /dev/da0p4
/dev/da0p4: 2048.0MB (4194304 sectors) block size 32768, fragment size 4096
         using 4 cylinder groups of 512.03MB, 16385 blks, 65664 inodes.
                 with soft updates
super-block backups (for fsck_ffs -b #) at:
192, 1048832, 2097472, 3146112

# mount /dev/da0p4 /mnt

# dd if=/dev/urandom of=/mnt/test8k.bin bs=8k count=250000 conv=sync status=progress
   2036400128 bytes (2036 MB, 1942 MiB) transferred 18.013s, 113 MB/s
   250000+0 records in
   250000+0 records out
   2048000000 bytes transferred in 18.084497 secs (113246167 bytes/sec)

why the difference?

My non-expert observation is that when swap gets used, all writes start backing up and
it starts thrashing. it's a thing I'd expect to see with slow media like microSD but 
not on faster hardware.

I have the following sysctls set to minimise swap use

vm.pageout_oom_seq=120
vm.pfault_oom_attempts=-1
vm.pageout_update_period=0
vfs.zfs.arc.min=536870912
vfs.zfs.arc_max=1073741824

this is a rpib4 with 8GB

how can I fix?
--