bdb log file 预设长度的性能优化
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 预设长度的性能优化的更多相关文章
- oracle之 等待事件LOG FILE SYNC (awr)优化
log file sycn是ORACLE里最普遍的等待事件之一,一般log file sycn的等待时间都非常短 1-5ms,不会有什么问题,但是一旦出问题,往往都比较难解决.什么时候会产生log f ...
- hbase性能优化总结
hbase性能优化总结 1. 表的设计 1.1 Pre-Creating Regions 默认情况下,在创建HBase表的时候会自动创建一个region分区,当导入数据的时候,所有的HBase客户端都 ...
- 完全揭秘log file sync等待事件-转自itpub
原贴地址:http://www.itpub.net/thread-1777234-1-1.html 谢谢 guoyJoe 老大 这里先引用一下tanel poder大师的图: 什么是log fil ...
- Android性能优化问题总结
性能优化这块,分为UI性能优化.内存优化.数据库优化.网络优化.耗电优化等等.可以从1.如何发现问题,2.怎么解决问题,3.解决效果对比,这几个方面去描述.举个简单例子——UI优化,可以从 UI出现什 ...
- 理解LGWR,Log File Sync Waits以及Commit的性能问题[转]
理解LGWR,Log File Sync Waits以及Commit的性能问题 一.概要: 1. Commit和log filesync的工作机制 2. 为什么log file wait太久 3. ...
- RAC 性能分析 - 'log file sync' 等待事件
简介 本文主要讨论 RAC 数据库中的'log file sync' 等待事件.RAC 数据库中的'log file sync' 等待事件要比单机数据库中的'log file sync' 等待事件复杂 ...
- Oracle之 等待事件log file sync + log file parallel write (awr优化)
这是3月份某客户的情况,原因是server硬件故障后进行更换之后,业务翻译偶尔出现提交缓慢的情况.我们先来看下awr的情况. 我们能够看到,该系统的load profile信息事实上并不高,每秒才21 ...
- Java程序性能优化Tip
本博客是阅读<java time and space performance tips>这本小书后整理的读书笔记性质博客,增加了几个测试代码,代码可以在此下载:java时空间性能优化测试代 ...
- mysql数据库性能优化(包括SQL,表结构,索引,缓存)
优化目标减少 IO 次数IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当 ...
随机推荐
- C++设计模式-备忘录模式(1)
备忘录模式:备忘录对象时一个用来存储另外一个对象内部状态的快照对象. 备忘录模式的用意是在不破坏封装的条件下,将一个对象的状态捉住并外部化,存储起来从而可以在将来合适的时候把这个对象还原到存储起来的状 ...
- mysql分表和表分区详解
为什么要分表和分区? 日常开发中我们经常会遇到大表的情况,所谓的大表是指存储了百万级乃至千万级条记录的表.这样的表过于庞大,导致数据库在查询和插入的时候耗时太长,性能低下,如果涉及联合查询的情况,性能 ...
- thinkphp 添加 修改删除
在 MainController.class.php 添加 public function zhuCe() { //时间两个逻辑 // 1 显示页面 2向数据库添加 if(empty($_POST)) ...
- Hibernate 注解的用法以及说明(二)
注解映射必须满足两大条件:Hibernate3.2以上版本和JSEE 5. @Entity 类注释,所有要持久化的类都要有@Entity public class Org implements ...
- curl 模拟登录微信公众平台带验证码
这段时间一直写个项目, 从切图到前端到后台都要搞定,真tm累. 今天下午手残,不停用错误的密码去模拟登录微信公众平台,结果后来出现验证码,瞬间悲剧(菜鸟从来没搞过带验证码的). 研究了一下,发现其实很 ...
- AFN框架内部结构
AFN结构体 - NSURLConnection + AFURLConnectionOperation + AFHTTPRequestOperation + AFHTTPRequestOperatio ...
- 谷歌Cartographer学习(1)-快速安装测试
谷歌自己提供了安装方法,但是安装比较繁琐,我做了一定的修改,代码放到个人github上,https://github.com/hitcm/. ros下面的安装非常快捷,只需要catkin_make即可 ...
- 去除inline-block之间的间距
a标签的父容器添加: font-size: 0; -webkit-text-size-adjust:none;
- QT toLocal8Bit奇怪的问题
#include "mainwindow.h" #include "ui_mainwindow.h" #include<QDebug> MainWi ...
- 全自动ARP实时绑定BAT文件
全自动ARP实时绑定BAT文件 说明一下,这个BVS脚本,它会每六秒钟清除一次ARP缓存.并绑定网关.真正做到了实时防护! 代码如下:请另存为.BAT文件.再运行一下,就可以了 path c:\;c: ...