Skip to content

ci(benchmarks): add percentage-based regression gate for microbenchmarks - #20057

Open
igoragoli wants to merge 8 commits into
mainfrom
augusto/add-percentage-based-performance-gates
Open

ci(benchmarks): add percentage-based regression gate for microbenchmarks#20057
igoragoli wants to merge 8 commits into
mainfrom
augusto/add-percentage-based-performance-gates

Conversation

@igoragoli

@igoragoli igoragoli commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a check-big-regressions job in the gate stage, before check-slo-breaches. Fails when a metric regressed more than 10% against baseline.

Small regressions accumulate and lead to PRs with unrelated changes breaching performance SLOs. Percentage-based checks should reduce this.

Known flaky benchmarks cannot fail the gate. benchmark_analyzer convert reads FLAKY_BENCHMARKS_REGEX during the microbenchmarks job and marks matching benchmarks, and the regression check skips marked benchmarks.

Testing

https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/2016179612

Failed because of flaky benches varying more than 10%. #20050 marks those as flaky and should be merged before.

Risks

Any flaky benchmark that varies more than 10% will block PRs.

The fix is either to:

  • Add the scenario to FLAKY_BENCHMARKS_REGEX in microbenchmarks.yml, then re-run microbenchmarks and the gate. Re-running the gate alone is not enough, since the flaky mark is applied when microbenchmarks converts its results.
    • This was added to our CI benchmarking docs.
  • Applying the performance/ignore-performance-regression label, as described in Performance Quality Gates.

Additional Notes

Adds a check-big-regressions job in the gate stage, before
check-slo-breaches, failing when a metric regressed more than 10% against
the baseline commit. The step script drops FLAKY_BENCHMARKS_REGEX matches
before comparing, since benchmark_analyzer compare pairwise has no
exclusion flag.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@igoragoli
igoragoli requested a review from a team as a code owner September 3, 2026 16:36
@igoragoli igoragoli added the changelog/no-changelog A changelog entry is not required for this PR. label Sep 3, 2026
@igoragoli
igoragoli requested a review from a team as a code owner September 3, 2026 16:36
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against main using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

.gitlab/benchmarks/README.md                                            @DataDog/apm-ecosystems-performance @DataDog/apm-core-python
.gitlab/benchmarks/bp-runner.microbenchmarks.fail-on-regression.yml     @DataDog/apm-ecosystems-performance @DataDog/apm-core-python
.gitlab/benchmarks/microbenchmarks.md                                   @DataDog/apm-ecosystems-performance @DataDog/apm-core-python
.gitlab/benchmarks/microbenchmarks.yml                                  @DataDog/apm-ecosystems-performance @DataDog/apm-core-python

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 3, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@igoragoli
igoragoli marked this pull request as draft September 3, 2026 16:37
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 3, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 230 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 230 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._utils -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.internal.ci_visibility.git_client -×-> ddtrace.trace  (product:ci_visibility -> product:tracing, score=132)
ddtrace.profiling.collector.stack -×-> ddtrace.trace  (product:profiling -> product:tracing, score=132)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e6d9d7ae5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .gitlab/benchmarks/microbenchmarks.yml
Comment thread .gitlab/benchmarks/microbenchmarks.md Outdated
Comment thread .gitlab/benchmarks/steps/check-big-regressions.sh Outdated
Comment thread .gitlab/benchmarks/steps/check-big-regressions.sh Outdated
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-py | check-big-regressions — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-py | download_dependency_wheels: [3.15.0rc1, 3.15]

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 3 tests - 3 passed on retry View in Datadog

🚧 4 tests that failed were ignored due to quarantine View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 23cbffd | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Sep 3, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-09-04 15:20:47

Comparing candidate commit 23cbffd in PR branch augusto/add-percentage-based-performance-gates with baseline commit 6ad4c28 in branch main.

📊 Benchmarking dashboard

Found 0 performance improvements and 9 performance regressions! Performance is the same for 577 metrics, 10 unstable metrics, 3 known flaky benchmarks, 15 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:httppropagationextract-tracecontext_headers

  • 🟥 execution_time [+2.633µs; +2.854µs] or [+7.125%; +7.724%]

scenario:httppropagationinject-ids_only

  • 🟥 execution_time [+1.995µs; +2.179µs] or [+11.827%; +12.913%]

scenario:iastaspects-join_aspect

  • 🟥 execution_time [+39.742µs; +45.702µs] or [+17.659%; +20.308%]

scenario:iastaspects-title_aspect

  • 🟥 execution_time [+60.481µs; +69.217µs] or [+21.745%; +24.886%]

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+123.079µs; +129.506µs] or [+29.703%; +31.254%]

scenario:iastaspectssplit-rsplit_aspect

  • 🟥 execution_time [+16.051µs; +19.544µs] or [+11.329%; +13.794%]

