Slow samba/nfs read in OpenWrt stable/dev

Hi, I installed openwrt on zyxel310 with kirkwood verzion. Everything work as I need, but samba/NFS read speed is realy bad. In original firmware is it about 20MiB/s write and 35MiB/s read over SMB, 35MiB/s write and 50MiB/s read over NFS.

Read speed in openwrt is about 10Mib/s over samba and about 20MiB/s over NFS - write speed is god - as in original fw

type o2019-07-09

root@OpenWrt:~# cat /etc/config/samba4 
config samba
        option 'workgroup'              'WORKGROUP'
        option 'description'    'Samba on OpenWrt'
        option 'charset'                'UTF-8'
        option 'homes'                  '0'

config 'sambashare'
        option 'name' 'videa'
        option 'path' '/mnt/sda/videa'
        option 'users' 'admin,user,guest'
        option 'guest_ok' 'yes'
#       option 'create_mask' '0700'
#       option 'dir_mask' '0700'
        option 'read_only' 'no'
root@OpenWrt:~# 

root@OpenWrt:~# cat /etc/samba/smb.conf.template 
[global]
        netbios name = |NAME| 
        interfaces = |INTERFACES|
        server string = |DESCRIPTION|
        unix charset = |CHARSET|
        workgroup = |WORKGROUP|

        ## This global parameter allows the Samba admin to limit what interfaces on a machine will serve SMB requests.
        bind interfaces only = yes

        ## time for inactive connections to-be closed in minutes
        deadtime = 15

        ## disable core dumps
        enable core files = no

        ## set security (auto, user, domain, ads)
        security = user

        ###XXX my changes 2019-07-08
        #read raw = Yes
        aio read size = 40960000
        aio write size = 40960000
        ###XXXend of my changes 2019-07-08


        ## This parameter controls whether a remote client is allowed or required to use SMB encryption.
        ## It has different effects depending on whether the connection uses SMB1 or SMB2 and newer:
    ## If the connection uses SMB1, then this option controls the use of a Samba-specific extension to the SMB protocol introduced in Samba 3.2 that makes use of the Unix extensions.
        ## If the connection uses SMB2 or newer, then this option controls the use of the SMB-level encryption that is supported in SMB version 3.0 and above and available in Windows 8 and newer. 
        ##(default/auto,desired,required,off)
        #smb encrypt = default

        ## set invalid users
        invalid users = root

        ## map unknow users to guest
        map to guest = Bad User

        ## allow client access to accounts that have null passwords. 
        null passwords = yes

        ## The old plaintext passdb backend. Some Samba features will not work if this passdb backend is used. (NOTE: enabled for size reasons)
        ## (tdbsam,smbpasswd,ldapsam)
        passdb backend = smbpasswd

        ## Set location of smbpasswd ('smbd -b' will show default compiled location)
        #smb passwd file = /etc/samba/smbpasswd 

        ## LAN/WAN options (IPTOS_LOWDELAY TCP_NODELAY) WAN (IPTOS_THROUGHPUT)
        socket options = IPTOS_LOWDELAY TCP_NODELAY

        ## lower CPU useage if supported
        use sendfile = yes

        ## samba will behave as previous versions of Samba would and will fail the lock request immediately if the lock range cannot be obtained.
        #blocking locks = No

        ## disable loading of all printcap printers by default (iprint, cups, lpstat)
        load printers = No
        printcap name = /dev/null

        ## Enabling this parameter will disable Samba's support for the SPOOLSS set of MS-RPC's.
        disable spoolss = yes

        ## This parameters controls how printer status information is interpreted on your system.
        ## (BSD, AIX, LPRNG, PLP, SYSV, HPUX, QNX, SOFTQ)
        printing = bsd

        ## Disable that nmbd is acting as a WINS server for unknow netbios names
        #dns proxy = No

        ## win/unix user mapping backend
        #idmap config * : backend = tdb

        ## Allows the server name that is advertised through MDNS to be set to the hostname rather than the Samba NETBIOS name.
        ## This allows an administrator to make Samba registered MDNS records match the case of the hostname rather than being in all capitals.
        ## (netbios, mdns)
        mdns name = mdns

        ## Clients that only support netbios won't be able to see your samba server when netbios support is disabled.
        #disable netbios = Yes

        ## Setting this value to no will cause nmbd never to become a local master browser.
        #local master = no

        ## (auto, yes) If this is set to yes, on startup, nmbd will force an election, and it will have a slight advantage in winning the election. It is recommended that this parameter is used in conjunction with domain master = yes, so that nmbd can guarantee becoming a domain master. 
        #preferred master = yes

        ## (445 139) Specifies which ports the server should listen on for SMB traffic.
        ## 139 is netbios/nmbd
        #smb ports = 445 139

        ## This is a list of files and directories that are neither visible nor accessible.
        ## Each entry in the list must be separated by a '/', which allows spaces to be included in the entry. '*' and '?' can be used to specify multiple files or directories as in DOS wildcards.
        veto files = /Thumbs.db/.DS_Store/._.DS_Store/.apdisk/

        ## If a directory that is to be deleted contains nothing but veto files this deletion will fail unless you also set the delete veto files parameter to yes.
        delete veto files = yes

