Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enable frame caching by default in the sampling profiler
Turn on cache_frames=True in the sampling profiler and the external inspection benchmark. This significantly reduces the cost of sampling deep stacks since unchanged parent frames don't need to be re-read from the target process.
  • Loading branch information
pablogsal committed Dec 1, 2025
commit 19047cfb71fe1ecd2df3a74ecae3aebc10336af6
4 changes: 2 additions & 2 deletions Lib/profiling/sampling/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def __init__(self, pid, sample_interval_usec, all_threads, *, mode=PROFILING_MOD
if _FREE_THREADED_BUILD:
self.unwinder = _remote_debugging.RemoteUnwinder(
self.pid, all_threads=self.all_threads, mode=mode, native=native, gc=gc,
skip_non_matching_threads=skip_non_matching_threads
skip_non_matching_threads=skip_non_matching_threads, cache_frames=True
)
else:
only_active_threads = bool(self.all_threads)
self.unwinder = _remote_debugging.RemoteUnwinder(
self.pid, only_active_thread=only_active_threads, mode=mode, native=native, gc=gc,
skip_non_matching_threads=skip_non_matching_threads
skip_non_matching_threads=skip_non_matching_threads, cache_frames=True
)
# Track sample intervals and total sample count
self.sample_intervals = deque(maxlen=100)
Expand Down
2 changes: 1 addition & 1 deletion Tools/inspection/benchmark_external_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def main():
elif args.threads == "only_active":
kwargs["only_active_thread"] = True
unwinder = _remote_debugging.RemoteUnwinder(
process.pid, **kwargs
process.pid, cache_frames=True, **kwargs
)
results = benchmark(unwinder, duration_seconds=args.duration)
finally:
Expand Down