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.
Replace the current naive submodule fetching code with one that mostly does the minimal amount of necessary work/fetching
.cache/nix
as usual, thencheckout
&submodule update
into the temp directory using--work-tree
. It doesn't get much more direct than that.HEAD
of that repo (and there is no direct way to check out submodules for a specific commit that is notHEAD
). Instead, we do a cheap clone into the temp dir that shares all objects, including those of submodules, with the original repo. Note that if the submodule commit has not yet been fetched into the original repo,submodule update
will then fetch it into the temp dir, so checking out another commit afterwards will fetch the upstream again. This could potentially be improved by fetching into.cache/nix
even for local repos.Some measurements:
Store-copying (prefetched) Nixpkgs without submodules/with submodules (old)/with submodules (new)
Store-copying a repositories with actual submodules:
And the local repo that triggered #5280 in the first place:
TL;DR: no overhead from
submodules = true;
without submodules and reasonable one with submodulesI am only 90% sure this all makes sense and covers at least as many cases as the current code, so please do give it a try & come up with weird edge cases.