You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by "Peter Bacsko (Jira)" <ji...@apache.org> on 2023/11/29 18:33:00 UTC
[jira] [Updated] (YUNIKORN-2210) Metrics: use WithLabelValues instead of With
[ https://issues.apache.org/jira/browse/YUNIKORN-2210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Bacsko updated YUNIKORN-2210:
-----------------------------------
Description:
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}
was:
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}
> 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
> Priority: Major
>
> 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: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org