# samba read performances

## digrouz

Hello,

I've a nas server installed with gentoo. I've good performances in ftp (read and write) and in write with samba. What I feel strange, is that I've less performances with samba in read (about half of the write speed).

It's something like that:

ftp read: 100Mo/s

ftp write: 100Mo/s

Samba write: 95 Mo/s

Samba read: 45Mo/s

I did the test several times with files of about 2Go and I got all the time nearly the same results. 

How to explain that? and also how to improve that read speed?

Here is my smb.conf:

```

[global]

workgroup = USERSHARE

server string = Samba Server %v

printcap name = /dev/null

load printers = no

printable = no

printing = bsd

interfaces = lo eth0

bind interfaces only = yes

hosts allow = 127.0.0.1 192.168.0.0/24

hosts deny = 0.0.0.0/0

netbios name = SMBSRV

security= share

guest ok = yes

log file = /var/log/samba/log.%m

log level= 1

max log size = 50

local master = no

dos charset = CP850

unix charset = UTF-8

display charset = UTF-8

aio read size    = 65536

aio write size   = 65536

aio write behind = true

socket options   = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

min receivefile size = 131072

max protocol = smb2

use sendfile = yes

preferred master = yes

strict sync = no

sync always = no

[usershare]

        comment = shared folder

        path = /mnt/data

        valid users = myuser

        guest ok = no

        browseable = yes

        writable = yes

```

----------

## enihcam

Change

```

socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

```

to

```

socket options = SO_KEEPALIVE TCP_CORK IPTOS_THROUGHPUT

```

1. 'TCP_NODELAY IPTOS_LOWDELAY' only benefits interactive console, e.g. telnet.

2. Do not use 'SO_RCVBUF/SO_SNDBUF', so linux kernel can automatically adjust them to the best values.

3. sendfile() always befriends with TCP_CORK, whereas it with TCP_NODELAY is a nightmare.

----------

## enihcam

 *enihcam wrote:*   

> Change
> 
> ```
> 
> socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
> ...

 

Sorry, I forgot to mention:

Before enable TCP_CORK, in 'static const smb_socket_option socket_options[]'@/lib/util/util_net.c you need to add:

"

{"TCP_CORK", IPPROTO_TCP, TCP_CORK, 0, OPT_BOOL},

"

----------

