-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conversation
@@ -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()); |
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.
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); |
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.
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); |
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.
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).
No description provided.