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 优化中需要第一优先考虑,当 ...
随机推荐
- ZOJ 3209 Treasure Map (Dancing Links)
Treasure Map Time Limit: 2 Seconds Memory Limit: 32768 KB Your boss once had got many copies of ...
- 如何进入IT行业?
其实IT行业就如一个具有标准配件的机一样是开放的行业,无论你是否科班出身,无论你是什么学历,只要你掌握相关的针对性很强的计算机知识,想在IT行业发展随时可以即插即用,这主要由IT行业的特点确PC定的. ...
- win10家庭版快速升级专业版
win10家庭普通版升级专业版方法: 1.点击“开始”,选择控制面板. 2.点击“系统与安全”,选择“Windows Anytime Upgrade”.(或者:单击「开始」按钮,在搜索框中,键入any ...
- thinkphp 动态验证码
<?php namespace Home\Controller; use Think\Controller; class TestController extends Controller { ...
- 完整地mybatis + springmvc用checkbox实现批量删除
因为自己在网上找了半天,都找不到完整地代码(脑袋笨,不会变通到自己项目里),所以在这里记下了近乎完整的代码 前端代码 <span style="cursor:pointer;" ...
- (转)在MAC上查找和设置$JAVA_HOME
最近升级了MAC OS,装了JDK7 for mac,在这里下载JDK7 for mac,装完之后发现在默认的路径下找不到JDK7的HOME,如下所示: $ which java /usr/bin/j ...
- scp详解
scp 命令 ================== scp 可以在 2个 linux 主机间复制文件: 命令基本格式: scp [可选参数] file_source file_targe ...
- Android ActionBar
ActionBar 在android3.0中就加入了,但是android3.0适用于平板电脑的,在手机不能使用.android 4.0之后也开始有AndroidBar.所以说要想使用androidBa ...
- Linux中的输入重定向,变量
1 :分号 格式:命令1:命令2;命令3 说明:命令之间用分号隔开是顺序执行,命令之间没有任何逻辑关系 2 && 逻辑与 格式:命令1 && 命令2 说明:命令1正 ...
- h5整理--详解css的相对定位和绝对定位
浏览器默认状态下position的属性默认值是static也就是没有定位,元素出现在正常的文档流中,这个时候给元素设置的left,right.bottom.top这些偏移属性是没有效果的,不会生效: ...