Skip to content

parse_specs: special case for concretizing lookups quickly#47556

Merged
tgamblin merged 11 commits intodevelopfrom
bugfix/fast-spec-lookups
Nov 12, 2024
Merged

parse_specs: special case for concretizing lookups quickly#47556
tgamblin merged 11 commits intodevelopfrom
bugfix/fast-spec-lookups

Conversation

@becker33
Copy link
Copy Markdown
Member

#44843 added unification semantics for parsing specs from the CLI, but there are a couple special cases in which we can avoid calls to the concretizer for speed when the specs can all be resolved by lookups.

special case 1: solving a single spec

special case 2: all specs are either concrete (come from a file) or have an abstract hash. In this case if concretizer:unify:true we need an additional check to confirm the specs are compatible.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality labels Nov 12, 2024
Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple suggestions but otherwise LGTM

@tgamblin
Copy link
Copy Markdown
Member

@haampie this looks good to me at first glance -- see if this fixes the perf regressions you saw.

@spackbot-app spackbot-app bot added the tests General test capability(ies) label Nov 12, 2024
@tgamblin tgamblin enabled auto-merge (squash) November 12, 2024 07:18
@tgamblin tgamblin force-pushed the bugfix/fast-spec-lookups branch from 4af1191 to ff572fb Compare November 12, 2024 07:18
@tgamblin tgamblin dismissed their stale review November 12, 2024 07:22

addressed my own review.

@tgamblin tgamblin requested a review from haampie November 12, 2024 07:22
@tgamblin tgamblin added this to the v0.23 milestone Nov 12, 2024
Signed-off-by: Todd Gamblin <[email protected]>
@tgamblin tgamblin force-pushed the bugfix/fast-spec-lookups branch from acd61d0 to e032658 Compare November 12, 2024 07:45
@tgamblin
Copy link
Copy Markdown
Member

Ok I think this is ready to go when the tests pass so feel free to approve if you agree.

@haampie
Copy link
Copy Markdown
Member

haampie commented Nov 12, 2024

This doesn't work in the one example I tried it on: spack -E stage /xyz where /xyz is an installed spec hits this code path:

specs = spack.cmd.parse_specs(args.specs, concretize=False)
specs = spack.cmd.matching_specs_from_env(specs)  # <- concretizes

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I tested this on @haampie's example as well as a few others. I like the new tests as well.

@tgamblin tgamblin merged commit 1809b81 into develop Nov 12, 2024
@tgamblin tgamblin deleted the bugfix/fast-spec-lookups branch November 12, 2024 22:04
fryeguy52 pushed a commit to fryeguy52/spack that referenced this pull request Dec 17, 2024
We added unification semantics for parsing specs from the CLI, but there are a couple
of special cases in which we can avoid calls to the concretizer for speed when the
specs can all be resolved by lookups.

- [x] special case 1: solving a single spec

- [x] special case 2: all specs are either concrete (come from a file) or have an abstract
      hash. In this case if concretizer:unify:true we need an additional check to confirm
      the specs are compatible.

- [x] add a parameterized test for unifying on the CI

---------

Signed-off-by: Todd Gamblin <[email protected]>
Co-authored-by: Todd Gamblin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants