Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Filename generation: sorting by inode number



On 2015-04-25 11:14:51 -0700, Bart Schaefer wrote:
> On Apr 25,  7:11am, Mikael Magnusson wrote:
> }
> } Everything is possible with the "o" glob qualifier by virtue of the
> } "e" specifier;
> } zmodload -aF zsh/stat -b:stat b:zstat
> } ls -Udi *(noe:'zstat -L -A REPLY +inode $REPLY:')
> 
> That's why I asked about whether the hash-ordering affected efficiency
> of stat().

Indeed:

$ sudo drop-caches && time grep -q zzz 1000*(oN)
grep -q zzz 1000*(oN)  0.03s user 0.32s system 0% cpu 40.726 total

$ sudo drop-caches && time grep -q zzz 1000*(noe:'zstat -L -A REPLY +inode $REPLY:')
grep -q zzz 1000*(noe:'zstat -L -A REPLY +inode $REPLY:')  0.06s user 0.14s system 12% cpu 1.590 total

but "oc" is slower (confirmed by 3 tests each), even though the files
have been created with no inode change, e.g.:

$ sudo drop-caches && time grep -q zzz 1000*(oc)
grep -q zzz 1000*(oc)  0.01s user 0.19s system 7% cpu 2.589 total

The probable cause is the low ctime resolution (1 second?).

> Although the inode number is available this way, we could
> also get it from the dirent structure.

Yes, this would be more efficient, but perhaps not noticeable.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author