diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2023-09-08 09:25:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 09:25:50 +0200 |
commit | 39b9f214a8b633eaa18270e20564cd75078a792e (patch) | |
tree | de815688b73867492859aad87a2c77ca31f6918c /var | |
parent | 7631b5ea14fb48f8859015b48fc379e06c9d4141 (diff) | |
download | spack-39b9f214a8b633eaa18270e20564cd75078a792e.tar.gz spack-39b9f214a8b633eaa18270e20564cd75078a792e.tar.bz2 spack-39b9f214a8b633eaa18270e20564cd75078a792e.tar.xz spack-39b9f214a8b633eaa18270e20564cd75078a792e.zip |
Speed-up `spack external find` execution (#39843)
* Perform external spec detection with multiple workers
The logic to perform external spec detection has been refactored
into classes. These classes use the GoF "template" pattern to account
for the small differences between searching for "executables" and
for "libraries", while unifying the larger part of the algorithm.
A ProcessPoolExecutor is used to parallelize the work.
* Speed-up external find by tagging detectable packages automatically
Querying packages by tag is much faster than inspecting the repository,
since tags are cached. This commit adds a "detectable" tag to every
package that implements the detection protocol, and external detection
uses it to search for packages.
* Pass package names instead of package classes to workers
The slowest part of the search is importing the Python modules
associated with candidate packages. The import is done serially
before we distribute the work to the pool of executors.
This commit pushes the import of the Python module to the job
performed by the workers, and passes just the name of the packages
to the executors.
In this way imports can be done in parallel.
* Rework unit-tests for Windows
Some unit tests were doing a full e2e run of a command
just to check a input handling. Make the test more
focused by just stressing a specific function.
Mark as xfailed 2 tests on Windows, that will be fixed
by a PR in the queue. The tests are failing because we
monkeypatch internals in the parent process, but the
monkeypatching is not done in the "spawned" child
process.
Diffstat (limited to 'var')
-rw-r--r-- | var/spack/repos/builtin/packages/gcc/package.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py index 5bd047a13f..0af58650de 100644 --- a/var/spack/repos/builtin/packages/gcc/package.py +++ b/var/spack/repos/builtin/packages/gcc/package.py @@ -1020,11 +1020,11 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage): """ # Detect GCC package in the directory of the GCC compiler # or in the $PATH if self.compiler.cc is not an absolute path: - from spack.detection import by_executable + from spack.detection import by_path compiler_dir = os.path.dirname(self.compiler.cc) - detected_packages = by_executable( - [self.__class__], path_hints=([compiler_dir] if os.path.isdir(compiler_dir) else None) + detected_packages = by_path( + [self.name], path_hints=([compiler_dir] if os.path.isdir(compiler_dir) else None) ) # We consider only packages that satisfy the following constraint: |