[solved] What am I doing wrong? (Speed on USB attached disk)

Post Reply
domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

[solved] What am I doing wrong? (Speed on USB attached disk)

Unread post by domih » Mon Apr 15, 2019 2:46 pm

Both N2 and UX4 with eMMC 128GB, Ubuntu 18.04. All over console mode via SSH (X not running). Using iozone3.
USB 3 case via an ANKER USB 3 hub. Both unpowered. Disk: a laptop 320GB from my stash.

XU4

Code: Select all

root@xu4a:/media/domih# iozone -i 0 -s 1g -t 2
        Iozone: Performance Test of File I/O
                Version $Revision: 3.429 $
                Compiled for 32 bit mode.
                Build: linux

        Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
                     Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
                     Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
                     Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
                     Vangel Bojaxhi, Ben England, Vikentsi Lapa.

        Run began: Sun Apr 14 21:33:57 2019

        File size set to 1048576 kB
        Command line used: iozone -i 0 -s 1g -t 2
        Output is in kBytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 kBytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
        Throughput test with 2 processes
        Each process writes a 1048576 kByte file in 4 kByte records

        Children see throughput for  2 initial writers  =   85521.12 kB/sec
        Parent sees throughput for  2 initial writers   =   80130.00 kB/sec
        Min throughput per process                      =   42519.87 kB/sec
        Max throughput per process                      =   43001.25 kB/sec
        Avg throughput per process                      =   42760.56 kB/sec
        Min xfer                                        = 1037208.00 kB

        Children see throughput for  2 rewriters        =   83022.19 kB/sec
        Parent sees throughput for  2 rewriters         =   78345.90 kB/sec
        Min throughput per process                      =   41461.14 kB/sec
        Max throughput per process                      =   41561.05 kB/sec
        Avg throughput per process                      =   41511.09 kB/sec
        Min xfer                                        = 1046060.00 kB
N2

Code: Select all

domih@n2a:/media/usb0$ iozone -i 0 -s 1g -t 2
        Iozone: Performance Test of File I/O
                Version $Revision: 3.429 $
                Compiled for 64 bit mode.
                Build: linux

        Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
                     Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
                     Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
                     Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
                     Vangel Bojaxhi, Ben England, Vikentsi Lapa.

        Run began: Sun Apr 14 22:12:35 2019

        File size set to 1048576 kB
        Command line used: iozone -i 0 -s 1g -t 2
        Output is in kBytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 kBytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
        Throughput test with 2 processes
        Each process writes a 1048576 kByte file in 4 kByte records

        Children see throughput for  2 initial writers  =    2800.53 kB/sec
        Parent sees throughput for  2 initial writers   =    2800.42 kB/sec
        Min throughput per process                      =    1400.24 kB/sec
        Max throughput per process                      =    1400.29 kB/sec
        Avg throughput per process                      =    1400.27 kB/sec
        Min xfer                                        = 1048540.00 kB

        Children see throughput for  2 rewriters        =    9946.16 kB/sec
        Parent sees throughput for  2 rewriters         =    9945.85 kB/sec
        Min throughput per process                      =    4954.84 kB/sec
        Max throughput per process                      =    4991.32 kB/sec
        Avg throughput per process                      =    4973.08 kB/sec
        Min xfer                                        = 1040928.00 kB
Last edited by domih on Thu Apr 18, 2019 7:15 pm, edited 2 times in total.

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: What am I doing wrong?

Unread post by odroid » Mon Apr 15, 2019 2:58 pm

Your 320GB HDD seems to be slow.
Try the following commands on the HDD mount point.
Write command
dd if=/dev/zero of=test oflag=direct bs=8M count=64
Read command
dd if=test of=/dev/null iflag=direct bs=8M
These users thanked the author odroid for the post:
domih (Tue Apr 16, 2019 4:58 pm)

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

Re: What am I doing wrong?

Unread post by domih » Tue Apr 16, 2019 4:15 pm

Thank you for you answer. Yes, this laptop 320GB disk from my old stash does not shine in terms of performance. However, the iozone results between the N2 and XU4 are not so good for the N2. Scroll the entire code section of my previous post to compare.

Anyway, in order to get to the point and remove the iozone from the story. I proceeded with the tests shown below.

N2

Code: Select all

# Create 1, 2 and 4 GB files on eMMC
cd ~
time dd if=/dev/zero of=file_1gb.txt count=1024 bs=1048576
  real    0m5.598s
  user    0m0.016s
  sys     0m4.140s
time dd if=/dev/zero of=file_2gb.txt count=1024 bs=2097152
  real    0m13.452s
  user    0m0.020s
  sys     0m7.728s
time dd if=/dev/zero of=file_4gb.txt count=1024 bs=4194304
  real    0m32.093s
  user    0m0.016s
  sys     0m16.800s

# Copy from eMMC to USB 3 disk
mkdir /media/usb0/test
time cp ~/file_1gb.txt /media/usb0/test
  real    0m52.495s
  user    0m0.156s
  sys     0m29.420s
