Conversation
77eafc3 to
59675c6
Compare
|
I'll have a look after the Christmas break. The tests look good from a quick scan. I wouldn't call this "unified" since it's the only place in spack where cache invalidation (for something remote) is needed. The only thing that could be unified is fetching sources & binaries the same way (by content hash), but that requires more steps |
|
@haampie Thanks! No rush, enjoy your break. 🎄 Cache invalidation is not strictly necessary for current functionality but IMO there are benefits to having it:
IMHO the end result will be more elegant and maintainable if all three use a unified cache implementation under the hood, keeping the complex |
|
@haampie Will you have time to review this in the coming weeks? |
4540725 to
0aedba7
Compare
0aedba7 to
a039e98
Compare
Spack contains at least two caches for remote files, with a proposed third:
BinaryIndexCachecaches theindex.jsonfetched from configured mirrors,*.spackfiles for CI users.All three are implemented separately, use very different management schemes and reinvent cache validity algorithms depending on the situation. This is a large maintenance burden for three otherwise similar problems. Fundamentally, all three caches cache remote files that change over time (with varying frequencies).
This PR implements a single
NetworkCacheclass that abstracts away the details of maintaining a network cache, providing a convenient URL-based interface tofetch()remote files via a unified code path. The class is self-contained and robust for later planned improvements/extensions, and is both parallel-safe and space-friendly using content hashes. The added tests drive this new code with 99% coverage.The end-goal is to (eventually) unify all network caches to primarily use
NetworkCache. The first user is theBinaryIndexCache, which has been gutted to remove the network and caching code (much of which was rewritten recently by #34641). TheBinaryIndexCachenow primarily implements an in-memory cache of Spec objects from buildcache indices, not theindex.jsonfiles themselves.