Commit 5ed0654
committed
Use fdatasync for commits
We can use fdatasync to save 1 extra write per call, for a total of 2 writes
per commit, since we do two sync, one for data block up to the header, then
another after the header.
As of OTP 25 (our oldest supported version):
* On Linux/BSDs: fdatasync()
* On Window: FlushFileBuffers() i.e. the same as for file:sync/1
* On MacOS: fcntl(fd,F_FULLFSYNC/F_BARRIERFSYNC)
According to https://linux.die.net/man/2/fdatasync
> fdatasync() is similar to fsync(), but does not flush modified metadata
unless that metadata is needed in order to allow a subsequent data retrieval
to be correctly handled. For example, changes to st_atime or
st_mtime (respectively, time of last access and time of last modification; see
stat(2)) do not require flushing because they are not necessary for a
subsequent data read to be handled correctly. On the other hand, a change to
the file size (st_size, as made by say ftruncate(2)), would require a metadata
flush.
The key things for us are:
* It updates the size (positions) correctly
* We do not rely or care about atime/mtime for safety or correctness
* Erlang VM does the right thing on all the supported OSes1 parent 3d7a019 commit 5ed0654
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
603 | 608 | | |
604 | 609 | | |
605 | 610 | | |
| |||
0 commit comments