Add OpenMetrics hot path benchmarks#23839
Conversation
|
80a2fc8 to
b84d759
Compare
|
Current local benchmark values from the workspace run: Command used: cd datadog_checks_base
DDEV_SKIP_GENERIC_TAGS_CHECK=true \
UV_PROJECT_ENVIRONMENT=.venv-hotpath \
UV_LINK_MODE=copy \
uv run --python 3.13 \
--with-editable . \
--with-editable ../datadog_checks_tests_helper \
--with pytest \
--with pytest-benchmark \
--with hypothesis \
--with datadog-checks-dev \
--with '.[deps,json,db]' \
pytest tests/base/checks/openmetrics/test_v2/test_hotpath_bench.py \
--benchmark-only \
--benchmark-min-rounds=5 \
--benchmark-disable-gc \
--benchmark-sort=nameNote: GNU
All 11 benchmark tests passed in this environment. |
|
Updated benchmark run after adding the family-count probes requested by the Agent-side SMP investigation. Run command: cd datadog_checks_base
DDEV_SKIP_GENERIC_TAGS_CHECK=true \
UV_PROJECT_ENVIRONMENT=.venv-hotpath \
UV_LINK_MODE=copy \
uv run --python 3.13 \
--with-editable . \
--with-editable ../datadog_checks_tests_helper \
--with pytest \
--with pytest-benchmark \
--with hypothesis \
--with datadog-checks-dev \
--with '.[deps,json,db]' \
pytest tests/base/checks/openmetrics/test_v2/test_hotpath_bench.py \
--benchmark-only \
--benchmark-min-rounds=5 \
--benchmark-disable-gc \
--benchmark-sort=name \
--benchmark-json=/tmp/openmetrics_hotpath_bench.jsonResults from this container:
Interpretation relative to the Agent macro/SMP profile:
|
Validation ReportAll 21 validations passed. Show details
|
Codecov Report❌ Patch coverage is Additional details and impacted files🚀 New features to boost your workflow:
|
What does this PR do?
Adds focused pytest-benchmark coverage for OpenMetrics v2 hot paths identified from the Agent SMP macro investigation:
The benchmark payloads mirror the macro investigation dimensions: fixed sample count, label cardinality, and metric-family count.
Motivation
Agent SMP macro profiling showed OpenMetrics throughput degradation is driven by OpenMetrics-specific Python paths rather than generic Agent ingestion. cProfile from real SMP macro runs identified these hot paths:
prometheus_client.parser.parse_labelsand parser helpers (_next_unquoted_char,_next_term,_unquote_unescape).MetricTransformer.get/compile_transformerfor high-family-count payloads.generate_sample_datalabel/tag handling.aggregator.submit_metricas a linear submission contributor.This draft PR does not optimize behavior yet. It makes those code paths reproducible in integrations-core benchmarks so candidate fixes can be evaluated with targeted benchmark evidence alongside the existing macro SMP signal.
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged