Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
af65c15
It might work but the code is bad
savannahostrowski Nov 3, 2025
ec28f88
Account for function doing CPU work before/after spawning workers
savannahostrowski Nov 3, 2025
1e01766
Merge branch 'main' into async-tachyon
savannahostrowski Nov 3, 2025
2a2e197
Code cleanup
savannahostrowski Nov 3, 2025
61dc0bb
WIP
savannahostrowski Nov 3, 2025
c9c34a5
Merge branch 'main' into async-tachyon
savannahostrowski Nov 13, 2025
cc9e9ab
Remove depth
savannahostrowski Nov 13, 2025
9b22f1e
Make keyword only
savannahostrowski Nov 13, 2025
890474d
Fix tests
savannahostrowski Nov 13, 2025
563ecff
Bruuuh, it worked
savannahostrowski Nov 13, 2025
112ce73
Simplify algo
pablogsal Nov 14, 2025
2beed97
Fix multiple parents
pablogsal Nov 14, 2025
7315953
Good shit
pablogsal Nov 14, 2025
f8e9d72
Deque, deduplicate yields, propagate thread_id
savannahostrowski Nov 14, 2025
9a4875f
📜🤖 Added by blurb_it.
blurb-it[bot] Nov 14, 2025
ec6fb51
Remove deduplication of leaves to ensure call stacks can be properly …
savannahostrowski Nov 14, 2025
67e1f74
Merge branch 'async-tachyon' of https://github.com/savannahostrowski/…
savannahostrowski Nov 14, 2025
e9ae950
Fix WASI
savannahostrowski Nov 14, 2025
acef9a0
More WASI fixes
savannahostrowski Nov 14, 2025
2953454
Merge main
savannahostrowski Nov 23, 2025
09f5205
Fix tests
savannahostrowski Nov 23, 2025
dc7abae
Fix broken imports
savannahostrowski Nov 24, 2025
36c8b3c
Remove old test file
savannahostrowski Nov 24, 2025
be6d228
Merge remote-tracking branch 'upstream/main' into async-tachyon
pablogsal Nov 24, 2025
64ccb1a
Fixes
pablogsal Nov 24, 2025
fca9c88
fixup! Fixes
pablogsal Nov 25, 2025
394069d
Merge main
savannahostrowski Dec 1, 2025
3d9d2fb
Fix test error
savannahostrowski Dec 1, 2025
1134431
Fix quotations for consistency
savannahostrowski Dec 1, 2025
f0242e1
Merge remote-tracking branch 'upstream/main' into async-tachyon
pablogsal Dec 6, 2025
56661dc
Update to latest main
pablogsal Dec 6, 2025
ff983d8
Fix tests
pablogsal Dec 6, 2025
2203021
Fix tests
pablogsal Dec 6, 2025
e6eaa2c
CLI update
pablogsal Dec 6, 2025
47ebc11
Small fixes
pablogsal Dec 6, 2025
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
Deque, deduplicate yields, propagate thread_id
  • Loading branch information
savannahostrowski committed Nov 14, 2025
commit f8e9d72024afb2406f294fd386e691bb5187fe82
32 changes: 24 additions & 8 deletions Lib/profiling/sampling/collector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import ABC, abstractmethod
from collections import deque

from _remote_debugging import FrameInfo

Expand Down Expand Up @@ -71,11 +72,15 @@ def _find_leaf_tasks(self, child_to_parents, all_task_ids):

def _build_linear_stacks(self, leaf_task_ids, task_map, child_to_parents):
for leaf_id in leaf_task_ids:
# BFS queue: (current_task_id, frames_so_far, path_for_cycle_detection)
queue = [(leaf_id, [], frozenset())]
# Track yielded paths to avoid duplicates from multiple parent paths
yielded_paths = set()

# BFS queue: (current_task_id, frames_so_far, path_for_cycle_detection, thread_id)
# Use deque for O(1) popleft instead of O(n) list.pop(0)
queue = deque([(leaf_id, [], frozenset(), None)])

while queue:
current_id, frames, path = queue.pop(0)
current_id, frames, path, thread_id = queue.popleft()

# Cycle detection
if current_id in path:
Expand All @@ -84,12 +89,20 @@ def _build_linear_stacks(self, leaf_task_ids, task_map, child_to_parents):
# End of path (parent ID not in task_map)
if current_id not in task_map:
if frames:
_, thread_id = task_map[leaf_id]
yield frames, thread_id, leaf_id
# Deduplicate yields based on path taken
path_sig = frozenset(path)
if path_sig not in yielded_paths:
yielded_paths.add(path_sig)
yield frames, thread_id, leaf_id
continue

# Process current task
task_info, tid = task_map[current_id]

# Set thread_id from first task if not already set
if thread_id is None:
thread_id = tid

new_frames = list(frames)
new_path = path | {current_id}

Expand All @@ -107,9 +120,12 @@ def _build_linear_stacks(self, leaf_task_ids, task_map, child_to_parents):
parent_ids = child_to_parents.get(current_id, [])

if not parent_ids:
# Root task - yield complete stack
yield new_frames, tid, leaf_id
# Root task - yield complete stack (deduplicate)
path_sig = frozenset(new_path)
if path_sig not in yielded_paths:
yielded_paths.add(path_sig)
yield new_frames, thread_id, leaf_id
else:
# Continue to each parent (creates multiple paths if >1 parent)
for parent_id in parent_ids:
queue.append((parent_id, new_frames, new_path))
queue.append((parent_id, new_frames, new_path, thread_id))
Loading