Repository navigation
fix(profiling): keep fast-copy intent across faulthandler during warmup [backport 4.15] - #21240
Conversation
Codeowners resolved asResolved from the full PR diff against No remaining files require a CODEOWNERS review. |
Circular import analysis
|
Dependency direction analysis
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
More details
Fast-copy intent remains available during warmup for faulthandler coordination, while latched foreign-handler fallback blocks reclamation based solely on that intent. Static review found no reportable defect; runtime signal-handler and fork behavior was not exercised.
🤖 Bits Code Review · Commit 8dba1a9
LLM ValidationLLM Validation Gate — python-tracer-agent🔴 FAIL
AnalysisChanged instruction file(s): Blocking — 1 case(s) regressed; the gate failed on the worst below.
Results
Cases
Per-dimension scores, token usage, latency, and estimated cost are in the CI job logs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e79e1b08a
ℹ️ 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".
There was a problem hiding this comment.
More details
Preserving fast-copy intent keeps faulthandler coordination enabled during syscall warmup while retaining foreign-handler fallback protection. Static review found no actionable regression; runtime behavior was not exercised.
🤖 Bits Code Review · Commit 5040b97
…up (#21230) Warmup clears `fast_copy_active` while our SIGSEGV handler is still installed. Handler install/uninstall/reclaim keyed off that flag, so `faulthandler.enable()` in the window took the handler unnoticed and the warmup deadline pinned the process to the syscall copy for life. This PR adds persistent `fast_copy_desired` (untouched by warmup), uses `fast_copy_handler_ops_enabled()` for those handler ops, and publishes `fast_copy_memory_desired` in internal metadata. It also pins the mid-warmup fork path: a child re-runs the warmup decision instead of inheriting `fast_copy_active == false` for life (gunicorn/celery prefork). * new unit tests (faulthandler during warmup; fork during warmup) None. Stack: **1/3** (includes mid-warmup fork pin). Next: sticky foreign takeover (#21232). https://datadoghq.atlassian.net/browse/PROF-15995 - [ ] The changes have been tested in real services in staging - [ ] The PR does not result in new crashes Co-authored-by: vlad.scherbich <vlad.scherbich@datadoghq.com> (cherry picked from commit c1198df)
5040b97 to
92f2a23
Compare
Pull request was converted to draft
There was a problem hiding this comment.
A no-op faulthandler.disable() during warmup can overwrite a native library’s SIGSEGV/SIGBUS handler and cause the sampler to enable fast copy instead of retaining its syscall fallback.
🤖 Bits Code Review · Commit 92f2a23
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92f2a237db
ℹ️ 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".
There was a problem hiding this comment.
A faulthandler call during warmup can conceal a foreign signal-handler takeover, bypassing syscall fallback and potentially creating a cyclic crash-handler chain.
🤖 Bits Code Review · Commit 92f2a23
| // for non-recovery faults, so both systems coexist correctly. | ||
| if (fast_copy_active) { | ||
| // Reclaim after coordinated swap when we still want or hold memcpy recovery. | ||
| if (fast_copy_handler_ops_enabled()) { |
There was a problem hiding this comment.
Check ownership before reclaiming handlers during warmup
If a foreign component takes over SIGSEGV/SIGBUS during warmup and faulthandler.enable() runs before the deadline, desired remains true and fallback is still false. The uninstall leaves the foreign handler untouched, but this reinstall puts the profiler above faulthandler, concealing the takeover from the sampler and allowing fast-copy upgrade instead of syscall fallback. If the foreign handler saved the profiler's handler, this creates a profiler → faulthandler → foreign → profiler cycle that disrupts crash handling. Detect and latch foreign ownership before coordinated swaps; the enable/disable paths need coordinated handling because legitimate swaps also temporarily remove profiler ownership.
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
What each reaction means
- 👍 Useful: correct, and you're fixing it or will.
- 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
- 😕 Unclear: you can't tell what it means or why it matters.
- 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.
🤖 Bits Code Review · Open Bits AI session
Description
Backport of #21230 to 4.15 (same squash as #21723).
Cherry-pick
c1198df465. Conflict insampler.cpp: kept 4.15's foreign-handler log lines (no ownership APIs on this branch); took PR1'sseed_fast_copy_profiler_stats()+sampler_active_.store(false)on the no-fallback stop path.Testing
Unit tests from source for faulthandler-during-warmup and mid-warmup fork.
Risks
Same as #21230 / #21723.
Additional Notes
https://datadoghq.atlassian.net/browse/PROF-15995
Pre-review checklist