[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [nmh-workers] for me a useful script
From: |
Valdis Klētnieks |
Subject: |
Re: [nmh-workers] for me a useful script |
Date: |
Thu, 23 May 2019 14:20:57 -0400 |
On Thu, 23 May 2019 13:45:02 -0400, Jude DaShiell said:
> echo "first available message:"
> scan -width 6|head -1
scan -width 6 first will be much faster.
> echo "last available message:"
> scan -width 6|tail -1
scan -width 6 last will be much faster.
If you have 10,000 entries in a folder, scan first/last still has to read and
sort the directory, but it can find first and last without opening a file.
A quick test:
[~] strace -f scan -width 6 +inbox 2>| /tmp/inbox | head -1
1
[~] grep open /tmp/inbox | tail -1
openat(AT_FDCWD, "1171", O_RDONLY) = 3
Yes, it reads that many files before the back-pressure SIGPIPE from 'head -1'
exiting catches up with it.
scan | tail will have to open and read all 10,000 files.....
pgpwxu4hTgf6u.pgp
Description: PGP signature