
Filesystem 性能比較 1
BtrFS, Ext2, Ext4, JFS, XFSの性能を調査しました.
ファイルの作成,stat,削除(unlink)
続き → 性能比較2 (fio)
調査方法
100,000個のファイルの,作る時間,statで調べる時間,削除する時間を測定しました.
各ファイルは0バイトです.
ディレクトリエントリやinodeの処理の時間を測っていると言えます.
ファイルデータがないので.ディスク上データレイアウト実装やブロック確保の影響は含まれていません。
プログラムは記事の末尾にあります.
環境
CPU: Intel Core i7-3770 CPU @ 3.40GHz, clock rate 3.4 GHz (fixed)
HDD: Seagate Barracuda 7200.9, ST3808110AS (80.0GB)
OS: Ubuntu 20.04.3 LTS, desktop, Linux 5.15.25
Memory: 16 GB
/dev/sdb全体をformat (ex. mkfe.ext2 /dev/sdb)
結果
ファイル作成


JFSが非常に遅いです.
XFSも遅いです。XFSは、もともとIRIX用のファイルシステムで、大きなファイルシの処理が速いと言われているものです。
ファイルstat

ファイル削除

プログラム
#define MAX 100000
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <sys/stat.h>
char fname[MAX][11];
void main(){
int fd, i;
struct timespec ts[4];
struct stat statbuf;
for(i=0; i<MAX; i++){
sprintf( fname[i], "/mnt/%05d", i);
}
clock_gettime(CLOCK_REALTIME, ts);
for(i=0; i<MAX; i++){
fd = open( fname[i], O_CREAT);
close(fd);
}
clock_gettime(CLOCK_REALTIME, ts+1);
for(i=0; i<MAX; i++){
stat( fname[i], &statbuf);
}
clock_gettime(CLOCK_REALTIME, ts+2);
for(i=0; i<MAX; i++){
unlink( fname[i]);
}
clock_gettime(CLOCK_REALTIME, ts+3);
for(i=0; i<4; i++){
printf("%ld.%09ld ",ts[i].tv_sec,ts[i].tv_nsec);
}
printf("\n");
}
fs=xfs
if [ ${fs} = "fat" ]
then
mkfs.${fs} -I /dev/sdb
elif [ ${fs} = "xfs" ]
then
mkfs.${fs} -f /dev/sdb
else
echo y | mkfs.${fs} /dev/sdb
fi
mount /dev/sdb /mnt/
mount | grep sdb > result.${fs}.txt
./a.out >> result.${fs}.txt
sync
umount /mnt/
補足
既存ファイル数とファイルstat時間の関係も調べたい.本当は,Ext3も入れたい.