[CELEBORN-1485][0.4] Refactor addCounter, addGauge and addTimer of AbstractSource to reduce CPU utilization#2928
Closed
cfmcgrady wants to merge 2 commits into
Closed
[CELEBORN-1485][0.4] Refactor addCounter, addGauge and addTimer of AbstractSource to reduce CPU utilization#2928cfmcgrady wants to merge 2 commits into
cfmcgrady wants to merge 2 commits into
Conversation
…tSource to reduce CPU utilization Refactor `addCounter`, `addGauge` and `addTimer` of `AbstractSource` to reduce CPU utilization. `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. No. Cluster test. <img width="1345" alt="image" src="https://github.com/apache/celeborn/assets/10048174/4c0a7f92-3cc5-45f8-941f-e1d0166043e1"> Closes apache#2593 from SteNicholas/CELEBORN-1485. Authored-by: SteNicholas <programgeek@163.com> Signed-off-by: mingji <fengmingxiao.fmx@alibaba-inc.com>
33ba500 to
7cb630d
Compare
Contributor
Author
|
cc @SteNicholas @FMX |
turboFei
approved these changes
Nov 20, 2024
SteNicholas
approved these changes
Nov 20, 2024
Contributor
Author
|
thanks, merging to branch-0.4(v0.4.3). |
cfmcgrady
added a commit
that referenced
this pull request
Nov 20, 2024
…stractSource to reduce CPU utilization backport #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 <programgeek163.com> Closes #2928 from cfmcgrady/CELEBORN-1485-0.4. Lead-authored-by: SteNicholas <programgeek@163.com> Co-authored-by: Fu Chen <cfmcgrady@gmail.com> Signed-off-by: Fu Chen <cfmcgrady@gmail.com>
cfmcgrady
added a commit
to cfmcgrady/incubator-celeborn
that referenced
this pull request
Aug 21, 2025
…stractSource to reduce CPU utilization backport apache#2593 to branch-0.4 Refactor `addCounter`, `addGauge` and `addTimer` of `AbstractSource` to reduce CPU utilization. `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. No. Cluster test. <img width="1345" alt="image" src="https://github.com/apache/celeborn/assets/10048174/4c0a7f92-3cc5-45f8-941f-e1d0166043e1"> Closes apache#2593 from SteNicholas/CELEBORN-1485. Authored-by: SteNicholas <programgeek163.com> Closes apache#2928 from cfmcgrady/CELEBORN-1485-0.4. Lead-authored-by: SteNicholas <programgeek@163.com> Co-authored-by: Fu Chen <cfmcgrady@gmail.com> Signed-off-by: Fu Chen <cfmcgrady@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
backport #2593 to branch-0.4
What changes were proposed in this pull request?
Refactor
addCounter,addGaugeandaddTimerofAbstractSourceto reduce CPU utilization.Why are the changes needed?
addCounter,addGaugeandaddTimerofAbstractSourcechecks whether the metric key exist viaMetricRegistry#getMetricswhich 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:The implementation of
MetricRegistry#getMetricsis as follows:Refactor
addCounter,addGaugeandaddTimerofAbstractSourceto reduce CPU utilization.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Cluster test.
Closes #2593 from SteNicholas/CELEBORN-1485.
Authored-by: SteNicholas programgeek@163.com