[1] : https://github.com/joerick/pyinstrument [2] : https://github.com/benfred/py-spy
You can then post-process that trivially to get low resolution aggregate information like normal statistical/sampling profilers generate.
I assume the hooks Python makes available are probably just kind of bad for this use case and they do not have access to a proper high speed log.
It says it is licensed under Apache License 2.0, but also under "Prosperity Public License 3.0.0" which limits use for a commercial purpose to 30 days.
Building FunctionTrace, a graphical Python profiler - https://news.ycombinator.com/item?id=24175395 - Aug 2020 (4 comments)
They will probably get a build system going so wheels can be used eventually.
The main use case is data science and other long-running batch jobs. Some differences:
1. It does memory profiling at basically no performance overhead; sounds like for FunctionTrace it's high overhead so off by default. And it catches _all_ memory allocations, not just Python API ones. This is based on using sampling, so it's not useful for profiling tiny functions (but for data science/scientific computing it'll work just fine).
2. Uses sampling for performance profiling, unlike FunctionTrace. Again, perfectly fine for any non-micro-benchmark data science program.
3. Also has a timeline view, without having to upload your data anywhere.
4. No native stacks yet.
5. Shows you if you're using CPU or I/O for every particular sample.
1. You claim ~5% overhead [1] and it is not useful for profiling tiny functions. They claim ~10% overhead when handling tiny functions and, who I believe to be the author of the package below, said it averages low single digit percents (i.e <5%) on normal non-worst cases. This is comparable or less overhead than you claim.
2. Sampling is so much worse than a full execution trace from a performance optimization and observability perspective it is ridiculous. Yes, a magnifying glass and a microscope are both okay for looking at ants, but only one is good for looking at cells. People prefer sampling because it was traditionally lower overhead, but for the same cost full tracing is so much better it is not even worth comparing, the result is patently obvious.
3. No “upload” is done. You are not sending data to them, everything is local. They are just opening the profiling data using Firefox to use it as a viewer like how you might open a PDF in Firefox.
Recording only callers instead of stacks means you literally cannot distinguish different control flows going through a common function at some point. All tools, like the mentioned ones, which pretend to reconstruct a flame graph or similar visualization don't actually work. A common cause for degenerate cases are function decorators used by multiple functions, especially if the decorator appears multiple times on the stack.
So for many practical programs the output of these is simply wrong and misleading.
Whenever I go to the demo it just loads forever :(