time cp ~/file_2gb.txt /media/usb0/test
  real    1m47.707s
  user    0m0.348s
  sys     1m0.704s
time cp ~/file_4gb.txt /media/usb0/test
  real    3m29.919s
  user    0m0.656s
  sys     1m59.524s

# Create 1, 2 and 4 GB files on USB 3 disk
mkdir /media/usb0/test2
cd /media/usb0/test2
time dd if=/dev/zero of=file_1gb.txt count=1024 bs=1048576
  real    0m21.616s
  user    0m0.024s
  sys     0m11.504s
time dd if=/dev/zero of=file_2gb.txt count=1024 bs=2097152
  real    0m42.767s
  user    0m0.016s
  sys     0m22.308s
time dd if=/dev/zero of=file_4gb.txt count=1024 bs=4194304
  real    1m31.172s
  user    0m0.016s
  sys     0m45.312s

cd ~
rm -fr file_1gb.txt file_2gb.txt file_4gb.txt
rm -fr /media/usb0/test /media/usb0/test2
XU4

Note: I added the N2 results for comparison.

Code: Select all

# Create 1, 2 and 4 GB files on eMMC
cd ~
time dd if=/dev/zero of=file_1gb.txt count=1024 bs=1048576
  real    0m7.130s     # n2: real    0m5.598s
  user    0m0.001s     # n2: user    0m0.016s
  sys     0m5.021s     # n2: sys     0m4.140s
time dd if=/dev/zero of=file_2gb.txt count=1024 bs=2097152
  real    0m15.015s    # n2: real    0m13.452s
  user    0m0.009s     # n2: user    0m0.020s
  sys     0m10.462s    # n2: sys     0m7.728s
time dd if=/dev/zero of=file_4gb.txt count=1024 bs=4194304
  real    0m30.879s    # n2: real    0m32.093s
  user    0m0.013s     # n2: user    0m0.016s
  sys     0m21.387s    # n2: sys     0m16.800s
CONCLUSION: The N2 now shows better results than the XU4 :D

Code: Select all

# Copy from eMMC to USB 3 disk

sudo mkdir /media/domih
sudo chown domih.domih /media/domih
suso mount /dev/sda1 /media/domih
mkdir /media/domih/test
  
time cp ~/file_1gb.txt /media/domih/test
  real    0m11.664s    # n2: real    0m52.495s
  user    0m0.011s     # n2: user    0m0.156s
  sys     0m7.792s     # n2: sys     0m29.420s
time cp ~/file_2gb.txt /media/domih/test
  real    0m25.926s    # n2: real    1m47.707s
  user    0m0.020s     # n2: user    0m0.348s
  sys     0m17.225s    # n2: sys     1m0.704s
time cp ~/file_4gb.txt /media/domih/test
  real    0m51.039s    # n2: real    3m29.919s
  user    0m0.056s     # n2: user    0m0.656s
  sys     0m34.228s    # n2: sys     1m59.524s
CONCLUSION: :o

Code: Select all

# Create 1, 2 and 4 GB files on USB 3 disk
mkdir /media/domih/test2
cd /media/domih/test2
time dd if=/dev/zero of=file_1gb.txt count=1024 bs=1048576
  real    0m11.569s    # n2: real    0m21.616s
  user    0m0.009s     # n2: user    0m0.024s
  sys     0m6.262s     # n2: sys     0m11.504s
time dd if=/dev/zero of=file_2gb.txt count=1024 bs=2097152
  real    0m24.220s    # n2: real    0m42.767s
  user    0m0.013s     # n2: user    0m0.016s
  sys     0m13.533s    # n2: sys     0m22.308s
time dd if=/dev/zero of=file_4gb.txt count=1024 bs=4194304
  real    0m49.207s    # n2: real    1m31.172s
  user    0m0.004s     # n2: user    0m0.016s
  sys     0m27.696s    # n2: sys     0m45.312s

cd ~
rm -fr file_1gb.txt file_2gb.txt file_4gb.txt
rm -fr /media/domih/test /media/domih/test2
CONCLUSION: :o

Info about the disk from my old stash

Code: Select all

sudo fdisk -l

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0xcfdabbdf

Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1       65535 625072829 625007295  298G 83 Linux
Now, for the real kicker, one difference between the N2 and the XU4 is that Ubuntu automounts the USB drives on the N2.

So let's do the experiment show below on the N2.

Code: Select all

# On n2
sudo mount
../..
/dev/mmcblk0p2 on / type ext4 (rw,relatime,stripe=32716,data=ordered)
/dev/sda1 on /media/usb0 type ext4 (rw,nodev,noexec,noatime,nodiratime,sync,stripe=8191,data=ordered)
../..

# Unmount the automounted volume
sudo umount /media/usb0

# Remount it manually
sudo mkdir /media/domih
sudo chown domih.domih /media/domih
suso mount /dev/sda1 /media/domih
sudo mount
../..
/dev/sda1 on /media/domih type ext4 (rw,relatime,stripe=8191,data=ordered)
../..

