block allocation algorithm [Was] Re: heavily fragmented file system.. How to defrag it on-line??]
Hi guys,
Reiser3 has worse fragmentation than ext3 in this test case. Reiser4 was better, but it had a bad worst case and still wasn't as good as xfs.
I'm especially interested in getting reiser3 to produce fewer fragments in this test.
Comments?
-------- Original Message --------
Subject: Re: [OT] block allocation algorithm [Was] Re: heavily fragmented file system.. How to defrag it on-line??
Date: Mon, 15 Mar 2004 11:13:32 +0800
From: Isaac Claymore <[email protected]>
To: Andreas Dilger <[email protected]>
CC: [email protected]
References: <[email protected]> <[email protected]> <[email protected]> <[email protected]>
Quoted 10 lines · Andreas Dilger
Quoted 8 lines · Isaac Claymore
I've got a workload that several clients tend to write to separate files under a same dir simultaneously, resulting in heavily fragmented files. And, even worse, those files are rarely read simultaneously, thus read performance degrades quite alot.
I'm wondering whether there's any feature that helps alleviating fragmentation in such workloads. Does writing to different dirs(of a same filesystem) help?
Quoted 7 lines
Very much yes. Files allocated from different directories will get blocks from different parts of the filesystem (if available), so they should be less fragmented. In 2.6 there is a heuristic that files opened by different processes allocate from different parts of a group, even within the same directory, but that only really helps if the files themselves aren't too large (i.e. under 8MB or so).
Thanks, I did some test on this last weekend, and here're the results in case someone is interested:
Test environment:
kernel: 2.6.3 with latest reiser4 patches applied.
OS: Debian testing/unstable
HW: Intel(R) Pentium(R) 4 CPU 1.80GHz, 256M RAM
For each FS configuration, my test went on as: dumping 3 files of 1G each simultaneously, and measure the fragmentation with 'filefrag'.
Each test iteration was done on a freshly formatted filesystem.
Here goes the figures & my evaluations:
1. reiser3, 3 files under a same dir:
sandbox:/mnt/foo [1016]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1018]# filefrag f0 f1 f2
f0: 470 extents found
f1: 461 extents found
f2: 470 extents found
My Evaluation: badly fragmented!
2. reiser3, 3 files under 3 different dirs:
sandbox:/mnt [1028]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir1/foo bs=16M count=64&;dd if=/dev/zero of=dir2/foo bs=16M count=64&;wait
sandbox:/mnt [1029]# filefrag dir0/foo dir1/foo dir2/foo dir0/foo: 448 extents found
dir1/foo: 462 extents found
dir2/foo: 443 extents found
My Evaluation: still bad, spreading the files under different dirs did no visible good.
3. ext3, 3 files under a same dir:
sandbox:/mnt/foo [1041]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1044]# filefrag f0 f1 f2
f0: 202 extents found, perfection would be 9 extents
f1: 207 extents found, perfection would be 9 extents
f2: 208 extents found, perfection would be 9 extents
My Evaluation: much better than reiser3, yet far from perfection.
4. ext3, 3 files under 3 different dirs:
sandbox:/mnt [1054]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir1/foo bs=16M count=64&;dd if=/dev/zero of=dir2/foo bs=16M count=64&;wait
sandbox:/mnt [1056]# sandbox:/mnt [1056]# filefrag dir0/foo dir1/foo dir2/foo dir0/foo: 91 extents found, perfection would be 9 extents dir1/foo: 9 extents found
dir2/foo: 95 extents found, perfection would be 9 extents
My Evaluation: spreading the files under different dirs DID help quite alot! but can we get even better result by spread the files more sparsely? (see next test)
5. still ext3, mkdir 10 dirs first, then dumping the files under the 1st, 5th, and 9th dirs:
sandbox:/mnt [1085]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1086]# filefrag dir{0,4,9}/foo dir0/foo: 11 extents found, perfection would be 9 extents dir4/foo: 11 extents found, perfection would be 9 extents dir9/foo: 10 extents found, perfection would be 9 extents
My Evaluation: almost perfect!
6. XFS, 3 files under a same dir:
sandbox:/mnt/foo [1112]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1114]# filefrag f0 f1 f2
f0: 25 extents found
f1: 11 extents found
f2: 20 extents found
My Evaluation: this'd be the BEST result I got, when dumping into a same dir.
7. XFS, dumping into 3 dirs among ten, similar to test 5:
sandbox:/mnt [1127]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1128]# filefrag dir0/foo dir4/foo dir9/foo dir0/foo: 1 extent found
dir4/foo: 1 extent found
dir9/foo: 1 extent found
My Evaluation: impressed! cant be any better now.
8. Reiser4, 1 dir
sandbox:/mnt/foo [1155]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1156]# filefrag f0 f1 f2
f0: 45 extents found
f1: 6011 extents found
f2: 45 extents found
My Evaluation: far better than it's brother reiser3. the 6011 extents of f1 was weird, i'd have done more iterations to get an average, just blame lazy me ;)
9. Reiser4, 3 dirs among 10:
sandbox:/mnt [1165]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1167]# filefrag dir{0,4,9}/foo
dir0/foo: 42 extents found
dir4/foo: 50 extents found
dir9/foo: 46 extents found
My Evaluation: nice figures, really. and unlike its elder brother, using more dirs DID help.
Quoted 11 lines
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/_______________________________________________
Ext3-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/ext3-users
Signature · 9 lines
Regards, Isaac () ascii ribbon campaign - against html e-mail /\ - against microsoft attachments _______________________________________________ Ext3-users mailing list [email protected] https://www.redhat.com/mailman/listinfo/ext3-users
Quoted 9 lines · Mike Fedyk
Hi guys,
Reiser3 has worse fragmentation than ext3 in this test case. Reiser4 was better, but it had a bad worst case and still wasn't as good as xfs.
I'm especially interested in getting reiser3 to produce fewer fragments in this test.
Comments?
There's a great deal of room for improvement in the reiser3 block allocator. I've got patches against 2.4.x that make it much smarter by trying to spread large files apart from each other but keep small files (and small directories) close together.
Those are on hold until the logging and acls are done and in, but if people want to play around with porting them I can send you a copy.
-chris
Quoted 11 lines · Chris Mason
Quoted 7 lines · Mike Fedyk
Hi guys,
Reiser3 has worse fragmentation than ext3 in this test case. Reiser4 was better, but it had a bad worst case and still wasn't as good as xfs.
I'm especially interested in getting reiser3 to produce fewer fragments in this test.
Comments?
Quoted 7 lines
There's a great deal of room for improvement in the reiser3 block allocator. I've got patches against 2.4.x that make it much smarter by trying to spread large files apart from each other but keep small files (and small directories) close together.
Those are on hold until the logging and acls are done and in, but if people want to play around with porting them I can send you a copy.
If I knew more than Shell and Perl, I'd take you up on that offer. Maybe in ~6 months. Lurking on the kernel lists really teaches you a lot. :-D
Mike
Zam, please analyze why we have so many fragments in Reiser4. It should not be. At most we should have 1 fragment per invocation of slum flushing.
Hans
Quoted 212 lines · Mike Fedyk
Hi guys,
Reiser3 has worse fragmentation than ext3 in this test case. Reiser4 was better, but it had a bad worst case and still wasn't as good as xfs.
I'm especially interested in getting reiser3 to produce fewer fragments in this test.
Comments?
-------- Original Message --------
Subject: Re: [OT] block allocation algorithm [Was] Re: heavily fragmented file system.. How to defrag it on-line??
Date: Mon, 15 Mar 2004 11:13:32 +0800
From: Isaac Claymore <[email protected]>
To: Andreas Dilger <[email protected]>
CC: [email protected]
References: <[email protected]> <[email protected]> <[email protected]> <[email protected]>Quoted 10 lines · Andreas Dilger
Quoted 1 line · Isaac Claymore
I've got a workload that several clients tend to write to separate
files
Quoted 1 line
under a same dir simultaneously, resulting in heavily fragmented
files.
Quoted 4 lines
And, even worse, those files are rarely read simultaneously, thus read performance degrades quite alot.
Quoted 1 line
I'm wondering whether there's any feature that helps alleviating
fragmentation in such workloads. Does writing to different dirs(of
a same
Quoted 9 lines
Quoted 1 line
filesystem) help?
Very much yes. Files allocated from different directories will get blocks from different parts of the filesystem (if available), so they should be less fragmented. In 2.6 there is a heuristic that files opened by different processes allocate from different parts of a group, even within the same directory, but that only really helps if the files themselves aren't too large (i.e. under 8MB or so).
Thanks, I did some test on this last weekend, and here're the results in case someone is interested:
Test environment:
kernel: 2.6.3 with latest reiser4 patches applied.
OS: Debian testing/unstable
HW: Intel(R) Pentium(R) 4 CPU 1.80GHz, 256M RAMFor each FS configuration, my test went on as: dumping 3 files of 1G each simultaneously, and measure the fragmentation with 'filefrag'.
Each test iteration was done on a freshly formatted filesystem.
Here goes the figures & my evaluations:
1. reiser3, 3 files under a same dir:
sandbox:/mnt/foo [1016]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1018]# filefrag f0 f1 f2
f0: 470 extents found
f1: 461 extents found
f2: 470 extents foundMy Evaluation: badly fragmented!
2. reiser3, 3 files under 3 different dirs:
sandbox:/mnt [1028]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir1/foo bs=16M count=64&;dd if=/dev/zero of=dir2/foo bs=16M count=64&;wait
sandbox:/mnt [1029]# filefrag dir0/foo dir1/foo dir2/foo dir0/foo: 448 extents found
dir1/foo: 462 extents found
dir2/foo: 443 extents foundMy Evaluation: still bad, spreading the files under different dirs did no visible good.
3. ext3, 3 files under a same dir:
sandbox:/mnt/foo [1041]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1044]# filefrag f0 f1 f2
f0: 202 extents found, perfection would be 9 extents
f1: 207 extents found, perfection would be 9 extents
f2: 208 extents found, perfection would be 9 extentsMy Evaluation: much better than reiser3, yet far from perfection.
4. ext3, 3 files under 3 different dirs:
sandbox:/mnt [1054]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir1/foo bs=16M count=64&;dd if=/dev/zero of=dir2/foo bs=16M count=64&;wait
sandbox:/mnt [1056]# sandbox:/mnt [1056]# filefrag dir0/foo dir1/foo dir2/foo dir0/foo: 91 extents found, perfection would be 9 extents dir1/foo: 9 extents found
dir2/foo: 95 extents found, perfection would be 9 extentsMy Evaluation: spreading the files under different dirs DID help quite alot! but can we get even better result by spread the files more sparsely? (see next test)
5. still ext3, mkdir 10 dirs first, then dumping the files under the 1st, 5th, and 9th dirs:
sandbox:/mnt [1085]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1086]# filefrag dir{0,4,9}/foo dir0/foo: 11 extents found, perfection would be 9 extents dir4/foo: 11 extents found, perfection would be 9 extents dir9/foo: 10 extents found, perfection would be 9 extents
My Evaluation: almost perfect!
6. XFS, 3 files under a same dir:
sandbox:/mnt/foo [1112]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1114]# filefrag f0 f1 f2
f0: 25 extents found
f1: 11 extents found
f2: 20 extents foundMy Evaluation: this'd be the BEST result I got, when dumping into a same dir.
7. XFS, dumping into 3 dirs among ten, similar to test 5:
sandbox:/mnt [1127]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1128]# filefrag dir0/foo dir4/foo dir9/foo dir0/foo: 1 extent found
dir4/foo: 1 extent found
dir9/foo: 1 extent foundMy Evaluation: impressed! cant be any better now.
8. Reiser4, 1 dir
sandbox:/mnt/foo [1155]# dd if=/dev/zero of=f0 bs=16M count=64&;dd if=/dev/zero of=f1 bs=16M count=64&;dd if=/dev/zero of=f2 bs=16M count=64&;wait
sandbox:/mnt/foo [1156]# filefrag f0 f1 f2
f0: 45 extents found
f1: 6011 extents found
f2: 45 extents foundMy Evaluation: far better than it's brother reiser3. the 6011 extents of f1 was weird, i'd have done more iterations to get an average, just blame lazy me ;)
9. Reiser4, 3 dirs among 10:
sandbox:/mnt [1165]# dd if=/dev/zero of=dir0/foo bs=16M count=64&;dd if=/dev/zero of=dir4/foo bs=16M count=64&;dd if=/dev/zero of=dir9/foo bs=16M count=64&;wait
sandbox:/mnt [1167]# filefrag dir{0,4,9}/foo
dir0/foo: 42 extents found
dir4/foo: 50 extents found
dir9/foo: 46 extents foundMy Evaluation: nice figures, really. and unlike its elder brother, using more dirs DID help.
Quoted 11 lines
Cheers, Andreas
Signature · 9 lines
Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/ _______________________________________________ Ext3-users mailing list [email protected] https://www.redhat.com/mailman/listinfo/ext3-users
Signature · 1 line
Hans