LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   DD oflag=direct (http://www.linuxquestions.org/questions/linux-general-1/dd-oflag%3Ddirect-4175444216/)

DubDriver 01-04-2013 06:08 PM

DD oflag=direct
 
I am hoping someone can enlighten me a bit on DD and oflag=direct.

If I understand it correctly this simply bypasses the system cache and writes directly to the disk. I would think that system cache would improve performance?

dd if=/dev/zero of=test bs=512M count=1 conv=fdatasync
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 0.910243 s, 590 MB/s

dd if=/dev/zero of=sb-io-test bs=512M count=1 conv=fdatasync oflag=direct
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 0.452991 s, 1.2 GB/s

Very odd, just doesn't make sense to me, hoping someone can chime in with something that adds up. I really appreciate the input!

syg00 01-04-2013 06:18 PM

Reboot and run your tests in the reverse order .... ;)

Cache effects are subtle and not always obvious - you have to be extremely vigilant to obviate them. Look up drop_caches.

DubDriver 01-04-2013 06:28 PM

Quote:

Originally Posted by syg00 (Post 4863209)
Reboot and run your tests in the reverse order .... ;)

Cache effects are subtle and not always obvious - you have to be extremely vigilant to obviate them. Look up drop_caches.

dd if=/dev/zero of=test bs=512M count=1 conv=fdatasync oflag=direct
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 0.187328 s, 2.9 GB/s

dd if=/dev/zero of=test bs=512M count=1 conv=fdatasync
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 0.795389 s, 675 MB/s

This is directly after a reboot. Machine is an IBM x3650 M4 with 8x600GB 2.5's and a M5015.

Appreciate the input!

DubDriver 01-05-2013 08:39 AM

It doesn't seem to matter what the machine is. Here is another example. It just seems the DD test without the oflag=direct should perform far better. These tests were done directly after a reboot using drop_cache.

dd if=/dev/zero of=test bs=512M count=1 conv=fdatasync oflag=direct
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 0.948172 s, 566 MB/s

echo 3 > /proc/sys/vm/drop_caches

dd if=/dev/zero of=test bs=512M count=1 conv=fdatasync
1+0 records in
1+0 records out
536870912 bytes (537 MB) copied, 1.2269 s, 438 MB/s

syg00 01-05-2013 05:49 PM

There are several factors at play - not just the page cache.
The page cache is (amongst other things) an attempt to provide consistency in I/O response time(s), as well as eliminating I/O where possible. Databases use direct_io when they want outright performance. One of it's side benefits is that it bypasses the I/O schedulers as well as the page cache.

You will get better data if you use a real data source - /dev/zero is a poor choice to investigate the benefits or otherwise of the page cache. Personally I always like to ensure I use a real data source, and that the data are (much) larger than can be kept in memory.
Multiple runs give better confidence.


All times are GMT -5. The time now is 06:10 AM.