Skip to content

check remote mirrors for hashes provided by the user#22503

Closed
cosmicexplorer wants to merge 2 commits intospack:developfrom
cosmicexplorer:spec-parsing-includes-remotes
Closed

check remote mirrors for hashes provided by the user#22503
cosmicexplorer wants to merge 2 commits intospack:developfrom
cosmicexplorer:spec-parsing-includes-remotes

Conversation

@cosmicexplorer
Copy link
Copy Markdown
Contributor

@cosmicexplorer cosmicexplorer commented Mar 24, 2021

Problem

This is a partial solution to #19085. Users would like to be able to use spec hash prefixes on the command line that they've seen from remote mirrors, e.g. from the output of spack buildcache list -l --allarch. Right now, hash prefixes are converted into a single concrete Spec instance within SpecParser, and they only check the local Database instance for that.

This is step 2 of a solution to #19085, after #22500. This is only a partial solution to it because in addition to spack buildcache list, we would also like to ensure that hash prefixes from the output of e.g. spack spec can be provided to the spack command line. We plan to create a separate Database instance with its own TTL for that later feature.

This requires #21723 to work for some reason.

Solution

  1. Add find_prefix_hash() to BinaryCacheIndex to trawl through all its known specs and match hash prefixes.
  2. Add _lookup_local_or_remote_hash() to SpecParser to check both the local and remote databases for a hash prefix specified on the command line.

Result

We can now perform the following set of commands:

# mcclanahan7@turingtarpit: ~/tools/spack 18:43:43
; spack buildcache list -l --allarch xz
... # lots of output...
-- linux-ubuntu20.04-x86_64 / [email protected] -------------------------
ighzjcu [email protected]  kamfyq4 [email protected]~pic  jc3ghdk [email protected]+pic
# mcclanahan7@turingtarpit: ~/tools/spack 18:50:13
; spack spec -l xz/ighzjcu # hash prefix specified from the buildcache output
Input spec
--------------------------------
[email protected]%[email protected] arch=linux-ubuntu20.04-x86_64

Concretized
--------------------------------
ighzjcu  [email protected]%[email protected] arch=linux-ubuntu20.04-x86_64

HOWEVER, it takes 1 full minute to run the above command, which traverses remote databases for a hash prefix after fetching them. We plan to follow up on this PR with a third one that uses an auxiliary local Database instance to store specs from buildcaches, which is expected to make matching remote spec prefixes as fast as local spec prefixes.

# type: (str) -> List[Spec]
return (spack.store.db.get_by_hash(find_hash) or
# If the hash doesn't exist locally, check the remote.
spack.binary_distribution.binary_index.find_prefix_hash(find_hash))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@becker33, I think this is what you were saying last week that we cannot do, i.e. check the database and then the binary mirrors sequentially, when we look for matches for a hash prefix. If I understood your argument correctly, you were saying if we search those places for a hash prefix sequentially, we could end up in a situation where we mistakenly return a spec from the install database (because we found there exactly one spec with the queried hash prefix), when we should have raised an ambiguous hash exception (because the binary mirrors or active env contain specs with the same hash prefix, possibly even the spec the user actually meant when they abbreviated the full hash with a prefix).

@cosmicexplorer I came here because I, too, want the spec parser to look somewhere other than just the install database for hashes. And I made the same sequential searching mistake in my PR here. Where you are trying to get spack to include all binary specs in its hash search, my goal is to have it include all specs from the active concrete environment. So I'm looking to create some kind of dictionary to map hashes to specs which will be populated from all the locations where hashes can exist: db, binary mirrors, active environment (if concrete).

@cosmicexplorer cosmicexplorer force-pushed the spec-parsing-includes-remotes branch from 8a010b1 to 6651954 Compare February 19, 2022 09:18
@cosmicexplorer cosmicexplorer marked this pull request as draft February 19, 2022 09:19
@becker33
Copy link
Copy Markdown
Member

becker33 commented Jun 5, 2024

This was implemented in #35042. Closing this as completed.

@becker33 becker33 closed this Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants