On Sat, Jun 20, 2026 at 03:24:52PM -0500, Tim Chase wrote:
> Okay, hit this one today and it seems weird/buggy.
> 
> I'm unsure whether it's pkg_info itself or some artifact of perl's
> runtime, but I had cause to slap ktrace on pkg_info and while
> browsing through the kdump info, I discovered that it was doing a
> stat(2) on every file in the $CWD.
> 
> To reproduce:
> 
>   $ mkdir -p ~/tmp/poc/{empty,full}
>   $ cd ~/tmp/poc/full
>   $ jot 100 | xargs touch
>   $ ktrace -f ../full.ktrace pkg_info -Q remind
>   $ cd ../empty
>   $ ktrace -f ../empty.ktrace pkg_info -Q remind
>   $ cd ..
> 
> then
> 
>   $ for f in full.ktrace empty.ktrace ; do echo -n $f ; kdump -f $f": " | 
> grep -c 'NAMI *"\.' ; done
> 
> (remove the -c for the self-evident file-listing)
> 
> On large directories with tens of thousands of files in them
> (especially on spinning-rust HDDs rather than flash media), this
> has a noticeable delay.
> 
> So it seems buggy that the performance of pkg_info depends on the
> number of files in the current working directory.  Especially since
> pkg_info should almost certainly have no reason to be statting my
> current directory.

As far as I know, the default PKG_PATH has included the current
directory nearly from the start.

https://github.com/openbsd/src/commit/86fd39bc815c07599fed3993f842dc5b4117c412

With the addition of using the "installpath" (which comes from
/etc/installurl) that probably doesn't make a whole lot of sense
anymore, especially as folks usually don't keep packages in the
directory where they run any of the pkg tooling.  Plus, all it does is
surprisingly complain about not being a trusted package if you do have
one.

https://github.com/openbsd/src/commit/b1b61206d60851b7b85c170a97c4c2afb7eed612

Comments, OK?


Index: OpenBSD/PackageLocator.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm,v
diff -u -p -r1.111 PackageLocator.pm
--- OpenBSD/PackageLocator.pm   13 Jun 2023 09:07:17 -0000      1.111
+++ OpenBSD/PackageLocator.pm   21 Jun 2026 18:20:28 -0000
@@ -37,7 +37,7 @@ sub add_default($self, $state, $p)
                        $p->add($o);
                }
        } else {
-               $w = "./:installpath";
+               $w = "installpath";
        }
        if (defined $ENV{PKG_PATH}) {
                $w = $ENV{PKG_PATH};

Reply via email to