diff options
author | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-03-04 15:21:32 +0100 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@vespa.ai> | 2024-03-04 15:28:05 +0100 |
commit | b1511dfda39e4bb238e689115f675c9ffaf2477b (patch) | |
tree | 0b8af223a4a71b11d1b3581b59413727aa293df9 | |
parent | d888d06261e427205d95b67a03ee02051e4dad30 (diff) |
Use smaller buffers for Document(Update) serialization
Default buffer size is 64 KiB, which adds a lot of unnecessary
GC pressure when operations are small (which is often the case).
Now explicitly preallocate just 8 KiB for documents and 4 KiB
for updates.
Additionally, use explicit HEAD serializer for `Document`
serialization, as `serialize()` for some reason uses v6 internally
(this only has an observable effect for updates, but still good to
use the most recent version).
-rw-r--r-- | documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java index ef1575e2101..778eaeda5f0 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/RoutableFactories80.java @@ -193,8 +193,8 @@ abstract class RoutableFactories80 { } private static ByteBuffer serializeDoc(Document doc) { - var buf = new GrowableByteBuffer(); - doc.serialize(buf); + var buf = new GrowableByteBuffer(8 * 1024, 2.0f); + doc.serialize(DocumentSerializerFactory.createHead(buf)); buf.flip(); return buf.getByteBuffer(); } @@ -233,7 +233,7 @@ abstract class RoutableFactories80 { } private static ByteBuffer serializeUpdate(DocumentUpdate update) { - var buf = new GrowableByteBuffer(); + var buf = new GrowableByteBuffer(4 * 1024, 2.0f); update.serialize(DocumentSerializerFactory.createHead(buf)); buf.flip(); return buf.getByteBuffer(); |