wang-jiahua opened a new issue, #10490:
URL: https://github.com/apache/rocketmq/issues/10490

   ## Background
   
   Three independent per-RPC/per-metrics micro-allocations found via JFR 
`settings=profile`:
   
   1. **Logback `BasicStatusManager`**: Logback internal status events 
(`InfoStatus`, `BodyEvent`, etc.) accumulate during XML configuration loading. 
Adding `NopStatusListener` suppresses callback overhead.
   
   2. **`TopicMessageType.getMetricsValue()`**: Calls `value.toLowerCase()` on 
every invocation, allocating a new `String` each time. The result is 
deterministic per enum constant and should be cached.
   
   3. **`RemotingHelper.getRequestCodeDesc()` / `getResponseCodeDesc()`**: Uses 
`Map.getOrDefault(code, String.valueOf(code))` which eagerly evaluates 
`String.valueOf(code)` even when the key exists in the map. Changing to `get()` 
+ null check avoids unnecessary `String` allocation on hit.
   
   ## Proposed Changes
   
   - Add `<statusListener 
class="ch.qos.logback.core.status.NopStatusListener"/>` to 
`rmq.broker.logback.xml`
   - Cache `metricsValue` in `TopicMessageType` enum constructor with 
`Locale.ROOT`
   - Replace `getOrDefault` with `get` + null check in `RemotingHelper`
   
   ## Expected Impact
   
   ~200-300 bytes per RPC eliminated from these three allocation sites.


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