Skip to main content

Module fast_timeout

Module fast_timeout 

Source
Expand description

The fast and more complicated version of pingora-timeout

The following optimizations are applied:

  • The timeouts lazily initialize their timer when the Future is pending for the first time.
  • There is no global lock for creating and cancelling timeouts.
  • Timeout timers are rounded to the next 10ms tick and timers are shared across all timeouts with the same deadline.

In order for this to work, a standalone thread is created to arm the timers, which has some overhead. As a general rule, the benefits of this don’t outweigh the overhead unless there are more than about 100 timeout() calls/sec in the system. Use regular tokio timeout or super::tokio_timeout in the low usage case.

Structs§

FastOrTokioTimeout
The timeout selector generated by fast_timeout().
FastTimeout
The timeout generated by fast_timeout().

Constants§

DEFAULT_FAST_TIMEOUT_TO_TOKIO_THRESHOLD
Default duration above which fast_timeout() falls back to Tokio’s timeout.

Functions§

fast_sleep
Similar to tokio::time::sleep but more efficient.
fast_timeout
Similar to tokio::time::timeout but more efficient.
fast_timeout_to_tokio_threshold
Return the duration above which fast_timeout() falls back to Tokio’s timeout.
pause_for_fork
Pause the timer for fork()
set_fast_timeout_to_tokio_threshold
Set the duration above which fast_timeout() falls back to Tokio’s timeout.
unpause
Unpause the timer after fork()