#pingora #non-blocking #async #tokio #async-io #async-networking

pingora-timeout

Highly efficient async timer and timeout system for Tokio runtimes

3 unstable releases

new 0.2.0 May 10, 2024
0.1.1 Apr 18, 2024
0.1.0 Feb 27, 2024

#613 in Asynchronous

Download history 671/week @ 2024-02-26 802/week @ 2024-03-04 621/week @ 2024-03-11 841/week @ 2024-03-18 487/week @ 2024-03-25 850/week @ 2024-04-01 631/week @ 2024-04-08 484/week @ 2024-04-15 1272/week @ 2024-04-22 3419/week @ 2024-04-29 2766/week @ 2024-05-06

7,973 downloads per month
Used in 15 crates (6 directly)

Apache-2.0

23KB
399 lines

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

Dependencies

~3–10MB
~92K SLoC