GGraziadei commented on code in PR #8707:
URL: https://github.com/apache/storm/pull/8707#discussion_r3309709857


##########
storm-client/src/jvm/org/apache/storm/serialization/KryoTupleSerializer.java:
##########
@@ -38,7 +51,16 @@ public byte[] serialize(Tuple tuple) {
             kryoOut.writeInt(ids.getStreamId(tuple.getSourceComponent(), 
tuple.getSourceStreamId()), true);
             tuple.getMessageId().serialize(kryoOut);
             kryo.serializeInto(tuple.getValues(), kryoOut);
-            return kryoOut.toBytes();
+
+            byte[] rawBytes = kryoOut.getBuffer();
+            int dataLength = kryoOut.position();
+
+            if (this.isCompressionEnabled && dataLength > 
this.compressionThreshold) {

Review Comment:
   Thanks for the feedback! This makes total sense. Overloading the compress 
method to accept an offset and length is a great way to avoid that intermediate 
Arrays.copyOf allocation. Reducing GC overhead on the serialization path is 
definitely a win. I'll get this applied.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to