pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Improve configurability for IO related behavoir
2+ messages / 2 participants
[nested] [flat]

* Improve configurability for IO related behavoir
@ 2022-05-28 12:11  浩辰 何 <hehaochen@hotmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: 浩辰 何 @ 2022-05-28 12:11 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Dear developers:

I have some suggestions on PostgreSQL's IO behavior. I am not sure my opinions are right. Many thanks for your time!

It is documented that :
wal_sync_method​ (enum): The open_*​ options also use O_DIRECT if available.
Shall PostgreSQL consider making O_DIRECT configurable? In MySQL, innodb_flush_method​ can change if use  O_DIRECT or not.
I made some benchmarking on O_DIRECT of MySQL, and I find that sometimes, using O_DIRECT may hurt performance.
https://ibb.co/BVWnwnh
[https://i.ibb.co/1fyzbzC/003.png]<https://ibb.co/BVWnwnh;
003<https://ibb.co/BVWnwnh;
Image 003 hosted in ImgBB
ibb.co






Comparing the blue (buffered IO) and green (direct IO) lines, I find buffered IO is faster. So I think having such parameter in PostgreSQL
is reasonable.

On the other hand, wal_sync_method​ only controls how WAL is written to devices, while for data file I notice that PostgreSQL uses
sync_file_range(2)​. So shall we also make it configurable? I also find that in some systems, open​ with O_SYNC is much more faster
than write​ + fsync​ :

https://ibb.co/f1VsCC1

[https://i.ibb.co/gjbxDDj/Picture1.png]<https://ibb.co/f1VsCC1;
Picture1<https://ibb.co/f1VsCC1;
Image Picture1 hosted in ImgBB
ibb.co
Furthermore, the results above are also related to IO API supported by OS. MySQL support synchronized IO and Linux libaio​. It seems
that PostgreSQL only supports synchronized IO, so shall we support more IO engines? like io_uring​ which is very popular in recent years.

Thanks & best,
Haochen


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Improve configurability for IO related behavoir
@ 2022-05-28 20:33  Thomas Munro <thomas.munro@gmail.com>
  parent: 浩辰 何 <hehaochen@hotmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Thomas Munro @ 2022-05-28 20:33 UTC (permalink / raw)
  To: 浩辰 何 <hehaochen@hotmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Sun, May 29, 2022 at 4:29 AM 浩辰 何 <hehaochen@hotmail.com> wrote:
> Furthermore, the results above are also related to IO API supported by OS. MySQL support synchronized IO and Linux libaio. It seems
> that PostgreSQL only supports synchronized IO, so shall we support more IO engines? like io_uring which is very popular in recent years.

Hi Haochen,

There is an active project to bring these things to PostgreSQL.
https://wiki.postgresql.org/wiki/AIO has some information and links.
The short version is that there is a development patch set to add
these GUCs:

io_method=worker,io_uring,posix_aio,iocp,...
io_data_direct=on,off
io_wal_direct=on,off

It also adds a bunch of specialised logic that knows how to initiate
IO in key places (scans, writeback, recovery, ...), because it's not
enough to just turn off kernel I/O buffering, we also have to do all
the work the kernel is doing for us or performance will be terrible.





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-05-28 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 12:11 Improve configurability for IO related behavoir 浩辰 何 <hehaochen@hotmail.com>
2022-05-28 20:33 ` Thomas Munro <thomas.munro@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox