question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coroutine-aware wall-time profiling

See original GitHub issue

For 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:closed
  • Created 4 years ago
  • Comments:46 (22 by maintainers)

github_iconTop GitHub Comments

7reactions
sumerccommented, Nov 26, 2019

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 the coroutine-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.

5reactions
sumerccommented, Dec 4, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found