Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
1–10 of 38 posts
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#2Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#3looks awesome. how easy is it to use this to profile a webapp written in a framework like django? Open-metrics? just curious
sudo austin-tui -Cp
See https://github.com/P403n1x87/austin#examples for more details. To avoid using sudo on Linux you can do
sudo setcap cap_sys_ptrace+ep `which austin`
and then simply
austin-tui -Cp
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#4- py-spy: https://github.com/benfred/py-spy (written in Rust)
- pyflame: https://github.com/uber-archive/pyflame (C++, seems to be not maintained anymore)
The "no performance cost" thing is interesting: my experience writing a similar profiler is that there are a couple of things that can affect performance a little bit:
1. You have to make a lot of system calls to read the memory of the target process, and if you want to sample at a high rate then that does use some CPU. This can be an issue if you only have 1 CPU.
2. you have two choices when reading memory from a process: you can either race with the program and hope that you read its memory to get the function stack before it changes what function it's running (and you're likely to win the race, because C is faster than Python), or you can pause the program briefly while taking a sample. py-spy has an option to choose which one you want to do: https://github.com/benfred/py-spy#how-can-i-avoid-pausing-th...
Definitely this method is a lot lower overhead than a tracing profiler that instruments every single function call, and in practice it works well.
One thing I think is nice about this kind of profiler is that reading memory from the target process sounds like a complicated thing, but it's not: you can see austin's code for reading memory here, and it's implemented for 3 platforms in just 130 lines of C: https://github.com/P403n1x87/austin/blob/877e2ff946ea5313e47...
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#5Two other profilers that also let you spy on a running Python program: - py-spy: https://github.com/benfred/py-spy (written in Rust) - pyflame: https://github.com/uber-archive/pyflame (C++, seems to be not maintained anymore) The "no performance cost" thing is interesting: my experience writing a similar profiler is that there are a couple of things that can affect performance a little bit: 1. You have to make a lot…
As for the race conditions, Austin does not introduce any pauses. Even if it did, there would be no guarantee that it paused at a "good" point, so there are no real benefits in terms of accuracy in pausing. Error rates are quite low anyway, so the actual benefit comes from not pausing at all.
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#6looks awesome. how easy is it to use this to profile a webapp written in a framework like django? Open-metrics? just curious
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#7looks awesome. how easy is it to use this to profile a webapp written in a framework like django? Open-metrics? just curious
Pyinstrument might be easier to profile web requests: https://github.com/joerick/pyinstrument#profile-a-web-reques...
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#8Two other profilers that also let you spy on a running Python program: - py-spy: https://github.com/benfred/py-spy (written in Rust) - pyflame: https://github.com/uber-archive/pyflame (C++, seems to be not maintained anymore) The "no performance cost" thing is interesting: my experience writing a similar profiler is that there are a couple of things that can affect performance a little bit: 1. You have to make a lot…
But it's not right for every use case: by design austin/py-spy can only really profile the whole program, and if you want to profile a specific function or endpoint in your program, something like PyInstrument https://github.com/joerick/pyinstrument (which includes Django middlewares & Flask decorators) is a lot more useful.
Re: Show HN: Austin-Tui – Spy inside a running Python program at no performance cost
#9Two other profilers that also let you spy on a running Python program: - py-spy: https://github.com/benfred/py-spy (written in Rust) - pyflame: https://github.com/uber-archive/pyflame (C++, seems to be not maintained anymore) The "no performance cost" thing is interesting: my experience writing a similar profiler is that there are a couple of things that can affect performance a little bit: 1. You have to make a lot…
Also, this kind of profiler is great because you can use it on any running Python program, which is pretty magical and very useful. (especially when it's an application you didn't write) But it's not right for every use case: by design austin/py-spy can only really profile the whole program, and if you want to profile a specific function or endpoint in your program, something like PyInstrument https://github.com/joer…
https://github.com/P403n1x87/austin-python
An early attempt at an APM that was specifically designed to measure endpoint response times was here
https://github.com/P403n1x87/austin/blob/apm/austin/apm.py
The problem with statistical profilers is that they might fail to catch every single call, especially when they are fast.