nmh-workers
[Top] [All Lists]

Re: merge pick and scan

2022-04-21 21:12:32
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
[...]

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.

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

--Ken

<Prev in Thread] Current Thread [Next in Thread>