netudima commented on code in PR #4707:
URL: https://github.com/apache/cassandra/pull/4707#discussion_r3037286928
##########
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:
I would not expect a lot from this change alone - it is just 1 object per
request (executed in native transport or read stage thread, depends on how many
requests are progress in a a moment), it is more like a side note because we've
touched this part of the code.
--
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]