mirror of
https://github.com/python/cpython.git
synced 2025-10-25 10:44:55 +00:00
gh-138385: Sample all interpreters in the tachyon profiler (#138398)
This commit is contained in:
parent
01895d233b
commit
03ee060ec8
7 changed files with 884 additions and 320 deletions
|
|
@ -9,16 +9,22 @@ def __init__(self):
|
|||
self.call_trees = []
|
||||
self.function_samples = collections.defaultdict(int)
|
||||
|
||||
def collect(self, stack_frames):
|
||||
for thread_id, frames in stack_frames:
|
||||
if frames:
|
||||
# Store the complete call stack (reverse order - root first)
|
||||
call_tree = list(reversed(frames))
|
||||
self.call_trees.append(call_tree)
|
||||
def _process_frames(self, frames):
|
||||
"""Process a single thread's frame stack."""
|
||||
if not frames:
|
||||
return
|
||||
|
||||
# Count samples per function
|
||||
for frame in frames:
|
||||
self.function_samples[frame] += 1
|
||||
# Store the complete call stack (reverse order - root first)
|
||||
call_tree = list(reversed(frames))
|
||||
self.call_trees.append(call_tree)
|
||||
|
||||
# Count samples per function
|
||||
for frame in frames:
|
||||
self.function_samples[frame] += 1
|
||||
|
||||
def collect(self, stack_frames):
|
||||
for frames in self._iter_all_frames(stack_frames):
|
||||
self._process_frames(frames)
|
||||
|
||||
|
||||
class CollapsedStackCollector(StackTraceCollector):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue