External USB storage on Raspberry PI 4 can be slow.

It is known the Raspberry PI firmware can have problems with USB sticks.
Can you perform some tuning on the OS , i.e. quircks, to improve write speeds.
Currently i have merely 0.5MB/s transfer write speed with a USB3.0 stick.
 
Here is a benchmark for my Armv7 Hummingboard with a mSATA installed. USB and microSD are pathetic.
Code:
root@generic:~ # diskinfo -wS /dev/ada0
/dev/ada0
        512             # sectorsize
        256060514304    # mediasize in bytes (238G)
        500118192       # mediasize in sectors
        0               # stripesize
        0               # stripeoffset
        496149          # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        SanDisk SD7SF6S256G1122 # Disk descr.
        162313400264    # Disk ident.
        ahcich0         # Attachment
        Yes             # TRIM/UNMAP support
        0               # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Synchronous random writes:
         0.5 kbytes:    832.1 usec/IO =      0.6 Mbytes/s
           1 kbytes:    829.9 usec/IO =      1.2 Mbytes/s
           2 kbytes:    835.1 usec/IO =      2.3 Mbytes/s
           4 kbytes:    747.1 usec/IO =      5.2 Mbytes/s
           8 kbytes:    803.6 usec/IO =      9.7 Mbytes/s
          16 kbytes:    849.0 usec/IO =     18.4 Mbytes/s
          32 kbytes:   1061.1 usec/IO =     29.5 Mbytes/s
          64 kbytes:   1477.6 usec/IO =     42.3 Mbytes/s
         128 kbytes:   1752.2 usec/IO =     71.3 Mbytes/s
         256 kbytes:   2450.0 usec/IO =    102.0 Mbytes/s
         512 kbytes:   3850.1 usec/IO =    129.9 Mbytes/s
        1024 kbytes:   6595.1 usec/IO =    151.6 Mbytes/s
        2048 kbytes:  11992.1 usec/IO =    166.8 Mbytes/s
        4096 kbytes:  22661.0 usec/IO =    176.5 Mbytes/s
Here is my benchmark for external -M.2 to USB3- jumbo thumbdrive:
Code:
root@generic:~ # diskinfo -Sw /dev/da0
/dev/da0
        512             # sectorsize
        2199023255040   # mediasize in bytes (2.0T)
        4294967295      # mediasize in sectors
        0               # stripesize
        0               # stripeoffset
        267349          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        ASMT 2115       # Disk descr.
        00000000000000000000    # Disk ident.
        umass-sim0      # Attachment
        No              # TRIM/UNMAP support
        Unknown         # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Synchronous random writes:
         0.5 kbytes: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 04 ff 6b 9d 00 00 01 00
(da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
(da0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
973026.4 usec/IO =      0.0 Mbytes/s
           1 kbytes:
dmesg
Code:
FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 06:33:09 UTC 2021
    root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm
FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
VT: init without driver.
No PSCI/SMCCC call function found
CPU: ARM Cortex-A9 r2p10 (ECO: 0x00000000)
CPU Features:
  Multiprocessing, Thumb2, Security, VMSAv7, Coherent Walk
Optional instructions:
  UMULL, SMULL, SIMD(ext)
LoUU:2 LoC:2 LoUIS:2
Cache level 1:
 32KB/32B 4-way data cache WB Read-Alloc Write-Alloc
 32KB/32B 4-way instruction cache Read-Alloc
real memory  = 1073741824 (1024 MB)
avail memory = 1035747328 (987 MB)
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
 
How about some more 32bit Arm numbers. This is the same 'M.2 drive to USB3' jumbo thumbdrive used above.
Raspberry Pi2 rev-1.1
Code:
root@generic:~ # diskinfo -Sw /dev/da0
/dev/da0
        512             # sectorsize
        256060514304    # mediasize in bytes (238G)
        500118192       # mediasize in sectors
        0               # stripesize
        0               # stripeoffset
        31130           # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        ASMT 2115       # Disk descr.
        00000000000000000000    # Disk ident.
        No              # TRIM/UNMAP support
        Unknown         # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Synchronous random writes:
         0.5 kbytes:   1355.0 usec/IO =      0.4 Mbytes/s
           1 kbytes:   1349.3 usec/IO =      0.7 Mbytes/s
           2 kbytes:   1375.0 usec/IO =      1.4 Mbytes/s
           4 kbytes:   1277.5 usec/IO =      3.1 Mbytes/s
           8 kbytes:   1394.1 usec/IO =      5.6 Mbytes/s
          16 kbytes:   1856.2 usec/IO =      8.4 Mbytes/s
          32 kbytes:   2601.2 usec/IO =     12.0 Mbytes/s
          64 kbytes:   3718.4 usec/IO =     16.8 Mbytes/s
         128 kbytes:   6548.8 usec/IO =     19.1 Mbytes/s
         256 kbytes:  12226.1 usec/IO =     20.4 Mbytes/s
         512 kbytes:  24138.0 usec/IO =     20.7 Mbytes/s
        1024 kbytes:  45574.9 usec/IO =     21.9 Mbytes/s
        2048 kbytes:  87460.0 usec/IO =     22.9 Mbytes/s
        4096 kbytes: 171299.7 usec/IO =     23.4 Mbytes/s
        8192 kbytes: 339765.8 usec/IO =     23.5 Mbytes/s

Code:
FreeBSD 12.2-RELEASE r366954 GENERIC arm
FreeBSD clang version 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
VT: init without driver.
CPU: ARM Cortex-A53 r0p4 (ECO: 0x00000080)
CPU Features:
  Multiprocessing, Thumb2, Security, Virtualization, Generic Timer, VMSAv7,
  PXN, LPAE, Coherent Walk
Optional instructions:
  SDIV/UDIV, UMULL, SMULL, SIMD(ext)
LoUU:2 LoC:3 LoUIS:2
Cache level 1:
 32KB/64B 4-way data cache WB Read-Alloc Write-Alloc
 32KB/64B 2-way instruction cache Read-Alloc
Cache level 2:
 512KB/64B 16-way unified cache WB Read-Alloc Write-Alloc
real memory  = 993312768 (947 MB)
avail memory = 956174336 (911 MB)
 
It is known the Raspberry PI firmware can have problems with USB sticks.
Can you perform some tuning on the OS , i.e. quircks, to improve write speeds.
Currently i have merely 0.5MB/s transfer write speed with a USB3.0 stick.
What's the benchmark you used, because perhaps that's the problem?

What file system? If you're using UFS, you will need to have soft updates enabled to get better speed.

I don't believe you will ever get full speed out of USB on FreeBSD because they have not implemented interrupts in the USB driver, however, that speed is pitiful and obviously something is wrong.
 
I dunno about USB sticks but the external drive connected to the pi4 seems to do nearly 70MB/s. This is with an equal amount of network traffic going into the pi4 (it's a NAS)
 
USB 3.0 (or 3.1, 3.2 etc) is merely an interface specification not a specification of actual performance. For example, you can install a 1000mm wide pipe for incoming water to your house but that doesn't mean it's going to be fully pressurized as your supplier might have a much smaller dimension. Most USB sticks performs quite poorly when not doing sequential writes and that's by "design", high tiers ones might be to handle such work patterns better but they're usually quite a bit far from a somewhat decent SSD (both SSD and NVME) in comparison.
 
Back
Top