Skip to content

fix(profiling): Restore I/O GOT hooks on module shutdown - #4154

Merged
bwoebi merged 3 commits into
masterfrom
florian/prof-15878-unhook-io-got-on-mshutdown
Sep 4, 2026
Merged

fix(profiling): Restore I/O GOT hooks on module shutdown#4154
bwoebi merged 3 commits into
masterfrom
florian/prof-15878-unhook-io-got-on-mshutdown

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Sep 2, 2026

Copy link
Copy Markdown
Member

Description

Store the exact original value for each GOT or Mach-O slot changed by I/O profiling and restore it during MSHUTDOWN. Restoration only touches slots still pointing to our hook and only visits loaded images, so it does not clobber later hooks or dereference unloaded images.

If any loaded hook cannot be safely removed, keep the profiler extension loaded to prevent dangling function pointers.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

PROF-15878

@github-actions github-actions Bot added profiling Relates to the Continuous Profiler tracing labels Sep 2, 2026
@datadog-datadog-prod-us1-2

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

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

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

🚦 8 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.3] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | installer tests — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [7.3, valgrind] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

View all 8 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 54.99% (+0.00%)

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Sep 2, 2026

Copy link
Copy Markdown

Benchmarks [ profiler ]

Benchmark execution time: 2026-09-04 10:01:33

Comparing candidate commit 8a3a559 in PR branch florian/prof-15878-unhook-io-got-on-mshutdown with baseline commit 97d8eed in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 28 metrics, 8 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 ----------------------------------'

@pr-commenter

pr-commenter Bot commented Sep 2, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-09-02 19:16:55

Comparing candidate commit 1a4bea8 in PR branch florian/prof-15878-unhook-io-got-on-mshutdown with baseline commit 205c827 in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 193 metrics, 0 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:TraceAnnotationsBench/benchTraceAnnotationOverhead-opcache

  • 🟩 execution_time [-10.190µs; -3.830µs] or [-5.586%; -2.099%]

@realFlowControl
realFlowControl force-pushed the florian/prof-15878-unhook-io-got-on-mshutdown branch from 1a4bea8 to f8fe224 Compare September 4, 2026 09:02
@realFlowControl
realFlowControl force-pushed the florian/prof-15878-unhook-io-got-on-mshutdown branch from f8fe224 to ec8dfe3 Compare September 4, 2026 09:03
@realFlowControl
realFlowControl marked this pull request as ready for review September 4, 2026 09:07
@realFlowControl
realFlowControl requested review from a team as code owners September 4, 2026 09:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T09:12:48.126057Z ec8dfe3 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@realFlowControl realFlowControl changed the title [PROF-15878] Restore I/O GOT hooks on module shutdown fix(profiling): Restore I/O GOT hooks on module shutdown Sep 4, 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: ec8dfe3369

ℹ️ 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".

Comment thread profiling/src/io/got_elf64.rs Outdated
Comment thread profiling/src/io/got_elf64.rs
Comment thread profiling/src/io/got_elf64.rs

@bwoebi bwoebi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The only thing I notice is that the overwrite fetching is O(n^2), with n being the amount of shared objects loaded.
This is likely not an issue for low n.

@realFlowControl

Copy link
Copy Markdown
Member Author

The only thing I notice is that the overwrite fetching is O(n^2), with n being the amount of shared objects loaded. This is likely not an issue for low n.

@bwoebi exactly, n is small, this is only executed during mshutdown, so everything else seemed overkill

@bwoebi
bwoebi merged commit 3b1267d into master Sep 4, 2026
2159 of 2167 checks passed
@bwoebi
bwoebi deleted the florian/prof-15878-unhook-io-got-on-mshutdown branch September 4, 2026 13:15
@github-actions github-actions Bot added this to the 1.26.0 milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Relates to the Continuous Profiler tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants