Peter Bacsko created YUNIKORN-2210:
--------------------------------------

             Summary: Metrics: use WithLabelValues instead of With 
                 Key: YUNIKORN-2210
                 URL: https://issues.apache.org/jira/browse/YUNIKORN-2210
             Project: Apache YuniKorn
          Issue Type: Improvement
          Components: core - scheduler
            Reporter: Peter Bacsko
            Assignee: Peter Bacsko


In the metrics codebase, we use labels to specify the counters/gauges:

{noformat}
m.appMetricsLabel.With(prometheus.Labels{"state": state}).Dec()
m.appMetricsSubsystem.With(prometheus.Labels{"state": state}).Dec()

m.resourceMetricsLabel.With(prometheus.Labels{"state": state, "resource": 
resourceName}).Set(value)
m.resourceMetricsSubsystem.With(prometheus.Labels{"state": state, "resource": 
resourceName}).Set(value)
{noformat}

However, {{prometheus.Labels}} is a map[string]string, so we always create a 
map. This is completely unnecessary and has measurable performance impact. 
Noting earth shattering, but visible.

The following achieves the same, so we can save some memory:
{noformat}
m.appMetricsLabel.WithLabelValues(state).Dec()
m.appMetricsSubsystem.WithLabelValues(state).Dec()

m.resourceMetricsLabel.WithLabelValues(state, resourceName).Set(value)
m.resourceMetricsSubsystem.WithLabelValues(state, resourceName).Set(value)
{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to