mirror of
https://github.com/python/cpython.git
synced 2025-09-23 00:43:12 +00:00
gh-91048: Refactor and optimize remote debugging module (#134652)
Completely refactor Modules/_remote_debugging_module.c with improved code organization, replacing scattered reference counting and error handling with centralized goto error paths. This cleanup improves maintainability and reduces code duplication throughout the module while preserving the same external API. Implement memory page caching optimization in Python/remote_debug.h to avoid repeated reads of the same memory regions during debugging operations. The cache stores previously read memory pages and reuses them for subsequent reads, significantly reducing system calls and improving performance. Add code object caching mechanism with a new code_object_generation field in the interpreter state that tracks when code object caches need invalidation. This allows efficient reuse of parsed code object metadata and eliminates redundant processing of the same code objects across debugging sessions. Optimize memory operations by replacing multiple individual structure copies with single bulk reads for the same data structures. This reduces the number of memory operations and system calls required to gather debugging information from the target process. Update Makefile.pre.in to include Python/remote_debug.h in the headers list, ensuring that changes to the remote debugging header force proper recompilation of dependent modules and maintain build consistency across the codebase. Also, make the module compatible with the free threading build as an extra :) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
328a778db8
commit
42b25ad4d3
16 changed files with 2413 additions and 1081 deletions
|
@ -1,11 +1,10 @@
|
|||
"""Tools to analyze tasks running in asyncio programs."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from collections import defaultdict
|
||||
from itertools import count
|
||||
from enum import Enum
|
||||
import sys
|
||||
from _remote_debugging import get_all_awaited_by
|
||||
from _remote_debugging import RemoteUnwinder
|
||||
|
||||
|
||||
class NodeType(Enum):
|
||||
|
@ -118,6 +117,11 @@ def _find_cycles(graph):
|
|||
|
||||
|
||||
# ─── PRINT TREE FUNCTION ───────────────────────────────────────
|
||||
def get_all_awaited_by(pid):
|
||||
unwinder = RemoteUnwinder(pid)
|
||||
return unwinder.get_all_awaited_by()
|
||||
|
||||
|
||||
def build_async_tree(result, task_emoji="(T)", cor_emoji=""):
|
||||
"""
|
||||
Build a list of strings for pretty-print an async call tree.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue