Heater
Posts: 15841
Joined: Tue Jul 17, 2012 3:02 pm

Re: Stuttering when writing to a USB

Sat Jan 07, 2017 7:34 pm

Reading all the posts here, without following the details so much, I think we have two different discussions going on:

1) Is about total throughput, over some time, from net to disk. Or vice versa.

2) Is about instantaneous action. The "stuttering" thing that the OP started with.


As far as I can tell, Unix and Linux strive for optimal throughput, rather than worry about timing determinism.

That is to say, if I can move some giga bytes of stuff from A to B in 5 minutes instead of 10, then why would I worry if it stalls for some seconds here and there?

Of course such overall optimization is a pain if you actually want some real-time determinism.
Memory in C++ is a leaky abstraction .

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Sat Jan 07, 2017 10:10 pm

THERES NO THROUGHPUT IN MY NETWORK
I made it because i can properly attach you an example of what my problem is. If you copy something without using the network, just in local, it stutters sooooo much. The graphs that you see from LAN to LAN are the same that i could get if i copy something in rpi.
Just tell me how can it take 7 minutes to copy a 4GB file in USBs that can take easily 130 MB/s reading and 50 MB/s writing under 3.0. If you use 2.0 its maximum speed is 21 MB/s. It should take like 3 minutes, and instead it took more than 6! You know why? because it can start coping at 20 MB/s, but after some seconds it gonna stops copying and continue after a couple of seconds.

I know it can't perform as a normal machine, but please, it can't do well a simple task like copy a file. And it's not just copying files, it happens with everything, systems stutters too when it reads/writes something from SD. I just want to know if thats normal or i have to rma my rpi.

levelcrow
Posts: 47
Joined: Tue Aug 12, 2014 5:04 pm

Re: Stuttering when writing to a USB

Sun Jan 08, 2017 12:04 am

I didn't read the thread closely, but I wanted to post that I have seen what I think is similar behavior however in a different context.

I have my root filesystem on a USB drive and often run an rsync of the root directory to another USB drive to back my files up. Sometimes during the rsync process the writing suddenly stops and CPU usage dips down very low. There's a delay for a couple seconds before the seeming stall stops and rsync continues moving fast.

I always suspected this was because of my disk settings - I have my dirty ratio quite high and my expire_centisecs is very large. I set this up so as to minimize writes to disk and make my desktop experience snappier, particularly because the USB 2.0 drives I use don't have a fast on-disk cache. I always assumed the lagging was a bunch of writing to disk after the dirty ratio is surpassed, and maybe it is.

But maybe it isn't. I'm using a Raspberry Pi 3 with stock Raspbian.

ejolson
Posts: 5207
Joined: Tue Mar 18, 2014 11:47 am

Re: Stuttering when writing to a USB

Sun Jan 08, 2017 7:29 pm

EnfermeraSexy wrote:Just tell me how can it take 7 minutes to copy a 4GB file in USBs that can take easily 130 MB/s reading and 50 MB/s writing under 3.0. If you use 2.0 its maximum speed is 21 MB/s. It should take like 3 minutes, and instead it took more than 6! You know why? because it can start coping at 20 MB/s, but after some seconds it gonna stops copying and continue after a couple of seconds.
If it takes 3.3 minutes to read a 4GB file at 20 MB/sec and similarly 3.3 minutes to write the file at 20 MB/sec, a total elapsed time of around 6.6 minutes is expected. One should remember that the Raspberry Pi has only one USB channel that is multiplexed using an onboard hub. By design read from one device and write to the other do not occur in parallel.

Have you tried using higher quality USB cables?

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Sun Jan 08, 2017 8:38 pm

ejolson wrote:If it takes 3.3 minutes to read a 4GB file at 20 MB/sec and similarly 3.3 minutes to write the file at 20 MB/sec, a total elapsed time of around 6.6 minutes is expected. One should remember that the Raspberry Pi has only one USB channel that is multiplexed using an onboard hub. By design read from one device and write to the other do not occur in parallel.

Have you tried using higher quality USB cables?
It's the USB channel shared with sd card?
My cables are high quality cables (Aukey).

levelcrow wrote:I didn't read the thread closely, but I wanted to post that I have seen what I think is similar behavior however in a different context.

I have my root filesystem on a USB drive and often run an rsync of the root directory to another USB drive to back my files up. Sometimes during the rsync process the writing suddenly stops and CPU usage dips down very low. There's a delay for a couple seconds before the seeming stall stops and rsync continues moving fast.

I always suspected this was because of my disk settings - I have my dirty ratio quite high and my expire_centisecs is very large. I set this up so as to minimize writes to disk and make my desktop experience snappier, particularly because the USB 2.0 drives I use don't have a fast on-disk cache. I always assumed the lagging was a bunch of writing to disk after the dirty ratio is surpassed, and maybe it is.

But maybe it isn't. I'm using a Raspberry Pi 3 with stock Raspbian.
It's the exact same problem, just in other tasks

