Unix "find" expressions compiled to bytecode

(nullprogram.com)

78 points | by rcarmo 7 hours ago

2 comments

  • drob518 1 hour ago
    From the article:

    > I was later surprised all the real world find implementations I examined use tree-walk interpreters instead.

    I’m not sure why this would be surprising. The find utility is totally dominated by disk IOPS. The interpretation performance of find conditions is totally swamped by reading stuff from disk. So, keep it simple and just use a tree-walk interpreter.

  • tasty_freeze 4 hours ago
    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.
    • nasretdinov 2 hours ago
      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
    • CerryuDu 3 hours ago
      ... not to mention the time it takes to load directory entries and inodes when the cache is cold.