[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Could RAM possibly be just 3-4 times faster than bare hdd writes and reads? or, is the Linux kernel doing its 'magic' in the bg? or, ...



	Hi.

On Wed, Jun 17, 2020 at 10:33:51PM +0200, tomas@tuxteam.de wrote:
> So to test disk write speed, 'dsync' seems the way to go. When dumping
> to a device, there are no metadata (am I right there?), so probably
> again you want 'dsync'.
> 
> I don't know what 'nocache' would do for writing. For reading, it seems
> to make sense to avoid huge files (think a video) uselessly clobbering
> your cache (you're going to look at the blocks once, right?).

Ez.

Conventional dd:

$ strace dd if=/dev/zero of=/tmp/1 bs=1M count=1
openat(AT_FDCWD, "/dev/zero", O_RDONLY) = 3
...
openat(AT_FDCWD, "/tmp/1", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
<read/write is issued>


dsync dd (note O_DSYNC flag):

$ strace dd if=/dev/zero of=/tmp/1 bs=1M count=1 oflag=dsync
openat(AT_FDCWD, "/dev/zero", O_RDONLY) = 3
...
openat(AT_FDCWD, "/tmp/1", O_WRONLY|O_CREAT|O_TRUNC|O_DSYNC, 0666) = 3
<read/write is issued>


nocache dd (note fadvise64 syscall and the lack of O_DSYNC flag):

$ strace dd if=/dev/zero of=/tmp/1 bs=1M count=1 oflag=nocache
openat(AT_FDCWD, "/dev/zero", O_RDONLY) = 3
...
openat(AT_FDCWD, "/tmp/1", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
...
<read/write is issued>
...
fadvise64(1, 0, 1048576, POSIX_FADV_DONTNEED) = 0


Basically by "dsync" you're telling "I want chunks of this file to be
written to the disk every time I finish waiting write(2) syscall, but
feel free to cache it for other readers anyway", and by "nocache" you're
telling "I need it to evict from the filesystem cache once I close the
file but feel free to cache it before then, and I don't need to wait for
the disk writes every time I call write(2)".

Long story short, if you need a primitive I/O benchmark, you're better
with both dsync and nocache.

Reco


Reply to: