nmh-workers
[Top][All Lists]
Advanced

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

Re: merge pick and scan


From: Bakul Shah
Subject: Re: merge pick and scan
Date: Thu, 21 Apr 2022 19:28:33 -0700


> On Apr 21, 2022, at 7:12 PM, Ken Hornstein <kenh@pobox.com> wrote:
> 
>>> You see, nmh's dirty secret (ok ok, one of many!) is that the
>>> first thing every command does is read the entire directory.
>>> Yep, the whole thing.
>> 
>> If you use any syscall tracer, you will see that this is not what
>> happens. scan & pick will do a directory read only if no messages
>> are specified because the default is all. Otherwise they only touch
>> specified messages.
> 
> You are incorrect.
> 
> % strace scan 5705
> [...]
> chdir("/users/kenh/Mail/inbox") = 0
> openat(AT_FDCWD, "/users/kenh/Mail/inbox", O_RDONLY|O_NONBLOCK|O_CLOEXEC
> |O_DIRECTORY) = 3
> access("/users/kenh/Mail/inbox", W_OK) = 0
> getdents(3, /* 1365 entries */, 32768)  = 32768
> getdents(3, /* 1365 entries */, 32768)  = 32760
> getdents(3, /* 829 entries */, 32768)   = 19912
> getdents(3, /* 0 entries */, 32768)     = 0
> close(3)                                = 0
> [...]

I just did "kdump|egrep -i 'nami|open|read'" -- I was forgetting
things have changed in Unix and we no longer read(2) a directory!
Thanks!

> Anything that needs a "struct msgs" for a folder has to call
> folder_read() (which is almost all nmh programs) and folder_read()
> calls readdir() on the whole folder.

pick seems to even read the whole dir twice!

Modern unixes cache dir entries so the cost can't be too bad
(no idea about NFS as I try to avoid it).

> 
> (I've got more to say about the original proposal, but ... tomorrow).
> 
> --Ken




reply via email to

[Prev in Thread] Current Thread [Next in Thread]