Skip to content

Conversation

travisdowns
Copy link
Contributor

@travisdowns travisdowns commented Oct 2, 2025

Three primary changes related to prometheus endpoint:

  • Introduce bench for prometheus
  • Add test for global label functionality, which was missing
  • Convert prom endpoint to use (more) coroutines

These are precursors to a perf improvement I want to make.

Here is the benchmark output before/after the coroutine change:

before:

test iterations median mad min max allocs tasks inst cycles
metrics_perf_fixture.test_few_metrics 533000 1.847us 0.000ns 1.847us 1.847us 25.129 0.026 17925.7 6783.4
metrics_perf_fixture.test_large_families 2000000 548.379ns 0.000ns 548.379ns 548.379ns 4.164 0.002 8921.8 2174.8
metrics_perf_fixture.test_many_families 2000000 745.484ns 0.000ns 745.484ns 745.484ns 10.272 0.002 11362.2 2955.7
metrics_perf_fixture.test_middle_ground 2000000 542.494ns 0.000ns 542.494ns 542.494ns 4.745 0.002 8727.8 2152.5

after

test iterations median mad min max allocs tasks inst cycles
metrics_perf_fixture.test_few_metrics 569100 1.724us 0.000ns 1.724us 1.724us 25.128 0.021 17575.3 6297.5
metrics_perf_fixture.test_large_families 2000000 532.980ns 0.000ns 532.980ns 532.980ns 4.164 0.002 8922.6 2115.2
metrics_perf_fixture.test_many_families 2000000 722.662ns 0.000ns 722.662ns 722.662ns 10.272 0.002 11356.0 2867.4
metrics_perf_fixture.test_middle_ground 2000000 530.925ns 0.000ns 530.925ns 530.925ns 4.745 0.002 8728.0 2107.9

As expected the differences are ~nil, below the noise floor, as the coroutines are only introduced around a relatively long-running function.

@travisdowns travisdowns force-pushed the td-upstream-metrics-bench branch from af3732d to 52f9abc Compare October 3, 2025 00:34
Introduce metrics_perf benchmark. This is a precursor to work in
upcoming changes to:

 - Couroutinize metrics endpoint
 - Improve the perf of the prometheus endpoint

It tests a few flavors of metrics configurations that stress different
parts of the core metrics response loop.
There was no existing test coverage of the feature of adding a
label to all series in the seastar-side prometheus config. Add such
a test case to the prom http test.
Coroutinize and de-boilerplate up the prometheus metrics writing path.
We do not couroutinze the innermost loop, as this is using ss::async
and currently relies on that.

This is a precursor to performance improvements on this path. This
change is more or less performance neutral: there is a slight "fixed
cost" win for the body writing, but this doesn't matter much in the
larger context since the per-series overhead dominates and there is
no change in that case (for this change).
@travisdowns travisdowns force-pushed the td-upstream-metrics-bench branch from 52f9abc to eff3dc1 Compare October 3, 2025 00:36
@avikivity
Copy link
Member

Please fix spelling, especially "prom", I'm allergic.

#include <seastar/testing/perf_tests.hh>
#include <seastar/util/tmp_file.hh>

#include <boost/range/irange.hpp>
Copy link
Member

Choose a reason for hiding this comment

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

For new code, let's avoid boost::ranges, std::views::subrange is the replacement.

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe iota

using namespace seastar;
using namespace seastar::metrics;

remove_existing_metrics();
Copy link
Member

Choose a reason for hiding this comment

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

Not an expert on fixtures, but wouldn't that poison global state? So if a later test dependent on standard metrics, it would fail.

@avikivity
Copy link
Member

Looks good. The results are normalized per-metric?

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.

2 participants