divijvaidya opened a new pull request, #12967:
URL: https://github.com/apache/kafka/pull/12967

   `ListBuffer` should be preferred over `ArrayBuffer` in cases where:
   1. No indexing is required.
   2. The data structure is converted to Java's List from scala.
   
   `ListBuffer` has a [guaranteed constant time 
performance](https://docs.scala-lang.org/overviews/collections-2.13/performance-characteristics.html)
 for append operations which makes it a lucrative data structure for  cases 
when we create a list and append multiple entries to it.
   
   This PR modifies usage of `ArrayBuffer` to `ListBuffer` in latency sensitive 
code path. To prove the usefulness of this change, I am attaching a CPU profile 
for an [open messaging 
benchmark](https://openmessaging.cloud/docs/benchmarks/). Please note that the 
self-time of the `ReplicaManager.fetchMessages()` reduced after this changes 
(depicted by the empty space in top of the frame for 
`ReplicaManager.fetchMessages()`.
   
   **Before this PR**
    
   ![Screenshot 2022-12-08 at 15 30 
24](https://user-images.githubusercontent.com/71267/206517187-6ebbcad5-00b5-4706-a2b8-5c64dce71d9a.png)
   
   **After this PR**
   ![Screenshot 2022-12-08 at 15 30 
37](https://user-images.githubusercontent.com/71267/206517243-97938193-449d-4e46-9c32-fb9bc82c0469.png)
   
   
   Note: This PR piggybacks some general scala cleanup regarding usage of 
Optionals.


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to