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

pingora-timeout

Highly efficient async timer and timeout system for Tokio runtimes

5 releases (3 breaking)

0.4.0 Nov 1, 2024
0.3.0 Jul 12, 2024
0.2.0 May 10, 2024
0.1.1 Apr 18, 2024
0.1.0 Feb 27, 2024

#723 in Asynchronous

Download history 10162/week @ 2024-10-21 10444/week @ 2024-10-28 15140/week @ 2024-11-04 11671/week @ 2024-11-11 17412/week @ 2024-11-18 16035/week @ 2024-11-25 13528/week @ 2024-12-02 16140/week @ 2024-12-09 14186/week @ 2024-12-16 5609/week @ 2024-12-23 5728/week @ 2024-12-30 14887/week @ 2025-01-06 15081/week @ 2025-01-13 14298/week @ 2025-01-20 19051/week @ 2025-01-27 22447/week @ 2025-02-03

72,207 downloads per month
Used in 29 crates (7 directly)

Apache-2.0

23KB
398 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

~2.6–8.5MB
~74K SLoC