cpython/Lib/profiling/sampling
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
..
_assets gh-71648: Optimize PNG files (GH-138842) 2025-09-12 20:13:05 +00:00
_flamegraph_assets gh-140677 Add heatmap visualization to Tachyon sampling profiler (#140680) 2025-12-02 20:33:40 +00:00
_heatmap_assets gh-140677 Improve heatmap colors (#142241) 2025-12-06 20:27:16 +00:00
_shared_assets GH-142363: Contrast and gradient CSS fixes for Tachyon flamegraph (#142364) 2025-12-06 22:09:10 +00:00
_vendor gh-135953: Add flamegraph reporter to sampling profiler (#138715) 2025-09-09 23:06:45 +01:00
live_collector GH-141565: Add async code awareness to Tachyon (#141533) 2025-12-06 19:31:40 +00:00
__init__.py gh-140677 Add heatmap visualization to Tachyon sampling profiler (#140680) 2025-12-02 20:33:40 +00:00
__main__.py gh-138122: Refactor the CLI of profiling.sampling into subcommands (#141813) 2025-11-24 11:45:08 +00:00
_css_utils.py gh-140677 Add heatmap visualization to Tachyon sampling profiler (#140680) 2025-12-02 20:33:40 +00:00
_sync_coordinator.py gh-140729: Add __mp_main__ as a duplicate for __main__ for pickle to work (#140735) 2025-11-17 12:43:14 +00:00
cli.py GH-141565: Add async code awareness to Tachyon (#141533) 2025-12-06 19:31:40 +00:00
collector.py GH-141565: Add async code awareness to Tachyon (#141533) 2025-12-06 19:31:40 +00:00
constants.py gh-141645: Add a TUI mode to the new tachyon profiler (#141646) 2025-11-20 18:27:17 +00:00
gecko_collector.py gh-138122: Refactor the CLI of profiling.sampling into subcommands (#141813) 2025-11-24 11:45:08 +00:00
heatmap_collector.py gh-140677 Improve heatmap colors (#142241) 2025-12-06 20:27:16 +00:00
pstats_collector.py GH-141565: Add async code awareness to Tachyon (#141533) 2025-12-06 19:31:40 +00:00
sample.py gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137) 2025-12-06 22:37:34 +00:00
stack_collector.py GH-141565: Add async code awareness to Tachyon (#141533) 2025-12-06 19:31:40 +00:00
string_table.py gh-135953: Reduce memory usage of stack collectors (#138875) 2025-09-14 23:47:14 +01:00