gpt4 book ai didi

mysql - pwrite 并从 MYSQL 的 ioprofile 结果写入

转载 作者:行者123 更新时间:2023-11-29 19:38:41 27 4
gpt4 key购买 nike

我通过 ioprofile 检查了 MYSQL 的 IO 事件,发现 binlog 使用了大部分 write 系统调用,但是 transaction log 使用了大部分 write 类型 pwrite 系统调用,我的问题是为什么 binlog 使用了大部分 write 系统调用,但是 pwrite 用于事务日志吗?

 total      pread       read     pwrite      write      fsync       open      lseek filename
3027 0 549 0 2478 0 0 0 /data/mysql/XXX-bin.048425
1848 0 0 1820 0 28 0 0 /data/mysql/ib_logfile1

最佳答案

这两个操作本质上是等效的,只是 pwrite 接受第 4 个位置参数,而 write 隐式在句柄的当前偏移指针处写入数据。

binlog几乎都是通过在末尾追加数据来写入的。

重做日志更像是一个环形缓冲区,通常大小固定,其中写入从靠近结尾处回绕到靠近开头处。

The pwrite() function shall be equivalent to write(), except that it writes into a given position without changing the file pointer.

The first three arguments to pwrite() are the same as write() with the addition of a fourth argument offset for the desired position inside the file.

https://linux.die.net/man/3/pwrite

关于mysql - pwrite 并从 MYSQL 的 ioprofile 结果写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41437092/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com