From b1511dfda39e4bb238e689115f675c9ffaf2477b Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Mon, 4 Mar 2024 15:21:32 +0100 Subject: 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). --- .../yahoo/documentapi/messagebus/protocol/RoutableFactories80.java | 6 +++--- 1 file 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(); -- cgit v1.2.3