Skip to main content

reifydb_runtime/pool/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4//! Thread pool management for ReifyDB.
5//!
6//! Provides named, isolated thread pools for different workload classes:
7//! - **System pool**: lightweight system actors (flow, CDC, watermark, metrics)
8//! - **Query pool**: heavy query execution actors (WS, gRPC, HTTP)
9//!
10//! # Platform differences
11//!
12//! - **Native**: each pool is a separate `rayon::ThreadPool` with its own OS threads
13//! - **DST/WASM**: `Pools` is a zero-size marker (no real thread pools)
14
15#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
16mod native;
17
18#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
19mod wasm;
20
21#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
22pub use native::Pools;
23#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
24pub use wasm::Pools;
25
26/// Configuration for thread pool sizes.
27#[derive(Debug, Clone)]
28pub struct PoolConfig {
29	/// Threads for the system pool (lightweight actors).
30	pub system_threads: usize,
31	/// Threads for the query pool (execution-heavy actors).
32	pub query_threads: usize,
33	/// Threads for the async pool (tokio runtime).
34	pub async_threads: usize,
35}
36
37impl Default for PoolConfig {
38	fn default() -> Self {
39		Self {
40			system_threads: 1,
41			query_threads: 1,
42			async_threads: 0,
43		}
44	}
45}