I remember looking at python profiling tools a couple years ago and being pretty disappointed. Most added a huge amount of runtime noise, the lowest being something like +50% runtime, which to me is completely unacceptable. The profiler I wrote and use every day for a side project adds well less than 1% runtime overhead.
I wonder what the overhead of sys.monitoring is. It is possible to instrument functions like this without using that API.. you can just walk the AST at startup and do it yourself. Would be interesting to see a very minimal instrumenting profiler that did that and compare the two.
I also love the 'targeted'/instrumenting profiling API. I think sampling profilers are good at scratching the surface, but quickly run out of useful information when getting down to the goods. Happy to see people doing instrumenting profilers.
Thanks for sharing :)
Python 3.15 features a very good sampling profiler with excellent reporting: https://docs.python.org/3.15/library/profiling.sampling.html.
I'm wondering, is the overhead a problem for you because it skews profiling results, or does it lead to the overall runtime becoming too long?
So far I thought profiling might add overhead but the results themselves should be unaffected (modulo the usual pitfalls).