-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of keepalive rescheduling #8662
Conversation
If not all handlers were done, the keep alive would get rescheduled every second until the current time was greater than self._keepalive_time + self._keepalive_timeout Instead we will schedule the timer for either 1s later or self._keepalive_time + self._keepalive_timeout whichever is greater to avoid many timer handles
Before we would see 1 timer handle created every second for 60s per connection. After we get 1 timer handle total. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8662 +/- ##
=======================================
Coverage 97.97% 97.97%
=======================================
Files 107 107
Lines 33791 33794 +3
Branches 3969 3969
=======================================
+ Hits 33107 33110 +3
Misses 507 507
Partials 177 177
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I went to do some archeology before I mark this ready as the previous code didn't make much sense to me. |
It looks like the 1s delay was added in ad2366e Previously it was |
Thanks. I like the new version much better. |
Backport to 3.10: 💚 backport PR created✅ Backport PR branch: Backported as #8670 🤖 @patchback |
(cherry picked from commit be23d16)
Backport to 3.11: 💚 backport PR created✅ Backport PR branch: Backported as #8671 🤖 @patchback |
(cherry picked from commit be23d16)
…escheduling (#8670) Co-authored-by: J. Nick Koston <nick@koston.org>
…escheduling (#8671) Co-authored-by: J. Nick Koston <nick@koston.org>
What do these changes do?
If not all handlers were done, the keep alive would get rescheduled every second until the current time was greater than self._keepalive_time + self._keepalive_timeout
Instead we will reschedule the timer for the expected keep alive close time if the timer handle fires too early.
Are there changes in behavior for the user?
no
Is it a substantial burden for the maintainers to support this?
no
related issue #8613
Before we would see 1 timer handle created every second for 60s per connection. After we get 1 timer handle total for when the keepalive timeout is due.
before
after