cpython/Modules/Setup.stdlib.in
Pablo Galindo Salgado 572c780aa8
gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137)
This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks.

When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process.

The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory.

The sampling profiler now enables frame caching by default.
2025-12-06 22:37:34 +00:00

198 lines
9.2 KiB
Makefile

# -*- makefile -*-
#
# This file is autogenerated from Modules/Setup.stdlib.in.
#
# The file is not used by default yet. For testing do:
#
# ln -sfr Modules/Setup.stdlib Modules/Setup.local
#
# * @MODULE_{NAME}_TRUE@ is removed when configure detects all build
# dependencies for a module. Otherwise the template variable is replaced
# by a comment "#" and the module is skipped.
# * Module lines without any compiler and linker flags automatically use
# $(MODULE_{NAME}_CFLAGS) and $(MODULE_{NAME}_LDFLAGS). These flags are
# generated by PY_STDLIB_MOD macro.
# * All source files automatically depend on $(PYTHON_HEADERS) and
# $(MODULE_{NAME}_DEPS).
# * ${NAME}$(EXT_SUFFIX) rules automatically depend on $(MODULE_{NAME}_LDEPS),
# thus $(MODULE_{NAME}_LDEPS) must only contain Makefile rule names. To pass
# specific values to the linker, use $(MODULE_{NAME}_LDFLAGS) instead.
#
# See Modules/Setup and Modules/makesetup
#
# Build modules statically or as shared extensions
# *shared* / *static*
*@MODULE_BUILDTYPE@*
############################################################################
# Modules that should always be present (POSIX and Windows):
@MODULE_ARRAY_TRUE@array arraymodule.c
@MODULE__BISECT_TRUE@_bisect _bisectmodule.c
@MODULE__CSV_TRUE@_csv _csv.c
@MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c
@MODULE__JSON_TRUE@_json _json.c
@MODULE__LSPROF_TRUE@_lsprof _lsprof.c rotatingtree.c
@MODULE__MATH_INTEGER_TRUE@_math_integer mathintegermodule.c
@MODULE__PICKLE_TRUE@_pickle _pickle.c
@MODULE__QUEUE_TRUE@_queue _queuemodule.c
@MODULE__RANDOM_TRUE@_random _randommodule.c
@MODULE__REMOTE_DEBUGGING_TRUE@_remote_debugging _remote_debugging/module.c _remote_debugging/object_reading.c _remote_debugging/code_objects.c _remote_debugging/frames.c _remote_debugging/frame_cache.c _remote_debugging/threads.c _remote_debugging/asyncio.c
@MODULE__STRUCT_TRUE@_struct _struct.c
# build supports subinterpreters
@MODULE__INTERPRETERS_TRUE@_interpreters _interpretersmodule.c
@MODULE__INTERPCHANNELS_TRUE@_interpchannels _interpchannelsmodule.c
@MODULE__INTERPQUEUES_TRUE@_interpqueues _interpqueuesmodule.c
@MODULE__ZONEINFO_TRUE@_zoneinfo _zoneinfo.c
# needs libm
@MODULE_MATH_TRUE@math mathmodule.c
@MODULE_CMATH_TRUE@cmath cmathmodule.c
@MODULE__STATISTICS_TRUE@_statistics _statisticsmodule.c
# _decimal uses libmpdec
# either static libmpdec.a from Modules/_decimal/libmpdec or libmpdec.so
# with ./configure --with-system-libmpdec
@MODULE__DECIMAL_TRUE@_decimal _decimal/_decimal.c
# compression libs and binascii (optional CRC32 from zlib)
# bindings need -lbz2, -llzma, -lzstd, or -lz, respectively
@MODULE_BINASCII_TRUE@binascii binascii.c
@MODULE__BZ2_TRUE@_bz2 _bz2module.c
@MODULE__LZMA_TRUE@_lzma _lzmamodule.c
@MODULE__ZSTD_TRUE@_zstd _zstd/_zstdmodule.c _zstd/zstddict.c _zstd/compressor.c _zstd/decompressor.c
@MODULE_ZLIB_TRUE@zlib zlibmodule.c
# dbm/gdbm
# dbm needs either libndbm, libgdbm_compat, or libdb 5.x
@MODULE__DBM_TRUE@_dbm _dbmmodule.c
# gdbm module needs -lgdbm
@MODULE__GDBM_TRUE@_gdbm _gdbmmodule.c
# needs -lreadline or -ledit, sometimes termcap, termlib, or tinfo
@MODULE_READLINE_TRUE@readline readline.c
############################################################################
# HACL*-based Cryptographic Primitives
#
# Since the compilation of the built-in cryptographic modules depends
# on whether we are building on WASI or not, rules will be explicitly
# written. In the future, it should be preferrable to be able to setup
# the relevant bits here instead of in Makefile.pre.in or configure.ac.
# Hash functions can be disabled with --without-builtin-hashlib-hashes.
@MODULE__MD5_TRUE@_md5 md5module.c
@MODULE__SHA1_TRUE@_sha1 sha1module.c
@MODULE__SHA2_TRUE@_sha2 sha2module.c
@MODULE__SHA3_TRUE@_sha3 sha3module.c
@MODULE__BLAKE2_TRUE@_blake2 blake2module.c
# Since HMAC is always supported, the HACL* implementation modules must
# be built unconditionally.
@MODULE__HMAC_TRUE@_hmac hmacmodule.c
############################################################################
# XML and text
# pyexpat module uses libexpat
# either static libexpat.a from Modules/expat or libexpat.so with
# ./configure --with-system-expat
@MODULE_PYEXPAT_TRUE@pyexpat pyexpat.c
# _elementtree libexpat via CAPI hook in pyexpat.
@MODULE__ELEMENTTREE_TRUE@_elementtree _elementtree.c
@MODULE__CODECS_CN_TRUE@_codecs_cn cjkcodecs/_codecs_cn.c
@MODULE__CODECS_HK_TRUE@_codecs_hk cjkcodecs/_codecs_hk.c
@MODULE__CODECS_ISO2022_TRUE@_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
@MODULE__CODECS_JP_TRUE@_codecs_jp cjkcodecs/_codecs_jp.c
@MODULE__CODECS_KR_TRUE@_codecs_kr cjkcodecs/_codecs_kr.c
@MODULE__CODECS_TW_TRUE@_codecs_tw cjkcodecs/_codecs_tw.c
@MODULE__MULTIBYTECODEC_TRUE@_multibytecodec cjkcodecs/multibytecodec.c
@MODULE_UNICODEDATA_TRUE@unicodedata unicodedata.c
############################################################################
# Modules with some UNIX dependencies
#
@MODULE_FCNTL_TRUE@fcntl fcntlmodule.c
@MODULE_GRP_TRUE@grp grpmodule.c
@MODULE_MMAP_TRUE@mmap mmapmodule.c
# needs sys/soundcard.h or linux/soundcard.h (Linux, FreeBSD)
@MODULE__POSIXSUBPROCESS_TRUE@_posixsubprocess _posixsubprocess.c
@MODULE_RESOURCE_TRUE@resource resource.c
@MODULE_SELECT_TRUE@select selectmodule.c
@MODULE__SOCKET_TRUE@_socket socketmodule.c
@MODULE_SYSLOG_TRUE@syslog syslogmodule.c
@MODULE_TERMIOS_TRUE@termios termios.c
# multiprocessing
@MODULE__POSIXSHMEM_TRUE@_posixshmem _multiprocessing/posixshmem.c
@MODULE__MULTIPROCESSING_TRUE@_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
############################################################################
# Modules with third party dependencies
#
# needs -lffi and -ldl
@MODULE__CTYPES_TRUE@_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c @MODULE__CTYPES_MALLOC_CLOSURE@
# needs -lncurses[w], sometimes -ltermcap/tinfo
@MODULE__CURSES_TRUE@_curses _cursesmodule.c
# needs -lncurses[w] and -lpanel[w]
@MODULE__CURSES_PANEL_TRUE@_curses_panel _curses_panel.c
@MODULE__SQLITE3_TRUE@_sqlite3 _sqlite/blob.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c
# needs -lssl and -lcrypt
@MODULE__SSL_TRUE@_ssl _ssl.c
# needs -lcrypt
@MODULE__HASHLIB_TRUE@_hashlib _hashopenssl.c
# Linux: -luuid, BSD/AIX: libc's uuid_create()
@MODULE__UUID_TRUE@_uuid _uuidmodule.c
@MODULE__TKINTER_TRUE@_tkinter _tkinter.c tkappinit.c
############################################################################
# macOS specific modules
# _scproxy needs SystemConfiguration and CoreFoundation framework
@MODULE__SCPROXY_TRUE@_scproxy _scproxy.c
############################################################################
# Test modules
@MODULE_XXSUBTYPE_TRUE@xxsubtype xxsubtype.c
@MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
@MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c
@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c _testinternalcapi/test_critical_sections.c _testinternalcapi/complex.c
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/run.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/gc.c _testcapi/hash.c _testcapi/time.c _testcapi/bytes.c _testcapi/object.c _testcapi/modsupport.c _testcapi/monitoring.c _testcapi/config.c _testcapi/import.c _testcapi/frame.c _testcapi/type.c _testcapi/function.c _testcapi/module.c
@MODULE__TESTLIMITEDCAPI_TRUE@_testlimitedcapi _testlimitedcapi.c _testlimitedcapi/abstract.c _testlimitedcapi/bytearray.c _testlimitedcapi/bytes.c _testlimitedcapi/codec.c _testlimitedcapi/complex.c _testlimitedcapi/dict.c _testlimitedcapi/eval.c _testlimitedcapi/float.c _testlimitedcapi/heaptype_relative.c _testlimitedcapi/import.c _testlimitedcapi/list.c _testlimitedcapi/long.c _testlimitedcapi/object.c _testlimitedcapi/pyos.c _testlimitedcapi/set.c _testlimitedcapi/sys.c _testlimitedcapi/tuple.c _testlimitedcapi/unicode.c _testlimitedcapi/vectorcall_limited.c _testlimitedcapi/version.c _testlimitedcapi/file.c
@MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c
@MODULE__TESTCLINIC_LIMITED_TRUE@_testclinic_limited _testclinic_limited.c
# Some testing modules MUST be built as shared libraries.
*shared*
@MODULE__TESTIMPORTMULTIPLE_TRUE@_testimportmultiple _testimportmultiple.c
@MODULE__TESTMULTIPHASE_TRUE@_testmultiphase _testmultiphase.c
@MODULE__TESTSINGLEPHASE_TRUE@_testsinglephase _testsinglephase.c
@MODULE__CTYPES_TEST_TRUE@_ctypes_test _ctypes/_ctypes_test.c
# Limited API template modules; must be built as shared modules.
@MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c
@MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c
# for performance
*static*
@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c