You are not logged in.

#1 2013-06-23 13:44:51

archtom
Member
Registered: 2011-05-04
Posts: 58

[solved] too slow usb 3.0 write speed

Hey,

I have a new external USB 3.0 Western Digital 4 TB device for backups. I wrote a script for the backups to use rsync and I´m calling the script from terminal. The backup itself is working fine, but it is taking wayyyy too long. It is only writing to the external disk with 16 - 18 MB/s on an usb 3.0 port.

I already tried formatting the external drive ntfs and ext4, no real difference.

I searched around on the internet and this forum and found a tip to do this on every boot, but it makes no difference, too.

echo madvise > /sys/kernel/mm/transparent_hugepage/enabled
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag

Hope that anybody can help me with that. I don`t really know where to start and how to check what`s wrong.

Thanks

Last edited by archtom (2013-06-24 09:19:42)

Offline

#2 2013-06-23 13:59:45

hadrons123
Member
From: chennai
Registered: 2011-10-07
Posts: 1,249

Re: [solved] too slow usb 3.0 write speed

Sometimes it depends on the type of file you try. A single video file copies faster than a 1000 small bits of web-pages. I have experienced the same speed as yours. But NTFS->NTFS is usually slower. What is the size of the file you were moving?

Offline

#3 2013-06-23 14:10:05

archtom
Member
Registered: 2011-05-04
Posts: 58

Re: [solved] too slow usb 3.0 write speed

hadrons123 wrote:

Sometimes it depends on the type of file you try. A single video file copies faster than a 1000 small bits of web-pages. I have experienced the same speed as yours. But NTFS->NTFS is usually slower. What is the size of the file you were moving?

I tried a few kind of files, smaller and bigger, and even a bunch of files. It makes slight differences but the backup itself is slow if you take all files into consideration. You get the best impression if you take a really big file because you can really see the constant speed. I`m almost sure there is something wrong, perhaps with the kernel?

Offline

#4 2013-06-23 14:36:50

chord
Member
Registered: 2012-11-07
Posts: 121

Re: [solved] too slow usb 3.0 write speed

Your write speed looks as usual usb2.0
Did you have usb3 support enabled in your kernel .config and xhci_hcd module loaded?
If yes, what does 'hdparm -tT /dev/sdX' shows?

Offline

#5 2013-06-23 14:47:16

archtom
Member
Registered: 2011-05-04
Posts: 58

Re: [solved] too slow usb 3.0 write speed

chord wrote:

Your write speed looks as usual usb2.0
Did you have usb3 support enabled in your kernel .config and xhci_hcd module loaded?
If yes, what does 'hdparm -tT /dev/sdX' shows?

How do I check that if usb3 support is enabled? I´m using the default x86_64 kernel.

And how do I check if the xhci_hcd module is loaded? Will this command be o.k.?

lsmod | grep xhci_hcd

If yes, it seems loaded.

If it is not loaded, I do the following, right?

nano /etc/modules-load.d/usb.conf
xhci_hcd

And to what /dev/sdX is the hdparm referring to? To the external drive?

Sorry for so many questions but hopefully I will learn this stuff wink  thanks

Last edited by archtom (2013-06-23 15:04:27)

Offline

#6 2013-06-23 15:17:50

chord
Member
Registered: 2012-11-07
Posts: 121

Re: [solved] too slow usb 3.0 write speed

run as root:
zcat /proc/config.gz | grep XHCI_HCD
it will show if usb3 support enabled in your kernel.

here my zcat /proc/config.gz | grep XHCI_HCD output.

CONFIG_USB_XHCI_HCD=m
# CONFIG_USB_XHCI_HCD_DEBUGGING is not set

CONFIG_USB_XHCI_HCD should be set to "m" (for loading as module) or "y" (built-in-kernel)

If your kernel config already contains this option as "m" or "y", try to load module by running 'modprobe xhci_hcd' as root
If CONFIG_USB_XHCI_HCD is not set, kernel should be reconfigured and rebuilt.

/dev/sdX should point to your external drive, something like /dev/sdb or /dev/sdc. Correct value for your external drive could be obtained by running 'fdisk -l'

P.S.
By default CONFIG_USB_XHCI_HCD should be enabled in kernel config, so I think you just need to have xhci_hcd module to be loaded.

Last edited by chord (2013-06-23 15:22:34)

Offline

#7 2013-06-23 16:25:01

archtom
Member
Registered: 2011-05-04
Posts: 58

Re: [solved] too slow usb 3.0 write speed

thanks for your patience and your help, here are the three results

1   kernel module is loaded correctly on boot

lsmod | grep xhci_hcd
xhci_hcd               89743  0
usbcore               177091  4 ehci_hcd,ehci_pci,usbhid,xhci_hcd

2   usb3 is enabled correctly in kernel .config

zcat /proc/config.gz | grep XHCI_HCD
CONFIG_USB_XHCI_HCD=m
# CONFIG_USB_XHCI_HCD_DEBUGGING is not set

3   hdparm results (I don`t know if this is good or not)

