Skip to content
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

HttpCacheClient: make upload async #12115

Closed
wants to merge 5 commits into from

Conversation

ulfjack
Copy link
Contributor

@ulfjack ulfjack commented Sep 16, 2020

This matches the behavior for download, and improves performance for actions
with a lot of outputs.

The code was already using futures in the API and in the implementation,
but the glue code blocked on the internal future and returned an immediate
future to the caller, rather than doing it async.

Fixes #6091.

Change-Id: I3151aa96b879323e0000d3209f6b9bc8be0066d4

This matches the behavior for download, and improves performance for actions
with a lot of large outputs.

The code was already using futures in the API and in the implementation,
but the glue code blocked on the internal future and returned an immediate
future to the caller, rather than doing it async.

Fixes bazelbuild#6091.

Change-Id: I3151aa96b879323e0000d3209f6b9bc8be0066d4
@ulfjack
Copy link
Contributor Author

ulfjack commented Sep 16, 2020

@coeuvre

@coeuvre
Copy link
Member

coeuvre commented Sep 17, 2020

Thanks for the PR! LGTM. But some tests failed, any idea with that?

Change-Id: I35c27e37d53ba0d824479879ad1e93dd92cb2431
@ulfjack
Copy link
Contributor Author

ulfjack commented Sep 17, 2020

It was a bug in the change which I just fixed.

@ulfjack
Copy link
Contributor Author

ulfjack commented Sep 17, 2020

All tests pass!

Copy link
Member

@meisterT meisterT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits


try {
Channel ch = channelAcquired.getNow();
ChannelPipeline p = ch.pipeline();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you please change p to pipeline (or similar)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I changed the download side as well.

SettableFuture<Void> result = SettableFuture.create();
acquireUploadChannel()
.addListener(
(Future<Channel> chP) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: channelPromise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. I didn't change the download side.

uploadBlocking(digest.getHash(), digest.getSizeBytes(), in, /* casUpload= */ true);
} catch (IOException | InterruptedException e) {
try {
return uploadAsync(digest.getHash(), digest.getSizeBytes(), file.getInputStream(), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please re-add /* casUpload= */
(same a few lines below and line 695)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. Not sure how that got lost.

if (cause instanceof HttpException) {
HttpResponse response = ((HttpException) cause).response();
try {
// If the error is due to an expired auth token and we can reset the input stream,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: line too long

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also a couple more of these.

Change-Id: I288b16d5057a0cb2061bc226d39138d1881850e1
Change-Id: Id7363290b40925f4bc6af6e3f2a7b8e0fe2e722a
Change-Id: I72032f7b3e88de4d2e2b5abd2d89380f7fcc31e5
@ulfjack
Copy link
Contributor Author

ulfjack commented Sep 18, 2020

PTAL

@bazel-io bazel-io closed this in 159c3fe Sep 21, 2020
@ulfjack ulfjack deleted the async-http-cache-upload branch September 22, 2020 08:14
Yannic pushed a commit to Yannic/bazel that referenced this pull request Oct 5, 2020
This matches the behavior for download, and improves performance for actions
with a lot of outputs.

The code was already using futures in the API and in the implementation,
but the glue code blocked on the internal future and returned an immediate
future to the caller, rather than doing it async.

Fixes bazelbuild#6091.

Change-Id: I3151aa96b879323e0000d3209f6b9bc8be0066d4

Closes bazelbuild#12115.

Change-Id: I72032f7b3e88de4d2e2b5abd2d89380f7fcc31e5
PiperOrigin-RevId: 332796965
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jobs generating large amounts of files drastically slow down building with remote cache.
4 participants