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线程监控之旅

    宏巍软件 许向 大家好,我是上海宏巍信息技术有限公司(简称:宏巍软件)的许向,宏巍软件成立于2005年,是一家以电商ERP软件开发为主的高新技术科技型软件公司,致力于为大型网商和电子商务企业提供专业. ...

  2. PowerDesigner使用教程

    PowerDesigner是一款功能非常强大的建模工具软件,足以与Rose比肩,同样是当今最著名的建模软件之一.Rose是专攻UML对象模型的建模工具,之后才向数据库建模发展,而PowerDesign ...

  3. UITextView 显示不全的问题

    //设置UITextView的内边距 textView.contentInset = UIEdgeInsetsMake(0, 0, 20, 0);

  4. 2016年&2017年

    2016年在IBM已经工作4年了,从门户项目到今年的保险行业灾备项目,从之前的技术到现在的项目推进,由面对机器工作到,跟更多的人打交道,工作继续进行着,希望今天的项目尽早结束. 由于工作的原因,今年回 ...

  5. CODE[VS] 1230 元素查找

    1.题目戳这里 2.代码: #include<iostream> #include<algorithm> using namespace std; int n,m,a[1000 ...

  6. 关于Servlet手动配置web.xml部分代码

    <servlet> <!-- 文件名 --> <servlet-name>deleteServlet</servlet-name> <!-- 文件 ...

  7. MAC 安装j2ee.sh的办法

    It says it needs the DISPLAY variable set - what do I need to set it to? Instead of saying: ./java_e ...

  8. mysql存储过程 --游标的使用 取每行记录 (多字段)

    delimiter $ create PROCEDURE phoneDeal() BEGIN DECLARE id varchar(64); -- id DECLARE phone1 varchar( ...

  9. TP框架,根据当前应用状态对应的配置文件

    index.php define('APP_STATUS','website'); /ThinkPHP/Library/Think/Dispatcher.class.php /** * 应用程序初始化 ...

  10. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...