hdparm -tT /dev/sdc1
/dev/sdc1:
Timing cached reads:   14576 MB in  2.00 seconds = 7304.61 MB/sec
Timing buffered disk reads: 388 MB in  3.01 seconds = 128.78 MB/sec

hope this helps solving the problem, thanks

any ideas?

Last edited by archtom (2013-06-23 18:16:00)

Offline

#8 2013-06-23 18:39:25

chord
Member
Registered: 2012-11-07
Posts: 121

Re: [solved] too slow usb 3.0 write speed

All seems fine, including hdparm output.
Try to check write process speed itself (without read latency):
mount somewhere your drive's partition and run as root:
dd if=/dev/zero of=<your-mount-point>/zero.bin bs=10M count=100
it will write 1Gb binary file to your drive and will report a write speed.
For example, I have a write speed 143Mb/sec (1Gb in 7.3 secs)
If you will get something like this speed, I think nothing to do with usb3 and write process and you should look for bottleneck somewhere else (maybe a slow read)

Offline

#9 2013-06-23 20:10:57

archtom
Member
Registered: 2011-05-04
Posts: 58

Re: [solved] too slow usb 3.0 write speed

chord wrote:

All seems fine, including hdparm output.
Try to check write process speed itself (without read latency):
mount somewhere your drive's partition and run as root:
dd if=/dev/zero of=<your-mount-point>/zero.bin bs=10M count=100
it will write 1Gb binary file to your drive and will report a write speed.
For example, I have a write speed 143Mb/sec (1Gb in 7.3 secs)
If you will get something like this speed, I think nothing to do with usb3 and write process and you should look for bottleneck somewhere else (maybe a slow read)

Thanks again, I had to do it twice, the first time the file was created really quick, the second time seems to give a correct result. My result is:

dd if=/dev/zero of=/media/OFFICE_PARK/zero.bin bs=10M count=100
100+0 Datensätze ein
100+0 Datensätze aus
1048576000 Bytes (1,0 GB) kopiert, 8,69448 s, 121 MB/s

seems o.k. So perhaps we can go on with your other suggestion:

1     So how do I check the read speed?

2     Can it have something to do with the backup command? I´m using

rsync -a -z -v --delete --progress --links --stats --human-readable

perhaps its
-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
or what seems reasonable is
-z, --compress              compress file data during the transfer
perhaps the compression slows the speed down?

3     Other possible bottlenecks?

Last edited by archtom (2013-06-23 20:26:56)

Offline

#10 2013-06-24 06:52:01

fledermann
Member
From: Bielefeld, Germany
Registered: 2013-06-24
Posts: 49

Re: [solved] too slow usb 3.0 write speed

Hi archtom,

you might want to make sure your blocksize is correctly aligned to the internal architechture of the flash drive.
The quick-and-dirty way: just don't use a partition table and create the fs on /dev/sdX directly. Works fine in linux, but I think windows won't accept that.
Additionally, you can disable the journal and use noatime when mounting, but the former bears a higher risk of data curruption.

Fledermann

Last edited by fledermann (2013-06-24 08:14:29)

Offline

#11 2013-06-24 09:19:16

archtom
Member
Registered: 2011-05-04
Posts: 58

Re: [solved] too slow usb 3.0 write speed

Yay, it`s working with around 80 MB / sec now with this command

rsync -a -v --delete --progress --links --stats --human-readable

So the -z option was causing the slowdown... When I read the options of rsync during the script creation it seemed like a good option, but now I think it is ment for use with slow connections, not with fast ones.

I don`t know if there is any other problem with the -a option, but I need a lot of stuff from this and the speed is o.k. for me now.

Thanks for all the help

Offline

#12 2016-12-15 16:22:29

albin75
Member
Registered: 2016-12-14
Posts: 1

Re: [solved] too slow usb 3.0 write speed

This post is interesting. I have been looking a few days now to figure out how to make the USB3.0 work properly.

But i do not understand how to change the -z option.

Offline

#13 2016-12-15 19:07:54

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,847
Website

Re: [solved] too slow usb 3.0 write speed

albin75, please do not necrobump old topics, especially when they are marked as solved.

https://wiki.archlinux.org/index.php/Co … bumping.22

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB