-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Don't download source tarball if not needed. #9819
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
Open
yshui
wants to merge
3
commits into
NixOS:master
Choose a base branch
from
yshui:improve-cached-fetchTarball
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
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.
When do we want to download if not changed?
Uh oh!
There was an error while loading. Please reload this page.
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.
Errr, it's fully explained in my comments above
to summarize, if the unpacked tarball is available in store, we don't need to download the source tarball if not changed.
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.
err sorry I might have gotten the negation backwards. What you propose of downloading if and if needed sounds reasonable. I am asking when would one not want the semantics you proposed? e.g. When would one want to download again if we already have?
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.
personally i can't come up with a scenario where re-downloading would be preferable. do you have something in mind?
Uh oh!
There was an error while loading. Please reload this page.
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.
errrr, did i misunderstand your question?
in code,
onlyIfChangedwould befalsefor a "normal"downloadFilecall. so say the user callsbuiltins.fetchurlthen the file will be downloaded if it's unchanged but not in store.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.
@yshui Sorry I am still a bit confused. It seems in both cases you are saying "if we have it in the store and it didn't change we don't need to redownload it". I am missing something --- maybe missing that
nix flake updateneed not care what is in the store?Uh oh!
There was an error while loading. Please reload this page.
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.
Fine. let me just list all the possible cases here.
So, there's two blobs involved for
fetchTarball.tarball.tar.gz, andunpacked-tarball/. for our purposes, we assume both have a entry in fetcher cache. Now, let's consider different cases where either or both of them are in the store.tarball.tar.gzandunpacked-folder/are in store.fetchTarballfetchestarball.tar.gzwithetagfrom cache, gets 304, stops. Which is good.tarball.tar.gzis in store.fetchTarballfetchestarball.tar.gzwithetagfrom cache, gets 304, unpacks the tarball already in store. This is good too.fetchTarballignores cache entry fortarball.tar.gz, redownloads it, unpacks it. Good.unpacked-tarball/is in store.a.
tarball.tar.gzis changed at the specified urlfetchTarballignores cache entry fortarball.tar.gz, redownloads it, unpacks it. Good.b.
tarball.tar.gzis unchanged at the specified urlfetchTarballignores cache entry fortarball.tar.gz, redownloads it, then reuse theunpacked-tarball/in store. NOT good.This PR avoids redownloading
tarball.tar.gzin case (4.b)OTOH,
fetchurlonly puts one blob into the store. this is the case wheredownloadFileis called withonlyIfChanged = false. and the cases forfetchurlare:doesn't matter if the file at the source url is changed or not,
downloadFileneeds to download it. this is whyonlyIfChangedshould be false.downloadFiledownloads the file if it has changed at the source url. this is the current behavior and is unchanged.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.
Thanks very much @yshui. The big thing I was forgetting what that there is both the unpack and packed versions.
@edolstra has a PR that changes how the unpacked stuff is downlodaed that we are merging soon. I suspect we should land that first.
My only question left is, why does
builtins.fetchurluse the tarball fetcher at all? Shouldn't it just use the file fetcher?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.
maybe the way i phrased caused some confusion, but
builtins.fetchurldoesn't calldownloadTarball, it callsdownloadFile.Whereas
builtins.fetchTarballwill calldownloadTarball, and that in turn callsdownloadFile