chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 5:40 pm

Hi!, first of a diagram of the devices:

Image

Western Digital 2.5 4 TB USB 3.0 hdd
Raspberry pi 3 with Raspbian Buster / samba version 4.9.5-Debian
Fire TV 4k with Kodi 18.5

Long post warning, there is a TLDR at the bottom!

Background:

I always used a raspberry pi (since rpi1 days), to stream media files to kodi without a problem (files around 3 to 18 Mbps of video bitrate). The rpi3 runs smb, pymedusa and transmission-daemon. The problem started out nowhere, with no apparent changes to my setup.

The Problem:

Around 3 weeks ago, I started to get random buffering problems (around 5-10 seconds) when watching video on Kodi, any type of file, small 500-800 MB files (3mbps bitrate) files or big 15 GB files with higher bitrate. I never had this problem before. This happens sometimes only

Troubleshooting:

I first assumed it could be a Kodi problem, so I started messing with buffering settings with no luck (Never had to do this). I also updated to latest version.

I had installed an old FireTV that I have meaning to upgrade to latest one (4k) for a while, So I did that and installed and configured Kodi from scratch. Same problem

I also tried to stream 2 small files at the same time, one using kodi on the firetv, one using vlc on a windows 10 laptop, they both buffered at exact same time.

So I moved to network problems, I did some speed tests:

IPERF Tests:

IPERF Fire TV 4k (Wireless) <---- ~130 Mbps ----> win10 desktop (Wired)
IPERF Fire TV 4k (Wireless) <---- ~95 Mbps ----> rpi3 (Wired)
IPERF Win10 Desktop (Wired) <---- ~95 Mbps ----> rpi3 (Wired)

SMB/CIFS File Transfer Tests:

Fire TV 4k (Wireless) <---- ~65 Mbps--------rpi3 (Wired)
Fire TV 4k (Wireless) <---- ~104 Mbps------Win10 Desktop (Wired)
Win10 Desktop (Wired) <---- ~85 Mbps-----rpi3 (Wired)
Win10 Laptop (Wireless) <---- ~85 Mbps----rpi3 (Wired)

So everything in the network looks good , keep in mind I get buffering problems trying to stream a small 2-3 Mbps video bitrate file (Around 500-800 MB in size).

So I copied some of the video files to my Desktop PC and shared them via smb/cifs in windows 10, added the share in kodi, and buffering problems disappeared, any type of file streamed perfectly. So this led me to believe the problem was the raspberry pi itself.

So the first thing I did was turn off transmission, pymedusa, etc except samba, the problem persisted. I also was doing some testing with docker and unifi controller container and also homeassistant with it, I stopped everything.

At the time I was running raspbian stretch, and I think the problem started after doing an apt update; apt dist-upgrade, and rebooting some time later.

I backed up everything, grabbed a new sd card and installed latest raspbian buster on it, configured the external ext4 drive mount and samba only. The problem persisted: random buffering on any type of file. I also configured NFS on the pi and kodi and the problem was the same.

I used another new sd card and installed latest openmediavault raspberry pi version on it, and setup the samba share. The problem persisted.
So I went back the sd card with the new buster install on it, and started doing some more testing:

-Started bmon on the raspberry pi and started playing a small file on the FireTV/Kodi, I could see the sudden drop on speed on the graph when the 5-10 seconds buffering started.

-Started playing a small file on the FireTV/Kodi and also at the same time started a throttled (So I don’t use up all the bandwidth) smb copy using robocopy, from the raspberry pi to my desktop pc. When buffering started, I could see the speed drop on bmon on the pi, and also in the copy I was doing to my wired desktop (was also looking at Ethernet graph on the desktop).

-Copied a video file to the internal sd card of the pi, and started again playing a file on the FireTV from the usb hard drive, and at the same time started a copy from the internal sd to my desktop pc. When the buffering started I could see the drop in speed in the stream, but not in the copy to the desktop.

So, I guess it’s a problem reading from the usb hdd and not the Ethernet port of the raspberry pi.

I plugged a 32gb flash drive , formatted as ext4 , moved some files there and shared them via samba, and I played the files from it perfectly, no buffering, no slowdown, anything.

