PostgreSQL 18 preview - 允许所有场景开启并发IO
PostgreSQL 18 preview - 允许所有场景开启并发IO
之前,effective_io_concurrency (用于常规 I/O) 和 maintenance_io_concurrency (用于维护任务的 I/O) 这两个参数在不支持 fadvise 的机器上不能设置为大于 0 的值。 fadvise 是一个系统调用,用于向操作系统提供关于文件访问模式的提示。
PostgreSQL 18 这个补丁解除了对 effective_io_concurrency 和 maintenance_io_concurrency 参数的限制,允许在所有系统上启用 IO 并发,即使这些系统不支持 fadvise。
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=2a5e709e721cf5f890cde51755b84cfe25d1c4d9
Enable IO concurrency on all systems master github/master
author Andres Freund <[email protected]>
Sun, 30 Mar 2025 23:14:55 +0000 (19:14 -0400)
committer Andres Freund <[email protected]>
Sun, 30 Mar 2025 23:16:47 +0000 (19:16 -0400)
commit 2a5e709e721cf5f890cde51755b84cfe25d1c4d9
tree e48d7981c9ea2c20b9da99e5f78c7173875f7c68 tree
parent ae3df4b34155d4a3811762e78d5076e64df66fba commit | diff
Enable IO concurrency on all systems Previously effective_io_concurrency and maintenance_io_concurrency could not
be set above 0 on machines without fadvise support. AIO enables IO concurrency
without such support, via io_method=worker.
Currently only subsystems using the read stream API will take advantage of
this. Other users of maintenance_io_concurrency (like recovery prefetching)
which leverage OS advice directly will not benefit from this change. In those
cases, maintenance_io_concurrency will have no effect on I/O behavior.
Author: Melanie Plageman <[email protected]>
Reviewed-by: Noah Misch <[email protected]>
Discussion: https://postgr.es/m/CAAKRu_atGgZePo=_g6T3cNtfMf0QxpvoUh5OUqa_cnPdhLd=gw@mail.gmail.com
AI 解读
补丁: Enable IO concurrency on all systems (在所有系统上启用 IO 并发)
这个补丁解除了对 effective_io_concurrency 和 maintenance_io_concurrency 参数的限制,允许在所有系统上启用 IO 并发,即使这些系统不支持 fadvise。
背景:
之前, effective_io_concurrency(用于常规 I/O) 和maintenance_io_concurrency(用于维护任务的 I/O) 这两个参数在不支持fadvise的机器上不能设置为大于 0 的值。fadvise是一个系统调用,用于向操作系统提供关于文件访问模式的提示。这是因为在没有 fadvise的情况下,PostgreSQL 依赖于操作系统来管理 I/O 并发,而操作系统可能无法有效地做到这一点。解决方案:
AIO (Asynchronous I/O) 的引入,特别是通过 io_method=worker模式,使得即使在没有fadvise支持的情况下也能实现 IO 并发。io_method=worker使用单独的工作进程来执行 I/O 操作,从而绕过了对fadvise的依赖。影响:
现在,即使在不支持 fadvise的系统上,也可以将effective_io_concurrency和maintenance_io_concurrency设置为大于 0 的值,从而启用 IO 并发。当前受益者: 目前,只有使用 read_streamAPI 的子系统才能利用这一变化。read_streamAPI 已经针对 AIO 进行了优化。潜在的局限性: 其他使用 maintenance_io_concurrency的模块(例如恢复预取),如果直接利用操作系统建议 (OS advice),则不会从此更改中受益。 在这些情况下,maintenance_io_concurrency将对 I/O 行为没有影响。 这意味着这些模块仍然依赖于fadvise,如果系统不支持fadvise,则maintenance_io_concurrency将被忽略。总结:
这个补丁通过利用 AIO 的
io_method=worker模式,解除了对 IO 并发的限制,使其可以在所有系统上启用,即使这些系统不支持fadvise。 虽然目前只有read_streamAPI 受益,但这是一个重要的进步,因为它为在更多 PostgreSQL 模块中启用 IO 并发铺平了道路。 需要注意的是,对于那些仍然依赖fadvise的模块,maintenance_io_concurrency仍然没有效果。
简单来说,这个补丁让更多的人能用上 IO 并发,即使他们的操作系统比较老或者配置比较特殊。 虽然不是所有地方都能立刻用上,但这是一个好的开始。