Skip to content

Commit f54d7e5

Browse files
ulfjackCopybara-Service
authored and
Copybara-Service
committed
Enable bulk writes in the HttpBlobStore
Second attempt of 0654620, which I am rolling back. The problem is that FilterOutputStream.write is just plain wrong and we shouldn't inherit FilterOutputStream at all, but instead do it manually (which actually requires less code). This was a performance regression in deccc48. Fixed #4944. PiperOrigin-RevId: 191215696
1 parent df7731f commit f54d7e5

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import java.io.ByteArrayInputStream;
4444
import java.io.FileInputStream;
4545
import java.io.FilterInputStream;
46-
import java.io.FilterOutputStream;
4746
import java.io.IOException;
4847
import java.io.InputStream;
4948
import java.io.OutputStream;
@@ -199,23 +198,31 @@ public boolean get(String key, OutputStream out) throws IOException, Interrupted
199198
}
200199

201200
@SuppressWarnings("FutureReturnValueIgnored")
202-
private boolean get(String key, OutputStream out, boolean casDownload)
201+
private boolean get(String key, final OutputStream out, boolean casDownload)
203202
throws IOException, InterruptedException {
204203
final AtomicBoolean dataWritten = new AtomicBoolean();
204+
205205
OutputStream wrappedOut =
206-
new FilterOutputStream(out) {
206+
new OutputStream() {
207+
// OutputStream.close() does nothing, which is what we want to ensure that the
208+
// OutputStream can't be closed somewhere in the Netty pipeline, so that we can support
209+
// retries. The OutputStream is closed in the finally block below.
210+
211+
@Override
212+
public void write(byte[] b, int offset, int length) throws IOException {
213+
dataWritten.set(true);
214+
out.write(b, offset, length);
215+
}
207216

208217
@Override
209218
public void write(int b) throws IOException {
210219
dataWritten.set(true);
211-
super.write(b);
220+
out.write(b);
212221
}
213222

214223
@Override
215-
public void close() {
216-
// Ensure that the OutputStream can't be closed somewhere in the Netty
217-
// pipeline, so that we can support retries. The OutputStream is closed in
218-
// the finally block below.
224+
public void flush() throws IOException {
225+
out.flush();
219226
}
220227
};
221228
DownloadCommand download = new DownloadCommand(uri, casDownload, key, wrappedOut);

0 commit comments

Comments
 (0)