From 29e5771aa4d3996c226312fc21c09e7f81ab31f4 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 3 Jul 2023 21:15:16 +0200 Subject: [PATCH 1/2] scheduler-perf: shorten "Name" label in metrics Because the JSON file gets written at the end of the top-level benchmark, all data items had `BenchmarkPerfScheduling/` as prefix in the `Name` label. This is redundant and makes it harder to see the actual name. Now that common prefix gets removed. --- test/integration/scheduler_perf/scheduler_perf_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/integration/scheduler_perf/scheduler_perf_test.go b/test/integration/scheduler_perf/scheduler_perf_test.go index ecbfce6887b..8671b6381ce 100644 --- a/test/integration/scheduler_perf/scheduler_perf_test.go +++ b/test/integration/scheduler_perf/scheduler_perf_test.go @@ -996,7 +996,10 @@ func runWorkload(ctx context.Context, tb testing.TB, tc *testCase, w *workload, if concreteOp.CollectMetrics { collectorCtx, collectorCancel = context.WithCancel(ctx) defer collectorCancel() - collectors = getTestDataCollectors(tb, podInformer, fmt.Sprintf("%s/%s", tb.Name(), namespace), namespace, tc.MetricsCollectorConfig, throughputErrorMargin) + name := tb.Name() + // The first part is the same for each work load, therefore we can strip it. + name = name[strings.Index(name, "/")+1:] + collectors = getTestDataCollectors(tb, podInformer, fmt.Sprintf("%s/%s", name, namespace), namespace, tc.MetricsCollectorConfig, throughputErrorMargin) for _, collector := range collectors { // Need loop-local variable for function below. collector := collector From 6b01ece5806ae46f6f1b3f476af026f54eea27ff Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 3 Jul 2023 21:16:53 +0200 Subject: [PATCH 2/2] scheduler-perf: fix perfdash display problem perfdash expects all data items to have the same set of labels. It then renders drop-down buttons for each label with all values found for each label. Previously, data items that didn't have a label didn't match any label filter in perfdash and couldn't get selected because perfdash doesn't have "unset" in it's drop-down menus. To avoid that, scheduler-perf now collects all labels and then adds missing labels with "not applicable" as value: { "data": { "Average": 939.7071223010004, "Perc50": 927.7987421383649, "Perc90": 2166.153846153846, "Perc95": 2363.076923076923, "Perc99": 2520.6153846153848 }, "unit": "ms", "labels": { "Metric": "scheduler_pod_scheduling_duration_seconds", "Name": "SchedulingBasic/5000Nodes/namespace-2", "extension_point": "not applicable", "result": "not applicable" } }, ... { "data": { "Average": 1.1172570650000004, "Perc50": 1.1418367346938776, "Perc90": 1.5500000000000003, "Perc95": 1.6410256410256412, "Perc99": 3.7333333333333334 }, "unit": "ms", "labels": { "Metric": "scheduler_framework_extension_point_duration_seconds", "Name": "SchedulingBasic/5000Nodes/namespace-2", "extension_point": "Score", "result": "not applicable" } }, --- test/integration/scheduler_perf/util.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/integration/scheduler_perf/util.go b/test/integration/scheduler_perf/util.go index 79bc3ab10bb..327f1dd4310 100644 --- a/test/integration/scheduler_perf/util.go +++ b/test/integration/scheduler_perf/util.go @@ -196,6 +196,27 @@ func makeBasePod() *v1.Pod { } func dataItems2JSONFile(dataItems DataItems, namePrefix string) error { + // perfdash expects all data items to have the same set of labels. It + // then renders drop-down buttons for each label with all values found + // for each label. If we were to store data items that don't have a + // certain label, then perfdash will never show those data items + // because it will only show data items that have the currently + // selected label value. To avoid that, we collect all labels used + // anywhere and then add missing labels with "not applicable" as value. + labels := sets.New[string]() + for _, item := range dataItems.DataItems { + for label := range item.Labels { + labels.Insert(label) + } + } + for _, item := range dataItems.DataItems { + for label := range labels { + if _, ok := item.Labels[label]; !ok { + item.Labels[label] = "not applicable" + } + } + } + b, err := json.Marshal(dataItems) if err != nil { return err