On Fri, Aug 04, 2017 at 11:12:01AM -0400, Michael Reed wrote:
> $ sysctl -n kern.version
> OpenBSD 6.1-current (GENERIC.MP) #44: Thu Aug  3 12:12:07 MDT 2017
>     [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> 
> ---------
> 
> It looks like PkgInfo.pm revision 1.45 (discussed briefly in this[3] thread)
> made "pkg_info -Q" very slow:
> 
> PkgInfo.pm 1.44 [1]
> $ for i in 1 2 3; do time pkg_info -Q xfce > /dev/null; done
>     0m01.78s real     0m00.58s user     0m00.13s system
>     0m01.51s real     0m00.46s user     0m00.11s system
>     0m01.41s real     0m00.42s user     0m00.06s system
> 
> PkgInfo.pm 1.45 [2]
> $ for i in 1 2 3; do time pkg_info -Q xfce > /dev/null; done
>     0m45.10s real     0m03.08s user     0m03.30s system
>     0m44.07s real     0m02.57s user     0m03.11s system
>     0m41.49s real     0m03.15s user     0m03.72s system
> 
> I don't know enough perl to debug this fully, but I thought I would at least
> bring this issue to the developers attention, assuming it's not already
> known :)

Thanks for bringing it to light!

Here is some profiling information for anyone interested:
https://deftly.net/pkg_info_trace/

Attached is a diff that only calls find_pkg when other flags that need
it are included in the options.

Index: OpenBSD/PkgInfo.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v
retrieving revision 1.45
diff -u -p -r1.45 PkgInfo.pm
--- OpenBSD/PkgInfo.pm  3 Aug 2017 13:08:58 -0000       1.45
+++ OpenBSD/PkgInfo.pm  4 Aug 2017 17:10:57 -0000
@@ -406,18 +406,13 @@ sub print_info
                }
                $state->say("#1", $compose);
        } elsif ($state->opt('I')) {
-               if ($state->opt('Q')) {
-                       $state->say(
-                           is_installed($pkg) ? "#1 (installed)" : "#1", $pkg);
+               if ($state->opt('q')) {
+                       $state->say("#1", $pkg);
                } else {
-                       if ($state->opt('q')) {
-                               $state->say("#1", $pkg);
-                       } else {
-                               my $l = 20 - length($pkg);
-                               $l = 1 if $l <= 0;
-                               $state->say("#1#2#3", $pkg, " "x$l,
-                                   get_comment($handle->info));
-                       }
+                       my $l = 20 - length($pkg);
+                       $l = 1 if $l <= 0;
+                       $state->say("#1#2#3", $pkg, " "x$l,
+                           get_comment($handle->info));
                }
        } else {
                if ($state->opt('c')) {
@@ -606,10 +601,15 @@ sub parse_and_run
                my $r = $state->repo->match_locations($partial);
 
                for my $p (sort map {$_->name} @$r) {
-                       $self->find_pkg($state, $p,
-                           sub {
-                               $self->print_info($state, @_);
-                           });
+                       if ($state->hasanyopt('cdfMqs')) {
+                               $self->find_pkg($state, $p,
+                                   sub {
+                                       $self->print_info($state, @_);
+                                   });
+                       } else {
+                               $state->say(
+                                   is_installed($p) ? "#1 (installed)" : "#1", 
$p);
+                       }
                }
 
                return 0;


> 
> 
> [1]: 
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm?rev=1.44&content-type=text/x-cvsweb-markup
> [2]: 
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm?rev=1.45&content-type=text/x-cvsweb-markup
> [3]: https://marc.info/?l=openbsd-tech&m=150134645310914&w=2
> 

-- 
PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A  4AF0 1F81 112D 62A9 ADCE

Reply via email to