Re: fdatasync behaviour in macOS
Sitsofe Wheeler <[email protected]> Wed, 10 Dec 2025 23:04:39 +0000
| Newsgroups | org.kernel.vger.fio |
|---|---|
| Message-ID | <CALjAwxjyNHgvA65V_5njhXKK=QiRsgFE5XHzr2qOdoxZcfQ39A@mail.gmail.com> |
Hi, On Wed, 10 Dec 2025 at 06:07, Anil Sharma <[email protected]> wrote: > > I am using fio to benchmark serial fsync in macOS. From what I could understand, both fsync and fdatasync are linked to F_FULLSYNC in macOS. But the output is very different. fsync=1 can only get 110 tps where fdatasync=1 option can get 5.5K tps. Which seems like we are only writing to OS Page Cache. > > Question: > Can we get a confirmation whether the fdatasync option is mapped to F_FULLSYNC? fio's fdatasync call is currently (as fio fio 3.41) *not* mapped to fcntl(..., F_FULLFSYNC) on macOS and if we read fio's source we can confirm this: If you look at https://github.com/axboe/fio/blob/fio-3.41/io_u.c#L2463-L2474 you can see what fio uses to do fsync depends on whether CONFIG_FCNTL_SYNC is defined. In that block you can see the call to fdatasync *only* depends on whether CONFIG_FDATASYNC is defined and it will never be mapped to fcntl(..., F_FULLFSYNC). Over in configure you can see the probe for fcntl(..., F_FULLFSYNC) in https://github.com/axboe/fio/blob/fio-3.41/configure#L706-L723 and the probe for fdatasync(...) over in https://github.com/axboe/fio/blob/fio-3.41/configure#L1252-L1268 . If you check the config.log on macOS you can see that "Compiling test case fcntl(F_FULLFSYNC)" and "Compiling test case fdatasync" both succeed leading to CONFIG_FCNTL_SYNC and CONFIG_FDATASYNC both being defined (see https://github.com/axboe/fio/blob/fio-3.41/configure#L3075-L3077 and https://github.com/axboe/fio/blob/fio-3.41/configure#L3380-L3382 for where these symbols are output). > Please let me know if this needs to go in github issues. Hmm it's not something I personally will work on (although I can 't speak for others) so it's one of those things where a well formed patch/PR would be more useful but there's some debate as to whether it's worth it. It's well known that fsync() alone on macOS doesn't trigger *drive* cache flushes (unlike Linux) so I don't think it's a surprise that fdatasync() has the same behaviour as fsync()... However, I can see how fio's remapping of just fsync and not fdatasync is surprising. I guess the question is: does it make sense to even use fdatasync=1 with fio on macOS if it's just going to do the same heavyweight fcntl(..., F_FULLFSYNC) work as the current fsync() -> fcntl(..., F_FULLFSYNC) mapping or should it just be disabled entirely? -- Sitsofe