diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2020-11-09 14:07:50 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2020-11-09 14:07:50 +0000 |
commit | a7f0aceeaba7f59ca2d02460a17011c89548533e (patch) | |
tree | b8c98aff9271037fbe378efda9fe7d5887082dd7 /usr.sbin/pkg_add | |
parent | 6d22f148a5e741c80eb20bf645304e6dcb239209 (diff) |
speed up the dependency check pass significantly:
first pass will read packing-lists fully, use that to cache along dependency
information, so we don't have to read packing-list again during second pass.
we do not cache full plists for the file checks, because
1/ that is significantly larger
2/ that pass is disk io bound anyway
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCheck.pm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm index 3d929aef017..aa99e2e21f3 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCheck.pm,v 1.73 2020/11/09 13:28:31 espie Exp $ +# $OpenBSD: PkgCheck.pm,v 1.74 2020/11/09 14:07:49 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -80,6 +80,10 @@ sub mark_indirect_depends $self->mark_available_lib(@_); } +sub cache_depends +{ +} + package OpenBSD::PackingElement::DefineTag; sub mark_indirect_depends @@ -233,6 +237,13 @@ sub basic_check $state->{known}{$name}{'dir'} = 1; } +package OpenBSD::PackingElement::Depend; +sub cache_depends +{ + my ($self, $copy) = @_; + $self->add_object($copy); +} + package OpenBSD::PackingElement::Dependency; sub find_dependencies { @@ -304,6 +315,11 @@ sub find_dependencies } } +sub cache_depends +{ + &OpenBSD::PackingElement::Depend::cache_depends; +} + package OpenBSD::PkgCheck::State; our @ISA = qw(OpenBSD::AddCreateDelete::State); @@ -813,6 +829,9 @@ sub sanity_check $self->may_remove($state, $name); } $plist->mark_indirect_depends($plist->pkgname, $state); + my $p = OpenBSD::PackingList->new; + $plist->cache_depends($p); + $state->{plist_cache}{$plist->pkgname} = $p; $state->{exists}{$plist->pkgname} = 1; }); } @@ -824,7 +843,7 @@ sub dependencies_check $self->for_all_packages($state, $l, "Direct dependencies", sub { my $name = shift; $state->log->set_context($name); - my $plist = OpenBSD::PackingList->from_installation($name); + my $plist = $state->{plist_cache}{$name}; my $checker = OpenBSD::DirectDependencyCheck->new($state, $name); $state->{localbase} = $plist->localbase; @@ -834,6 +853,7 @@ sub dependencies_check push(@{$state->{reverse}{$dep}}, $name); } }); + delete $state->{plist_cache}; } sub reverse_dependencies_check |