[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: the correct way to read a big directory? Mutt?

Quoting Vincent Lefevre (vincent@vinc17.net):
> On 2015-04-24 16:39:51 -0500, David Wright wrote:
> > Well that's a relief. I was getting worried about there being some
> > "magic" involved when you said you didn't use cacheing. So, looking
> > back at https://lists.debian.org/debian-user/2015/04/msg01265.html ,
> > 
> >  "In which case, if you want to know how come mutt is so fast, take a
> >  look at the source. Just to mention one optimisation I would consider:
> >  slurp the directory and sort the entries by inode. Open the files in
> >  inode order.
> When you said that, I didn't know that this was taken from Mutt (or
> perhaps you suggested that without looking at the Mutt source?).

I think I had been reading around the ext2/3/4 filesystem descriptions
and happened upon this trick at some random link close by.

> This is now done in my script, but I had to use the ReadDir module
> from CPAN, since both readdir implementations in Perl (the standard
> readdir Perl function and POSIX::readdir) just return the file name.
> And this ReadDir module isn't available in a Debian package.

Python's library function listdir suffers the same way. If you want
the inode, you have to call stat to get it. (I haven't looked for
external modules like ReadDir as I don't have very large directories.)


Reply to: