Skip to content

feat(profiler): add Python 3.11 support #4343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

Yun-Kim
Copy link
Contributor

@Yun-Kim Yun-Kim commented Oct 20, 2022

Description

Python 3.11 has made some new changes to their C internal API that we need to address in a couple of places, mostly in our profiler. The profiler changes have been separated from the tracer PR #4125 and pulled into here.

I've created some initial work adding Python 3.11 to Riot and C API fixes. The fixes include:

  • Python 3.11 now creates PyFrameObject lazily and cannot be directly accesed through a PyThreadState object, and instead recommends using a helper function PyThreadState_GetFrame() which was earlier introduced in Python 3.9 (Link to issue).
  • Python 3.11 removed redundant data fields from their exception representation (exc.exc_type and exc.exc_traceback) and now recommends using the Py_TYPE() and PyException_GetTraceback() helpers to access those values from the only remaining field exc.exc_value. (Link to CPython change, Link to Cython fix)

Note:

Checklist

Motivation

Design

Testing strategy

Relevant issue(s)

Testing strategy

Reviewer Checklist

  • Title is accurate.
  • Description motivates each change.
  • No unnecessary changes were introduced in this PR.
  • PR cannot be broken up into smaller PRs.
  • Avoid breaking API changes unless absolutely necessary.
  • Tests provided or description of manual testing performed is included in the code or PR.
  • Release note has been added for fixes and features, or else changelog/no-changelog label added.
  • All relevant GitHub issues are correctly linked.
  • Backports are identified and tagged with Mergifyio.
  • Add to milestone.

@Yun-Kim Yun-Kim changed the title feat(profiler) support Python 3.11 feat(profiler) add Python 3.11 support Oct 20, 2022
@Yun-Kim Yun-Kim changed the title feat(profiler) add Python 3.11 support feat(profiler): add Python 3.11 support Oct 20, 2022
@Yun-Kim Yun-Kim force-pushed the yun-kim/profiler-py311 branch from 787df4c to cbc9309 Compare October 21, 2022 16:40
@mergify
Copy link
Contributor

mergify bot commented Oct 25, 2022

@Yun-Kim this pull request is now in conflict 😩

@mergify mergify bot added the conflicts label Oct 25, 2022
@mergify mergify bot removed the conflicts label Oct 26, 2022
Kyle-Verhoog added a commit that referenced this pull request Oct 26, 2022
Python 3.11 has made some new changes to their C internal API that we need to address in a couple of places, mostly in our profiler. I've moved the profiler changes into #4343 and changed this PR to focus on the tracer and integrations supporting Python 3.11. Note that some of the profiler changes were kept in this PR to ensure that the profiler can compile with Python 3.11 per our setup/install rules.

The major tracer-related fix is:

    Python 3.11 moved _PyFloat_Pack8() into their internal C API and replaced it with PyFloat_Pack8() to their public C API (Link to CPython issue). We use it once in ddtrace.internal.pack_template.h where I've added a Python version check to use the correct corresponding function.

Note: grpcio with pytest-asyncio is causing Python segmentation faults on the test_unary_exception and test_unary_cancellation test cases, and from the traceback it doesn't look like dd-trace-py is involved. You can reproduce this using this gist which does not involve dd-trace-py. As a result I am skipping the grpcio_asyncio tests with Python 3.11.

Co-authored-by: Kyle Verhoog <kyle@verhoog.ca>
mergify bot pushed a commit that referenced this pull request Oct 26, 2022
Python 3.11 has made some new changes to their C internal API that we need to address in a couple of places, mostly in our profiler. I've moved the profiler changes into #4343 and changed this PR to focus on the tracer and integrations supporting Python 3.11. Note that some of the profiler changes were kept in this PR to ensure that the profiler can compile with Python 3.11 per our setup/install rules.

The major tracer-related fix is:

    Python 3.11 moved _PyFloat_Pack8() into their internal C API and replaced it with PyFloat_Pack8() to their public C API (Link to CPython issue). We use it once in ddtrace.internal.pack_template.h where I've added a Python version check to use the correct corresponding function.

Note: grpcio with pytest-asyncio is causing Python segmentation faults on the test_unary_exception and test_unary_cancellation test cases, and from the traceback it doesn't look like dd-trace-py is involved. You can reproduce this using this gist which does not involve dd-trace-py. As a result I am skipping the grpcio_asyncio tests with Python 3.11.

Co-authored-by: Kyle Verhoog <kyle@verhoog.ca>
(cherry picked from commit c94cc14)

# Conflicts:
#	tox.ini
@mergify
Copy link
Contributor

mergify bot commented Oct 26, 2022

@Yun-Kim this pull request is now in conflict 😩

@mergify mergify bot added the conflicts label Oct 26, 2022
@mergify mergify bot removed the conflicts label Oct 27, 2022
@jd
Copy link
Contributor

jd commented Nov 9, 2022

I pushed a PR here: #4511

@Yun-Kim
Copy link
Contributor Author

Yun-Kim commented Nov 9, 2022

Closing as replaced by #4511.

@Yun-Kim Yun-Kim closed this Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants