summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2016-04-06 12:05:29 -0700
committerMario Melara <maamelara@gmail.com>2016-04-06 12:05:29 -0700
commit749508af010ee90009a61bb42a8f8214a6fabd21 (patch)
tree980018c8871d6aef097c955954f2a9b5a61be1ba /lib
parent3bf75fab3f37bc2edb70bd49060c3831777c21dc (diff)
downloadspack-749508af010ee90009a61bb42a8f8214a6fabd21.tar.gz
spack-749508af010ee90009a61bb42a8f8214a6fabd21.tar.bz2
spack-749508af010ee90009a61bb42a8f8214a6fabd21.tar.xz
spack-749508af010ee90009a61bb42a8f8214a6fabd21.zip
Found loops calling all_compilers that were always reading in the config file which lead to a slowdown, the fix is to cache the config file so we don't waste time re-reading the config file in again.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compilers/__init__.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 9601ae3e3a..caf438e232 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -151,20 +151,25 @@ def remove_compiler_from_config(compiler_spec, arch=None, scope=None):
spack.config.update_config('compilers', update, scope)
+_cache_config_file = {}
def all_compilers_config(arch=None, scope=None):
"""Return a set of specs for all the compiler versions currently
available to build with. These are instances of CompilerSpec.
"""
# Get compilers for this architecture.
- arch_config = get_compiler_config(arch, scope)
- # Merge 'all' compilers with arch-specific ones.
- # Arch-specific compilers have higher precedence.
- merged_config = get_compiler_config('all', scope=scope)
- merged_config = spack.config._merge_yaml(merged_config, arch_config)
+ global _cache_config_file #Create a cache of the config file so we don't load all the time.
- return merged_config
+ if not _cache_config_file:
+ arch_config = get_compiler_config(arch, scope)
+ # Merge 'all' compilers with arch-specific ones.
+ # Arch-specific compilers have higher precedence.
+ _cache_config_file = get_compiler_config('all', scope=scope)
+ _cache_config_file = spack.config._merge_yaml(_cache_config_file, arch_config)
+ return _cache_config_file
+ else:
+ return _cache_config_file
def all_compilers(arch=None, scope=None):
# Return compiler specs from the merged config.