cscotta commented on code in PR #4707:
URL: https://github.com/apache/cassandra/pull/4707#discussion_r3037156224


##########
src/java/org/apache/cassandra/db/ReadResponse.java:
##########
@@ -239,9 +244,15 @@ private LocalDataResponse(UnfilteredPartitionIterator 
iter, ColumnFilter selecti
 
         private static ByteBuffer build(UnfilteredPartitionIterator iter, 
ColumnFilter selection)
         {
-            try (DataOutputBuffer buffer = new DataOutputBuffer())
+            // Size output buffer to 10% above the moving average to absorb 
minor variance and limit rebuffering.
+            double bufferSizeEstimate = 
Double.isNaN(estimatedResponseBytes.get()) ? 128 : estimatedResponseBytes.get();
+            int initialBufferSize = (int) (bufferSizeEstimate * 1.1);
+
+            try (DataOutputBuffer buffer = new 
DataOutputBuffer(initialBufferSize))
             {
                 
UnfilteredPartitionIterators.serializerForIntraNode().serialize(iter, 
selection, buffer, MessagingService.current_version);
+                estimatedResponseBytes.update(buffer.position());
+
                 return buffer.buffer();

Review Comment:
   Updated with this as well, though I don't actually see a difference in the 
allocation profile after making this change (see attachments on ticket).



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to