################ Filesystem and creation rules ################
        ## reported filesystem type (NTFS,Samba,FAT)
        #fstype = FAT

        ## Allows a user who has write access to the file (by whatever means, including an ACL permission) to modify the permissions (including ACL) on it.
        #dos filemode = Yes

        ## file/dir creating rules
        #create mask = 0666
        #directory mask = 0777
        #force group = root
        #force user = root
        #inherit owner = windows and unix
################################################################
root@OpenWrt:~# 

I used stable version, dev verzion, classic samba, samba4. Disk is WDRED 4TB, smart is god

Can You help me please?

echo deadline > /sys/block/sdX/queue/scheduler 
echo 250 > /sys/.../sdX/queue/iosched/read_expire
[ etc etc ]

Thank You, I'll try it in this afternoon, but hdparm -Tt shows speed about 200-300MB/s read - it does not mean god disk I/O performance?

(sorry for my english - I know - is very bad...)

Compile using -O2 instead of -Os, any other common filesystem than ext4 will be very slow on the kirkwood platform such as BTRFS or NTFS.

the file system is ext4 (one partition on the entire disk)

If you transfer a file, have a look using top which process pegs and give fio a spin to determine if it's a subsystem performance issue.

thank You, I'll try this

From the samba doc's on aio read/write size:

The only reasonable values for this parameter are 0 (no async I/O) and 1 (always do async I/O).

Nothing else sticks out to me, other than that i can only point you to the new "experimental" samba alternative cifsd over at my repo. I'm still waiting on a final fix from the dev's and than it should be ready to-be merged into the official dev-branch.

thank You a lot, I used the wrong instructions probably. I will fix it and I'll try to use your repo

TOP when I move 4GB file from NAS to desktop:

5693  5190 admin    S    28336  11%  80% /usr/sbin/smbd -F
    7     2 root     SW       0   0%   1% [ksoftirqd/0]
  184     2 root     SW       0   0%   1% [kswapd0]
 5698  5619 root     R     1128   0%   0% top
 5618  1944 root     S      948   0%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    5     2 root     IW       0   0%   0% [kworker/u2:0]
 5695  5190 admin    S    27916  11%   0% /usr/sbin/smbd -F
 5696  5190 admin    S    27916  11%   0% /usr/sbin/smbd -F
 5190     1 root     S    27508  11%   0% /usr/sbin/smbd -F
 5200  5190 root     S    25124  10%   0% {cleanupd} /usr/sbin/smbd -F
 5199  5190 root     S    25120  10%   0% {smbd-notifyd} /usr/sbin/smbd -F
 5191     1 root     S    16096   6%   0% /usr/sbin/nmbd -F
 2096     1 nobody   S     1760   1%   0% avahi-daemon: running [OpenWrt.local]
 1999     1 root     S     1588   1%   0% /sbin/netifd
    1     0 root     S     1412   1%   0% /sbin/procd
 2073     1 root     S     1388   1%   0% /usr/bin/dbus-daemon --system
 2032     1 root     S     1292   1%   0% /usr/sbin/odhcpd
 1911     1 dnsmasq  S     1224   0%   0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
 5619  5618 root     S     1136   0%   0% -ash
 2255     1 root     S<    1132   0%   0% /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org
 2295  1999 root     S     1128   0%   0% udhcpc -p /var/run/udhcpc-br-lan.pid -s /lib/netifd/dhcp.script -f -t 0 -i br-lan -x hostname:OpenWrt -C -O 121
 1855     1 root     S     1080   0%   0% /sbin/logd -S 64
 1673     1 root     S     1052   0%   0% /sbin/ubusd
 2296  1999 root     S      884   0%   0% odhcp6c -s /lib/netifd/dhcpv6.script -P0 -t120 br-lan
 1944     1 root     S      884   0%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
 1688     1 root     S      856   0%   0% /sbin/urngd
 1675     1 root     S      744   0%   0% /sbin/askfirst /usr/libexec/login.sh
  990     2 root     IW<      0   0%   0% [kworker/0:1H]
 1671     2 root     SW       0   0%   0% [jbd2/sda-8]

TOP when I move that file back:

