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
fixup! Fixes
  • Loading branch information
pablogsal committed Nov 25, 2025
commit fca9c8872947b939818f77c4be33d85aa7ce259c
91 changes: 61 additions & 30 deletions Lib/test/test_profiling/test_sampling_profiler/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def test_single_root_task(self):
self.assertEqual(thread_id, 100)

def test_parent_child_chain(self):
"""Test _build_linear_stacks: BFS follows parent links from leaf to root."""
"""Test _build_linear_stacks: BFS follows parent links from leaf to root.

Task graph:

Parent (id=1)
|
Child (id=2)
"""
collector = PstatsCollector(sample_interval_usec=1000)

child = MockTaskInfo(
Expand Down Expand Up @@ -91,10 +98,17 @@ def test_parent_child_chain(self):
self.assertIn("parent_fn", func_names)

def test_multiple_leaf_tasks(self):
"""Test _find_leaf_tasks: identifies multiple leaves correctly."""
collector = PstatsCollector(sample_interval_usec=1000)
"""Test _find_leaf_tasks: identifies multiple leaves correctly.

Task graph (fan-out from root):

# Two leaves, one root
Root (id=1)
/ \
Leaf1 (id=10) Leaf2 (id=20)

Expected: 2 stacks (one for each leaf).
"""
collector = PstatsCollector(sample_interval_usec=1000)
leaf1 = MockTaskInfo(
task_id=10,
task_name="Leaf1",
Expand Down Expand Up @@ -125,10 +139,15 @@ def test_multiple_leaf_tasks(self):
self.assertEqual(leaf_ids, {10, 20})

def test_cycle_detection(self):
"""Test _build_linear_stacks: cycle detection prevents infinite loops."""
collector = PstatsCollector(sample_interval_usec=1000)
"""Test _build_linear_stacks: cycle detection prevents infinite loops.

Task graph (cyclic dependency):

# A -> B -> A (cycle)
A (id=1) <---> B (id=2)

Neither task is a leaf (both have parents), so no stacks are produced.
"""
collector = PstatsCollector(sample_interval_usec=1000)
task_a = MockTaskInfo(
task_id=1,
task_name="A",
Expand Down Expand Up @@ -265,12 +284,14 @@ def test_diamond_pattern_multiple_parents(self):
"""
collector = PstatsCollector(sample_interval_usec=1000)

# Diamond: Root spawns A and B, both await Child
# Root (id=1)
# / \
# A(id=2) B(id=3)
# \ /
# Child(id=4)
# Diamond pattern: Root spawns A and B, both await Child
#
# Root (id=1)
# / \
# A (id=2) B (id=3)
# \ /
# Child (id=4)
#

child = MockTaskInfo(
task_id=4,
Expand Down Expand Up @@ -375,11 +396,18 @@ def test_orphaned_parent_with_no_frames_collected(self):
def test_frame_ordering(self):
"""Test _build_linear_stacks: frames are collected in correct order (leaf->root).

Verifies stack is built bottom-up: leaf frames first, then parent frames.
Task graph (3-level chain):

Root (id=1) <- root_bottom, root_top
|
Middle (id=2) <- mid_bottom, mid_top
|
Leaf (id=3) <- leaf_bottom, leaf_top

Expected frame order: leaf_bottom, leaf_top, mid_bottom, mid_top, root_bottom, root_top
(stack is built bottom-up: leaf frames first, then parent frames).
"""
collector = PstatsCollector(sample_interval_usec=1000)

# 3-level chain with distinctive frame names
leaf = MockTaskInfo(
task_id=3,
task_name="Leaf",
Expand Down Expand Up @@ -438,23 +466,26 @@ def test_frame_ordering(self):
def test_complex_multi_parent_convergence(self):
"""Test _build_linear_stacks: multiple leaves with same parents pick deterministically.

Tests that when multiple leaves have multiple parents, each leaf picks the same parent
(sorted, first one) and all leaves are annotated with parent count.
Root
/ \\
A B
\\ /
LeafX LeafY
Tests that when multiple leaves have multiple parents, each leaf picks the same
parent (sorted, first one) and all leaves are annotated with parent count.

Task graph structure (both leaves awaited by both A and B):

Root (id=1)
/ \
A (id=2) B (id=3)
| \ / |
| \ / |
| \/ |
| /\ |
| / \ |
LeafX (id=4) LeafY (id=5)

Expected behavior: Both leaves pick parent A (lowest id=2) for their stack path.
Result: 2 stacks, both going through A -> Root (B is skipped).
"""
collector = PstatsCollector(sample_interval_usec=1000)

# More complex: 2 leaves, both with 2 parents each, converging to 1 root
# Root(1)
# / \
# A(2) B(3)
# / \ / \
# LeafX(4) LeafY(5)

leaf_x = MockTaskInfo(
task_id=4,
task_name="LeafX",
Expand Down
Loading