Crate pingora_timeout

Source
Expand description

A drop-in replacement of tokio::time::timeout which is much more efficient.

Similar to tokio::time::timeout but more efficient on busy concurrent IOs where timeouts are created and canceled very frequently.

This crate provides the following optimizations

  • The timeouts lazily initializes 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.

Benchmark:

438.302µs total, 4ns avg per iteration

v.s. Tokio timeout():

10.716192ms total, 107ns avg per iteration

Re-exports§

pub use fast_timeout::fast_sleep as sleep;
pub use fast_timeout::fast_timeout as timeout;

Modules§

fast_timeout
The fast and more complicated version of pingora-timeout
timer
Lightweight timer for systems with high rate of operations with timeout associated with them

Structs§

Elapsed
The error type returned when the timeout is reached.
Timeout
The timeout future returned by the timeout functions
TokioTimeout
The timeout generated by tokio_timeout().

Traits§

ToTimeout
The interface to start a timeout

Functions§

tokio_timeout
The tokio::time::timeout with just lazy timer initialization.