#orm #database

fast_pool

The Fast Pool based on channel

7 releases (2 stable)

1.0.1 Dec 20, 2025
1.0.0 Dec 18, 2025
0.3.7 May 19, 2025
0.3.6 Apr 29, 2025
0.1.9 Dec 28, 2023

#49 in Caching

Download history 642/week @ 2025-09-18 656/week @ 2025-09-25 427/week @ 2025-10-02 734/week @ 2025-10-09 879/week @ 2025-10-16 868/week @ 2025-10-23 775/week @ 2025-10-30 765/week @ 2025-11-06 759/week @ 2025-11-13 817/week @ 2025-11-20 967/week @ 2025-11-27 952/week @ 2025-12-04 902/week @ 2025-12-11 819/week @ 2025-12-18 665/week @ 2025-12-25 886/week @ 2026-01-01

3,436 downloads per month
Used in 29 crates (via rbdc-pool-fast)

Apache-2.0

27KB
500 lines

fast_pool

unsafe forbidden GitHub release

a fast async pool based on channel

  • support get(),get_timeout(),state() methods
  • support atomic max_open(Resize freely)
  • based on flume

why fast_pool?

  • fast get() method performance
//---- bench_pool windows ----
//Time: 14.0994ms ,each:130 ns/op
//QPS: 7086167 QPS/s
//---- bench_pool linux ----
//Time: 11.437625ms ,each:114 ns/op
//QPS: 8736453 QPS/s
  • Implement using only channels
  • no additional threads
  • Support asynchronous/tokio

how to use this?

  • step 1 add toml
fast_pool="0.3"
tokio = {version = "1",features = ["time","rt-multi-thread","macros"]}
  • step 2 impl trait
use std::ops::{DerefMut};
use std::time::Duration;
use async_trait::async_trait;
use fast_pool::{Manager, Pool};

#[derive(Debug)]
pub struct TestManager {}

impl Manager for TestManager {
    type Connection = String;
    type Error = String;

    async fn connect(&self) -> Result<Self::Connection, Self::Error> {
        Ok("conn".to_string())
    }

    async fn check(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> {
        //check should use conn.ping()
        if conn == "error" {
            return Err(Self::Error::from("error".to_string()));
        }
        Ok(())
    }
}

#[tokio::main]
async fn main() {
    let p = Pool::new(TestManager {});
    println!("status = {}",p.state());
    p.set_max_open(10);
    println!("status = {}",p.state());

    let mut conn = p.get().await.unwrap();
    println!("conn = {}",conn.deref_mut());
    let mut conn = p.get_timeout(Some(Duration::from_secs(1))).await.unwrap();
    println!("conn = {}",conn.deref_mut());
}

Dependencies

~3–4.5MB
~72K SLoC