mkdir /media/domih/test
Redo the tests with the manual mount.

Code: Select all

# Copy from eMMC to USB 3 disk
  
time cp ~/file_1gb.txt /media/domih/test
  real    0m11.664s    # n2: real    0m52.495s   # n2 (manual mount): real    0m6.381s
  user    0m0.011s     # n2: user    0m0.156s    # n2 (manual mount): user    0m0.024s
  sys     0m7.792s     # n2: sys     0m29.420s   # n2 (manual mount): sys     0m4.296s
time cp ~/file_2gb.txt /media/domih/test
  real    0m25.926s    # n2: real    1m47.707s   # n2 (manual mount): real    0m20.502s
  user    0m0.020s     # n2: user    0m0.348s    # n2 (manual mount): user    0m0.012s
  sys     0m17.225s    # n2: sys     1m0.704s    # n2 (manual mount): sys     0m9.732s
time cp ~/file_4gb.txt /media/domih/test
  real    0m51.039s    # n2: real    3m29.919s   # n2 (manual mount): real    0m46.050s
  user    0m0.056s     # n2: user    0m0.656s    # n2 (manual mount): user    0m0.104s
  sys     0m34.228s    # n2: sys     1m59.524s   # n2 (manual mount): sys     0m25.112s

# Create 1, 2 and 4 GB files on USB 3 disk
mkdir /media/domih/test2
cd /media/domih/test2
time dd if=/dev/zero of=file_1gb.txt count=1024 bs=1048576
  real    0m11.569s    # n2: real    0m21.616s   # n2 (manual mount): real    0m6.490s
  user    0m0.009s     # n2: user    0m0.024s    # n2 (manual mount): user    0m0.000s
  sys     0m6.262s     # n2: sys     0m11.504s   # n2 (manual mount): sys     0m4.540s
time dd if=/dev/zero of=file_2gb.txt count=1024 bs=2097152
  real    0m24.220s    # n2: real    0m42.767s   # n2 (manual mount): real    0m19.331s
  user    0m0.013s     # n2: user    0m0.016s    # n2 (manual mount): user    0m0.008s
  sys     0m13.533s    # n2: sys     0m22.308s   # n2 (manual mount): sys     0m10.160s
time dd if=/dev/zero of=file_4gb.txt count=1024 bs=4194304
  real    0m49.207s    # n2: real    1m31.172s   # n2 (manual mount): real    0m44.769s
  user    0m0.004s     # n2: user    0m0.016s    # n2 (manual mount): user    0m0.020s
  sys     0m27.696s    # n2: sys     0m45.312s   # n2 (manual mount): sys     0m21.384s
CONCLUSION: as on eMMC the N2 now shows better results than the XU4 on USB 3 disk :D :D

QUESTIONS
1) What's the story with the USB automount? Can this be improved to equal the manual mount?
2) No matter what, how to disable USB automount? I googled it but information is all over the place with plenty of info I definitely do not trust.
3) Or am I doing something awfully wrong and my conclusions are BS? Anybody, help?

User avatar
odroid
Site Admin
Posts: 31852
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 89 times
Been thanked: 255 times
Contact:

Re: What am I doing wrong?

Unread post by odroid » Tue Apr 16, 2019 4:47 pm

Good points!
We have to improve the USB storage auto-mount options.

I will forward the questions to a right person.
These users thanked the author odroid for the post:
domih (Tue Apr 16, 2019 4:58 pm)

mdrjr
Site Admin
Posts: 11710
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 0
Been thanked: 6 times
Contact:

Re: What am I doing wrong?

Unread post by mdrjr » Tue Apr 16, 2019 11:32 pm

Some answers..

1. Yes, see:
/etc/usbmount/usbmount.conf
2. Remove the usbmount package

Code: Select all

apt-get remove usbmount
3. Your conclusions are okay-ish, let me explain.
usbmount will mount the usb disk using flags preventing the kernel from caching anything and writing in realtime to the disk.
This is done to prevent in case someone removes a disk without umounting it. If you don't mount with realtime flags some data will be kept on ram until the kernel writes to the disk
If you remove the disk without a "umount" in this time frame data will be corrupt. Hence why realtime flags are used for usb disks
These users thanked the author mdrjr for the post (total 2):
domih (Wed Apr 17, 2019 11:37 am) • mad_ady (Wed Apr 17, 2019 12:58 pm)

domih
Posts: 108
Joined: Mon Feb 11, 2019 4:48 pm
languages_spoken: English, French
ODROIDs: UX4, HC2, N2, H2.
Has thanked: 34 times
Been thanked: 23 times
Contact:

[solved] What am I doing wrong?

Unread post by domih » Wed Apr 17, 2019 11:37 am

Thank you for your very timely answers. I removed usbmount.
IMHO, the remedy of forcing sync is worse than the illness of losing data ;-)
With Windows, OS X, many Linux you have to "eject" before plugging out a USB disk or key.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: snooty15041960 and 2 guests