User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Samba Performance

Tue Jan 01, 2013 2:41 pm

nginx wrote:A USB to Gigabit Ethernet dongle should be able to provide around 14MB/s unless some other bottleneck crops up which I'm not currently aware of. I have tested the real world transfer speed of the USB on the Pi to be around 28.7MB/s. Since USB is half duplex, the Samba transfer speed will be halved because it involves both read and write processes using the same bus, hence the 14MB/s figure.

Now I have to decide whether a whole 4MB/s gain is worth plonking down $20 for a USB Gigabit Ethernet dongle :D Then I have my doubts whether the driver will work or not but I guess the kernel can always be recompiled as long as the drivers are actually available for linux.
You'll have another bottle neck if you're reading/writting to a usb attached hard drive on the pi, but if you're just doing it to the SD card... well you might see some benefit.
Dear forum: Play nice ;-)

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Thu Jan 03, 2013 5:02 pm

What you are suggesting will require the use of a large SD card for downloading purpose. I am not sure if its a good idea to use a SD card for 24x7 downloading considering the limited write cycles. Transmission does thrash the hard drive pretty good, not sure a SD card can handle that.

Also using the Pi as a file server means you have to use an external USB drive :(

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Samba Performance

Thu Jan 03, 2013 5:10 pm

nginx wrote:
Also using the Pi as a file server means you have to use an external USB drive :(
I actually have two pis doing just this, one is a local drive for my house and the other is a remote site backup for my parents.

For the local drive I have it sharing media to my XBMC pi and even with it doing that I'm still able to get 1-2 MBps (yes capital B ;-) ) over my 54 Mbps wifi connection.

I suppose technically I'm using a nice internal hard drive and then a Sata -> USB adapter. It works very, very well.
Dear forum: Play nice ;-)

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Sat Jan 12, 2013 4:07 am

Just an update guys. I have been able to sort out the bottleneck in the read speed. I can now read and write both at 11MB/s steady. The problem was with my laptop hard drive not being able to write fast enough (its 5.5 years old & slow as hell). I tried copying files to/from the desktop for the first time and its going full throttle. I overclocked my Pi to Turbo but not sure its necessary since CPU is barely around the 50% mark during file transfer process.

Those of you who were reporting slow read speeds earlier like me, might want to check by copying to a secondary hard drive instead of your primary drive where OS is installed since Windows keep writing to the page file during file transfer causing the disk head to move around constantly and slow down the transfer.

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Mon Jan 28, 2013 6:30 am

Bliepo wrote:Hello everyone!

First off, I found this thread because I ran into some performance issues with samba myself (turned out to be the wireless). I now have speeds of about 10MB/s and because I read a lot of people are having performance issues, I decided to share as much details about my configuration as I can, in hope that this will be of help for people with bad performance.

First off, I am using the 2012-12-16 raspbian wheezy hard float image (http://www.raspberrypi.org/downloads). It's overclocked using the raspi-config tool (turbo option, so 1000MHz ARM, 500MHz core, 600MHz SDRAM, 6 overvolt).

Info about the hard drive using hdparm -I:

Code: Select all

 sudo hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
        Model Number:       Hitachi HDS721010CLA332
        Serial Number:      JP2940HD26YMKC
        Firmware Revision:  JP4OA3EA
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
        Used: unknown (minor revision code 0x0029)
        Supported: 8 7 6 5
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors: 1953525168
        Logical/Physical Sector size:           512 bytes
        device size with M = 1024*1024:      953869 MBytes
        device size with M = 1000*1000:     1000204 MBytes (1000 GB)
        cache/buffer size  = 29999 KBytes (type=DualPortCache)
        Form Factor: 3.5 inch
        Nominal Media Rotation Rate: 7200
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 0
        Advanced power management level: disabled
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    DOWNLOAD_MICROCODE
                Advanced Power Management feature set
                Power-Up In Standby feature set
           *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
                Media Card Pass-Through
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    URG for READ_STREAM[_DMA]_EXT
           *    URG for WRITE_STREAM[_DMA]_EXT
           *    WRITE_UNCORRECTABLE_EXT command
           *    Segmented DOWNLOAD_MICROCODE
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
           *    Phy event counters
           *    NCQ priority information
                Non-Zero buffer offsets in DMA Setup FIS
                DMA Setup Auto-Activate optimization
                Device-initiated interface power management
                In-order data delivery
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT LBA Segment Access (AC2)
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
        not     supported: enhanced erase
        224min for SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000cca373df5877
        NAA             : 5
        IEEE OUI        : 000cca
        Unique ID       : 373df5877
Checksum: correct
/etc/samba/smb.conf:

Code: Select all

[global]
        server string = %h server
        map to guest = Bad User
        obey pam restrictions = Yes
        pam password change = Yes
        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        unix password sync = Yes
        syslog = 0
        log file = /var/log/samba/log.%m
        max log size = 1000
        dns proxy = No
        usershare allow guests = Yes
        panic action = /usr/share/samba/panic-action %d
        idmap config * : backend = tdb

[allusers]
        comment = All Users
        path = /home/allusers
        valid users = @users
        read only = No
        create mask = 0660
        directory mask = 0771

[homes]
        comment = Home Directories
        valid users = @users
        read only = No
        create mask = 0700
        directory mask = 0700
        browseable = No
The file system used is ext4. For every samba user, I make a seperate image file (using the truncate command followed by mkfs.ext4 and then editing the /etc/fstab file to make it mount in /home/username).

I am using a phone charger that can provide 1500mA of current, with the original cable.

The PC was connected to a router (fonera 2.0n) several meters long. The raspberry pi was also connected to the same router, using a cable that is about 20cm long (guestimate). The USB cable connecting the HDD is about 1.5 to 1.8 meters.

==================================
Here are some things I 'learned' and wanted to share, which might help:
- Wireless is very slow, even if you are using 802.11n. When I used wireless, I had speeds of 100kb/s if I was lucky. Using a LAN cable on the same device got me speeds of about 10MB/s.
- It is a good idea to use testparm to create your smb.conf file, as it checks syntax and also makes the file considerably shorter. This can be done using the following commands:

Code: Select all

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.master
testparm -s /etc/samba/smb.conf.master | sudo tee /etc/samba/smb.conf
If you want to edit your configuration, simply edit smb.conf.master, instead of smb.conf and the rerun the command

Code: Select all

testparm -s /etc/samba/smb.conf.master | sudo tee /etc/samba/smb.conf
- Cable length does not seem to affect performance by much.

I will post back later to see how much overclocking and using wireless instead of LAN affects perfomance.
I'm unable to duplicate these performance figures. The best I can get is around 6.0-6.5 MB/s write speeds.

Bliepo
Posts: 15
Joined: Sun Dec 23, 2012 11:29 pm

Re: Samba Performance

Mon Jan 28, 2013 4:58 pm

compuguy wrote:I'm unable to duplicate these performance figures. The best I can get is around 6.0-6.5 MB/s write speeds.
Perhaps it's because you are using a different drive with lower performance? Or perhaps it's the config file. Can you test how fast the drive is by making an empty file using dd? And can you post your config file?

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Mon Jan 28, 2013 8:31 pm

Bliepo wrote:
compuguy wrote:I'm unable to duplicate these performance figures. The best I can get is around 6.0-6.5 MB/s write speeds.
Perhaps it's because you are using a different drive with lower performance? Or perhaps it's the config file. Can you test how fast the drive is by making an empty file using dd? And can you post your config file?
Here is my smb.conf

Code: Select all

[global]
	workgroup = HOME
	server string = %h server
	map to guest = Bad User
	obey pam restrictions = Yes
	pam password change = Yes
	passwd program = /usr/bin/passwd %u
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	unix password sync = Yes
	syslog = 0
	log file = /var/log/samba/log.%m
	max log size = 1000
	dns proxy = No
	wins server = 192.168.5.2
	usershare allow guests = Yes
	panic action = /usr/share/samba/panic-action %d
	idmap config * : backend = tdb

[homes]
	comment = Home Directories
	valid users = %S
	create mask = 0700
	directory mask = 0700
	browseable = No

[printers]
	comment = All Printers
	path = /var/spool/samba
	create mask = 0700
	printable = Yes
	print ok = Yes
	browseable = No

[print$]
	comment = Printer Drivers
	path = /var/lib/samba/printers

[PiStore]
	comment = USB Share
	path = /media/usb0
	read only = No
	create mask = 0777
	directory mask = 0777

Bliepo
Posts: 15
Joined: Sun Dec 23, 2012 11:29 pm

Re: Samba Performance

Mon Jan 28, 2013 8:52 pm

The configurations don't seem to differ that much, although I am by no mean an expert (very much not so in fact). I can only imagine it is due to the drive performance, or the amount of attached USB devices.

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Tue Jan 29, 2013 3:14 am

How can it possibly be drive performance? Have you ever seen or heard of a hard drive that reads and writes as slow as 6MB/s? That is pen drive level performance and these days even pen drives can do better than that.

tbar
Posts: 98
Joined: Thu Nov 24, 2011 6:10 am

Re: Samba Performance

Tue Jan 29, 2013 7:14 am

Have you tried adding the following to smb.conf:

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65535 SO_SNDBUF=65535

You are not using NTFS but EXT4, right?

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Tue Jan 29, 2013 5:37 pm

Bliepo wrote:The configurations don't seem to differ that much, although I am by no mean an expert (very much not so in fact). I can only imagine it is due to the drive performance, or the amount of attached USB devices.
There is only one USB 2.0 Hard Drive attached, formatted EXT4.
tbar wrote:Have you tried adding the following to smb.conf:

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65535 SO_SNDBUF=65535

You are not using NTFS but EXT4, right?
Correct. I've tried those tweaks before, and they didn't seem to work, but I'll try them again.

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Thu Jan 31, 2013 1:08 am

Bliepo wrote:
compuguy wrote:I'm unable to duplicate these performance figures. The best I can get is around 6.0-6.5 MB/s write speeds.
Perhaps it's because you are using a different drive with lower performance? Or perhaps it's the config file. Can you test how fast the drive is by making an empty file using dd? And can you post your config file?
I did get a chance to test drive performance on the usb drive using dd. It seems to write at a speed of 2.1-2.2 MB/s which is suprisingly slower than the network performance....

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Thu Jan 31, 2013 2:50 am

Why don't you to connect that USB drive to your PC and see if its really that slow? Then you'll know for sure.

Are you using a powered USB hub? Connecting a 2.5" drive directly to the Pi's USB does not work well for me due to power constraints.

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Thu Jan 31, 2013 3:18 am

nginx wrote:Why don't you to connect that USB drive to your PC and see if its really that slow? Then you'll know for sure.

Are you using a powered USB hub? Connecting a 2.5" drive directly to the Pi's USB does not work well for me due to power constraints.
It is not a 2.5" drive, its a self powered 3.5" WD USB Drive. I'll try it on another Linux machine and see if there is any performance is different.

Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.

technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: Samba Performance

Thu Jan 31, 2013 3:56 am

compuguy wrote:
It is not a 2.5" drive, its a self powered 3.5" WD USB Drive. I'll try it on another Linux machine and see if there is any performance is different.

Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
I think the other poster's point was that the USB built into the pi probably pumps less power than that on your PC.
Your drive isn't "self powered", it's just USB powered so you don't see that power.

I would suggest a powered USB hub would be your answer.

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Thu Jan 31, 2013 4:18 am

technion wrote:
compuguy wrote:
It is not a 2.5" drive, its a self powered 3.5" WD USB Drive. I'll try it on another Linux machine and see if there is any performance is different.

Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
I think the other poster's point was that the USB built into the pi probably pumps less power than that on your PC.
Your drive isn't "self powered", it's just USB powered so you don't see that power.

I would suggest a powered USB hub would be your answer.
When I mean it was self powered, I meant the drive has its own power adapter that plugs into a wall socket. I can try connecting a usb hub in between the drive, but I'm doubting that will fix the issue. The one thing I haven't tried is changing the power source. It is currently being powered from the USB port on my FiOS router.

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Thu Jan 31, 2013 4:22 am

technion wrote:
compuguy wrote:
It is not a 2.5" drive, its a self powered 3.5" WD USB Drive. I'll try it on another Linux machine and see if there is any performance is different.

Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
I think the other poster's point was that the USB built into the pi probably pumps less power than that on your PC.
Your drive isn't "self powered", it's just USB powered so you don't see that power.

I would suggest a powered USB hub would be your answer.
If his drive is 3.5", then it actually is self-powered i.e. it has its own power adapter. USB cannot provide 12V that a 3.5" drive needs. But having said that 5V is still required to power everything else other than the motor of the drive and that power comes from the USB. So a powered USB hub is still recommended.

The power source of the Pi itself is another major factor. If its model B then 1A is the bare minimum if you're running headless. 1.5A if you have a monitor, mouse and keyboard hooked as well.

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Thu Jan 31, 2013 4:55 am

nginx wrote:
technion wrote:
compuguy wrote:
It is not a 2.5" drive, its a self powered 3.5" WD USB Drive. I'll try it on another Linux machine and see if there is any performance is different.

Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
I think the other poster's point was that the USB built into the pi probably pumps less power than that on your PC.
Your drive isn't "self powered", it's just USB powered so you don't see that power.

I would suggest a powered USB hub would be your answer.
If his drive is 3.5", then it actually is self-powered i.e. it has its own power adapter. USB cannot provide 12V that a 3.5" drive needs. But having said that 5V is still required to power everything else other than the motor of the drive and that power comes from the USB. So a powered USB hub is still recommended.

The power source of the Pi itself is another major factor. If its model B then 1A is the bare minimum if you're running headless. 1.5A if you have a monitor, mouse and keyboard hooked as well.
I swapped the power source from the FiOS router to a 2 amp usb adapter. Ran DD and got similar performance (2.0-2.2 MB/s).

Update: Tried the drive connected through a hub, same performance as before. I've even swapped raspberry pi's to see if it was hardware related, but performance has not changed.

nginx
Posts: 41
Joined: Sun Dec 09, 2012 2:35 pm

Re: Samba Performance

Thu Jan 31, 2013 6:27 am

It's a powered USB hub right?

If yes, then I am out of suggestions. You seem to have tried pretty much everything. I don't know what could be causing the bottleneck. I am getting just over 11MB/s steady here with less than 50% cpu. I have three 3.5" drives and one 2.5" drive connected to the Pi right now, no issues. At this point all you can do is wait for someone else to come along and find a solution for you :(

tbar
Posts: 98
Joined: Thu Nov 24, 2011 6:10 am

Re: Samba Performance

Thu Jan 31, 2013 6:41 am

compuguy wrote: Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
Initially I had trouble getting my USB HDD setup to work without crashes. The following helped me stabilizing the setup:

Code: Select all

Set "smsc95xx.turbo_mode=N" in /boot/cmdline.txt and vm.min_free_kbytes = 8192 in /etc/sysctl.conf.
Do you run overclocked? Try running without to see if this has something to say...

compuguy
Posts: 25
Joined: Thu Jan 24, 2013 5:26 am

Re: Samba Performance

Thu Jan 31, 2013 7:04 am

nginx wrote:It's a powered USB hub right?

If yes, then I am out of suggestions. You seem to have tried pretty much everything. I don't know what could be causing the bottleneck. I am getting just over 11MB/s steady here with less than 50% cpu. I have three 3.5" drives and one 2.5" drive connected to the Pi right now, no issues. At this point all you can do is wait for someone else to come along and find a solution for you :(
Yep, a D-link dub-h7 usb 2.0 hub.
tbar wrote:
compuguy wrote: Just ran a dd performance test.on another machine, the drives performance is drasticly better on Ubuntu than the pi's debian distro (2.0 MB/s compared to 23.8 MB/s). It seems its something on the pi's end.
Initially I had trouble getting my USB HDD setup to work without crashes. The following helped me stabilizing the setup:

Code: Select all

Set "smsc95xx.turbo_mode=N" in /boot/cmdline.txt and vm.min_free_kbytes = 8192 in /etc/sysctl.conf.
Do you run overclocked? Try running without to see if this has something to say...
Yes I do run it overclocked, but removing the overclock doesn't seem to improve network/drive speed. I'll try those configuration changes when I get a chance, but based on a quick Google, that would slow down the Ethernet connection rather than speed it up.

tbar
Posts: 98
Joined: Thu Nov 24, 2011 6:10 am

Re: Samba Performance

Thu Jan 31, 2013 8:51 am

compuguy wrote: Yes I do run it overclocked, but removing the overclock doesn't seem to improve network/drive speed. I'll try those configuration changes when I get a chance, but based on a quick Google, that would slow down the Ethernet connection rather than speed it up.
Exactly. In my case the performance drop was about 0.5 MB/s but my RPi could handle a load without crashing.

tregre
Posts: 4
Joined: Mon Feb 18, 2013 8:40 pm

Re: Samba Performance

Mon Feb 18, 2013 8:45 pm

I have a HDD mounted and run samba. Using dd to test write speed I get write speed of 5 MB/s and read of 19 MB/s between HDD and SD card. Using windows 8 to write to the samba share I only get 0.5 MB/s with a wait cpu of 99%. Can someone help me? Any ideas?

tbar
Posts: 98
Joined: Thu Nov 24, 2011 6:10 am

Re: Samba Performance

Tue Feb 19, 2013 5:16 am

tregre wrote:I have a HDD mounted and run samba. Using dd to test write speed I get write speed of 5 MB/s and read of 19 MB/s between HDD and SD card. Using windows 8 to write to the samba share I only get 0.5 MB/s with a wait cpu of 99%. Can someone help me? Any ideas?
Have you tried the different options mentioned in earlier posts in this thread?

tregre
Posts: 4
Joined: Mon Feb 18, 2013 8:40 pm

Re: Samba Performance

Thu Feb 21, 2013 4:28 pm

I have tried adding in /etc/samba/smb.conf
socket options = TCP_NODELAY SO_RCVBUF=65535 SO_SNDBUF=65535
and otherwise it is:
[usb]
comment = USB Share
path = /media/USBHDD
writeable = Yes
only guest = Yes
create mask = 0777
directory mask = 0777
browseable = Yes
public = yes

Disk is ext4 formatted with external power source. My pi has another external power source that I think is good. My /etc/fstab for the disk is:
/dev/sda1 /media/USBHDD ext4 auto,user,exec,rw,sync 0 0

Return to “Networking and servers”