Skip to content

Simplify profiler sampling overhead attribution with a placeholder stack#5870

Merged
eregon merged 1 commit into
masterfrom
simplify-profiler_overhead_stack_thread
Jun 9, 2026
Merged

Simplify profiler sampling overhead attribution with a placeholder stack#5870
eregon merged 1 commit into
masterfrom
simplify-profiler_overhead_stack_thread

Conversation

@eregon

@eregon eregon commented Jun 8, 2026

Copy link
Copy Markdown
Member

Replace the confusing profiler_overhead_stack_thread parameter (which borrowed a real stack from the worker's owner thread) with a synthetic "Datadog::Profiling::Collectors::Stack" synthesized frame, matching the pattern used by GC and other synthesized stacks. This removes the stack_from_thread parameter and passes only one thread through the entire sampling call chain.

What does this PR do?
^

Motivation:
Simplicity

Change log entry

None

Additional Notes:

How to test the change?

@eregon
eregon requested review from a team as code owners June 8, 2026 16:52
@dd-octo-sts dd-octo-sts Bot added the profiling Involves Datadog profiling label Jun 8, 2026
@eregon eregon changed the title Simplify profiler sampling overhead attribution with a synthesized stack Simplify profiler sampling overhead attribution with a placeholder stack Jun 8, 2026

@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: c453716ae9

ℹ️ 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 ext/datadog_profiling_native_extension/collectors_thread_context.c Outdated
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jun 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 90.08% (+0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 41bcd1f | Docs | Datadog PR Page | Give us feedback!

@eregon
eregon force-pushed the simplify-profiler_overhead_stack_thread branch from c453716 to 0c44197 Compare June 8, 2026 16:54
@pr-commenter

pr-commenter Bot commented Jun 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-09 13:49:59

Comparing candidate commit 41bcd1f in PR branch simplify-profiler_overhead_stack_thread with baseline commit 5c9136e in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 44 metrics, 1 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:profiling - sample and serialize

  • 🟩 throughput [+0.372op/s; +0.377op/s] or [+8.923%; +9.054%]

@eregon
eregon force-pushed the simplify-profiler_overhead_stack_thread branch 4 times, most recently from 34c258e to 27d77fa Compare June 8, 2026 18:21
Comment thread ext/datadog_profiling_native_extension/collectors_thread_context.c Outdated
Comment thread spec/datadog/profiling/collectors/thread_context_spec.rb Outdated

@ivoanjo ivoanjo 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.

This is looking really good! Left a few notes :)

Comment thread ext/datadog_profiling_native_extension/collectors_thread_context.c
Comment thread ext/datadog_profiling_native_extension/collectors_thread_context.c Outdated
Comment thread ext/datadog_profiling_native_extension/collectors_thread_context.c Outdated
Comment thread spec/datadog/profiling/collectors/thread_context_spec.rb
Comment thread ext/datadog_profiling_native_extension/collectors_thread_context.c Outdated
@eregon
eregon force-pushed the simplify-profiler_overhead_stack_thread branch from 27d77fa to c189b9e Compare June 9, 2026 12:31

@ivoanjo ivoanjo 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

@eregon
eregon enabled auto-merge June 9, 2026 13:22
Replace the confusing profiler_overhead_stack_thread parameter (which
borrowed a real stack from the worker's owner thread) with a synthetic
"Datadog::Profiling::Collectors::Stack" placeholder frame, matching the pattern
used by GC and other placeholder stacks. This removes the stack_from_thread
parameter and passes only one thread through the entire sampling call chain.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@eregon
eregon force-pushed the simplify-profiler_overhead_stack_thread branch from c189b9e to 41bcd1f Compare June 9, 2026 13:23
@dd-octo-sts

dd-octo-sts Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Typing analysis

Note: Ignored files are excluded from the next sections.

Untyped methods

This PR introduces 2 partially typed methods, and clears 2 partially typed methods.

Partially typed methods (+2-2)Introduced:
sig/datadog/profiling/collectors/thread_context.rbs:27
└── def self.for_testing: (
          recorder: Datadog::Profiling::StackRecorder,
          ?max_frames: ::Integer,
          ?tracer: Datadog::Tracing::Tracer?,
          ?endpoint_collection_enabled: bool,
          ?waiting_for_gvl_threshold_ns: ::Integer,
          ?otel_context_enabled: (::Symbol? | bool),
          ?native_filenames_enabled: bool,
          **untyped
        ) -> Datadog::Profiling::Collectors::ThreadContext
sig/datadog/profiling/collectors/thread_context.rbs:48
└── def safely_extract_context_key_from: (untyped tracer) -> ::Symbol?
Cleared:
sig/datadog/profiling/collectors/thread_context.rbs:26
└── def self.for_testing: (
          recorder: Datadog::Profiling::StackRecorder,
          ?max_frames: ::Integer,
          ?tracer: Datadog::Tracing::Tracer?,
          ?endpoint_collection_enabled: bool,
          ?waiting_for_gvl_threshold_ns: ::Integer,
          ?otel_context_enabled: (::Symbol? | bool),
          ?native_filenames_enabled: bool,
          **untyped
        ) -> Datadog::Profiling::Collectors::ThreadContext
sig/datadog/profiling/collectors/thread_context.rbs:47
└── def safely_extract_context_key_from: (untyped tracer) -> ::Symbol?

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept on the line before the definition to remove it from the stats.

@eregon
eregon merged commit e014f83 into master Jun 9, 2026
592 checks passed
@eregon
eregon deleted the simplify-profiler_overhead_stack_thread branch June 9, 2026 13:51
@dd-octo-sts dd-octo-sts Bot added this to the 2.36.0 milestone Jun 9, 2026
ivoanjo added a commit that referenced this pull request Jul 7, 2026
Since #5870 / 41bcd1f
overhead samples no longer show up on the thread that does the sampling
so we can simplify this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants