暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL 15 preview - MacOS 通过 fcntl 关闭data cache, 支持 direct I/O

digoal 2021-01-07
812

作者

digoal

日期

2021-07-19

标签

PostgreSQL , direct I/O , wal


背景

仅仅当wal=minimal , max_wal_senders=0时支持dio, 为什么呢?

因为如果写入的wal要被立即读出, 还是开cache快点, 例如有standby时, 需要在wal写入后立即读出, 开cache更快.

```
man fcntl

F_NOCACHE Turns data caching off/on. A non-zero value in arg turns data caching off. A value of zero in arg turns data caching on.
```

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=2dbe8905711ba09a2214b6e835f8f0c2c4981cb3

```
Support direct I/O on macOS. master github/master
author Thomas Munro tmunro@postgresql.org
Sun, 18 Jul 2021 20:52:00 +0000 (08:52 +1200)
committer Thomas Munro tmunro@postgresql.org
Sun, 18 Jul 2021 23:01:01 +0000 (11:01 +1200)
commit 2dbe8905711ba09a2214b6e835f8f0c2c4981cb3
tree 775e44cb05c4dfa8f12e68eb388f04e9aa252c96 tree
parent f157db862225a7bfe041ca3f7b73e913e2a8d8d6 commit | diff
Support direct I/O on macOS.

Macs don't understand O_DIRECT, but they can disable caching with a
separate fcntl() call. Extend the file opening functions in fd.c to
handle this for us if the caller passes in PG_O_DIRECT.

For now, this affects only WAL data and even then only if you set:

max_wal_senders=0
wal_level=minimal

This is not expected to be very useful on its own, but later proposed
patches will make greater use of direct I/O, and it'll be useful for
testing if developers on Macs can see the effects.

Reviewed-by: Andres Freund andres@anarazel.de
Discussion: https://postgr.es/m/CA%2BhUKG%2BADiyyHe0cun2wfT%2BSVnFVqNYPxoO6J9zcZkVO7%2BNGig%40mail.gmail.com
```

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论