summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-05-28 23:36:34 +0200
committerGitHub <noreply@github.com>2021-05-28 21:36:34 +0000
commitf6febd2ef5058a265cbc389c2d05aa43e9678d81 (patch)
tree2199b97ff604b89bce6899a7f1e341f1cb4f0c06 /lib
parent7490d63c38f5cd8dd927ee0adda4e28578bbd60d (diff)
downloadspack-f6febd2ef5058a265cbc389c2d05aa43e9678d81.tar.gz
spack-f6febd2ef5058a265cbc389c2d05aa43e9678d81.tar.bz2
spack-f6febd2ef5058a265cbc389c2d05aa43e9678d81.tar.xz
spack-f6febd2ef5058a265cbc389c2d05aa43e9678d81.zip
Cache compiler lookup per package (#23988)
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 ```
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/package.py4
1 files changed, 3 insertions, 1 deletions
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)