2

Good day, I had a question that I could not find the answer. I tested my hard drive, mounted on /media/data using dd. Some simple scripts:

write:

echo "3" > /proc/sys/vm/drop_caches 
for i in {1..10}; do 
  dd if=/dev/zero of=/media/data/test/testfile-$i bs=4096 count=1310720 conv=fdatasync 
done

result: 
my-home# bash test1
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 30,7945 s, 174 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 30,8114 s, 174 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 30,9237 s, 174 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 30,9386 s, 174 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 30,8568 s, 174 MB/s

iostat:
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2,17    0,00    4,22   21,23    0,00   72,38
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0,00         0,00         0,00          0          0
sdb             172,00         0,00    176128,00          0     176128

read:

echo "3" > /proc/sys/vm/drop_caches 
for i in $(ls /media/data/iso); do 
  dd if=/media/data/iso/$i of=/dev/null bs=4096 
done 

result:
my-home# bash test1_read
632291328 bytes (632 MB, 603 MiB) copy, 3,46719 s, 182 MB/s
3994091520 bytes (4,0 GB, 3,7 GiB) copy, 21,4655 s, 186 MB/s
1317427200 bytes (1,3 GB, 1,2 GiB) copy, 7,03572 s, 187 MB/s
4696938496 bytes (4,7 GB, 4,4 GiB) copy, 25,0823 s, 187 MB/s
699400192 bytes (699 MB, 667 MiB) copy, 3,77014 s, 186 MB/s

iostat:
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           1,13    0,00    2,89   10,30    0,00   85,68

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0,00         0,00         0,00          0          0
sdb            1432,00    183296,00         0,00     183296          0

Speed is nice, but when I run these scripts simultaneously in different terminals. Write-script runs faster and takes away all the hard disk resources:

my-home# bash test1
Sep 29 7:57:57 UTC 2016
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 31,9903 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,0175 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,0138 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 31,9956 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,0198 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,136 s, 167 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 31,9074 s, 168 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,237 s, 167 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,0998 s, 167 MB/s
5368709120 bytes (5,4 GB, 5,0 GiB) copy, 32,4163 s, 166 MB/s

my-home# bash test1_read 
Sep 29 7:57:57 UTC 2016
632291328 bytes (632 MB, 603 MiB) copy, 3,46899 s, 182 MB/s
3994091520 bytes (4,0 GB, 3,7 GiB) copy, 149,177 s, 26,8 MB/
4696938496 bytes (4,7 GB, 4,4 GiB) copy, 214,307 s, 21,9 MB/s
263127040 bytes (263 MB, 251 MiB) copy, 1,44909 s, 182 MB/s

iostat:
                    Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
29.09.2016 08:03:17 sdb             164,00         1,38       157,03          2        314
29.09.2016 08:03:19 sdb             172,00         1,50       161,52          3        323
29.09.2016 08:03:21 sdb             163,00         1,38       156,52          2        313
29.09.2016 08:03:23 sdb             169,50         0,88       166,00          1        332
29.09.2016 08:03:25 sdb             164,50         0,38       162,01          0        324
29.09.2016 08:03:27 sdb             161,50         1,38       154,52          2        309
29.09.2016 08:03:29 sdb             168,00         0,50       165,51          1        331
29.09.2016 08:03:31 sdb             160,50         0,75       156,02          1        312
29.09.2016 08:03:33 sdb             164,00         0,38       162,00          0        324
29.09.2016 08:03:35 sdb             164,50         0,25       162,01          0        324
29.09.2016 08:03:37 sdb             277,50         0,88       156,52          1        313
29.09.2016 08:03:39 sdb             318,00         0,25       161,00          0        322
29.09.2016 08:03:41 sdb             313,50         1,00       154,35          2        308
29.09.2016 08:03:43 sdb             758,00        80,31        88,19        160        176
29.09.2016 08:03:45 sdb            1398,00       174,63         0,00        349          0
29.09.2016 08:03:47 sdb            1429,00       178,62         0,00        357          0
29.09.2016 08:03:49 sdb            1429,50       178,69         0,00        357          0
29.09.2016 08:03:51 sdb            1427,00       178,31         0,00        356          0
29.09.2016 08:03:53 sdb            1430,50       178,81         0,00        357          0
29.09.2016 08:03:55 sdb            1431,00       178,88         0,00        357          0
29.09.2016 08:03:57 sdb            1431,00       178,88         0,00        357          0
29.09.2016 08:03:59 sdb            1431,00       178,88         0,00        357          0
29.09.2016 08:04:01 sdb            1423,00       177,81         0,00        355          0
29.09.2016 08:04:03 sdb            1431,50       178,94         0,00        357          0

Why write a higher priority over reading? My scheduler is default for Linux Mint 18:

my-home# cat /sys/block/sdb/queue/scheduler 
noop [deadline] cfq 

And for this scheduler read have highest priority over write, but it's not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.