Optimize CS Persistence Stream Use (#60643) (#60647)

In the metadata persistence logic we failed to override the bulk write
method on the FilterOutputStream resulting in all the writes to it
running byte-by-byte in a loop adding a large number of bounds checks
needlessly.
This commit is contained in:
Armin Braun 2020-08-04 15:06:57 +02:00 committed by GitHub
parent bdd7347bbf
commit 212ce22d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -814,6 +814,12 @@ public class PersistedClusterStateService {
final ReleasableBytesStreamOutput releasableBytesStreamOutput = new ReleasableBytesStreamOutput(bigArrays);
try {
final FilterOutputStream outputStream = new FilterOutputStream(releasableBytesStreamOutput) {
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
}
@Override
public void close() {
// closing the XContentBuilder should not release the bytes yet