Hi,
I'm writing C code with some real-time constraints. I tested out the speed I can write to a disk with dd:
dd if=/dev/zero of=/dev/sdb bs=32K count=32768 oflag=direct
This writes 1GB of zeros to /dev/sdb in 32K block sizes
I reach about 103 MB/s with this
Now I programmatically do something similar:
open("/dev/sdb",O_WRONLY|O_CREAT|O_DIRECT|O_TRUNC, 0666);
I get a timestamp value write from a 32K buffer to /dev/sdb 10,000 times (in a for loop) get another timestamp value do a bit of number crunching to get the rate in MB/s and it is about 49 MB/s
Why can't I reach the same speed as dd? An strace reveals the same open command that I use.