-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
RemoteFSAccessor: Make the local NAR cache content-addressed #14948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Do we need to bump a cache version? |
|
@Ericson2314 There is no version at the moment. There shouldn't be any upgrade issues since the new file names in the cache have a different length. |
|
|
||
| ref<SourceAccessor> RemoteFSAccessor::addToCache(std::string_view hashPart, std::string && nar) | ||
| ref<SourceAccessor> RemoteFSAccessor::addToCache( | ||
| std::string_view hashPart, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| std::string_view hashPart, |
| } | ||
|
|
||
| auto narAccessor = makeNarAccessor(std::move(nar)); | ||
| nars.emplace(hashPart, narAccessor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| nars.emplace(hashPart, narAccessor); |
| StringSink sink; | ||
| store->narFromPath(storePath, sink); | ||
| return addToCache(storePath.hashPart(), std::move(sink.s)); | ||
| return addToCache(storePath.hashPart(), cacheFile, listingFile, std::move(sink.s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return addToCache(storePath.hashPart(), cacheFile, listingFile, std::move(sink.s)); | |
| auto accessor = addToCache(cacheFile, listingFile, std::move(sink.s)); | |
| narsHashes.emplace(storePath.hashPart(), info->narHash); | |
| nars.emplace(info->narHash, accessor); | |
| return accessor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no version at the moment. There shouldn't be any upgrade issues since the new file names in the cache have a different length.
sounds good
OK generally looks good, but I would make it a double map (see final comment) so we don't end up opening multiple NAR accessors for the same NAR.
Motivation
Previously, the local NAR cache was indexed by the store path hash. Making it content-addressed (i.e. indexed by NAR hash) provides some potential deduplication, but more importantly, makes it possible to substitute NARs from the local NAR cache with fewer trust issues (see DeterminateSystems#279).
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.