Re: stat benchmark

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Theodore Tso <tytso@...>
Cc: <linux-kernel@...>, <alexl@...>
Date: Sunday, April 27, 2008 - 7:29 pm

Theodore Tso <tytso@mit.edu> writes:


Yeah, Carl suggested this as well. 

Sorting by inode is a major improvement. The numbers are less stable,
but consistently much lower:

    Time to readdir(): 0.238737 s
    Time to stat 2366 files: 1.338904 s

compared to

    Time to readdir(): 0.227599 s
    Time to stat 2366 files: 7.981752 s

Of course, 1.3 seconds is still far from instant, but it may be the
best we can get given the realities of ext3 disk layout.

One thing that surprised me is that lstat is slightly slower than
stat. With lstat() instead of stat(), I get:

    Time to stat 2366 files: 1.472115 s
    Time to readdir(): 1.735542 s

I naively thought that stat() was a superset of lstat(), but
apparently not.


After I read Carl's mail I looked at what glib - which is used by both
Nautilus and the gtk+ file open dialog - does, and in fact the latest
version does actually read chunks of 1000 dirents and sorts them by
inode. The version I had installed when I wrote the benchmark just
stat'ed in readdir() order.

For a directory of ~2360 files, chunks of a 1000 files is actually
surprisingly worse than statting all of the files at once:

    Time to stat 1000 files: 1.008735 s
    Time to stat 1000 files: 0.738936 s
    Time to stat 366 files: 0.217002 s

I guess this just shows that seeks really is pretty much all that
matters. Glib should maybe use a larger chunk size.

I don't know if a general library outside glib would be useful. It
seems that just telling people to "sort by inode before statting"
would be just as effective as telling them "use this optimized
library".



Thanks,
Soren
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
stat benchmark, Soeren Sandmann, (Thu Apr 24, 4:59 pm)
Re: stat benchmark, Ulrich Drepper, (Mon Apr 28, 12:43 am)
Re: stat benchmark, Theodore Tso, (Mon Apr 28, 7:53 am)
Re: stat benchmark, J. Bruce Fields, (Mon Apr 28, 12:18 pm)
Re: stat benchmark, Avi Kivity, (Mon Apr 28, 7:59 am)
Re: stat benchmark, Theodore Tso, (Mon Apr 28, 9:31 am)
Re: stat benchmark, Carl Henrik Lunde, (Sun Apr 27, 6:40 pm)
Re: stat benchmark, Zach Brown, (Mon Apr 28, 1:46 pm)
Re: stat benchmark, Theodore Tso, (Fri Apr 25, 3:48 pm)
Re: stat benchmark, Soeren Sandmann, (Sun Apr 27, 7:29 pm)
Re: stat benchmark, Theodore Tso, (Sun Apr 27, 10:10 pm)
Re: stat benchmark, Carl Henrik Lunde, (Sun Apr 27, 8:13 pm)
Re: stat benchmark, Alexander Larsson, (Mon Apr 28, 3:41 pm)
Re: stat benchmark, Jan Engelhardt, (Thu Apr 24, 5:44 pm)
Re: stat benchmark, Christoph Hellwig, (Fri Apr 25, 3:01 am)
Re: stat benchmark, Justin Banks, (Thu Apr 24, 10:27 pm)
Re: stat benchmark, Carl Henrik Lunde, (Thu Apr 24, 5:42 pm)