cpython/Lib/asyncio
Pablo Galindo Salgado 1822f33b1a
[3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673)
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>

(cherry picked from commit 42b25ad4d3)
2025-05-25 22:10:20 +00:00
..
__init__.py GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640) 2025-01-22 17:25:29 +01:00
__main__.py gh-91048: Add filename:line_no information to asyncio pstree (#133478) 2025-05-05 23:07:33 +00:00
base_events.py gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306) 2025-05-05 04:58:07 +00:00
base_futures.py
base_subprocess.py [3.14] gh-114177: avoid calling connection lost callbacks when loop is already closed in asyncio subprocess (GH-134508) (#134561) 2025-05-23 04:58:51 +00:00
base_tasks.py
constants.py
coroutines.py gh-122858: Deprecate asyncio.iscoroutinefunction (#122875) 2024-08-11 16:35:51 +00:00
events.py gh-130322: drop deprecation of asyncio.set_event_loop (#132349) 2025-04-12 12:03:52 +05:30
exceptions.py
format_helpers.py gh-112997: Don't log arguments in asyncio unless debugging (#115667) 2024-02-27 17:39:08 -08:00
futures.py GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640) 2025-01-22 17:25:29 +01:00
graph.py [3.14] gh-133893: asyncio.graph: Replace TextIO annotation with io.Writer (GH-133894) (#133901) 2025-05-11 15:25:43 +00:00
locks.py gh-129403: Fix ValueError messages in asyncio.Barrier and threading.Barrier (#129419) 2025-01-30 11:11:12 +03:00
log.py
mixins.py
proactor_events.py gh-113892: Add a extra check to ProactorEventLoop.sock_connect to ensure that the given socket is in non-blocking mode (#119519) 2024-06-01 09:05:19 -07:00
protocols.py
queues.py gh-96471: Correct documentation for asyncio queue shutdown (#117621) 2024-04-08 14:50:54 +00:00
runners.py gh-130322: drop deprecation of asyncio.set_event_loop (#132349) 2025-04-12 12:03:52 +05:30
selector_events.py [3.14] gh-90871: fix connection backlog offset in asyncio (gh-134392) (gh-134421) 2025-05-21 16:27:13 +02:00
sslproto.py gh-118950: Fix SSLProtocol.connection_lost not being called when OSError is thrown (#118960) 2024-10-24 17:41:16 +00:00
staggered.py gh-129195: use future_add_to_awaited_by/future_discard_from_awaited_by in asyncio.staggered.staggered_race (#129253) 2025-01-26 21:14:16 +05:30
streams.py gh-117722: Fix Stream.readuntil with non-bytes buffer objects (#117723) 2024-04-11 07:41:55 -07:00
subprocess.py
taskgroups.py gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306) 2025-05-05 04:58:07 +00:00
tasks.py [3.14] gh-86802: Fix asyncio memory leak; shielded task exceptions log once through the exception handler (gh-134331) (gh-134343) 2025-05-20 19:43:09 +02:00
threads.py
timeouts.py gh-128559: Remove typing import from asyncio.timeouts (#128560) 2025-01-06 15:03:27 -08:00
tools.py [3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673) 2025-05-25 22:10:20 +00:00
transports.py gh-113812: Allow DatagramTransport.sendto to send empty data (#115199) 2024-02-16 18:38:07 -08:00
trsock.py
unix_events.py gh-127949: deprecate asyncio policy classes (#128216) 2024-12-24 17:30:26 +05:30
windows_events.py gh-127949: deprecate asyncio policy classes (#128216) 2024-12-24 17:30:26 +05:30
windows_utils.py