mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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.
This commit is contained in:
parent
332da6295f
commit
572c780aa8
24 changed files with 1855 additions and 142 deletions
2
Include/internal/pycore_runtime_init_generated.h
generated
2
Include/internal/pycore_runtime_init_generated.h
generated
|
|
@ -1607,6 +1607,7 @@ extern "C" {
|
|||
INIT_ID(c_parameter_type), \
|
||||
INIT_ID(c_return), \
|
||||
INIT_ID(c_stack), \
|
||||
INIT_ID(cache_frames), \
|
||||
INIT_ID(cached_datetime_module), \
|
||||
INIT_ID(cached_statements), \
|
||||
INIT_ID(cadata), \
|
||||
|
|
@ -2051,6 +2052,7 @@ extern "C" {
|
|||
INIT_ID(stacklevel), \
|
||||
INIT_ID(start), \
|
||||
INIT_ID(statement), \
|
||||
INIT_ID(stats), \
|
||||
INIT_ID(status), \
|
||||
INIT_ID(stderr), \
|
||||
INIT_ID(stdin), \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue