Is there a way to determine the optimal value for the bs parameter to dd?
Asked 13 years, 9 months ago
benchmarking since dd reports the amount of time and the transfer rate in MB/s when done.
MestreLion's voices in is head still seem to be correct as I observe things in RHEL-8.10 on a server having 768gb ram, doing a dd if=/dev/urandom of=test.txt
bytes bs = 512 {default} count = 2048000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 8.00883 s, 131 MB/s bs = 1024 count = 1024000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 6.65036 s, 158 MB/s bs = 4096 count = 256000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.62923 s, 186 MB/s bs = 32768 count = 32000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.57009 s, 188 MB/s bs = 262144 {256k} count = 4000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.31985 s, 197 MB/s bs = 1048576 {1Mb} count = 1000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.27937 s, 199 MB/s bs = 2097152 count = 500 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.28502 s, 198 MB/s bs = 8388608 count = 125 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.27615 s, 199 MB/s bs = 10M count = 100 1048576000 bytes (1.0 GB, 1000 MiB) copied, 5.33481 s, 197 MB/s
you should probably not use the default of 512 bytes anymore unless you have good reason to do based on the in/out device. The trend seems to be 1M up to around bs=10M is optimal. At bs=16M it drops down to 190 MB/s and at bs=32M got dd: warning: partial read (33554431 bytes); suggest iflag=fullblock which then succeeded but at 188 MB/s. And a bs=1024M count=10 did 10GiB at 193 MB/s so no real improvement going above bs=1M.
So maybe bs=10M today which would generally be an easy divide by ten for gigabyte size stuff. Next time I have to put data to USB connected SSD, I will test with a corresponding if=something of=/dev/sdb because I am curious.
# optiplex pc with 16gb ram and ssd running rhel-8.10 # of = encrypted usb disk on usb3.0 dd if=/dev/urandom of=/dev/sde bs=512 count=2048000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 37.493 s, 28.0 MB/s first time 1048576000 bytes (1.0 GB, 1000 MiB) copied, 6.00454 s, 175 MB/s dd if=/dev/urandom of=/dev/sde bs=4096 count=256000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.88175 s, 270 MB/s dd if=/dev/urandom of=/dev/sde bs=32768 count=32000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.56612 s, 294 MB/s dd if=/dev/urandom of=/dev/sde bs=262144 count=4000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.55416 s, 295 MB/s dd if=/dev/urandom of=/dev/sde bs=1048576 count=1000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.56577 s, 294 MB/s dd if=/dev/urandom of=/dev/sde bs=1M count=1000 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.52601 s, 297 MB/s dd if=/dev/urandom of=/dev/sde bs=2097152 count=500 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.57916 s, 293 MB/s dd if=/dev/urandom of=/dev/sde bs=2M count=500 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.53205 s, 297 MB/s dd if=/dev/urandom of=/dev/sde bs=8388608 count=125 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.68581 s, 284 MB/s dd if=/dev/urandom of=/dev/sde bs=8M count=125 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.61667 s, 290 MB/s dd if=/dev/urandom of=/dev/sde bs=10485760 count=10 104857600 bytes (105 MB, 100 MiB) copied, 0.367697 s, 285 MB/s dd if=/dev/urandom of=/dev/sde bs=10M count=100 1048576000 bytes (1.0 GB, 1000 MiB) copied, 3.69625 s, 284 MB/s