wushiyuanmaimob opened a new pull request, #10380:
URL: https://github.com/apache/rocketmq/pull/10380

   ### Which Issue(s) This PR Fixes
   
   - Fixes #9926
   
   ### Brief Description
   
   `MQAdminImpl.parsePublishMessageQueues()` is called on every message send 
(hot path). Under high throughput (50K+ TPS), it creates significant GC 
pressure by allocating a new `ArrayList` and N new `MessageQueue` objects per 
call — even when namespace is empty (the common case for most users), where the 
copied data is identical to the original.
   
   **Changes:**
   1. When namespace is null or empty, return the original list directly (zero 
allocation)
   2. When namespace stripping is needed, pre-allocate `ArrayList` with exact 
capacity to avoid internal array resizing
   3. Cache the namespace string to avoid repeated `getNamespace()` calls in 
the loop
   
   **Impact:** Eliminates per-message object allocation on the send path for 
the majority of users who don't use namespaces. For users with namespaces, 
reduces allocation by pre-sizing the list.
   
   ### How Did You Test This Change?
   
   - Added unit test 
`assertParsePublishMessageQueuesReturnsOriginalListWhenNoNamespace` — verifies 
same list instance is returned when namespace is empty
   - Added unit test `assertParsePublishMessageQueuesStripsNamespace` — 
verifies namespace stripping still works correctly
   - Ran full client module test suite: 566 tests passed, 0 failures


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

Reply via email to