Closed
Conversation
Kha
commented
Oct 17, 2021
Comment on lines
+459
to
+461
| runProgram("git", true, { "--git-dir", repoDir, "--work-tree", tmpDir, "checkout", "--quiet", input.getRev()->gitRev(), "." }); | ||
| // `-C` should be redundant, probably a bug in `git submodule` | ||
| runProgram("git", true, { "--git-dir", repoDir, "--work-tree", tmpDir, "-C", tmpDir, "submodule", "--quiet", "update", "--init", "--recursive" }); |
Contributor
Author
There was a problem hiding this comment.
This sequence (which existed before) should probably be covered by a repo lock to prevent races
This was referenced Oct 20, 2021
Contributor
|
... siphoning submodules stakeholders to #5497 |
|
I marked this as stale due to inactivity. → More info |
Contributor
Author
|
Closing in favor of #6530, see also #7862 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/nixas usual, thencheckout&submodule updateinto the temp directory using--work-tree. It doesn't get much more direct than that.HEADof 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 updatewill 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/nixeven 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.