Okay, I hit a crazy #OpenBSD (or possibly Perl) peculiarity today. For background context, OpenBSD's pkg_* tools are all written in Perl.
Testing stuff in a discussion with @rl_dane, I had cause to throw ktrace on the pkg_info command like
$ ktrace -f pkg_info.ktrace pkg_info -Q remind
All said, fairly boring. But when I was browsing through the dump
$ kdump -R -f pkg_info.ktrace | less
I found that it did a stat(2) call on every single file in my current working directory:
$ kdump -f pkg_info.ktrace -R | awk '/NAMI *"\./{++c; print}END{print "Total count:", c}'
This means that pkg_info runs noticeably faster in an empty directory than if run in a directory containing tens of thousands of files, especially if the machine uses a spinning-rust HDD rather than flash storage.
I haven't read the pkg_info source code deeply since I don't natively do perl, so I'm uncertain whether pkg_info is intentionally stat'ing every file, or whether perl just does this as part of its startup, but it seemed like a really weird behavior..


๐ต 

