RockteMQ-AI commented on issue #10537:
URL: https://github.com/apache/rocketmq/issues/10537#issuecomment-4767117691

   **Issue Evaluation**
   
   Category: `type/enhancement` | Status: **Evaluated**
   
   **Feasibility:** Feasible
   **Scope:** `remoting` module (`NettyRemotingAbstract`)
   **Compatibility:** Low risk — internal metrics path, no wire-format change.
   
   Both changes are valid:
   
   1. **AttributesBuilder caching**: Currently 
`remotingMetricsManager.newAttributesBuilder()` is called per RPC in 
`invokeAsyncImpl` (line ~240), `invokeSyncImpl` (line ~292), and 
`processRequestCommand` (line ~396). Caching via `getOrBuildAttributes()` would 
reduce per-request allocations on the hot path.
   
   2. **`processTimerElapsedMs()`**: 
`request.getProcessTimer().elapsed(TimeUnit.MILLISECONDS)` is used in 3 
locations within `NettyRemotingAbstract`. Replacing with the non-deprecated 
`processTimerElapsedMs()` is a straightforward cleanup.
   
   **Suggested approach:**
   - Add a lazy-initialized `AttributesBuilder` field or a 
`getOrBuildAttributes()` helper that reuses the builder across calls within the 
same RPC lifecycle.
   - Replace all `getProcessTimer().elapsed(TimeUnit.MILLISECONDS)` calls with 
`processTimerElapsedMs()`.
   - Ensure thread safety if the cached builder is shared across callback 
threads.
   
   ---
   *Automated evaluation by RockteMQ-AI*


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