Skip to content

fix(profiling): restore OPcache restart hook on shutdown - #4076

Merged
realFlowControl merged 1 commit into
masterfrom
florian/scp-1307-restore-opcache-restart-hook
Jul 29, 2026
Merged

fix(profiling): restore OPcache restart hook on shutdown#4076
realFlowControl merged 1 commit into
masterfrom
florian/scp-1307-restore-opcache-restart-hook

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Jul 29, 2026

Copy link
Copy Markdown
Member

Description

Apache graceful reloads can run MSHUTDOWN followed by another MINIT in the same process. The profiler installed ddog_php_prof_zend_accel_schedule_restart_hook during MINIT but did not restore the previous OPcache restart hook during MSHUTDOWN. The next MINIT could therefore capture the profiler callback as its own predecessor, causing infinite recursion and a stack-overflow SIGSEGV when OPcache scheduled a restart.

This restores the previous OPcache restart hook during timeline shutdown, before a subsequent module initialization can install it again.

Jira: SCP-1307

Testing

Reproduced locally with PHP 8.4.22 NTS, Apache mod_php, OPcache enabled, the profiler loaded. After an Apache graceful reload, opcache_reset() caused the unmodified master worker to exit with SIGSEGV and returned an empty HTTP response. With this change, opcache_reset() returned true over HTTP 200 and Apache logged no signal exit.

  • cargo fmt --check
  • cargo build -p datadog-php-profiling

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@realFlowControl realFlowControl added the profiling Relates to the Continuous Profiler label Jul 29, 2026
@realFlowControl
realFlowControl marked this pull request as ready for review July 29, 2026 06:49
@realFlowControl
realFlowControl requested a review from a team as a code owner July 29, 2026 06:49
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 29, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 4 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.1]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.3]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-php | merge-gate   View in Datadog   GitLab

View all 4 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

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

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Jul 29, 2026

Copy link
Copy Markdown

Benchmarks [ profiler ]

Benchmark execution time: 2026-07-29 07:00:21

Comparing candidate commit d1fd7f1 in PR branch florian/scp-1307-restore-opcache-restart-hook with baseline commit 24c4207 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 ----------------------------------'

@realFlowControl realFlowControl added the 🐛 bug Something isn't working label Jul 29, 2026
@realFlowControl realFlowControl added this to the 1.23.3 milestone Jul 29, 2026
@realFlowControl
realFlowControl merged commit 5c9fffc into master Jul 29, 2026
2155 of 2160 checks passed
@realFlowControl
realFlowControl deleted the florian/scp-1307-restore-opcache-restart-hook branch July 29, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working profiling Relates to the Continuous Profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants