ShiKaiWi opened a new issue, #9926: URL: https://github.com/apache/rocketmq/issues/9926
### Before Creating the Enhancement Request - [x] I have confirmed that this should be classified as an enhancement rather than a bug/feature. ### Summary During my benchmark (50K LMQ tps), the rocketmq client in my process shows massive memory allocation in the `parsePublishMessageQueues`. Here is my profiling result about the memory allocation: <img width="1396" height="218" alt="Image" src="https://github.com/user-attachments/assets/54cdd82e-788f-44d0-882b-d66e5efe538a" /> ### Motivation This multiple growths of the array list introduce a great influence on the performance under the high throughput workload. ### Describe the Solution You'd Like Here is a simple proposal: - do pre-allocation for the returned list of the `parsePublishMessageQueues`. - Just return the original `List<MessageQueue>` if the namespace is empty. ### Describe Alternatives You've Considered There are more complex solutions: - Upgrade the interface about the `MessageQueueSelector` to use `size of the message queue` and `accessor by index to MessageQueue` instead of `List<MessageQueue>`, so that no need to create another `List<MessageQueue>`. - Use thread-local buffer array list for the parsed `List<MessageQueue>` to avoid allocating memory for any to-be-sent message. ### Additional Context _No response_ -- 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]
