spec: Introduce cache for Spec objects.#51537
Merged
haampie merged 4 commits intospack:developfrom Jan 20, 2026
Merged
Conversation
Contributor
Author
|
@spackbot fix style |
|
Let me see if I can fix that for you! |
|
I was able to run spack style --fix==> Running style checks on spack
selected: import, isort, black, flake8, mypy
==> Modified files
lib/spack/spack/dependency.py
lib/spack/spack/directives.py
lib/spack/spack/spec.py
==> Running import checks
import checks were clean
==> Running isort checks
isort checks were clean
==> Running black checks
reformatted lib/spack/spack/directives.py
reformatted lib/spack/spack/spec.py
All done! ✨ 🍰 ✨
2 files reformatted, 1 file left unchanged.
black checks were clean
==> Running flake8 checks
flake8 checks were clean
==> Running mypy checks
Success: no issues found in 621 source files
mypy checks were clean
==> spack style checks were clean
I've updated the branch with style fixes. |
fce78a8 to
85b6350
Compare
And convert _EmptySpec to _ImmutableSpec to be used for the spec's in the cache to ensure they are not mutated. Timing comparison for: "spack-python -c 'import spack.repo; x = list(spack.repo.PATH.all_package_classes())'" develop ( 9c7f846 ): 23.4s This patch: 15.5s Thanks to @haampie for discussions and the _ImmutableSpec portion (plus a bunch of pre-work in other PRs to actually get rid of spec mutation elsewhere in spack)! Signed-off-by: Victor Brunini <[email protected]>
85b6350 to
eb5fccf
Compare
Signed-off-by: Victor Brunini <[email protected]>
haampie
reviewed
Jan 16, 2026
Signed-off-by: Victor Brunini <[email protected]>
1e5a657 to
186ba04
Compare
Member
|
If I take this PR + #51836 + #51858, and use runs in 3.7s on my macbook. That's 5.6x faster than |
alalazo
reviewed
Jan 19, 2026
haampie
previously approved these changes
Jan 19, 2026
alalazo
previously approved these changes
Jan 19, 2026
it will raise AttributeError, but that's fine. Signed-off-by: Harmen Stoppels <[email protected]>
c22be81 to
a1af0da
Compare
Member
|
@alalazo, I've changed it to Going with a persistent property |
haampie
approved these changes
Jan 19, 2026
alalazo
approved these changes
Jan 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split off of #51518 @haampie
Combined with #51535, #51536, #51367 and the reduced install task sleep time from #51491 this reduces the time for a no-op install of a development environment with 94 packages (including dependencies) from 8s to 2.8s for me. It also provides a similar reduction in time for
spack build-env --dump env.txt mypkgwhich we frequently use to start a shell with the build environment.