[ 
https://issues.apache.org/jira/browse/CASSANDRA-21285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18071285#comment-18071285
 ] 

C. Scott Andreas commented on CASSANDRA-21285:
----------------------------------------------

Thanks for feedback on the PR. I've incorporated both changes and pushed to the 
branch.

Interestingly, the call to `.buffer(false)` when returning the response doesn't 
seem to have made a difference in allocations at least as measured in the JFR 
profile.

I've attached fresh output comparing the initial patch (initial-patch) and the 
revised version with `.buffer(false)` incorporated (buffer-false). The total 
allocations look about the same between the two profiles, though in the revised 
version it looks like the allocations moved from NTR to ReadStage but sum to 
the same total over the duration of the run.

> Reduce allocations + copies due to rebuffering in LocalDataResponse row 
> serialization
> -------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-21285
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21285
>             Project: Apache Cassandra
>          Issue Type: Task
>          Components: Messaging/Client
>            Reporter: C. Scott Andreas
>            Assignee: C. Scott Andreas
>            Priority: Low
>             Fix For: 6.x
>
>         Attachments: CASSANDRA-21285.diff, after.png, before.png, 
> buffer-false.allocs.txt, buffer-false.png, initial-patch.allocs.txt, 
> initial-patch.png
>
>
> This patch reduces allocations due to rebuffering in LocalDataResponse row 
> serialization.
> Today, LocalDataResponse#build serializes row responses without providing a 
> size estimate when initializing a DataOutputBuffer. Read responses that 
> exceed the initial size of 128 bytes incur progressive size doubling, 
> allocation, and buffer copying until the result fits.
> This patch maintains a lightweight moving average of read response sizes and 
> uses this to size the initial response.
> In a read-heavy workload dominated by resultset paging, this change reduces 
> memory allocations/copies by about 9%. [1]
> The change is most visible in the Native-Transport-Requests threadpool.
> *Trunk:*
> {{Thread Pool                                         Threads       Allocated 
>        Count   % of Total}}
> {{----------------------------------------------------------------------------------------------------}}
> {{Native-Transport-Requests                                10       68.45 GiB 
>      348,724       74.02%}}
>  
> *Trunk + Patch:*
> {{Thread Pool                                         Threads       Allocated 
>        Count   % of Total}}
> {{----------------------------------------------------------------------------------------------------}}
> {{Native-Transport-Requests                                11       62.52 GiB 
>      324,523       74.13%}}
> —
> [1] Workload example: 
> [https://gist.github.com/cscotta/580378387c73b49822f287910771d14f]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to