typ5696  5190 admin    R    27988  11%  58% /usr/sbin/smbd -F
 5714     2 root     IW       0   0%   3% [kworker/u2:2]
    7     2 root     SW       0   0%   3% [ksoftirqd/0]
  184     2 root     SW       0   0%   2% [kswapd0]
 5715  5619 root     R     1128   0%   0% top
 1999     1 root     S     1588   1%   0% /sbin/netifd
 5618  1944 root     S      948   0%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
 5705  5190 root     S    27976  11%   0% /usr/sbin/smbd -F
 5190     1 root     S    27508  11%   0% /usr/sbin/smbd -F
 5200  5190 root     S    25124  10%   0% {cleanupd} /usr/sbin/smbd -F
 5199  5190 root     S    25120  10%   0% {smbd-notifyd} /usr/sbin/smbd -F
 5191     1 root     S    16096   6%   0% /usr/sbin/nmbd -F
 2096     1 nobody   S     1760   1%   0% avahi-daemon: running [OpenWrt.local]
    1     0 root     S     1412   1%   0% /sbin/procd
 2073     1 root     S     1388   1%   0% /usr/bin/dbus-daemon --system
 2032     1 root     S     1292   1%   0% /usr/sbin/odhcpd
 1911     1 dnsmasq  S     1224   0%   0% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
 5619  5618 root     S     1136   0%   0% -ash
 2255     1 root     S<    1132   0%   0% /usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org
 2295  1999 root     S     1128   0%   0% udhcpc -p /var/run/udhcpc-br-lan.pid -s /lib/netifd/dhcp.script -f -t 0 -i br-lan -x hostname:OpenWrt -C -O 121
 1855     1 root     S     1080   0%   0% /sbin/logd -S 64
 1673     1 root     S     1052   0%   0% /sbin/ubusd
 2296  1999 root     S      884   0%   0% odhcp6c -s /lib/netifd/dhcpv6.script -P0 -t120 br-lan
 1944     1 root     S      884   0%   0% /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
 1688     1 root     S      856   0%   0% /sbin/urngd
 1675     1 root     S      744   0%   0% /sbin/askfirst /usr/libexec/login.sh
e or paste code here

and before some minute I tierd vsftp - read speed was quite better - speed was around 16 MB/s. But nothing posted here helped - samba read speed is still around 10MB/s

If you're seeing ~80%+ or more it means that your CPU is pegged. Kirkwood isn't very fast by todays standards and Samba 4 isn't a slim application so this is about as good as it gets. You might be able to squeeze out a few more Mbyte/s by using -O2 but don't expect miracles.

1 Like

ok and thank You diizzy, it is quite sad :frowning:. But why is write speed ok - writing is more difficult than reading, or not?

Try create a share on /tmp this is the dynamic ramdisk openwrt uses. If you have >64MB ram you can use this to test raw performance, since no usb/sata or other problematic stuff is involved. So if you get much better read speeds from there, we know its the physical disk/interface that slows things down.

Hi Andy, thank You for Your god idea - but it is still the same - read/write speed is 10/22 MiB/s

Than i'm out of good ideas, the default config runs well for my system at 80-100 MB/s via sata interface on a wrt-1200AC.
There are unfortunately so many "samba speed tuning" guides out there that may work for a specific usecase/configuration, but its just try&error. Just be aware to use samba4 options and consult the docu: https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html if a tuning parameter is not already set by default to the suggested value.

PS: Other than that switching to cifsd may help.

Kirkwood is ARMv5 so it's going to be slow especially if encryption is involved so I don't think you need to spend more time on this "issue". Also, I think the generic config is well tuned for most use cases.

If you want something cheap and faster just grab a RPI4 although platform support is a bit immature at this stage however USB storage only.

1 Like

Sure, but this does not explain why write speeds are much higher and 10MB/s is way to slow for ARMv5, i would expect such speeds on a old mips router.

@rutu Try change this:

smb encrypt = off

I assume you connect from a windows 10 PC?
Than open admin powershell and do Get-SmbConnection so we can confirm what smb version is negotiated.

smb encrypt = off
without change :frowning:

Get-SmbConnection:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\WINDOWS\system32> Get-SmbConnection

ServerName ShareName UserName              Credential           Dialect NumOpens
---------- --------- --------              ----------           ------- --------
OPENWRT    videa     DESKTOP-6HD0EH6\marek DESKTOP-6HD0EH6\user 3.1.1   2

PS C:\WINDOWS\system32>

I don't think you need to spend more time on this "issue".

it is not about spending time, or searching cheap device - I used this NAS long times ago, and now I tried "get more" from it. First time I tried openwrt - I was waiting it is god solution for low-power devices. I used openwrt on Asus WL 500 gP V2, now I use it on tplink WDR3600 and no problems. Second time I'll try debian (probably) and then again original fw I think :slight_smile:

This year I will rebuild my falt - new kitchen, new living room, new many other things and I will buy new tv too and probably J5005 as a HPTC and homestorage. This is probably my last attempt with zyxel310. But I like this device - it spared a lot of my time with sharing and backup our data

I think - it is not a problem only in samba - NSF, VSFTP are in read slow to