integrated pyliveupdate for dynamic profiling#3
integrated pyliveupdate for dynamic profiling#3EvonX wants to merge 2 commits intotimabbott:masterfrom EvonX:master
Conversation
manage.py
Outdated
| # pyliveupdate integration | ||
| from pyliveupdate import * | ||
| UpdateStub().start() | ||
| from pyliveupdatescripts import * |
There was a problem hiding this comment.
Can you do this without using * imports? I guess I also don't see how this works -- does the behavior change just because of what was imported?
There was a problem hiding this comment.
Yes, I've modified it.
Sorry I haven't make it clear. These three lines of code will start a profiling-tub thread in Zulip, which will listen for a profiling-controller's commands to dynamically modify Zulip's code for profiling. So in order to make the behavior change, you may need to run a standalone profiling controller with pylu-controller -l. This will start a controller shell, in which you can type command like FP.profile(['zerver.lib.rate_limiter.**', 'zerver.lib.rest.**']) to start profiling a set of functions and FP.revert(1) to stop profiling without restarting Zulip. We have a demo here https://asciinema.org/a/304465. Hope it can help.
Please let me know if there is any questions.
If we had a rule like "max 3 requests in 2 seconds", there was an inconsistency between is_ratelimited() and get_api_calls_left(). If you had: request #1 at time 0 request #2 and #3 at some times < 2 Next request, if exactly at time 2, would not get ratelimited, but if get_api_calls_left was called, it would return 0. This was due to inconsistency on the boundary - the check in is_ratelimited was exclusive, while get_api_calls_left uses zcount, which is inclusive.
adding profiling support with pyliveupdate
Testing Plan:
GIFs or Screenshots:
Profiling results for zulip#13917