[Nottingham] 1GB of \0 (aka null)

Martin martin at ml1.co.uk
Mon Mar 27 22:05:09 BST 2006


Martin wrote:
> Duncan John Fyfe wrote:
> [---]
> 
>> Not shorter, but faster:
>>     dd if=/dev/zero count=131072 bs=8192 | sha1sum
[---]
> OK: Why?

A few timings:


./ddsha1sum01 | tee ddsha1sum01.log

count = 1073741824 bs = 1
1073741824+0 records in
1073741824+0 records out
668.67 user 2513.08 system 2:35:52 elapsed 34% CPU (0 text + 0 data 0 
max) k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 536870912 bs = 2
536870912+0 records in
536870912+0 records out
339.39 user 1244.71 system 1:16:56 elapsed 34% CPU (0 text + 0 data 0 
max) k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 268435456 bs = 4
268435456+0 records in
268435456+0 records out
171.22 user 649.48 system 40:29.94 elapsed 33% CPU (0 text + 0 data 0 
max) k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 134217728 bs = 8
134217728+0 records in
134217728+0 records out
84.98 user 338.90 system 20:58.47 elapsed 33% CPU (0 text + 0 data 0 
max) k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 67108864 bs = 16
67108864+0 records in
67108864+0 records out
42.60 user 166.66 system 10:27.60 elapsed 33% CPU (0 text + 0 data 0 
max) k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 33554432 bs = 32
33554432+0 records in
33554432+0 records out
21.32 user 89.70 system 5:34.31 elapsed 33% CPU (0 text + 0 data 0 max) 
k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 16777216 bs = 64
16777216+0 records in
16777216+0 records out
10.57 user 44.44 system 2:59.02 elapsed 30% CPU (0 text + 0 data 0 max) 
k 0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 8388608 bs = 128
8388608+0 records in
8388608+0 records out
5.46 user 21.43 system 1:56.74 elapsed 23% CPU (0 text + 0 data 0 max) k 
0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 4194304 bs = 256
4194304+0 records in
4194304+0 records out
2.87 user 11.62 system 1:12.36 elapsed 20% CPU (0 text + 0 data 0 max) k 
0 inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 2097152 bs = 512
2097152+0 records in
2097152+0 records out
0.49 user 3.91 system 0:46.46 elapsed 9% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 1048576 bs = 1024
1048576+0 records in
1048576+0 records out
0.30 user 2.44 system 0:43.27 elapsed 6% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 524288 bs = 2048
524288+0 records in
524288+0 records out
0.21 user 1.76 system 0:40.19 elapsed 4% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 262144 bs = 4096
262144+0 records in
262144+0 records out
0.14 user 1.35 system 0:43.64 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 183 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 131072 bs = 8192
131072+0 records in
131072+0 records out
0.09 user 1.25 system 0:43.54 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 184 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 65536 bs = 16384
65536+0 records in
65536+0 records out
0.09 user 1.34 system 0:23.66 elapsed 6% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 32768 bs = 32768
32768+0 records in
32768+0 records out
0.04 user 1.37 system 0:24.15 elapsed 5% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 16384 bs = 65536
16384+0 records in
16384+0 records out
0.03 user 1.28 system 0:40.46 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 8192 bs = 131072
8192+0 records in
8192+0 records out
0.01 user 1.34 system 0:39.56 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 4096 bs = 262144
4096+0 records in
4096+0 records out
0.01 user 1.33 system 0:36.97 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 2048 bs = 524288
2048+0 records in
2048+0 records out
0.01 user 1.31 system 0:36.90 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 1024 bs = 1048576
1024+0 records in
1024+0 records out
0.00 user 1.30 system 0:36.76 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 512 bs = 2097152
512+0 records in
512+0 records out
0.00 user 1.35 system 0:39.75 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 256 bs = 4194304
256+0 records in
256+0 records out
0.00 user 1.30 system 0:39.59 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 128 bs = 8388608
128+0 records in
128+0 records out
0.00 user 1.31 system 0:41.23 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 64 bs = 16777216
64+0 records in
64+0 records out
0.00 user 1.26 system 0:37.10 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 32 bs = 33554432
32+0 records in
32+0 records out
0.00 user 1.36 system 0:40.83 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 16 bs = 67108864
16+0 records in
16+0 records out
0.00 user 1.41 system 0:41.74 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 8 bs = 134217728
8+0 records in
8+0 records out
0.00 user 1.28 system 0:39.04 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 4 bs = 268435456
4+0 records in
4+0 records out
0.00 user 1.37 system 0:41.28 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 2 bs = 536870912
2+0 records in
2+0 records out
0.00 user 1.37 system 0:40.05 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -

count = 1 bs = 1073741824
1+0 records in
1+0 records out
0.00 user 1.38 system 0:41.79 elapsed 3% CPU (0 text + 0 data 0 max) k 0 
inputs + 0 outputs (0 major + 182 minor) pagefaults 0 swaps
2a492f15396a6768bcbca016993f4b4c8b0b5307  -


All from:

$ cat ./ddsha1sum01
#!/bin/bash
#
# time dd if=/dev/zero count=131072 bs=8192 | sha1sum
#

(( co=2**30, bs=1 ))
while (( co > 0 ))
do
         echo
         echo "count = $co bs = $bs"
         time -f '%U user %S system %E elapsed %P CPU (%X text + %D data 
%M max) k %I inputs + %O outputs (%F major + %R minor) pagefaults %W 
swaps' dd if=/dev/zero count=$co bs=$bs | sha1sum

         let "co >>= 1"
         let "bs <<= 1"
done


I'll let someone else graph up the numbers if interested to see how bs 
affects the system, user and elapsed time. In short, the bigger the bs 
gives the quicker the times provided that you have the memory for it.


Interesting (to some at least :-) )

Cheers,
Martin

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list