Re: possible optimization



On Mon, 2006-02-27 at 11:20 -0600, Federico Mena Quintero wrote:
> On Fri, 2006-02-24 at 10:30 +0100, Alexander Larsson wrote:
> > I just realised that when calculating the "size" calculation for folders
> > (the number of items in the folder) we're currently getting all
> > information from the files in that folder (i.e. a stat call per file)
> > when we only really need the filenames.
> 
> You don't even need the names.  stat("/some/directory") will give you
> the number of entries in the directory in the st_nlink field.  An empty
> directory has st_nlink=2 because of "." and "..".  This is useful for
> non-deep counts.

Hmm. This is interesting. How portable is this amongst filesystems? (Of
course, it'll only work for file:/// files.)

> Radek Doulik also pointed me to the interesting fact that Linux provides
> more than dirent.d_name for some filesystems; mail attached.  We could
> use dirent.d_type to avoid stat()ing sometimes.

I'm aware of this.

> So with st_nlink plus d_type==DT_DIR, we could do deep counts very
> quickly on at least ext2/ext3.

Unfortunately we need size in our deep counts too. (The only place we
show the deep count is the property dialog, and that shows the deep size
too.)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a gun-slinging skateboarding photographer who dotes on his loving old ma. 
She's a beautiful belly-dancing bounty hunter with a flame-thrower. They fight 
crime! 




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