ejolson
Posts: 5207
Joined: Tue Mar 18, 2014 11:47 am

Re: Stuttering when writing to a USB

Mon Jan 09, 2017 8:02 pm

EnfermeraSexy wrote:It's the USB channel shared with sd card?
My cables are high quality cables (Aukey).
As far as I know, the sdcard is separate. However, it could be much slower.

Theoretically USB2 has a 480 Mbit bandwidth of which about half is usable. This seems confirmed by these tests of the WD Pi drive. If you get in the neighborhood of 16 MB/sec with a disk to disk copy that would further confirm your Pi is working as expected.

It is difficult to ignore the graphs as they seem to indicate significant difference between NTFS and EXT4 performance. Is it possible the tests were made under different conditions with the NTFS filesystem on a USB drive but the EXT4 filesystem on the sdcard?

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Tue Jan 10, 2017 3:38 pm

ejolson wrote:As far as I know, the sdcard is separate. However, it could be much slower.

Theoretically USB2 has a 480 Mbit bandwidth of which about half is usable. This seems confirmed by these tests of the WD Pi drive. If you get in the neighborhood of 16 MB/sec with a disk to disk copy that would further confirm your Pi is working as expected.

It is difficult to ignore the graphs as they seem to indicate significant difference between NTFS and EXT4 performance. Is it possible the tests were made under different conditions with the NTFS filesystem on a USB drive but the EXT4 filesystem on the sdcard?
I'm sure i used my USB drive instead of the SD.
Is this the test you were looking for?

Code: Select all

pi@raspberrypi:~ $ sudo dd if=/dev/sda1 of=test bs=1048576 count=200
200+0 registros leídos
200+0 registros escritos
209715200 bytes (210 MB) copiados, 33,2309 s, 6,3 MB/s
pi@raspberrypi:~ $ sudo dd if=test of=/dev/sda1 bs=1048576
200+0 registros leídos
200+0 registros escritos
209715200 bytes (210 MB) copiados, 14,1249 s, 14,8 MB/s

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Sat Jan 14, 2017 3:48 pm

Hey!! I'm there with new test! I tried my HDD USB 2.0 and magically it works perfectly with rpi... there's no stutter int NTFS or EXT4.

I thought it could be the 4k reads and bla bla bla. I formatted them with the same filesystem, same blocks, same label etc etc and made some test with crystaldisk under my windows machine.
First of all i used them in the same 2.0 port.

HDD
Image

USB
Image
USB under 3.0
Image

Ok, write speed it's just a bit slower but wtf man, just see reads and writes under 4k...
I used same config to mount under rpi, same port... everything it's the same. I don't have external supply for HDD, it's just connected to the rpi.

Does anyone knows why is this happening?

PD: in log that i had attached i can see this line

Code: Select all

[    3.224189] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Could it be the problem?

tpylkko
Posts: 408
Joined: Tue Oct 14, 2014 5:21 pm

Re: Stuttering when writing to a USB

Sat Jan 14, 2017 7:37 pm

I have seen other benchmarks on the internet where ntfs results have been completely out of whack. I have read the explanation mentioned also in this thread earlier that other filesystems have code that works in kernel space whereas ntfs goes through fuse and therefore such results are not directly comparable.

the kernel message from dmesg above is normal for such simple storage devices AFAIK.

also, it is easily possible to misconfigure samba so that you get stuttering and other performance issues. Many blog sts about this are on the net.

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Sat Jan 14, 2017 8:43 pm

tpylkko wrote:I have seen other benchmarks on the internet where ntfs results have been completely out of whack. I have read the explanation mentioned also in this thread earlier that other filesystems have code that works in kernel space whereas ntfs goes through fuse and therefore such results are not directly comparable.

the kernel message from dmesg above is normal for such simple storage devices AFAIK.

also, it is easily possible to misconfigure samba so that you get stuttering and other performance issues. Many blog sts about this are on the net.
I'm getting stuttering in every app that uses USB. Samba is working properly under HDD, so we can discard bad configs.

ejolson
Posts: 5207
Joined: Tue Mar 18, 2014 11:47 am

Re: Stuttering when writing to a USB

Mon Jan 16, 2017 4:30 pm

EnfermeraSexy wrote:Hey!! I'm there with new test! I tried my HDD USB 2.0 and magically it works perfectly with rpi... there's no stutter int NTFS or EXT4.
The output of the first CrystalDiskMark seems to indicate the HDD is 10 times slower for 4K reads and writes. How is that better than the metrics for the USB and USB under 3.0 drives?

EnfermeraSexy
Posts: 17
Joined: Mon Jan 02, 2017 6:19 pm

Re: Stuttering when writing to a USB

Mon Jan 16, 2017 6:44 pm

ejolson wrote:The output of the first CrystalDiskMark seems to indicate the HDD is 10 times slower for 4K reads and writes. How is that better than the metrics for the USB and USB under 3.0 drives?
I don't know... i told you that my flash drive was really good, maybe flash memory it's build in a similar memory as SSD?

Return to “General discussion”