On 2018-05-21 22:27, Linda Walsh wrote:
Carlos E. R. wrote:
Try playing with options such as "oflag=direct",
--- I'll second this part, but seriously, 4k at a time?? ---- Do you have to write such small amounts?
dd if=/dev/zero of=foo bs=4k count=1K oflag=direct 4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0689802 s, 60.8 MB/s <<4k blocksize
dd if=/dev/zero of=foo bs=4M count=1K oflag=direct 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 5.24457 s, 819 MB/s <<4M blocksize
dd if=/dev/zero of=foo bs=8M count=512 oflag=direct 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 5.04259 s, 852 MB/ <<8M dd if=/dev/zero of=foo bs=16M count=256 oflag=direct 4294967296 bytes (4.3 GB, 4.0 GiB) copied, 4.90653 s, 875 MB/ <<16M
16M is the sweet stop on my system. Yours may vary.
Well, with a small block and direct writing to disk, the kernel cache is disabled and speed suffers. Increasing the size of the write block acts like having a cache, but in the application instead than by the kernel.
As for your tests:
# time dd if=/dev/zero of=file.txt count=2096576 bs=4096 8587575296 bytes (8.6 GB, 8.0 GiB) copied, 42.8592 s, 200 MB/s # time dd if=/dev/zero of=file.txt count=1096576 bs=4096 4491575296 bytes (4.5 GB, 4.2 GiB) copied, 2.69905 s, 1.7 GB/s
--- those are no good -- you are writing to ram which eventually gets full and needs to flush to disk. It's the pause when flushing to disk that is killing you.
use direct and it won't buffer into memory first.
Not exactly, because direct disables the cache and you see how that impacts small file writing. Rather measure the speed when the cache flushes, like forcing the cache to empty at the end of the dd command. Or, instead of "direct", try "nocache", which uses the cache, then empties it, which thus forces writing to disk. Or, write a file 10 times bigger than the ram. There may be a 10% error in the measurement. The code of the application can call directly a flush of each file when they are closed. I do not know how to emulate the flags that dd can use: direct, dsync, nocache... If I were the developer of that code I would try to find out and experiment. Maybe a flush for every file impacts a lot. -- Cheers / Saludos, Carlos E. R. (from 42.3 x86_64 "Malachite" at Telcontar)