yappi icon indicating copy to clipboard operation
yappi copied to clipboard

Feature request: Incremental stats clearing

Open sm-Fifteen opened this issue 5 years ago • 1 comments

Yappi is currently poorly suited to long-running applications, since the only way to free a set of profiling stats once they're no longer needed is to clear the all of the profiler's memory, effectively resetting it. In a multi-threaded or async system, this is almost certain to interfere with the other threads, and even if losing profiler data isn't critical, it could lead to some frustration when attempting to isolate some of the longer code paths applications that are meant to run for extended periods of time (such as any kind of server).

There should be an alternative to clear_stats() that allows the user to pass the same kind of filter passed to get_func_stats() to cleanup select parts of the profiler stats. Alternatively, this could be implementad as a method to YFuncStat, which would free all memory related to the function calls contained within.

sm-Fifteen avatar Jan 08 '20 15:01 sm-Fifteen

Thanks for the explanation.

We have also discussed this before on https://github.com/tiangolo/fastapi/issues/701 and clear_stats() filtering might be worth implementing for using in long running servers/middleware as you proposed.

sumerc avatar Jan 08 '20 18:01 sumerc