Skip to content

Commit

Permalink
Clarify tiny timeouts behavior and how it can affect performance (#6274
Browse files Browse the repository at this point in the history
…) (#6303)

Co-authored-by: Sviatoslav Sydorenko <sviat@redhat.com>
(cherry picked from commit 254d0e7)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
patchback[bot] and asvetlov committed Nov 12, 2021
1 parent c4502b0 commit 065c15b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/6274.doc.rst
@@ -0,0 +1 @@
Added an explanation of how tiny timeouts affect performance to the client reference document.
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

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
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Expand Up @@ -159,6 +159,7 @@ env
environ
eof
epoll
expirations
etag
facto
fallback
Expand Down

0 comments on commit 065c15b

Please sign in to comment.