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

   ## What is the purpose of the change
   
   Close #10423
   
   `LiteConsumerLagCalculator.getLagCountTopK` currently calls 
`getStoreTimestamp()` (disk I/O) for **every** offset entry, creates a 
`LiteLagInfo` for each, and uses `String.split()` for key parsing. This PR 
optimizes these hotspots.
   
   ## Brief changelog
   
   - **Defer `getStoreTimestamp` to topK results only**: accumulate 
`consumerOffset` in `LiteLagInfo` during traversal, compute timestamps for the 
final topK entries after heap filtering (N → K calls).
   - **Lazy object creation**: only instantiate `LiteLagInfo` when the entry 
qualifies for heap insertion.
   - **Replace `split()` with `indexOf()`**: parse `topicAtGroup` key via 
`indexOf` + `substring`, avoiding array allocation; check lite prefix before 
string extraction.
   - **Replace `AtomicLong` with `long[]`**: single-threaded traversal needs no 
atomic overhead.
   
   ## Verifying this change
   
   Existing unit tests cover the changed methods.


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