Skip to content

Commit

Permalink
Cache compiler lookup per package (spack#23988)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
haampie authored May 28, 2021
1 parent 7490d63 commit f6febd2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/spack/spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,11 +1269,13 @@ def architecture(self):
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)

Expand Down

0 comments on commit f6febd2

Please sign in to comment.