scenario:samplingrules-high_match

  • 🟥 execution_time [+14.082µs; +16.250µs] or [+9.065%; +10.460%]

scenario:telemetryaddmetric-1-count-metric-1-times

  • 🟥 execution_time [+365.992ns; +412.116ns] or [+12.609%; +14.199%]

scenario:tracer-small

  • 🟥 execution_time [+40.842µs; +43.217µs] or [+12.162%; +12.870%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:coreapiscenario-context_with_data_listeners

  • unstable execution_time [-694.011ns; +773.575ns] or [-6.295%; +7.016%]

scenario:coreapiscenario-core_dispatch_1_listener

  • unstable execution_time [-36.216ns; +29.429ns] or [-5.872%; +4.771%]

scenario:coreapiscenario-core_dispatch_50_listeners

  • unstable execution_time [-1690.008ns; +1601.841ns] or [-9.914%; +9.397%]

scenario:coreapiscenario-core_dispatch_exception_listeners

  • unstable execution_time [-1666.671ns; +814.375ns] or [-12.431%; +6.074%]

scenario:coreapiscenario-core_dispatch_listeners

  • unstable execution_time [-309.115ns; +335.535ns] or [-8.428%; +9.148%]

scenario:coreapiscenario-core_dispatch_no_args_listeners

  • unstable execution_time [-253.811ns; +247.359ns] or [-8.671%; +8.450%]

scenario:coreapiscenario-core_dispatch_with_results_1_listener

  • unstable execution_time [-62.732ns; +85.055ns] or [-5.544%; +7.518%]

scenario:coreapiscenario-core_dispatch_with_results_50_listeners

  • unstable execution_time [-3813.171ns; +4251.084ns] or [-9.295%; +10.363%]

scenario:coreapiscenario-core_dispatch_with_results_listeners

  • unstable execution_time [-758.143ns; +794.306ns] or [-9.363%; +9.810%]

scenario:packagesupdateimporteddependencies-import_many_stdlib_cached

  • unstable execution_time [-41.605µs; +37.205µs] or [-7.094%; +6.344%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:iastaspects-casefold_noaspect

  • 🟥 execution_time [+32.180µs; +37.674µs] or [+12.790%; +14.974%]

scenario:iastaspects-ljust_noaspect

  • 🟥 execution_time [+49.149µs; +55.006µs] or [+17.012%; +19.039%]

scenario:span-start

  • 🟥 execution_time [+1.722ms; +1.872ms] or [+12.267%; +13.334%]

Known flaky benchmarks without significant changes:

  • scenario:errortrackingflasksqli-baseline
  • scenario:flasksimple-iast-get
  • scenario:iastaspects-casefold_aspect
  • scenario:iastaspects-index_aspect
  • scenario:iastaspects-lower_aspect
  • scenario:iastaspects-replace_aspect
  • scenario:iastaspects-swapcase_aspect
  • scenario:iastaspects-title_noaspect
  • scenario:iastaspects-translate_aspect
  • scenario:iastaspects-translate_noaspect
  • scenario:iastaspects-upper_noaspect
  • scenario:packagespackageforrootmodulemapping-cache_off
  • scenario:packagespackageforrootmodulemapping-cache_on
  • scenario:sethttpmeta-all-enabled
  • scenario:telemetryaddmetric-record-100-metrics

igoragoli and others added 4 commits September 3, 2026 19:14
Replaces the repo-local step script with a bp-runner experiment, matching
how check-slo-breaches already works. The platform's fail_on_regression
step covers the baseline lookup, the bypass label and the missing-baseline
case, so none of that needs a local implementation.

Drops the jq flaky filtering with it. benchmark_analyzer convert reads
FLAKY_BENCHMARKS_REGEX and stamps flaky: "true" on matching benchmarks,
and both --fail-on-regression and --fail-on-breach already skip flagged
benchmarks, so the filtering was reimplementing an existing feature.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@igoragoli

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b89c2ebba

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .gitlab/benchmarks/README.md Outdated
fail-on-regression.sh reads ARTIFACTS_DIR/baseline_branch.txt to decide
whether a baseline exists. run-benchmarks.sh only writes it per-scenario
(reports/<scenario>/), and the loop only copied *.converted.json to the
flat reports/ dir the gate actually reads, so the gate always saw it
missing and warned+passed without comparing anything.

Confirmed live: https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/2013171889#L281
check-big-regressions and check-slo-breaches run concurrently in the same
stage, not sequentially. The threshold is set via bp-runner's
regression_threshold key, not a FAIL_ON_REGRESSION_THRESHOLD variable.
Also reframe the no-baseline warning around the actual trigger
(no baseline wheel built) rather than PR existence.
@igoragoli
igoragoli marked this pull request as ready for review September 4, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants