postgres 同理的code:

backend/cdb/cdblogsync.c, createZeroFilledNewFile()

    /*
* Zero-fill the file. We have to do this the hard way to ensure that all
* the file space has really been allocated --- on platforms that allow
* "holes" in files, just seeking to the end doesn't allocate intermediate
* space. This way, we know that we have all the space and (after the
* fsync below) that all the indirect blocks are down on disk. Therefore,
* fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the
* log file.
*/
MemSet(zbuffer, , sizeof(zbuffer));

看代码随手记:log_put.c, __log_write()

    /*
* If we're writing the first block in a log file on a filesystem that
* guarantees unwritten blocks are zero-filled, we set the size of the
* file in advance. This increases sync performance on some systems,
* because they don't need to update metadata on every sync.
*
* Ignore any error -- we may have run out of disk space, but that's no
* reason to quit.
*/
#ifdef HAVE_FILESYSTEM_NOTZERO
if (lp->w_off == && !__os_fs_notzero()) {
#else
if (lp->w_off == ) {
#endif
(void)__db_file_extend(env, dblp->lfhp, lp->log_size);
if (F_ISSET(dblp, DBLOG_ZERO))
(void)__db_zero_extend(env, dblp->lfhp,
, lp->log_size/lp->buffer_size, lp->buffer_size); }

我的理解:在flush log时使用fdatasync, 若log文件长度发生变化, 则仍需要写文件 metadata。

https://linux.die.net/man/2/fdatasync

fdatasync() is similar to fsync(), but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. For example, changes to st_atime or st_mtime (respectively, time of last access and time of last modification; see stat(2)) do not require flushing because they are not necessary for a subsequent data read to be handled correctly. On the other hand, a change to the file size (st_size, as made by say ftruncate(2)), would require a metadata flush.

bdb log file 预设长度的性能优化的更多相关文章

  1. oracle之 等待事件LOG FILE SYNC (awr)优化

    log file sycn是ORACLE里最普遍的等待事件之一,一般log file sycn的等待时间都非常短 1-5ms,不会有什么问题,但是一旦出问题,往往都比较难解决.什么时候会产生log f ...

  2. hbase性能优化总结

    hbase性能优化总结 1. 表的设计 1.1 Pre-Creating Regions 默认情况下,在创建HBase表的时候会自动创建一个region分区,当导入数据的时候,所有的HBase客户端都 ...

  3. 完全揭秘log file sync等待事件-转自itpub

    原贴地址:http://www.itpub.net/thread-1777234-1-1.html   谢谢 guoyJoe 老大 这里先引用一下tanel poder大师的图: 什么是log fil ...

  4. Android性能优化问题总结

    性能优化这块,分为UI性能优化.内存优化.数据库优化.网络优化.耗电优化等等.可以从1.如何发现问题,2.怎么解决问题,3.解决效果对比,这几个方面去描述.举个简单例子——UI优化,可以从 UI出现什 ...

  5. 理解LGWR,Log File Sync Waits以及Commit的性能问题[转]

    理解LGWR,Log File Sync Waits以及Commit的性能问题 一.概要: 1.  Commit和log filesync的工作机制 2.  为什么log file wait太久 3. ...

  6. RAC 性能分析 - 'log file sync' 等待事件

    简介 本文主要讨论 RAC 数据库中的'log file sync' 等待事件.RAC 数据库中的'log file sync' 等待事件要比单机数据库中的'log file sync' 等待事件复杂 ...

  7. Oracle之 等待事件log file sync + log file parallel write (awr优化)

    这是3月份某客户的情况,原因是server硬件故障后进行更换之后,业务翻译偶尔出现提交缓慢的情况.我们先来看下awr的情况. 我们能够看到,该系统的load profile信息事实上并不高,每秒才21 ...

  8. Java程序性能优化Tip

    本博客是阅读<java time and space performance tips>这本小书后整理的读书笔记性质博客,增加了几个测试代码,代码可以在此下载:java时空间性能优化测试代 ...

  9. mysql数据库性能优化(包括SQL,表结构,索引,缓存)

    优化目标减少 IO 次数IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当 ...

随机推荐

  1. Java垃圾回收机制 入门

    对于Java虚拟机的了解,我认为是一个Java程序员已经入门的重要标志,而JVM中的垃圾回收机制(Garbage Collection,简称GC)又是JVM中的重点,所以hans在这里用篇文章时间和大 ...

  2. delphi SPCOMM串口控件

    在Delphi7.0中安装Spcomm串口通信控件的方法为:选择Delphi7.0的“Component”菜单,点击“Install Component...”菜单项,然后在弹出的Into exist ...

  3. ubuntu14.04安装bodhi桌面系统后,unity启动界面改变,如何还原

    按一下 ctrl + alt + f1 # 出現 tty11. sudo service lxdm stop或sudo /etc/init.d/lxdm stop如果出現錯誤訊息 不理它 繼續2. s ...

  4. 查询AD账号的SID

    在非域控的计算机上可以查询所用AD用户的SID,不过现成的工具不能直接实现此目的,我们需要在这些计算机上安装RSAT(远程服务器管理工具),然后使用dsquery和dsget命令,来快速查询AD用户的 ...

  5. flash中网页跳转总结

    浏览器中,程序同时跳转两个网页地址,第一个地址不会跳转,只会跳转第二个地址,如果第二个地址做延时,则第一个正常跳转,第二个地址会被拦截: 浏览器中,接口返回事件的函数中不能程序跳转网页地址. 这两条结 ...

  6. 【经验】ansible 批量推送公钥

    1.使用 ssh-keygen -t rsa生成密钥对 ssh-keygen -t rsa 2.推送单个公钥到远程机器 格式: ssh-copy-id -i ~/.ssh/id_rsa.pub use ...

  7. bwa用法

    一 建立索引 比对之前,需要对fasta文件构建FM-index索引:bwa index -a bwtsw hg19.fasta 生成 hg19.fasta.amb.hg19.fasta.ann.hg ...

  8. 使用spring-data-solr做solr客户端

    solr的客户端基本上只有一个,那就是solrj,spring-data-solr是在solrj的基础上做的封装,使统一成spring-data的风格 官方网站: http://projects.sp ...

  9. 問題排查:类型“System.DateTime”的对象无法转换为类型“System.String”

    最近在擴充資料對接工具的功能 經常會遇到這個狀況 當然還有其他同類提示,例如 int/decimal 無法轉 System.String 等等 無獨有偶 這些錯誤幾乎都是在 DataTable 轉換成 ...

  10. 自动化-Appium

    1.手把手教你 Android 标准 APP 的四大自动化测试法宝:https://testerhome.com/topics/5846 2.中文 Appium API 文档:https://test ...