wang-jiahua opened a new pull request, #10517:
URL: https://github.com/apache/rocketmq/pull/10517

   ## Summary
   
   Three independent optimizations in the broker layer:
   
   ### 1. ConsumerOffsetManager — topicGroupKeyCache
   `commitOffset()` and related methods concatenate `topic + "@" + group` on 
every call for a stable set of (topic, group) pairs. Added a 2-level 
`ConcurrentHashMap<String, ConcurrentHashMap<String, String>>` cache so each 
unique (topic, group) pair is concatenated only once.
   
   ### 2. PullRequestHoldService — buildKeyCache
   `buildKey()` creates a `StringBuilder` and calls `toString()` on every pull 
request hold/check for stable `topic + "@" + queueId` keys. Added a 
`ConcurrentMap<String, String[]>` cache indexed by queueId per topic.
   
   ### 3. TransactionMetricsFlushService — busy spin fix (correctness bug)
   `waitForRunning()` was only called inside the `if` branch, so when the flush 
interval hadn't elapsed the `while` loop spun without yielding — wasting ~170 
CPU samples on an idle broker in JFR. Moved `waitForRunning()` before the `if` 
check so the thread always sleeps between iterations.
   
   ## Files Changed
   
   | File | Change |
   |---|---|
   | `broker/.../offset/ConsumerOffsetManager.java` | +26/-16: 
`buildTopicGroupKey()` + 2-level CHM cache, 10 call sites |
   | `broker/.../longpolling/PullRequestHoldService.java` | +22/-5: 
`buildKeyCache` with `String[]` per topic |
   | `broker/.../transaction/TransactionMetricsFlushService.java` | +7/-2: 
`waitForRunning()` moved before `if` branch |
   
   ## Commercial Version Compatibility
   
   Verified: `ConsumerOffsetManagerProxy` only overrides `configFilePath()`. No 
override conflicts with the new private methods. `PullRequestHoldService` and 
`TransactionMetricsFlushService` have no commercial extensions.


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