Tachyon gecko output: 1 row per thread, process or asyncio task

Hi,

I’m exploring the Tachyon features, and I’m especially interested by the Gecko format to render timeline profile in the Firefox Profiler, to profile services performing concurrent tasks using threads, processes or asyncio tasks.

The idea would be to have each concurrent task on a separate row in the timeline, whether it’s a thread, a subprocess or an asyncio task.

Would is be possible feature?

Testing with 3.15.0b3:

  • 3 threads are already properly rendered
  • but 3 processes are rendered on 1 line
  • and asyncio tasks fails with ‘_remote_debugging.AwaitedInfo’ object has no attribute ‘threads’

See the examples here: GitHub - dfroger/tachyon-lab: Exploring the features of the Python 3.15 sampling profiler · GitHub

Thanks for reading!

So the –gecko --async-aware crash is actually already fixed: gh-152434: Fix async-aware Gecko collection by lkollar · Pull Request #152442 · python/cpython · GitHub . I’ll try the latest commit of the 3.15 branch.

2 Likes

So testing with the lastest commits of `3.15`, the firefox profiler renders 1 row for all asyncio tasks.

For example, with this script:

import asyncio

async def foo_1():
    await asyncio.sleep(1)

async def foo_2():
    await asyncio.sleep(2)

async def foo_3():
    await asyncio.sleep(3)

async def foo():
    await asyncio.gather(
        asyncio.create_task(foo_1()),
        asyncio.create_task(foo_2()),
        asyncio.create_task(foo_3()),
    )

async def bar_1():
    await asyncio.sleep(1)

async def bar_2():
    await asyncio.sleep(2)

async def bar():
    await asyncio.create_task(bar_1())
    await asyncio.create_task(bar_2())

async def baz_1():
    await asyncio.sleep(1)

async def baz_2():
    await asyncio.sleep(2)

async def baz():
    await asyncio.gather(
        asyncio.create_task(baz_1()),
        asyncio.create_task(baz_2()),
    )

async def request():
    await asyncio.create_task(foo())
    await asyncio.create_task(bar())
    await asyncio.create_task(baz())

asyncio.run(request())
python -m profiling.sampling run --async-aware --async-mode=all --gecko -o trace.json demo.py

We get:

The idea would be to produce instead (by enabling the feature only when we know there not much tasks, to not end with thousand of rows):

This image is produced by a POC of vibe-coded commits here: GitHub - dfroger/cpython at gecko-timeline-asyncio · GitHub