Coroutine-aware wall-time profiling
See original GitHub issueFor the sake of profiling ASGI apps, it would be really helpful if there was a way to make use of python 3.7’s contextvars while filtering via yappi.get_func_stats
. If yappi supported this, you could get per-request-response-cycle profiling through an ASGI middleware.
I’m not sure if the necessary functionality already exists or not, but wanted to open an issue in case anyone else has thought about this, or in case someone is aware of an existing way to accomplish this.
See https://github.com/tiangolo/fastapi/issues/701 for more context on how we’d like to use this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:46 (22 by maintainers)
Top Results From Across the Web
Wall time profiling for multi-threaded application - Stack Overflow
I have two applications: one is multithreaded and one is completely sequential. Both applications perform the same task.
Read more >(feature request) pprof wall time profiling - Google Groups
Hey guys,. While cpu profiling is great for debugging where we spend our cpu, it's terrible for debugging latency issues because I/O, time ......
Read more >Quadrotor UAV 3D Path Planning with Optical-Flow-based ...
Performance of the algorithm is measured with software profiling and in terms of execution time for two embedded computer boards such as. NVIDIA...
Read more >The yappi from sumerc - GithubHelp
Rich in Feature set: Profiler results can show either Wall Time or actual CPU Time and can be aggregated from ... Coroutine-aware wall-time...
Read more >Yappi: Python profiler with thread, coroutine, and greenlet aware
Profile an asyncio application: You can see that coroutine wall-time's are correctly profiled. import asyncio import yappi async ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @dmontagu, I have been able to run your test case successfully! (I have renamed the test file to be
test_asyncio_context_vars.py
and added it to thecoroutine-profiling
branch.). A new API has been written and first tests indicate it is stable. I am extensively writing test cases, it would be nice if you can also get a look at it. The only change I needed to do is to change set_context_id_callback to the new API:set_tag_callback
. So, with the new version of Yappi you can simply tag any function regardless of thread or coroutine. I hope you can start using it in FastAPI and tell me about the progress.Ok. This will hopefully be my final update: I have done few changes related to get_func_stats() again: implemented filtering on C side and moved same tags into same hashtables. With these improvements, now 1000 concurrent requests is being done in ~3.7 secs! which seems to indicate 10x improvement. I think we no more need filtering on clear_stats() as the number of tags does not affect performance anymore while filtering on tag.(as we use a hashtable underneath.)
Anyway, I will be finalizing the tests and hopefully will be releasing a new version which includes lots of new, exciting stuff. Looking forward to your latest feedback and use cases in FastAPI, too, of course.