Skip to content
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

Clarify tiny timeouts behavior and how it can affect performance #6274

Merged
merged 5 commits into from Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/6274.doc.rst
@@ -0,0 +1 @@
Describe how tiny timeouts can affect performance.
asvetlov marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 25 additions & 0 deletions docs/client_reference.rst
Expand Up @@ -1710,6 +1710,31 @@ ClientTimeout

.. versionadded:: 3.3


.. note::

Timeouts larger than 5 seconds are rounded for scheduling on the next
second boundary (an absolute time where microseconds part is zero) for the
sake of performance.

E.g., assume a timeout is ``10``, absolute time when timeout should expire
is ``loop.time() + 5``, and it points to ``12345.67 + 10`` which is equal
to ``12355.67``.

The absolute time for the timeout cancellation is ``12356``.

It leads to grouping all close scheduled timeout expirations to exactly
the same time to reduce amount of loop wakeups.

.. versionchanged:: 3.7
asvetlov marked this conversation as resolved.
Show resolved Hide resolved

Rounding to the next seconds boundary is disabled for timeouts smaller
than 5 seconds for the sake of easy debugging.

In turn, tiny timeouts can lead to significant performance degradation
on production environment.


ETag
^^^^

Expand Down