Earlier quoted context omitted.
SSD controllers do write-leveling, the blocks a filesystem writes to is virtual and remapped (think VMEM)
wouldn't an ~8GB page/swap file being continuously rewritten on a 250GB drive still consume a non-negligible number of write cycles over several days / weeks at most?
Linux file write patterns: So you want to write to a file fast
31–40 of 53 posts
Re: Linux file write patterns: So you want to write to a file fast
#32Earlier quoted context omitted.
> Assuming all I/O failures are EINTR is really, really odd, as if to say disks never fill up or fail and sockets never disconnect. The point is to retry on EINTR and to abort completely in case of other IO failures. assert(errno == EINTR); continue; is equivalent to if (errno == EINTR) continue; abort(); > But somebody somewhere is reading this and thinking this is a "semantically correct pattern" (as it is introduc…
You are wrong. assert is a no-op when NDEBUG is defined. Some compilers will set that for you in an optimized build. Using an assert in place of real error checking or otherwise relying on its side effects is consequently a huge wtf in C.
Re: Linux file write patterns: So you want to write to a file fast
#33Earlier quoted context omitted.
SSD controllers do write-leveling, the blocks a filesystem writes to is virtual and remapped (think VMEM)
wouldn't an ~8GB page/swap file being continuously rewritten on a 250GB drive still consume a non-negligible number of write cycles over several days / weeks at most?
Re: Linux file write patterns: So you want to write to a file fast
#34actually since none of its tests ask to sync the data onto the disk, he might just be measuring each method efficiency in creating dirty pages. of course that depends on the amount of RAM the system has, and how the kernel VM parameters are tuned (sysctl vm.dirty_*) just add a fdatasync() call and you will take into account the time it takes to flush all dirty pages into the disk.
Re: Linux file write patterns: So you want to write to a file fast
#35Async I/O avoids this. You can tell the I/O subsystem what you want to read next even while doing a write. The I/O is posted to the disk in modern systems, and the disk will begin seeking to the read site in parallel with informing the OS that the write has completed. Posting I/O even helps for SSDs to avoid the idle time on the SSD media between write done and read start.
Re: Linux file write patterns: So you want to write to a file fast
#36actually since none of its tests ask to sync the data onto the disk, he might just be measuring each method efficiency in creating dirty pages. of course that depends on the amount of RAM the system has, and how the kernel VM parameters are tuned (sysctl vm.dirty_*) just add a fdatasync() call and you will take into account the time it takes to flush all dirty pages into the disk.
[deleted]
Re: Linux file write patterns: So you want to write to a file fast
#37It's 2014; why was the author using ext3 instead of ext4? Ext4 does have fallocate support. Also, if you use fallocate(2) instead of posix_fallocate(3), you don't have to worry about glibc trying to emulate fallocate() for those file systems which don't use it. Finally, it's a little surprising the author didn't try using O_DIRECT writes.
Re: Linux file write patterns: So you want to write to a file fast
#38actually since none of its tests ask to sync the data onto the disk, he might just be measuring each method efficiency in creating dirty pages. of course that depends on the amount of RAM the system has, and how the kernel VM parameters are tuned (sysctl vm.dirty_*) just add a fdatasync() call and you will take into account the time it takes to flush all dirty pages into the disk.
[deleted]
At least for Linux, I think that's dangerously untrue. On my machine, 'man write' even includes an explicit warning:
A successful return from write() does not make any
guarantee that data has been committed to disk.
In fact, on some buggy implementations, it does not
even guarantee that space has successfully been reserved
for the data. The only way to be sure is to call
fsync(2) after you are done writing all your data.
There are ways to configure a file system so this is not the case, but they are rare. Is there a reference you could point to that would clarify what you are saying?Re: Linux file write patterns: So you want to write to a file fast
#39Re: Linux file write patterns: So you want to write to a file fast
#40The author has failed to account for command latency. If you write some bytes, there are a bunch of hardware buffering delays in getting bytes to disk including seek and rotational latency. Async I/O avoids this. You can tell the I/O subsystem what you want to read next even while doing a write. The I/O is posted to the disk in modern systems, and the disk will begin seeking to the read site in parallel with informin…