So I’m 99% sure it’s a problem with usb hard drive

I ran fsck on the disk, smarttools, everything I could think, and it reports no errors:

Smart Output:

Code: Select all

pi@raspberrypi3:~ $ sudo smartctl -a /dev/sdc -d sat
smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.75-v7+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Elements / My Passport (USB, AF)
Device Model:     WDC WD40NMZW-11GX6S1
Serial Number:    WD-WX41D38KZPD2
LU WWN Device Id: 5 0014ee 00482c3cf
Firmware Version: 01.01A01
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Dec  9 12:43:38 2019 -03
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (19440) seconds.
Offline data collection
capabilities:                    (0x1b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        No Conveyance Self-test supported.
                                        No Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 700) minutes.
SCT capabilities:              (0x30b5) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   253   253   021    Pre-fail  Always       -       3316
  4 Start_Stop_Count        0x0032   099   099   000    Old_age   Always       -       1750
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   083   083   000    Old_age   Always       -       12430
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       137
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       127
193 Load_Cycle_Count        0x0032   097   097   000    Old_age   Always       -       311218
194 Temperature_Celsius     0x0022   102   096   000    Old_age   Always       -       50
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

Selective Self-tests/Logging not supported

I also ran “dstat -D sdb” when the buffering happens, you can see the slowdown on the read column:
Note: at the time I ran this, sdb was 4tb usb drive

Image

I ran hdparm on the 4tb disk and the 32gb usb drive, with similar results:

Western Digital 4TB 2.5 Hard Drive:

Code: Select all

pi@raspberrypi3:~ $ sudo hdparm -tT /dev/sdc

/dev/sdc:
 Timing cached reads:   1362 MB in  2.00 seconds = 680.98 MB/sec
 Timing buffered disk reads:  80 MB in  3.03 seconds =  26.44 MB/sec

Samsung 32 GB usb flash drive:

Code: Select all

pi@raspberrypi3:~ $ sudo hdparm -tT /dev/sdb

/dev/sdb:
 Timing cached reads:   1264 MB in  2.00 seconds = 631.71 MB/sec
SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 Timing buffered disk reads:  82 MB in  3.04 seconds =  26.96 MB/sec

Dmesg HDD output (caching mode page error seems to be normal after googling it):


Image

I have no idea what to do next, or what could be causing the random slowdown reading from the hard drive. Physical problem with the drive?, but it seems there is no problem with it.

Thanks!

TLDR: Having problems reading files over network, it randomly slowdowns and causes buffering on the media player, after months of everything working perfectly it suddenly happened. I think it’s a problem with USB Hard Drive itself, I plugged a flash drive, shared it and it didn’t present any problems. But is seems the hard drive is in perfect condition.
Last edited by chimi on Mon Dec 09, 2019 8:48 pm, edited 2 times in total.

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

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 7:03 pm

chimi wrote:
Mon Dec 09, 2019 5:40 pm
TLDR: Having problem reading files over network, it randomly slowdowns and causes buffering on the media player, after months of everything working perfectly it suddenly happened. I think it’s a problem with USB Hard Drive itself, I plugged a flash drive and shared it and it didn’t present any problems. But is seems the hard drive is in perfect condition.
I'm very impressed with your post, both the graphics and the clarity of the writing. Maybe the HD is spinning down and going to sleep, then takes a while to spin back up, at which point the buffer underruns happen. If so, why this changed when upgrading the operating system is a mystery. Maybe there are differences in default mount parameters or smartctl is intentionally putting the drive to sleep. Good luck tracking the problem down.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 7:45 pm

ejolson wrote:
Mon Dec 09, 2019 7:03 pm
I'm very impressed with your post, both the graphics and the clarity of the writing. Maybe the HD is spinning down and going to sleep, then takes a while to spin back up, at which point the buffer underruns happen. If so, why this changed when upgrading the operating system is a mystery. Maybe there are differences in default mount parameters or smartctl is intentionally putting the drive to sleep. Good luck tracking the problem down.

Thank you!, English is not my primary language and tried to show the problem as clearly as possible. I did toyed around with different fstab mount parameters with no luck and same results (right now using defaults,user,rw,noatime ). Default mount parameters worked perfectly with usb flash drive.

Good suggestion about smartctl, going to investigate that too, thanks.

One extra thing I want to try is to download an old rapsbian version (stretch), not update and test on it, and for the time being I think Im going to downgrade the usb hdd to and old 1tb drive I have and see how it goes.

rtramon
Posts: 13
Joined: Sat Jul 07, 2012 10:06 am
Location: 't Gooi

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 7:51 pm

Perhaps the harddisk suffers from “critical media error”, which slows down HD throughput. The output of dmesg would show that.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 8:21 pm

Thanks for the reply. dmesg shows no errors when the slowdown/buffering happens

swampdog
Posts: 288
Joined: Fri Dec 04, 2015 11:22 am

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 8:47 pm

This is more usual output from smartctl..

Code: Select all

foo@pi19:~ $ lsscsi
[0:0:0:0]    disk    asmedia  ASMT1153e        0     /dev/sda 
[1:0:0:0]    disk    JMicron  Tech             0203  /dev/sdb 
[2:0:0:0]    disk    JMicron  Tech             0203  /dev/sdc 
[3:0:0:0]    disk    JMicron  Tech             0203  /dev/sdd

foo@pi19:~ $ sudo smartctl -a /dev/sdd

smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.66-v7l+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     Hitachi HUA5C3030ALA640
Serial Number:    MJ0331YNG94R6A
LU WWN Device Id: 5 000cca 228c4290b
Firmware Version: MEAOAA10
User Capacity:    3,000,592,982,016 bytes [3.00 TB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    5700 rpm
Form Factor:      3.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 2.6, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Dec  9 20:15:08 2019 GMT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
                                        was completed without error.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever 
                                        been run.
Total time to complete Offline 
data collection:                (   28) seconds.
Offline data collection
capabilities:                    (0x5b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        No Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine 
recommended polling time:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 581) minutes.
SCT capabilities:              (0x003d) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   016    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   135   135   054    Pre-fail  Offline      -       107
  3 Spin_Up_Time            0x0007   123   123   024    Pre-fail  Always       -       564 (Average 568)
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       274
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   124   124   020    Pre-fail  Offline      -       36
  9 Power_On_Hours          0x0012   093   093   000    Old_age   Always       -       52233
 10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       235
192 Power-Off_Retract_Count 0x0032   098   098   000    Old_age   Always       -       2424
193 Load_Cycle_Count        0x0012   098   098   000    Old_age   Always       -       2424
194 Temperature_Celsius     0x0002   187   187   000    Old_age   Always       -       32 (Min/Max 13/56)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     49829         -
# 2  Short offline       Completed without error       00%     49821         -
# 3  Short offline       Completed without error       00%     49809         -
# 4  Short offline       Completed without error       00%     49798         -
# 5  Short offline       Completed without error       00%     49790         -
# 6  Short offline       Completed without error       00%     49780         -
# 7  Short offline       Completed without error       00%     49762         -
# 8  Short offline       Completed without error       00%     49738         -
# 9  Extended offline    Completed without error       00%     49725         -
#10  Extended offline    Completed without error       00%     49715         -
#11  Short offline       Completed without error       00%     49701         -
#12  Short offline       Completed without error       00%     49693         -
#13  Short offline       Completed without error       00%     49684         -
#14  Extended offline    Completed without error       00%     49663         -
#15  Short offline       Completed without error       00%     49649         -
#16  Short offline       Completed without error       00%     49634         -
#17  Short offline       Completed without error       00%     49612         -
#18  Short offline       Completed without error       00%     49606         -
#19  Short offline       Completed without error       00%     49585         -
#20  Short offline       Completed without error       00%     49561         -
#21  Short offline       Completed without error       00%     49543         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
The actual fields (ID#) vary from disk to disk.

This bit..
Selective Self-tests/Logging not supported
..I'm a bit unsure about. Are you able to actually initiate a test?

Code: Select all

# smartctl -t short /dev/sdc
^^^possibly with "-d sat"? If so, perform a (-t long) test.

If it doesn't work then you'll need to attach the disk to a PC and run 'smartctl' there. Note that increasingly these days cheap (and not so cheap) esata caddies don't work properly so unless you've got one which is known to be okay you're better off cabling the disk directly to a sata port on your PC.

The temperature on your disk seems a bit high. However I'm not sure we can trust the results when it's coming through (I assume, a usb hub) but otherwise appears fine. Like yourself, I'm not sure it is - for whatever reason. I'm usually wary (for instance) of needing to use "-d sat" option unless it's previously known to work.

I picked the above hitachi disk because it doesn't play ball nicely with smartmontools but still supplies more data than you're getting.

[edit]: There's also "-x" option (rather than "-a") but that may not help if the hub is interfering.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Mon Dec 09, 2019 9:11 pm

Hi! thanks for the reply

The disk is connected directly to the pi, It's this one: https://shop.westerndigital.com/product ... 40BBK-WESN

The enclosure has no apparent way of opening it without breaking it, so I can't connect it directly to my pc.

Since it's usb only, the only way to access smart features It's with the -d sat switch, I got that info from :

https://www.smartmontools.org/wiki/Supp ... SB-Devices

My hdd is 0x1058:0x25a1

I forgot to actually run tests on it! ha , I just did a :

Code: Select all

pi@raspberrypi3:~ $ sudo smartctl -t short /dev/sdc -d sat
smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.75-v7+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 2 minutes for test to complete.
Test will complete after Mon Dec  9 17:54:19 2019

Use smartctl -X to abort test.

Trimmed output after 2 minutes:

Code: Select all

....
SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     12435         -

Selective Self-tests/Logging not supported

And executed a long test:

Code: Select all

pi@raspberrypi3:~ $ sudo smartctl -t long /dev/sdc -d sat
smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.75-v7+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 702 minutes for test to complete.
Test will complete after Tue Dec 10 05:40:11 2019

Use smartctl -X to abort test.

It's going to take a while (12 hours is that normal?), so I report later .

Thank you again!

swampdog
Posts: 288
Joined: Fri Dec 04, 2015 11:22 am

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Tue Dec 10, 2019 6:17 am

chimi wrote:
Mon Dec 09, 2019 9:11 pm

And executed a long test:

Code: Select all

pi@raspberrypi3:~ $ sudo smartctl -t long /dev/sdc -d sat
smartctl 6.6 2017-11-05 r4594 [armv7l-linux-4.19.75-v7+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 702 minutes for test to complete.
Test will complete after Tue Dec 10 05:40:11 2019

Use smartctl -X to abort test.

It's going to take a while (12 hours is that normal?), so I report later .

Thank you again!
Hmm, probably ok. I'm not familiar with long tests via usb. The last time I had a 4Tb drive do a long test (in an esata caddy) it was estimated to be 486 minutes. You can see the status by doing "smartctl -a" once in a while and looking for "Self-test execution status". I must admit I don't know how the test is implemented: I've always assumed it's a single command sent to the disk (rather than multiple commands sent by smartd) but I could easily be wrong. If I am correct though, the time will depend on the drive & its firmware.

User avatar
DougieLawson
Posts: 36820
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Tue Dec 10, 2019 6:39 am

Have you considered that it may be GitHub.com that is rate limiting your downloads?

I've got a version of rpi-update that works from a one shot download that's hosted on my Raspberry Pi. You only need the ../commits & ../tarball folders to get that running.

If you run rpi-update natively then GitHub blocks the sixth machine for half an hour with its crass rate limiting.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Tue Dec 10, 2019 5:52 pm

swampdog wrote:
Tue Dec 10, 2019 6:17 am

Hmm, probably ok. I'm not familiar with long tests via usb. The last time I had a 4Tb drive do a long test (in an esata caddy) it was estimated to be 486 minutes. You can see the status by doing "smartctl -a" once in a while and looking for "Self-test execution status". I must admit I don't know how the test is implemented: I've always assumed it's a single command sent to the disk (rather than multiple commands sent by smartd) but I could easily be wrong. If I am correct though, the time will depend on the drive & its firmware.

Long/Extended test finished a few hours ago with no errors:

Code: Select all

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     12454         -
# 2  Extended captive    Interrupted (host reset)      90%     12442         -
# 3  Extended captive    Interrupted (host reset)      90%     12442         -
# 4  Short captive       Interrupted (host reset)      90%     12440         -
# 5  Short offline       Aborted by host               50%     12440         -
# 6  Short offline       Completed without error       00%     12435         -

Selective Self-tests/Logging not supported
Back to square one , ha.

Few test I have left to make:
-Use an old rapsbian version without updating it
-Replace the 4tb drive with a 1tb drive I have

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Tue Dec 10, 2019 7:06 pm

I also ran e4defrag and reported no fragmentation too:

Code: Select all

 
 Total/best extents                             175796/133659
 Average size per extent                        10610 KB
 Fragmentation score                            0
 [0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
 This directory (/mnt/RaspberryPI_NAS/) does not need defragmentation.
 Done.

swampdog
Posts: 288
Joined: Fri Dec 04, 2015 11:22 am

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Wed Dec 11, 2019 10:58 am

I doubt fragmentation would be an issue.

Might still be worth plugging it into your PC.

Raspbian:

Code: Select all

foo@pi18:/wrk $ chmod u+x z.sh && cat z.sh && ./z.sh
#!/bin/bash

C=2097152
D="/wrk"

dd if=/dev/urandom of="$D"/z bs=1024 count="$C" status=progress
echo "^^^ignore timing here 'cos of urandom"

time (rm -f "$D"/zz;sync;dd if="$D"/z of="$D"/zz status=progress;sync);echo
sync;dd if="$D"/zz of=/dev/null status=progress

rm -d "$D"/z "$D"/zz

2140047360 bytes (2.1 GB, 2.0 GiB) copied, 103 s, 20.8 MB/s
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 103.357 s, 20.8 MB/s
^^^ignore timing here 'cos of urandom
2132571648 bytes (2.1 GB, 2.0 GiB) copied, 63 s, 33.9 MB/s 
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 63.4449 s, 33.8 MB/s

real	1m3.697s
user	0m3.719s
sys	0m59.632s

2053603840 bytes (2.1 GB, 1.9 GiB) copied, 19 s, 108 MB/s
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 19.9036 s, 108 MB/s
..making C bigger (/wrk has only 5G free here) and noting the above is an SSD disk.

Repeat the above on the PC. If you use a live linux iso (eg: linux mint) then note it is possible to..

Code: Select all

$ sudo su -
# apt get install ..
..into the live environment should you wish to use some of the tools you installed under raspian. 'lsblk' and 'parted' to confirm you've got the correct disk. I'm not sure if the disk will automount or not.

The above pair of tests should tell you if the disk is okay or if the problem lies with the rpi usb.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Thu Dec 12, 2019 7:58 pm

Hi sorry the delay, first of all, I tested an old version of raspbian (stretch) without updating , I had to run apt update to install samba, because old package were not available in the mirror, but didn't run apt upgrade or dist-upgrade. Same results still buffering.

This are the usb hard drive tests:

Didn't change 2gb size because of time, 4tb drive writing was slow, started around 20mb/s and went down to 5-6mb/s)


USB 4 TB Hard Drive on RPI3 - USB 2.0 Connection

Code: Select all

2147165184 bytes (2.1 GB, 2.0 GiB) copied, 329.1 s, 6.5 MB/s   
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 347.682 s, 6.2 MB/s
^^^ignore timing here 'cos of urandom
2127071232 bytes (2.1 GB, 2.0 GiB) copied, 597 s, 3.6 MB/s    
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 597.655 s, 3.6 MB/s

real	10m3.520s
user	0m6.467s
sys	1m0.579s

2138423808 bytes (2.1 GB, 2.0 GiB) copied, 68.0012 s, 31.4 MB/s
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 68.5143 s, 31.3 MB/s
USB Flash drive 32 GB on RPI3 - USB 2.0 Connection

Code: Select all

2147311616 bytes (2.1 GB, 2.0 GiB) copied, 128.015 s, 16.8 MB/s 
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 128.028 s, 16.8 MB/s
^^^ignore timing here 'cos of urandom
2136850944 bytes (2.1 GB, 2.0 GiB) copied, 206 s, 10.4 MB/s    
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 206.466 s, 10.4 MB/s

real	3m40.624s
user	0m5.659s
sys	0m56.690s

2115812352 bytes (2.1 GB, 2.0 GiB) copied, 64 s, 33.1 MB/s      
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 64.9525 s, 33.1 MB/s


USB 4 TB Hard Drive on DesktopPC - USB 2.0 Connection

Image

USB 32GB Flash drive on on DesktopPC - USB 2.0 Connection

Image

Connected via 3.0 usb:

USB 4 TB Hard Drive on DesktopPC - USB 3.0 Connection

Image

USB 32GB Flash drive on on DesktopPC - USB 3.0 Connection

Image

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Thu Dec 12, 2019 9:27 pm

I booted debian on the desktop, connected the 4tb drive and configured samba . Streams perfectly no buffering.

So I guess is not the drive?

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

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 2:15 am

chimi wrote:
Thu Dec 12, 2019 9:27 pm
I booted debian on the desktop, connected the 4tb drive and configured samba . Streams perfectly no buffering.

So I guess is not the drive?
I think the default Samba protocol and encryption level changed in the last year or two. Maybe the 3B can't efficiently stream the more secure versions. I think SMB version 1 is still available, but needs to be explicitly enabled. Have you tried doing this to see if it helps?

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 2:18 am

ejolson wrote:
Fri Dec 13, 2019 2:15 am
chimi wrote:
Thu Dec 12, 2019 9:27 pm
I booted debian on the desktop, connected the 4tb drive and configured samba . Streams perfectly no buffering.

So I guess is not the drive?
I think the default Samba protocol and encryption level changed in the last year or two. Maybe the 3B can't efficiently stream the more secure versions. I think SMB version 1 is still available, but needs to be explicitly enabled. Have you tried doing this to see if it helps?
Thanks for the reply, yes I tested version 1 too. Setting it via client (kodi) and also on smb.cfg . I also tried nfs .

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 2:19 am

I think I fixed it, I decided to test on the raspberry an Y usb 3.0 cable I had laying around (to give extra power to the hard drive, the extra usb cable I connected to my router usb port)

This one:
Image

Speeds are now much better:

Code: Select all

2138420224 bytes (2.1 GB, 2.0 GiB) copied, 230 s, 9.3 MB/s  
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 230.946 s, 9.3 MB/s
^^^ignore timing here 'cos of urandom
2139016192 bytes (2.1 GB, 2.0 GiB) copied, 328 s, 6.5 MB/s 
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 328.296 s, 6.5 MB/s

real	5m41.714s
user	0m7.154s
sys	1m19.470s

2146812416 bytes (2.1 GB, 2.0 GiB) copied, 71 s, 30.2 MB/s 
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 71.0697 s, 30.2 MB/s


Going to test playback on the firetv later and report back.

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 3:42 am

Just tested and it works perfectly with the y cabled I connected.

No idea what happened.

It worked perfectly for months with just the regular usb cable (the one it came bundled to the hard drive).

Maybe somehow the raspberry pi 3 stopped giving the amps necessary to it, I don't know.

The rpi3 is powered with the official 2.5a power supply.

swampdog
Posts: 288
Joined: Fri Dec 04, 2015 11:22 am

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 8:59 am

Glad you sorted it. Sometimes bad luck can just keep on giving.

I had a fair bit of trouble with my first rpi4 and usb/ssd ..and adapters. New hardware. New OS (buster). Firmware/power issues on the forum. New ssd. New everything. Went through multiple adapters - they all worked on a PC as well. C'est la vie!

chimi
Posts: 12
Joined: Mon Dec 09, 2019 4:31 pm

Re: Random speed slowdown reading files from connected usb hard drive on rpi3 (not a network problem)

Fri Dec 13, 2019 5:36 pm

swampdog wrote:
Fri Dec 13, 2019 8:59 am
Glad you sorted it. Sometimes bad luck can just keep on giving.

I had a fair bit of trouble with my first rpi4 and usb/ssd ..and adapters. New hardware. New OS (buster). Firmware/power issues on the forum. New ssd. New everything. Went through multiple adapters - they all worked on a PC as well. C'est la vie!
I'm glad it's fixed too , it was driving me crazy ha.

And thanks for all your help !

Return to “Troubleshooting”