-
Notifications
You must be signed in to change notification settings - Fork 432
Add support for Python 3.14 tail call interpreter in native stack trace analysis #836
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
base: main
Are you sure you want to change the base?
Conversation
@copilot you need to change the cython pyx file to detect the eval functions that have LLVM names now. That is the most important part. |
I've already updated the Cython
Both functions now recognize symbols that start with |
@copilot You need a NEWS entry in news for towncrier |
@copilot We also need a new workflow that checks with Python from UV (3.14) that has the tail call activated. We can use the uv GitHub action:
We just need 3.14. Check other workflows such as the coverage one or the valgrind one to know more or less how that must be done |
Added GitHub Actions workflow in commit 190f326. The workflow is in |
|
||
- name: Run tests | ||
run: | | ||
python -m pytest -vvv --log-cli-level=info tests/unit/test_frame_tools.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should run all the tests
@copilot This is not running with Python from
Also run all tests not just that one |
Updated in commit d8d8ee4:
|
@copilot you need to create a venv first:
Ensure to use 3.14 there |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #836 +/- ##
==========================================
- Coverage 92.46% 92.39% -0.07%
==========================================
Files 99 99
Lines 11840 11842 +2
Branches 425 426 +1
==========================================
- Hits 10948 10942 -6
- Misses 892 900 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1222d0c
to
a82ef86
Compare
Implement support for Python 3.14's tail call interpreter in Memray. The changes enable Memray to correctly identify Python frame boundaries when native stack traces contain LLVM-generated tail call functions. Signed-off-by: Pablo Galindo Salgado <[email protected]>
a82ef86
to
c6b56cb
Compare
Plan to fix Python 3.14 tail call interpreter support
frame_tools.py
that identifies Python frame boundaries_is_cpython_internal_symbol
function to recognize_TAIL_CALL_*.llvm.*
patternsuv run
and run all testsuv venv
step to create virtual environmentSummary
Successfully implemented support for Python 3.14's tail call interpreter in Memray. The changes enable Memray to correctly identify Python frame boundaries when native stack traces contain LLVM-generated tail call functions.
Changes Made
1. Pure Python Code (
src/memray/reporters/frame_tools.py
)_TAIL_CALL_*.llvm.*
symbols2. Cython Code (
src/memray/_memray.pyx
)hybrid_stack_trace()
to recognize tail call patterns in native stack correlationget_symbolic_support()
to detect tail call patterns for symbolic support3. Tests (
tests/unit/test_frame_tools.py
)_TAIL_CALL_INSTRUMENTED_CALL.llvm.*
patterns_TAIL_CALL_POP_TOP.llvm.*
patternsis_frame_interesting()
to ensure proper filtering4. NEWS Entry (
news/822.bugfix
)5. CI/CD Workflow (
.github/workflows/test_uv_python.yml
)astral-sh/setup-uv@v6
action to install Python 3.14uv venv --python 3.14
uv run pytest
to run all tests with UV's Python environmentPattern Detection Logic
A symbol is recognized as a Python frame boundary if:
_PyEval_EvalFrameDefault
orPyEval_EvalFrameEx
(traditional), OR_TAIL_CALL_
AND contains.llvm.
(Python 3.14 tail call)Backward Compatibility
✓ Python 3.8-3.13: Traditional
_PyEval_EvalFrameDefault
detection continues to work✓ Python 3.14 without tail call: Traditional detection continues to work
✓ Python 3.14 with tail call: New LLVM pattern detection is activated
✓ All patterns can coexist in mixed environments
Code Statistics
frame_tools.py
(core logic)_memray.pyx
(including comments)test_frame_tools.py
(test coverage)The implementation is minimal, surgical, and maintains full backward compatibility.
Original prompt
Fixes #822
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.