Skip to content

Conversation

@bazel-io
Copy link
Member

By using a Piped{Input,Output}Stream pair backed by a virtual thread, uploads of VirtualActionInput no longer have to materialize the full input in memory and thus require less peak heap.

Closes #28259.

PiperOrigin-RevId: 855713407
Change-Id: I3e382fd4da2fe0f2899d5b00d19d718ddce1a54c

Commit 92dad2c

By using a `Piped{Input,Output}Stream` pair backed by a virtual thread, uploads of `VirtualActionInput` no longer have to materialize the full input in memory and thus require less peak heap.

Closes bazelbuild#28259.

PiperOrigin-RevId: 855713407
Change-Id: I3e382fd4da2fe0f2899d5b00d19d718ddce1a54c
@bazel-io bazel-io requested a review from a team as a code owner January 13, 2026 15:21
@bazel-io bazel-io added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Jan 13, 2026
@bazel-io bazel-io requested a review from coeuvre January 13, 2026 15:21
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant improvement by avoiding the materialization of VirtualActionInputs in memory during uploads, utilizing PipedInputStream and PipedOutputStream backed by virtual threads. This change effectively reduces peak heap memory usage, which is crucial for performance and stability, especially with large virtual inputs. The changes are well-aligned with the goal of optimizing memory footprint. However, there are a couple of areas that need attention regarding error handling and API documentation to ensure correctness and clarity.

Comment on lines +243 to +245
throw new IllegalStateException(
"writeTo is not expected to throw as pipedOut doesn't", e);
}

Choose a reason for hiding this comment

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

high

The IllegalStateException message here states that writeTo is "not expected to throw as pipedOut doesn't". However, PipedOutputStream.write can indeed throw an IOException if the pipe is broken or closed (e.g., if the reading thread dies unexpectedly). Wrapping this in an IllegalStateException with a misleading message could obscure the root cause of potential issues. It's better to either handle the IOException more gracefully or at least provide a more accurate error message that acknowledges the possibility of an IOException from the underlying stream.

Suggested change
throw new IllegalStateException(
"writeTo is not expected to throw as pipedOut doesn't", e);
}
throw new IllegalStateException(
"Failed to write virtual action input to piped output stream", e);

@@ -100,7 +99,7 @@ ListenableFuture<Void> downloadBlob(
* as late as possible and close the blob as soon as they are done with it.
*/

Choose a reason for hiding this comment

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

high

The Javadoc states that "consumers should call {@link #get} as late as possible and close the blob as soon as they are done with it." However, the Blob interface no longer extends Closeable. This makes the documentation misleading, as there is no close() method to call directly on the Blob interface. The documentation should be updated to reflect this change, or if Blob implementations are still expected to be closed, an alternative mechanism should be documented.

   * as late as possible. Implementations are responsible for managing the lifecycle of any underlying resources.

@fmeum
Copy link
Collaborator

fmeum commented Jan 13, 2026

Gemini findings are interesting, let's not cherry-pick this into 9.0.0 (but perhaps into 9.1.0).

@fmeum fmeum closed this Jan 13, 2026
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Remote-Exec Issues and PRs for the Execution (Remote) team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants