I am writing C code with some limitations in real time. I tested the speed that I can write to disk using 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 am doing something similar programmatically:
open("/dev/sdb",O_WRONLY|O_CREAT|O_DIRECT|O_TRUNC, 0666);
I get the timestamp value write from the 32K buffer to / dev / sdb 10,000 times (in the for loop) to get a different timestamp value do a few crunches to get the speed in MB / s, and this is about 49 MB / s
Why can't I reach the same speed as dd? The same open command that I use appears in strace.
source share