Do we really need correct st_nlink count for directories?
Thu Apr 24 13:35:00 GMT 2008
According to Eric Blake on 4/24/2008 7:32 AM:
> But if it takes an entire directory read to determine a
> correct st_nlink, in order to avoid an entire directory as an
> optimization, then it isn't optimal. I'm all for dropping correct
> st_nlink, and using 1 instead.
More importantly, if it will speed up the stat() of a directory in the
case where the st_nlink optimization is not being used (which I believe is
more often the case), then the performance improvement of not counting
subdirs for a faster stat() definitely outweighs the loss in optimization
on the few places where the readdir() st_nlink optimization even makes
sense (for example, even though find is coded to use the st_nlink
optimization, I would hazard a guess that less than 50% of find queries
are actually able to use it, because there are only a limited subset of
queries where you only care about identifying subdirectories, rather than
visiting all files in the directory).
Don't work too hard, make some time for fun as well!
Eric Blake email@example.com
More information about the Cygwin-developers