gh-138385: Sample all interpreters in the tachyon profiler (#138398)

This commit is contained in:
Pablo Galindo Salgado 2025-09-09 00:41:08 +01:00 committed by GitHub
parent 01895d233b
commit 03ee060ec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 884 additions and 320 deletions

View file

@ -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):