Skip to content

feat(ddtrace/tracer): remove locking on sampling priority access#4546

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
dario.castane/atomic-trace-priority
Mar 24, 2026
Merged

feat(ddtrace/tracer): remove locking on sampling priority access#4546
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
dario.castane/atomic-trace-priority

Conversation

@darccio

@darccio darccio commented Mar 16, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Turns trace.priority into atomic.Pointer to avoid using trace.mu locking.

Motivation

Complete #1905 work using the current benchmarking platform.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • There is a benchmark for any new code, or changes to existing code.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.

Unsure? Have a question? Request a review!

@darccio
darccio requested review from a team as code owners March 16, 2026 16:32
@darccio
darccio force-pushed the dario.castane/atomic-trace-priority branch from 9f27836 to d2cd5ce Compare March 16, 2026 16:42
@pr-commenter

pr-commenter Bot commented Mar 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-24 18:43:20

Comparing candidate commit 6855c92 in PR branch dario.castane/atomic-trace-priority with baseline commit 0472a95 in branch main.

Found 25 performance improvements and 0 performance regressions! Performance is the same for 190 metrics, 9 unstable metrics.

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:BenchmarkExtractW3C-25

  • 🟩 allocations [-1; -1] or [-4.348%; -4.348%]

scenario:BenchmarkInjectW3C-25

  • 🟩 execution_time [-58.213ns; -44.587ns] or [-2.669%; -2.044%]

scenario:BenchmarkOTelApiWithCustomTags/datadog_otel_api-25

  • 🟩 allocations [-1; -1] or [-3.846%; -3.846%]

scenario:BenchmarkOTelApiWithCustomTags/otel_api-25

  • 🟩 allocations [-1; -1] or [-2.439%; -2.439%]

scenario:BenchmarkPartialFlushing/Disabled-25

  • 🟩 execution_time [-8.199ms; -5.950ms] or [-3.033%; -2.201%]

scenario:BenchmarkPartialFlushing/Enabled-25

  • 🟩 execution_time [-9.702ms; -8.008ms] or [-3.530%; -2.914%]

scenario:BenchmarkPayloadVersions/detailed_1000spans/v1_0-25

  • 🟩 execution_time [-19.944µs; -18.380µs] or [-3.180%; -2.931%]

scenario:BenchmarkPayloadVersions/detailed_100spans/v1_0-25

  • 🟩 execution_time [-2.274µs; -2.107µs] or [-3.538%; -3.277%]

scenario:BenchmarkPayloadVersions/detailed_10spans/v1_0-25

  • 🟩 execution_time [-253.882ns; -226.118ns] or [-3.275%; -2.917%]

scenario:BenchmarkPayloadVersions/metastruct_1000spans/v1_0-25

  • 🟩 execution_time [-21.771µs; -19.554µs] or [-6.277%; -5.638%]

scenario:BenchmarkPayloadVersions/metastruct_100spans/v1_0-25

  • 🟩 execution_time [-1.927µs; -1.768µs] or [-4.863%; -4.462%]

scenario:BenchmarkPayloadVersions/metastruct_10spans/v1_0-25

  • 🟩 execution_time [-247.760ns; -192.640ns] or [-3.417%; -2.657%]

scenario:BenchmarkPayloadVersions/simple_1000spans/v1_0-25

  • 🟩 allocated_mem [-3 bytes; -3 bytes] or [-5.455%; -5.455%]
  • 🟩 execution_time [-20.385µs; -19.574µs] or [-6.772%; -6.503%]

scenario:BenchmarkPayloadVersions/simple_100spans/v1_0-25

  • 🟩 execution_time [-2.414µs; -1.960µs] or [-7.683%; -6.236%]

scenario:BenchmarkPayloadVersions/simple_10spans/v1_0-25

  • 🟩 execution_time [-290.235ns; -252.765ns] or [-6.885%; -5.996%]

scenario:BenchmarkSingleSpanRetention/no-rules-25

  • 🟩 execution_time [-7.589µs; -6.015µs] or [-3.057%; -2.423%]

scenario:BenchmarkSingleSpanRetention/with-rules/match-all-25

  • 🟩 execution_time [-7.909µs; -6.136µs] or [-3.135%; -2.432%]

scenario:BenchmarkSingleSpanRetention/with-rules/match-half-25

  • 🟩 execution_time [-7.935µs; -6.587µs] or [-3.143%; -2.609%]

scenario:BenchmarkStartSpan-25

  • 🟩 execution_time [-53.360ns; -42.440ns] or [-3.265%; -2.597%]

scenario:BenchmarkStartSpanConfig/scenario_WithStartSpanConfig-25

  • 🟩 allocations [-1; -1] or [-5.556%; -5.556%]
  • 🟩 execution_time [-65.282ns; -51.718ns] or [-2.707%; -2.145%]

scenario:BenchmarkStartSpanConfig/scenario_none-25

  • 🟩 allocations [-1; -1] or [-5.000%; -5.000%]
  • 🟩 execution_time [-70.564ns; -53.836ns] or [-2.755%; -2.102%]

scenario:BenchmarkTracerAddSpans-25

  • 🟩 allocations [-1; -1] or [-4.762%; -4.762%]

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Mar 16, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 95.24%
Overall Coverage: 59.82% (+3.73%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6855c92 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

We should add checkatomic and see what checklocks also thinks.

Comment thread ddtrace/tracer/spancontext.go
@darccio
darccio requested a review from kakkoyun March 17, 2026 12:10
@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.67%. Comparing base (0472a95) to head (6855c92).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ddtrace/tracer/tracer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
ddtrace/tracer/spancontext.go 88.14% <100.00%> (ø)
ddtrace/tracer/textmap.go 84.04% <100.00%> (ø)
ddtrace/tracer/tracer.go 88.90% <0.00%> (ø)

... and 439 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@genesor genesor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@darccio

darccio commented Mar 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dario.castane/atomic-trace-priority branch March 24, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants