Skip to content

chore(profiling): native C++/Rust py3.15 ABI support - #18503

Closed
vlad-scherbich wants to merge 1 commit into
vlad/profiling-native-test-install-subdirfrom
vlad/ddtracepy-315-profiling-native
Closed

chore(profiling): native C++/Rust py3.15 ABI support#18503
vlad-scherbich wants to merge 1 commit into
vlad/profiling-native-test-install-subdirfrom
vlad/ddtracepy-315-profiling-native

Conversation

@vlad-scherbich

@vlad-scherbich vlad-scherbich commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

← Prev: #18488 | Next → #18504

PROF-14200

Description

Updates the native C++/Rust stack profiler for CPython 3.15 ABI changes.

CPython 3.15 made two breaking changes to internal frame structures:

  • PyFrameState enum fully renumbered (all values changed; FRAME_COMPLETED removed)
  • FRAME_OWNED_BY_CSTACK removed from _frameowner

Echion (frame.cc, tasks.h):

  • Exhaustive switch on _frameowner (no default:-Wswitch fires on new values)
  • FRAME_OWNED_BY_CSTACK compiled out on 3.15+
  • Three-tier is_entry assignment for 3.15+ / 3.12–3.14 / pre-3.12
  • tasks.h: PyGen_yf updated for renumbered gi_frame_state values

New compile-time regression guards (test_cpython_layout_contracts.cpp):
static_asserts for every CPython enum Echion depends on, covering 3.11–3.15+. Fires at build time if CPython renumbers or removes a value in a future release.

New runtime gtest (test_frame_state_315.cpp):
Validates PyGen_yf behavior under all 3.15 frame states, including FRAME_SUSPENDED_YIELD_FROM_LOCKED (free-threaded builds).

Build system (cmake):

  • NativeHeaders.cmake: new module that locates CPython internal headers for gtest targets
  • FindLibNative.cmake, ddup/CMakeLists.txt, stack/CMakeLists.txt, fuzz/CMakeLists.txt: consume NativeHeaders
  • sample.cpp: include Python.h before system headers to avoid _POSIX_C_SOURCE redefinition on Linux aarch64 with 3.15's pyconfig.h

Rust / crashtracker:

  • crashtracker_runtime_stacks.rs, crashtracker.rs: gate PyFrame_GetBack on 3.14+ and Py_LIMITED_API
  • tracer_flare.rs: cargo fmt / style cleanup

Testing

CI: profiling_native matrix (sanitizers, valgrind) on py3.15.

Local:

  • test_frame_state_315: 6 tests passed
  • test_cpython_layout_contracts: 2 tests passed

Risks

  • Free-threaded Python 3.15 (nogil): compiles but not yet validated end-to-end
  • CPython 3.15 is still in beta

Additional Notes

Part of the Python 3.15 support stack. Relates to #17809.

@datadog-official

datadog-official Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 5 Pipeline jobs failed

Changelog | Validate changelog   View in Datadog   GitHub Actions

DataDog/apm-reliability/dd-trace-py | build macos: [amd64, 3.9 3.10 3.11]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-py | build_base_venvs: [3.15]   View in Datadog   GitLab

View all 5 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Jun 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-08 13:09:29

Comparing candidate commit 6abf4b7 in PR branch vlad/ddtracepy-315-profiling-native with baseline commit 3f47516 in branch vlad/profiling-native-test-install-subdir.

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

scenario:iastaspectsospath-ospathbasename_aspect

  • 🟥 execution_time [+88.672µs; +97.381µs] or [+20.280%; +22.272%]

scenario:span-start

  • 🟥 execution_time [+1.177ms; +1.347ms] or [+7.435%; +8.507%]

@github-actions github-actions Bot added the stale label Jul 9, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed after a period of inactivity.
After this much time, it will likely be easier to open a new pull request with the
same changes than to update this one from the base branch. Please comment or reopen
if you think this pull request was closed in error.

@github-actions github-actions Bot closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant