From f6febd2ef5058a265cbc389c2d05aa43e9678d81 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 28 May 2021 23:36:34 +0200 Subject: Cache compiler lookup per package (#23988) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: ``` $ hyperfine '~/spack/bin/spack -e . build-env rocfft' Benchmark #1: ~/spack/bin/spack -e . build-env rocfft Time (mean ± σ): 1.593 s ± 0.016 s [User: 1.468 s, System: 0.126 s] Range (min … max): 1.575 s … 1.628 s 10 runs ``` After: ``` $ hyperfine '~/spack/bin/spack -e . build-env rocfft' Benchmark #1: ~/spack/bin/spack -e . build-env rocfft Time (mean ± σ): 1.407 s ± 0.020 s [User: 1.280 s, System: 0.127 s] Range (min … max): 1.393 s … 1.455 s 10 runs ``` --- lib/spack/spack/package.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 169958f704..9958f16efe 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1269,11 +1269,13 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)): raise ValueError("Can only get the arch for concrete package.") return spack.architecture.arch_for_spec(self.spec.architecture) - @property + @property # type: ignore + @memoized def compiler(self): """Get the spack.compiler.Compiler object used to build this package""" if not self.spec.concrete: raise ValueError("Can only get a compiler for a concrete package.") + return spack.compilers.compiler_for_spec(self.spec.compiler, self.spec.architecture) -- cgit v1.2.3-70-g09d2