2012-02-29 13:31:08

by Jacek Luczak

[permalink] [raw]
Subject: getdents - ext4 vs btrfs performance

Hi All,

Long story short: We've found that operations on a directory structure
holding many dirs takes ages on ext4.

The Question: Why there's that huge difference in ext4 and btrfs? See
below test results for real values.

Background: I had to backup a Jenkins directory holding workspace for
few projects which were co from svn (implies lot of extra .svn dirs).
The copy takes lot of time (at least more than I've expected) and
process was mostly in D (disk sleep). I've dig more and done some
extra test to see if this is not a regression on block/fs site. To
isolate the issue I've also performed same tests on btrfs.

Test environment configuration:
1) HW: HP ProLiant BL460 G6, 48 GB of memory, 2x 6 core Intel X5670 HT
enabled, Smart Array P410i, RAID 1 on top of 2x 10K RPM SAS HDDs.
2) Kernels: All tests were done on following kernels:
- 2.6.39.4-3 -- the build ID (3) is used here for internal tacking of
config changes mostly. In -3 we've introduced ,,fix readahead pipeline
break caused by block plug'' patch. Otherwise it's pure 2.6.39.4.
- 3.2.7 -- latest kernel at the time of testing (3.2.8 has been
release recently).
3) A subject of tests, directory holding:
- 54GB of data (measured on ext4)
- 1978149 files
- 844008 directories
4) Mount options:
- ext4 -- errors=remount-ro,noatime,data=writeback
- btrfs -- noatime,nodatacow and for later investigation on
copression effect: noatime,nodatacow,compress=lzo

In all tests I've been measuring time of execution. Following tests
were performed:
- find . -type d
- find . -type f
- cp -a
- rm -rf

Ext4 results:
| Type | 2.6.39.4-3 | 3.2.7
| Dir cnt | 17m 40sec | 11m 20sec
| File cnt | 17m 36sec | 11m 22sec
| Copy | 1h 28m | 1h 27m
| Remove| 3m 43sec


2012-02-29 13:52:07

by Chris Mason

[permalink] [raw]
Subject: Re: getdents - ext4 vs btrfs performance

On Wed, Feb 29, 2012 at 02:31:03PM +0100, Jacek Luczak wrote:
> Hi All,
>
> Long story short: We've found that operations on a directory structure
> holding many dirs takes ages on ext4.
>
> The Question: Why there's that huge difference in ext4 and btrfs? See
> below test results for real values.
>
> Background: I had to backup a Jenkins directory holding workspace for
> few projects which were co from svn (implies lot of extra .svn dirs).
> The copy takes lot of time (at least more than I've expected) and
> process was mostly in D (disk sleep). I've dig more and done some
> extra test to see if this is not a regression on block/fs site. To
> isolate the issue I've also performed same tests on btrfs.
>
> Test environment configuration:
> 1) HW: HP ProLiant BL460 G6, 48 GB of memory, 2x 6 core Intel X5670 HT
> enabled, Smart Array P410i, RAID 1 on top of 2x 10K RPM SAS HDDs.
> 2) Kernels: All tests were done on following kernels:
> - 2.6.39.4-3 -- the build ID (3) is used here for internal tacking of
> config changes mostly. In -3 we've introduced ,,fix readahead pipeline
> break caused by block plug'' patch. Otherwise it's pure 2.6.39.4.
> - 3.2.7 -- latest kernel at the time of testing (3.2.8 has been
> release recently).
> 3) A subject of tests, directory holding:
> - 54GB of data (measured on ext4)
> - 1978149 files
> - 844008 directories
> 4) Mount options:
> - ext4 -- errors=remount-ro,noatime,data=writeback
> - btrfs -- noatime,nodatacow and for later investigation on
> copression effect: noatime,nodatacow,compress=lzo

For btrfs, nodatacow and compression don't really mix. The compression
will just override it. (Just FYI, not really related to these results).

>
> In all tests I've been measuring time of execution. Following tests
> were performed:
> - find . -type d
> - find . -type f
> - cp -a
> - rm -rf
>
> Ext4 results:
> | Type | 2.6.39.4-3 | 3.2.7
> | Dir cnt | 17m 40sec | 11m 20sec
> | File cnt | 17m 36sec | 11m 22sec
> | Copy | 1h 28m | 1h 27m
> | Remove| 3m 43sec

Are the btrfs numbers missing? ;)

In order for btrfs to be faster for cp -a, the files probably didn't
change much since creation. Btrfs maintains extra directory indexes
that help in sequential backup scans, but this usually means slower
delete performance.

But, how exactly did you benchmark it? If you compare a fresh
mkfs.btrfs where you just copied all the data over with an ext4 FS that
has been on the disk for a long time, it isn't quite fair to ext4.

-chris

2012-02-29 14:00:34

by Lukas Czerner

[permalink] [raw]
Subject: Re: getdents - ext4 vs btrfs performance

On Wed, 29 Feb 2012, Chris Mason wrote:

> On Wed, Feb 29, 2012 at 02:31:03PM +0100, Jacek Luczak wrote:
> > Hi All,
> >
> > Long story short: We've found that operations on a directory structure
> > holding many dirs takes ages on ext4.
> >
> > The Question: Why there's that huge difference in ext4 and btrfs? See
> > below test results for real values.
> >
> > Background: I had to backup a Jenkins directory holding workspace for
> > few projects which were co from svn (implies lot of extra .svn dirs).
> > The copy takes lot of time (at least more than I've expected) and
> > process was mostly in D (disk sleep). I've dig more and done some
> > extra test to see if this is not a regression on block/fs site. To
> > isolate the issue I've also performed same tests on btrfs.
> >
> > Test environment configuration:
> > 1) HW: HP ProLiant BL460 G6, 48 GB of memory, 2x 6 core Intel X5670 HT
> > enabled, Smart Array P410i, RAID 1 on top of 2x 10K RPM SAS HDDs.
> > 2) Kernels: All tests were done on following kernels:
> > - 2.6.39.4-3 -- the build ID (3) is used here for internal tacking of
> > config changes mostly. In -3 we've introduced ,,fix readahead pipeline
> > break caused by block plug'' patch. Otherwise it's pure 2.6.39.4.
> > - 3.2.7 -- latest kernel at the time of testing (3.2.8 has been
> > release recently).
> > 3) A subject of tests, directory holding:
> > - 54GB of data (measured on ext4)
> > - 1978149 files
> > - 844008 directories
> > 4) Mount options:
> > - ext4 -- errors=remount-ro,noatime,data=writeback
> > - btrfs -- noatime,nodatacow and for later investigation on
> > copression effect: noatime,nodatacow,compress=lzo
>
> For btrfs, nodatacow and compression don't really mix. The compression
> will just override it. (Just FYI, not really related to these results).
>
> >
> > In all tests I've been measuring time of execution. Following tests
> > were performed:
> > - find . -type d
> > - find . -type f
> > - cp -a
> > - rm -rf
> >
> > Ext4 results:
> > | Type | 2.6.39.4-3 | 3.2.7
> > | Dir cnt | 17m 40sec | 11m 20sec
> > | File cnt | 17m 36sec | 11m 22sec
> > | Copy | 1h 28m | 1h 27m
> > | Remove| 3m 43sec
>
> Are the btrfs numbers missing? ;)
>
> In order for btrfs to be faster for cp -a, the files probably didn't
> change much since creation. Btrfs maintains extra directory indexes
> that help in sequential backup scans, but this usually means slower
> delete performance.

Exactly and IIRC ext4 have directory entries stored in hash order which
does not really help the sequential access.

>
> But, how exactly did you benchmark it? If you compare a fresh
> mkfs.btrfs where you just copied all the data over with an ext4 FS that
> has been on the disk for a long time, it isn't quite fair to ext4.

I have the same question, note that if the files on ext4 has been worked
with it may very well be that directory hash trees are not in very good
shape. You can attempt to optimize that by e2fsck (just run fsck.ext4 -f
<device>) but that may take quite some time and memory, but it is worth
trying.

Thanks!
-Lukas

>
> -chris
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--

2012-02-29 14:22:43

by Chris Mason

[permalink] [raw]
Subject: Re: getdents - ext4 vs btrfs performance

On Wed, Feb 29, 2012 at 08:51:58AM -0500, Chris Mason wrote:
> On Wed, Feb 29, 2012 at 02:31:03PM +0100, Jacek Luczak wrote:
> > Ext4 results:
> > | Type | 2.6.39.4-3 | 3.2.7
> > | Dir cnt | 17m 40sec | 11m 20sec
> > | File cnt | 17m 36sec | 11m 22sec
> > | Copy | 1h 28m | 1h 27m
> > | Remove| 3m 43sec
>
> Are the btrfs numbers missing? ;)

[ answered in a different reply, btrfs is faster in everything except
delete ]

The btrfs readdir uses an index that is much more likely to be
sequential on disk than ext. This makes the readdir more sequential and
it makes the actual file IO more sequential because we're reading things
in the order they were created instead of (random) htree index order.

>
> In order for btrfs to be faster for cp -a, the files probably didn't
> change much since creation. Btrfs maintains extra directory indexes
> that help in sequential backup scans, but this usually means slower
> delete performance.
>
> But, how exactly did you benchmark it? If you compare a fresh
> mkfs.btrfs where you just copied all the data over with an ext4 FS that
> has been on the disk for a long time, it isn't quite fair to ext4.
>

But, the consistent benchmarking part is really important. We shouldn't
put an aged ext4 up against a fresh mkfs.btrfs. Did you do ext4
comparisons on a fresh copy?

-chris