summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-09-08 09:25:50 +0200
committerGitHub <noreply@github.com>2023-09-08 09:25:50 +0200
commit39b9f214a8b633eaa18270e20564cd75078a792e (patch)
treede815688b73867492859aad87a2c77ca31f6918c /share
parent7631b5ea14fb48f8859015b48fc379e06c9d4141 (diff)
downloadspack-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 'share')
-rwxr-xr-xshare/spack/spack-completion.bash2
-rwxr-xr-xshare/spack/spack-completion.fish4
2 files changed, 4 insertions, 2 deletions
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index d41b540a0e..e3ddbc45b5 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -1119,7 +1119,7 @@ _spack_external() {
_spack_external_find() {
if $list_options
then
- SPACK_COMPREPLY="-h --help --not-buildable --exclude -p --path --scope --all -t --tag"
+ SPACK_COMPREPLY="-h --help --not-buildable --exclude -p --path --scope --all -t --tag -j --jobs"
else
_all_packages
fi
diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish
index c4b9d47871..d4cb61e85d 100755
--- a/share/spack/spack-completion.fish
+++ b/share/spack/spack-completion.fish
@@ -1586,7 +1586,7 @@ complete -c spack -n '__fish_spack_using_command external' -s h -l help -f -a he
complete -c spack -n '__fish_spack_using_command external' -s h -l help -d 'show this help message and exit'
# spack external find
-set -g __fish_spack_optspecs_spack_external_find h/help not-buildable exclude= p/path= scope= all t/tag=
+set -g __fish_spack_optspecs_spack_external_find h/help not-buildable exclude= p/path= scope= all t/tag= j/jobs=
complete -c spack -n '__fish_spack_using_command external find' -s h -l help -f -a help
complete -c spack -n '__fish_spack_using_command external find' -s h -l help -d 'show this help message and exit'
@@ -1602,6 +1602,8 @@ complete -c spack -n '__fish_spack_using_command external find' -l all -f -a all
complete -c spack -n '__fish_spack_using_command external find' -l all -d 'search for all packages that Spack knows about'
complete -c spack -n '__fish_spack_using_command external find' -s t -l tag -r -f -a tags
complete -c spack -n '__fish_spack_using_command external find' -s t -l tag -r -d 'filter a package query by tag (multiple use allowed)'
+complete -c spack -n '__fish_spack_using_command external find' -s j -l jobs -r -f -a jobs
+complete -c spack -n '__fish_spack_using_command external find' -s j -l jobs -r -d 'explicitly set number of parallel jobs'
# spack external list
set -g __fish_spack_optspecs_spack_external_list h/help