Ext4 Fast Commit

简介: # 概述Fast Commit 是 Linux 5.10 引入的一个新的轻量级日志方案,根据 ATC-17 的论文 “iJournaling: Fine-Grained Journaling for Improving the Latency of Fsync System Call” 实现。在我们常用的 ext4 data=ordered 日志模式下,fsync() 系统调用会因为无关 IO

概述

Fast Commit 是 Linux 5.10 引入的一个新的轻量级日志方案,根据 ATC-17 的论文 “iJournaling: Fine-Grained Journaling for Improving the Latency of Fsync System Call” 实现。
在我们常用的 ext4 data=ordered 日志模式下,fsync() 系统调用会因为无关 IO 操作导致显著的时延。Fast Commit 根据写入日志中的元数据反推,只提交与当前 transaction 相关的操作,从而优化 fsync() 的时延。
启用 Fast Commit 特性后,系统中将会有两个日志,快速提交日志用于可以优化的操作,常规日志用于标准提交。其中 Fast Commit 日志包含上一次标准提交之后执行的操作。
从作者的 benchmark 测试数据来看,打开 Fast Commit 特性后,本地 ext4 文件系统有 20% ~ 200% 的性能提升;NFS 场景也有 30% ~ 75% 的性能提升。

Benchmark Config w/o Fast Commit w/ Fast Commit Delta
Fsmark
Fsmark
Local, 8 threads
NFS, 4 threads
1475.1 files/s
299.4 files/s
4309.8 files/s
409.45 files/s
+192.2%
+36.8%
Dbench
Dbench
Local, 2 procs
NFS, 2 procs
33.32 MB/s
8.84 MB/s
70.87 MB/s
11.88 MB/s
+112.7%
+34.4%
Dbench
Dbench
Local, 10 procs
NFS, 10 procs
90.48 MB/s
34.62 MB/s
110.12 MB/s
52.83 MB/s
+21.7%
+52.6%
FileBench
FileBench
Local, 16 threads
NFS, 16 threads
10442.3 ops/s
1531.3 ops/s
18617.8 ops/s
2681.5 ops/s
+78.3%
+75.1%

如何使用

Alibaba Cloud Linux 3 / Ali5000 已经升级到 Linux 5.10 内核,因此内核默认已经支持 Fast Commit 特性。
但当前默认安装的 e2fsprogs 版本为 1.45.6,从 e2fsprogs 上游提交记录来看,需要 1.46.0 版本才支持 Fast Commit,因此当前在 Alibaba Cloud Linux 3 / Ali5000 中还不能直接使用该特性。

1、下载最新的 e2fsprogs 包并编译。

wget https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-1.46.2.tar.gz
tar -xvf e2fsprogs-1.46.2.tar.gz
cd e2fsprogs-1.46.2
./configure
make

2、格式化打开 fast commit 特性。

./misc/mke2fs -t ext4 -O fast_commit /dev/vdc1

dumpe2fs 可以看到已经打开 fast commit:
Filesystem features: has_journal ext_attr resize_inode dir_index fast_commit filetype extent 64bit flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize

此外,超级块中多出 Overhead blocks 字段:
Overhead blocks: 126828

同时,Journal size 也由默认的 128M 变成 130M,应该是默认 fast commit journal size 为 journal size / 64 带来的增量:
Journal size: 130M

性能测试

在 Alibaba Cloud Linux 3 中使用 fs_mark 对比测试结果显示,性能有 1 倍以上的提升,表明在频繁 fsync() 场景的确有很大性能提升,对数据库 MySQL/PostgreSQL 等场景会有较大的性能优化。

测试命令为 2 线程:

./fs_mark  -d  /mnt/vdc1/testdir1/  -d  /mnt/vdc1/testdir2/  -D  16  -N  256  -n  409600  -L  1  -S  1  -s  4096

测试结果(data=ordered, barrier):

Test Round w/o Fast Commit w/ Fast Commit Delta
Round 1 5528.5 11448.1 +107.07%
Round 2 5512.3 11499.9 +108.62%

测试结果(data=writeback, nobarrier):

Test Round w/o Fast Commit w/ Fast Commit Delta
Round 1 7976.0 18437.4 +131.16%
Round 2 8005.2 18471.0 +130.74%

Reference

ATC-17 论文:
https://www.usenix.org/system/files/conference/atc17/atc17-park.pdf

LWN 文章:
https://lwn.net/Articles/842385/

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
【异常】svn: E200009: Commit failed (details follow)/both sides of the move must be committed together的解决办法
svn: E200009: Commit failed (details follow)/both sides of the move must be committed together的解决办法
475 0
|
8月前
|
前端开发 JavaScript Shell
手写 git hooks 脚本(pre-commit、commit-msg)
手写 git hooks 脚本(pre-commit、commit-msg)
212 0
|
8月前
|
开发工具 git
git报错,error: You have not concluded your merge (MERGE_HEAD exists). hint: Please,
git报错,error: You have not concluded your merge (MERGE_HEAD exists). hint: Please,
86 0
|
8月前
|
存储 安全 开发工具
【Git】(fetch first)和(non-fast-forward)问题解决
【Git】(fetch first)和(non-fast-forward)问题解决
240 1
|
11月前
|
缓存 Oracle 关系型数据库
Oracle中控制commit的三个参数 commit_write, commit_logging和 commit_wait
Oracle中控制commit的动作有三个参数 commit_write, commit_logging和 commit_wait,按重要性分别说明如下
139 0
|
开发工具 git
【已解决】git取消分支合并(fatal: There is no merge to abort (MERGE_HEAD missing).)
git取消分支合并(fatal: There is no merge to abort (MERGE_HEAD missing).)
967 0
SVN commit:remains in tree-conflict解决方案
<span style="font-size:14px">       今天提交SVN时报异常</span><span style="font-size:14px; color:rgb(255,0,0); font-family:Arial; line-height:21px">SVN commit: ……remains in tree-conflict</span><span style
3157 0
|
开发工具 git
Commit request failed Commit failed. Ref must be HEAD and is HEAD
Commit request failed Commit failed. Ref must be HEAD and is HEAD
Commit request failed Commit failed. Ref must be HEAD and is HEAD
|
数据安全/隐私保护
SmartSVN无法提交的解决办法:because it was moved from which is not part of the commit; both sides of the move
SmartSVN无法提交的解决办法:because it was moved from which is not part of the commit; both sides of the move
329 0
1110. Complete Binary Tree (25)
#include #include #include #include using namespace std; struct node { int ad, l, r; }; vector visited(20, ...
957 0