-
Notifications
You must be signed in to change notification settings - Fork 829
perf: remove unused all-device scan in metrics collector #2166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Gaurav-205
wants to merge
1
commit into
Project-HAMi:master
from
Gaurav-205:fix/metrics-unused-device-scan
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,6 @@ import ( | |
| "fmt" | ||
| "log" | ||
| "net/http" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
|
|
@@ -355,25 +354,6 @@ func (cc ClusterManagerCollector) Collect(ch chan<- prometheus.Metric) { | |
| float64(ctrdevval.Usedcores), | ||
| val.Namespace, val.NodeID, val.Name, fmt.Sprint(ctridx), ctrdevval.UUID) | ||
| } | ||
| var totaldev int32 | ||
| found := false | ||
| for _, ni := range *nu { | ||
| for _, nodedev := range ni.Devices.DeviceLists { | ||
| if strings.Compare(nodedev.Device.ID, ctrdevval.UUID) == 0 { | ||
| totaldev = nodedev.Device.Totalmem | ||
| found = true | ||
| break | ||
| } | ||
| } | ||
| if found { | ||
| break | ||
| } | ||
| } | ||
| klog.V(4).InfoS("Total memory for device", | ||
| "deviceUUID", ctrdevval.UUID, | ||
| "totalMemory", totaldev, | ||
| "nodeID", val.NodeID, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the loop u deleted broke on the first uuid hit while ranging |
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find! This looks reasonable tbh. The removed scan only feeds a verbose log line and does not affect any emitted metric. One question tho... was this
totalMemorylog used for any debugging flow, or is the node memory limit metric enough for that case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I checked the full metrics collector flow. totaldev was only used by that klog.V(4) message; it does not affect emitted metrics, scheduling, or allocation.
For debugging device capacity, the collector already exposes the same per-device total-memory information through hami_gpu_memory_limit_bytes and hami_node_gpu_overview (device_memory_limit). So the verbose log is redundant, and removing the scan does not reduce Prometheus visibility.
If maintainers prefer retaining a V(4) log for troubleshooting, I can add one using the already available per-device data, without restoring the all-node scan.