Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] config: cache profile.bashrc stat results (bug 649806)
Date: Sun, 15 Jul 2018 14:27:50
Message-Id: 20180715072747.1c7a6df5@professor-x
In Reply to: [gentoo-portage-dev] [PATCH] config: cache profile.bashrc stat results (bug 649806) by Zac Medico
1 On Sat, 14 Jul 2018 22:05:55 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Optimize config to stat profile.bashrc files once in the constructor,
5 > in order to avoid repeated stat calls in the setcpv method.
6 >
7 > Bug: https://bugs.gentoo.org/649806
8 > ---
9 > pym/portage/package/ebuild/config.py | 13 ++++++++-----
10 > 1 file changed, 8 insertions(+), 5 deletions(-)
11 >
12 > diff --git a/pym/portage/package/ebuild/config.py
13 > b/pym/portage/package/ebuild/config.py index 88acac5cc..320d9f6c0
14 > 100644 --- a/pym/portage/package/ebuild/config.py
15 > +++ b/pym/portage/package/ebuild/config.py
16 > @@ -274,6 +274,7 @@ class config(object):
17 > self.mycpv = clone.mycpv
18 > self._setcpv_args_hash =
19 > clone._setcpv_args_hash self._soname_provided = clone._soname_provided
20 > + self._profile_bashrc = clone._profile_bashrc
21 >
22 > # immutable attributes (internal policy
23 > ensures lack of mutation) self._locations_manager =
24 > clone._locations_manager @@ -725,6 +726,10 @@ class config(object):
25 > self._license_manager.extract_global_changes( \
26 > self.configdict["conf"].get("ACCEPT_LICENSE",
27 > ""))
28 > + # profile.bashrc
29 > + self._profile_bashrc =
30 > tuple(os.path.isfile(os.path.join(profile.location, 'profile.bashrc'))
31 > + for profile in profiles_complex)
32 > +
33 > if local_config:
34 > #package.properties
35 > propdict =
36 > grabdict_package(os.path.join( @@ -1596,11 +1601,9 @@ class
37 > config(object):
38 > bashrc_files = []
39 >
40 > - for profile in
41 > self._locations_manager.profiles_complex:
42 > - profile_bashrc =
43 > os.path.join(profile.location,
44 > - 'profile.bashrc')
45 > - if os.path.exists(profile_bashrc):
46 > - bashrc_files.append(profile_bashrc)
47 > + for profile, profile_bashrc in
48 > zip(self._locations_manager.profiles_complex, self._profile_bashrc):
49 > + if profile_bashrc:
50 > +
51 > bashrc_files.append(os.path.join(profile.location, 'profile.bashrc'))
52 > if profile in self._pbashrcdict: cpdict =
53 > self._pbashrcdict[profile].get(cp) if cpdict:
54
55 looks good
56
57 --
58 Brian Dolbec <dolsen>

Replies