From b1507a19544f1a4d311879ad498ffcadec598e83 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 12 Nov 2021 12:59:02 +0200 Subject: [PATCH] Clarify tiny timeouts behavior and how it can affect performance (#6274) Co-authored-by: Sviatoslav Sydorenko (cherry picked from commit 254d0e7d7242e5ffe927501f3ee1370b354b0a96) --- CHANGES/6274.doc.rst | 1 + docs/client_reference.rst | 25 +++++++++++++++++++++++++ docs/spelling_wordlist.txt | 1 + 3 files changed, 27 insertions(+) create mode 100644 CHANGES/6274.doc.rst diff --git a/CHANGES/6274.doc.rst b/CHANGES/6274.doc.rst new file mode 100644 index 0000000000..38d0ea1c99 --- /dev/null +++ b/CHANGES/6274.doc.rst @@ -0,0 +1 @@ +Added an explanation of how tiny timeouts affect performance to the client reference document. diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 51139bfe28..9710cc43fb 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -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 ^^^^ diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 565a07a6d7..e8a1e03813 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -159,6 +159,7 @@ env environ eof epoll +expirations etag facto fallback