GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Yury Selivanov 2025-01-22 08:25:29 -08:00 committed by GitHub
parent 60a3a0dd6f
commit 188598851d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 2923 additions and 241 deletions

View file

@ -111,23 +111,7 @@ static void call_ll_exitfuncs(_PyRuntimeState *runtime);
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
#if defined(MS_WINDOWS)
#pragma section("PyRuntime", read, write)
__declspec(allocate("PyRuntime"))
#elif defined(__APPLE__)
__attribute__((
section(SEG_DATA ",PyRuntime")
))
#endif
_PyRuntimeState _PyRuntime
#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__))
__attribute__ ((section (".PyRuntime")))
#endif
GENERATE_DEBUG_SECTION(PyRuntime, _PyRuntimeState _PyRuntime)
= _PyRuntimeState_INIT(_PyRuntime, _Py_Debug_Cookie);
_Py_COMP_DIAG_POP

View file

@ -1515,6 +1515,7 @@ init_threadstate(_PyThreadStateImpl *_tstate,
tstate->dict_global_version = 0;
_tstate->asyncio_running_loop = NULL;
_tstate->asyncio_running_task = NULL;
tstate->delete_later = NULL;
@ -1697,6 +1698,7 @@ PyThreadState_Clear(PyThreadState *tstate)
Py_CLEAR(tstate->threading_local_sentinel);
Py_CLEAR(((_PyThreadStateImpl *)tstate)->asyncio_running_loop);
Py_CLEAR(((_PyThreadStateImpl *)tstate)->asyncio_running_task);
Py_CLEAR(tstate->dict);
Py_CLEAR(tstate->async_exc);