Joe Rickerby
Joe Rickerby
I'm keeping this as an issue in the tracker, because it might be a good idea if the stack sampler condensed recursion into a `[recursion]` synthetic frame after 1-3 instances...
That SO post has a minimal reproducer. ``` from pyinstrument import Profiler import gc def a(): profiler = Profiler() profiler.start() a=1+1 b=a+2 profiler.stop() profiler.output_text(unicode=True, color=False, show_all=False, ) profiler.reset() profiler =...
I wonder if this is because I don't implement `tp_traverse` or `tp_clear` on [ProfilerState_Type](https://github.com/joerick/pyinstrument/blob/328e2098f7e0d1782cfa54ef7b11a12992b73de0/pyinstrument/low_level/stat_profile.c#L123)...? Any CPython wizards willing to offer advice would be appriciated :)
Any chance you can share the file that wouldn't load? It might be too large, or maybe the stack trace is too deep.
I'm not sure... are you sure your program doesn't start a profiler somewhere else? Or perhaps the middleware function is reentrant somehow?
closing due to inactivity
Sure, if you want to send a PR for the above, it sounds sensible to me!
Thanks. BTW, the part that is supposed to trim that off is `Session._trim_stem()`. https://github.com/joerick/pyinstrument/blob/main/pyinstrument/session.py#L132-L150
It looks like there's a bug here, it's caused by a profile that has zero duration. The simplest fix would be to add a special case to `frame_proportion_of_total_time` to just...
I'm no FastAPI expert, but if you figure something simple out, happy to update the docs.