Change RemoteActionInputFetcher to use temp files before staging#11340
Change RemoteActionInputFetcher to use temp files before staging#11340sohaibiftikhar wants to merge 1 commit intobazelbuild:masterfrom
Conversation
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
|
||
| private static Path toTmpDownloadPath(Path actualPath) { | ||
| return actualPath.getParentDirectory().getRelative( | ||
| actualPath.getBaseName() + "." + actualPath.hashCode() |
There was a problem hiding this comment.
This should give a unique + deterministic enough name so that we don't need to sort all downloads before moving to final location.
There was a problem hiding this comment.
Why not use the same approach as RemoteCache?
There was a problem hiding this comment.
Because RemoteCache collects all outputs before doing the moveToFinalLocation. This class was designed a bit differently in that it can call downloadFileAsync from two different methods (downloadFile and prefetchFiles) and the shared variables downloadsInProgress and downloadedPaths are controlled per download here.
So I would have to move the synchronized blocks to those two methods and that looked like a lot more refactoring to me. I can make that change if you think that is the way to go. But this seems cleaner to me.
| "Failed to move to final location %s. -> %s", tmpPath, path | ||
| ); | ||
| } | ||
| synchronized (lock) { |
There was a problem hiding this comment.
Moved the synchronize block below. A file is considered to be downloaded only after its permissions are set and it has been moved to its final location.
There was a problem hiding this comment.
I think this is wrong. You are doing this even when the above code fails with an IOException
|
cc @ulfjack |
ulfjack
left a comment
There was a problem hiding this comment.
I would generally prefer a temporary location in a place where it can't conflict with other files. In this case, it could potentially conflict (same for RemoteCache). That said, this seems like a reasonable change. I posted a question on the code above. Also, did you consider rm-ing the file after download instead of downloading to a temporary location.
I wonder how @jmmv does this in the dynamic strategy - I think he said he was planning to download to a temp location as well. Is there a way to make the different implementations more consistent with each other?
|
|
||
| private static Path toTmpDownloadPath(Path actualPath) { | ||
| return actualPath.getParentDirectory().getRelative( | ||
| actualPath.getBaseName() + "." + actualPath.hashCode() |
There was a problem hiding this comment.
Why not use the same approach as RemoteCache?
There is a Maybe someone with more knowledge of that part could point that out. |
|
I went through various iterations to make the "download as temp" feature work (for the internal version of this feature).
So essentially, we do this: Path tempDestFile =
actionTempsDir.getChild("output-" + lastTempOutput.getAndAdd(1) + ".tmp");More details here: https://jmmv.dev/2019/12/bazel-dynamic-execution-download-times.html Would be great if the external logic of this code did the same. |
|
@sohaibiftikhar Are you still working on this? |
|
I was involved with some other work that put this on a sidetrack. I can finish this by aligning with what @jmmv proposes here. |
|
What's the current state? |
|
cc @coeuvre |
23cb6d3 to
8c13d43
Compare
|
Closing this PR as as the referenced issue has been fixed. |
Attempts fixing #11339