#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

#708 in Asynchronous

Download history 8665/week @ 2024-09-21 9463/week @ 2024-09-28 8195/week @ 2024-10-05 10914/week @ 2024-10-12 8973/week @ 2024-10-19 11210/week @ 2024-10-26 15552/week @ 2024-11-02 11570/week @ 2024-11-09 16934/week @ 2024-11-16 15187/week @ 2024-11-23 12831/week @ 2024-11-30 17172/week @ 2024-12-07 14903/week @ 2024-12-14 6498/week @ 2024-12-21 5424/week @ 2024-12-28 11576/week @ 2025-01-04

40,777 downloads per month
Used in 30 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–9MB
~74K SLoC