aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
index 03af9d78a6..0c8791990e 100644
--- a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
+++ b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java
@@ -384,14 +384,17 @@ public class GrpcServerImpl implements RPCServer {
static class RpcOutputStream extends OutputStream {
private static final int CHUNK_SIZE = 8192;
- private final String commandId;
- private final String responseCookie;
+ // Store commandId and responseCookie as ByteStrings to avoid String -> UTF8 bytes conversion
+ // for each serialized chunk of output.
+ private final ByteString commandIdBytes;
+ private final ByteString responseCookieBytes;
+
private final StreamType type;
private final GrpcSink sink;
RpcOutputStream(String commandId, String responseCookie, StreamType type, GrpcSink sink) {
- this.commandId = commandId;
- this.responseCookie = responseCookie;
+ this.commandIdBytes = ByteString.copyFromUtf8(commandId);
+ this.responseCookieBytes = ByteString.copyFromUtf8(responseCookie);
this.type = type;
this.sink = sink;
}
@@ -402,8 +405,8 @@ public class GrpcServerImpl implements RPCServer {
ByteString input = ByteString.copyFrom(b, off + i, Math.min(CHUNK_SIZE, inlen - i));
RunResponse.Builder response = RunResponse
.newBuilder()
- .setCookie(responseCookie)
- .setCommandId(commandId);
+ .setCookieBytes(responseCookieBytes)
+ .setCommandIdBytes(commandIdBytes);
switch (type) {
case STDOUT: response.setStandardOutput(input); break;
@@ -421,7 +424,7 @@ public class GrpcServerImpl implements RPCServer {
log.info(
String.format(
"Client disconnected received for command %s on thread %s",
- commandId, Thread.currentThread().getName()));
+ commandIdBytes.toStringUtf8(), Thread.currentThread().getName()));
throw new IOException("Client disconnected");
}
}