Windows now has fdatasync()

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Windows now has fdatasync()
Date: 2021-12-12 02:48:10
Message-ID: CA+hUKGJZJVO=iX+eb-PXi2_XS9ZRqnn_4URh0NUQOwt6-_51xQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While porting some new IO code to lots of OSes I noticed in passing
that there is now a way to do synchronous fdatasync() on Windows.
This mechanism doesn't have an async variant, which is what I was
actually looking for (which turns out to doable with bleeding edge
IoRings, more on that later), but I figured this might be useful
anyway. I see that at least one other open source database has
discovered it and seen speedups. Like some other file API
improvements discussed recently, it's Windows 10+ and NTFS only. I
tried out a quick POC patch and it runs a bit faster than fsync(), as
expected. I'm not sure if it's worth bothering with or not given the
other options, but figured it was worth sharing.

While testing that I also couldn't resist adding an extra output line
to pg_test_fsync to run open_datasync in buffered I/O mode, like
PostgreSQL actually does in real life. I guess I should really change
it to duplicate less code, though...

[1] https://www.postgresql.org/message-id/flat/1527846213.2475.31.camel%40cybertec.at

Attachment Content-Type Size
0001-Fix-treatment-of-direct-I-O-in-pg_test_fsync.patch text/x-patch 3.6 KB
0002-Add-fdatasync-wrapper-for-Windows.patch text/x-patch 5.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-12-12 02:50:17 pg_upgrade should truncate/remove its logs before running
Previous Message Peter Geoghegan 2021-12-11 23:11:42 Re: Unifying VACUUM VERBOSE and log_autovacuum_min_duration output