Help me improve the speed of nfsv4

I am currently running samba and nfsv4 from the same laptop, which is being used as a home server. The server (laptop) is using FreeBSD 13.2-Release. Both services (samba and nfsv4) are sharing the same folders. When accessing the shared folders from the desktop (FreeBSD 13.2 + KDE) I notice that samba is almost twice as fast than nfsv4. According to KDE I get around 90-100MiB/s when copying to and from a samba share and around 40-50MiB/s to and from nfsv4. This took me by surprise as I was expecting the opposite, especially when both the server and client are using FreeBSD. Considering that mount_smbfs(8) doesn't support SMB2 and SMB3, I was keen to use nfsv4, but this would be sacrificing speed. Any suggestions what I could do to improve the speed of nfsv4?

Here are some more information:

On client side
Code:
nfsstat -m
192.168.0.92:/Share on /mnt
nfsv4,minorversion=2,tcp,resvport,nconnect=1,hard,cto,sec=sys,acdirmin=3,acdirmax=6
0,acregmin=5,acregmax=60,nametimeo=60,negnametimeo=60,rsize=65536,wsize=65536,readd
irsize=65536,readahead=1,wcommitsize=8388608,timeout=120,retrans=2147483647

On server side /etc/rc.conf
Code:
nfs_server_enable="YES"
nfsv4_server_enable="YES"
nfsuserd_enable="YES"


Perf3 test between the two
Code:
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.10 GBytes   942 Mbits/sec    0             sender
[  5]   0.00-10.01  sec  1.10 GBytes   940 Mbits/sec                  receiver
 
Can you run a proper benchmark with read and write and seek on the two volumes (through NFS and through Samba)?

bonnie comes to mind. My version is here:

For me NFSv3 was slightly faster than 4.
Thanks. Bonnie results for nfsv4 mount

Code:
              -------Sequential Output-------- ---Sequential Input-- --Random--
              -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
          100 95920 35.9 98343  7.5 19391 10.5 99347 57.2 2965794 98.1 2529.1  9.9

I don't know how to test samba mount with bonnie. I can only access the samba share via file manager (Thunar or Dolphin) as a shared folder that points to smb://192.168.0.50/Share. I can't mount it to a folder due to SMB2/3 not being supported, in order to test bonnie.

Playing around with this, I also noticed slight different speeds between Thunar and Dolphin.
 
You are benchmarking the cache. The file size used with bonnie must be at least twice that of main memory, and four times main memory is better.

Edit: and with large files you need to skip the "Per Char" tests, as they will take for ever...
 
I would argue that you should move fio (which is in ports) instead of bonnie as it's much more flexible.


For general testing these pages will point you in the right direction
 
What is the underlying file system of you server ?
In the case of ZFS, NFS do sync writes whereas SMB does not.
You could apply the property zfs set sync=disabled yourtestfs and redo your write speed tests.
 
Thanks both. I have run the above bonnie test with sync= disable/standard.

zfs sync=standard
Code:
         ---Sequential Output----- ---Input---- ------Random-- -----Random----
         ---Block---- ---Rewrite-- ---Block---- ---ro Seeks--- -Seeks rewrite-
    MB    M/sec %CPU    M/sec %CPU   M/sec %CPU      /sec  %CPU     /sec  %CPU
 24576    90.7   7.4    23.7   9.6    109.7   6.6   2807.4  13.5   815.9  24.1

zfs sync=disabled
Code:
         ---Sequential Output----- ---Input---- ------Random-- -----Random----
         ---Block---- ---Rewrite-- ---Block---- ---ro Seeks--- -Seeks rewrite-
    MB    M/sec %CPU    M/sec %CPU   M/sec %CPU      /sec  %CPU     /sec  %CPU
 24576   109.5   8.5    24.6  10.2    110.9   6.8   3112.2  13.7  1156.2  23.4

I seem to be getting resonable speed. I get a better replication of the above speed when using Thunar than Dolphin as a file manager.

What's the risk when disabling zfs sync?
 
I wouldn't bother. You are getting close to the speed of your ethernet anyway. I don't see a performance problem here.

I don't know why KDE would get lower speeds.
 
Back
Top