"Mikheev, Vadim" <vmikheev@SECTORBASE.COM> writes:
>> $ gcc -Wall -O -DINIT_WRITE -DUSE_DSYNC -DBLOCKS=1 tfsync.c
> ^^^^^^^^^^^
> You should use -DUSE_OSYNC to test O_SYNC.
Ooops ... let's hear it for cut-and-paste, and for sharp-eyed readers!
Just for completeness, here are the results for O_SYNC:
$ gcc -Wall -O -DINIT_WRITE -DUSE_OSYNC -DBLOCKS=1 tfsync.c
$ time a.out
real 0m43.44s
user 0m0.02s
sys 0m0.74s
$ gcc -Wall -O -DINIT_WRITE -DUSE_OSYNC -DBLOCKS=4 tfsync.c
$ time a.out
real 0m26.38s
user 0m0.01s
sys 0m0.59s
$ gcc -Wall -O -DINIT_WRITE -DUSE_OSYNC -DBLOCKS=8 tfsync.c
$ time a.out
real 0m23.86s
user 0m0.01s
sys 0m0.59s
$ gcc -Wall -O -DINIT_WRITE -DUSE_OSYNC -DBLOCKS=64 tfsync.c
$ time a.out
real 0m22.93s
user 0m0.01s
sys 0m0.66s
Better than fsync(), but still not up to O_DSYNC.
> So seems we can use O_DSYNC without losing log write performance
> comparing with write() + fsync. Though, we didn't tested write() +
> fdatasync() yet...
Good point, we should check fdatasync() too --- although I have no
machines where it's different from fsync().
regards, tom lane