Provide more info in dtrace probes

While creating a python profiler using dtrace, I found some cases that confuse dtrace-based profiler.

  1. When there are multiple function calls in one line, the line number is not useful.
1  a = 3
2  b = func(func(func(a)))

This will report the entry/return of func() three times.

function-entry:main.py:2
function-return:main.py:2
function-entry:main.py:2
function-return:main.py:2
function-entry:main.py:2
function-return:main.py:2
  1. async functions return and re-entry on every await point.
    While it is useful to be able to measure every block between await points, this confuses the profiler.
1 async def func():
2     a = 1
3     b = await f()
4     c = 2
5     d = await g()
6     return (await h()) if some_flag else (await i())
function-return:3
function-entry:3
function-return:5
function-entry:5
function-return:6
function-entry:6
function-return:6

Note that in the last line, by looking at function-entry:6 it is not possible to know which branch was taken.

It will be useful for profilers if dtrace provides

  • a column number of the function call
  • separate event type for await points / raise, or add a flag argument to function__return to indicate whether it’s await, raise, or return.