Skip to content
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

[fix]: remove unused func #1895

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SamYuan1990
Copy link
Collaborator

it seems we don't need updateProcessResourceUtilizationMetrics function any more as it just done a wait group.
and if so, we can remove that wait group, as the wait group has 2 funcs to wait, and we removed one.

Copy link
Contributor

github-actions bot commented Dec 14, 2024

🤖 SeineSailor

Here's a concise summary of the pull request changes:

Summary: This pull request refactors the metric collector and watcher components, improving code readability and reducing complexity.

Key Changes:

  1. Removed unused updateProcessResourceUtilizationMetrics function and associated wait group.
  2. Simplified updateResourceUtilizationMetrics function by direct calls instead of waiting for the wait group.
  3. Updated NewObjListWatcher function signature, changing the return type.
  4. Initialized IsWatcherEnabled global variable with a bool pointer instead of the value itself.

Impact: These changes improve code maintainability, reduce unnecessary complexity, and clean up unused code. Some changes affect the external interface and behavior of the code.

Observations: The refactoring efforts are commendable, as they enhance code readability and simplify the logic. However, it's essential to ensure that the updated NewObjListWatcher function signature doesn't break any dependent components or integrations. Additionally, consider adding tests to validate the correctness of the changes, especially those affecting the external interface.

@@ -99,15 +99,15 @@ func newK8sClient() *kubernetes.Clientset {
}

func NewObjListWatcher(bpfSupportedMetrics bpf.SupportedMetrics) (*ObjListWatcher, error) {
w := &ObjListWatcher{
w := ObjListWatcher{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -63,15 +62,15 @@ type Collector struct {

func NewCollector(bpfExporter bpf.Exporter) *Collector {
bpfSupportedMetrics := bpfExporter.SupportedMetrics()
c := &Collector{
c := Collector{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SamYuan1990 SamYuan1990 marked this pull request as ready for review December 14, 2024 06:32
Copy link
Collaborator

@sunya-ch sunya-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix on heap escapes are good to me.
However, I'm not sure about the removal of unimplemented updateNodeResourceUtilizationMetrics.

// aggregate processes' resource utilization metrics to containers, virtual machines and nodes
c.AggregateProcessResourceUtilizationMetrics()
}

// update the node metrics that are not related to aggregated resource utilization of processes
func (c *Collector) updateNodeResourceUtilizationMetrics(wg *sync.WaitGroup) {
Copy link
Collaborator

@sunya-ch sunya-ch Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep this for TODO list when we have metrics those are not related to aggregated resource utilization of processes. @rootfs. Do you recall who introduce this function?
Note that, I have no objection on removing this.

@rootfs
Copy link
Contributor

rootfs commented Jan 7, 2025

can you split into two PRs? one for heap optimization and one for unused functions @SamYuan1990

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants