cfmcgrady opened a new pull request, #2928:
URL: https://github.com/apache/celeborn/pull/2928

   backport https://github.com/apache/celeborn/pull/2593 to branch-0.4
   
   ### What changes were proposed in this pull request?
   
   Refactor `addCounter`, `addGauge` and `addTimer` of `AbstractSource` to 
reduce CPU utilization.
   
   ### Why are the changes needed?
   
   `addCounter`, `addGauge` and `addTimer` of `AbstractSource` checks whether 
the metric key exist via `MetricRegistry#getMetrics` which iterates all metrics 
and put into map at present. It causes that adding counter of active connection 
count metric for application dimension would increase high CPU utilization when 
there are many active connections:
   
   <img width="1350" alt="image" 
src="https://github.com/apache/celeborn/assets/10048174/cc882fac-eec1-417b-ba17-f3012053c6c7";>
   
   The implementation of `MetricRegistry#getMetrics` is as follows:
   
   ```
   private <T extends Metric> SortedMap<String, T> getMetrics(Class<T> klass, 
MetricFilter filter) {
       final TreeMap<String, T> timers = new TreeMap<>();
       for (Map.Entry<String, Metric> entry : metrics.entrySet()) {
           if (klass.isInstance(entry.getValue()) && 
filter.matches(entry.getKey(), entry.getValue())) {
               timers.put(entry.getKey(), (T) entry.getValue());
           }
       }
       return Collections.unmodifiableSortedMap(timers);
   }
   ```
   
   Refactor `addCounter`, `addGauge` and `addTimer` of `AbstractSource` to 
reduce CPU utilization.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Cluster test.
   
   <img width="1345" alt="image" 
src="https://github.com/apache/celeborn/assets/10048174/4c0a7f92-3cc5-45f8-941f-e1d0166043e1";>
   
   Closes #2593 from SteNicholas/CELEBORN-1485.
   
   Authored-by: SteNicholas <[email protected]>
   


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