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

Reduce big memory allocations when sending and receiving data from a remote builder #209

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

britzl
Copy link
Contributor

@britzl britzl commented Oct 11, 2021

No description provided.

@@ -186,10 +186,8 @@ public void buildEngine(HttpServletRequest request,
if (remoteBuilderEnabled && isRemotePlatform(platform)) {
LOGGER.info("Building engine on remote builder");

final byte[] bytes = remoteEngineBuilder.build(uploadDirectory, platform, sdkVersion);
remoteEngineBuilder.build(uploadDirectory, platform, sdkVersion, response.getOutputStream());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The final output of a build is supposed to go to the response.getOutputStream() so we might as well pass that to the remote engine builder.

response.getEntity().writeTo(bos);

final byte[] bytes = bos.toByteArray();
response.getEntity().writeTo(out);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Write the response directly to the output stream without first reading all of the bytes into a byte array

} catch (IOException e) {
throw new IllegalStateException(e);
}
AbstractContentBody body = new FileBody(path.toFile(), ContentType.DEFAULT_BINARY, relativePath);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't read the all of the bytes from each file. Add each file directly to the multi part request builder (and hopefully the underlying implementation is clever enough to read the bytes sequentially as they are sent over the wire).

@britzl britzl requested a review from JCash October 11, 2021 20:03
@britzl britzl merged commit 282227d into dev Oct 12, 2021
@britzl britzl deleted the dev-reduce-remote-build-memory-usage branch October 12, 2021 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants