News for hackers. Stuff that matters.
Re:Unix "find" expressions compiled to bytecode by tasty_freeze on Friday December 26, 2025 @10:39AM (#46393130)
That is a fun exercise, but I imagine the time to evaluate the conditional expression is a tiny fraction, just a percent or less, than the time it takes to make the file system calls.
Re:Unix "find" expressions compiled to bytecode by nasretdinov on Friday December 26, 2025 @12:13PM (#46393995)
For many cases you don't even need to make stat() call to determine whether or not the file is a directory (d_type specifically can tell it: https://man7.org/linux/man-pages/man3/readdir.3.html). That's what allows find(1) to be so quick
Re:Unix "find" expressions compiled to bytecode by loeg on Friday December 26, 2025 @03:23PM (#46395811)
You could imagine determining from the parsed expression whether or not stat'ing was required.

NFS has readdirplus, but I don't think it ever made its way into Linux/POSIX. (Some filesystems could efficiently return dirents + stat information.)

Re:Unix "find" expressions compiled to bytecode by nasretdinov on Friday December 26, 2025 @03:59PM (#46396195)
> readdirplus

Well, it definitely does _something_, because on NFS the subsequent stat() calls after reading the directory names do indeed complete instantly :), at least in my testing.

Re:Unix "find" expressions compiled to bytecode by loeg on Friday December 26, 2025 @04:10PM (#46396301)
I mean, readdirplus as a local filesystem API. Ultimately unix programs are just invoking getdents() (or equivalent) + stat() (or statx, whatever). Linux nfsclient probably caches the result of readdirplus for subsequent stat.
Re:Unix "find" expressions compiled to bytecode by CerryuDu on Friday December 26, 2025 @11:34AM (#46393596)
... not to mention the time it takes to load directory entries and inodes when the cache is cold.