Skip to main content

reifydb_runtime/pool/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4//! Execution domains organized by workload shape. Long-lived actors run on the actor pool (two worker groups:
5//! `coordination` for tiny high-frequency handlers, `flow` for heavy flow execution) with per-worker run queues and
6//! pinned dispatch. Short-lived work (per-request actors, one-shot jobs) runs on the task pool. Data-parallel work
7//! runs on the compute pool (rayon behind an install-only API). Async I/O runs on the embedded tokio runtime.
8//! Native targets get the real pools; single-threaded and DST targets get the inline stub variant. The `Pools` type
9//! both impls hand back is what `SharedRuntime` carries around.
10
11#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
12pub(crate) mod actor_pool;
13
14#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
15pub mod compute;
16
17#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
18mod native;
19
20#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
21pub(crate) mod task;
22
23#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
24mod wasm;
25
26#[cfg(all(not(reifydb_single_threaded), not(reifydb_target = "dst")))]
27pub use native::Pools;
28#[cfg(any(reifydb_single_threaded, reifydb_target = "dst"))]
29pub use wasm::Pools;
30
31#[derive(Debug, Clone)]
32pub struct PoolConfig {
33	pub coordination_threads: usize,
34
35	pub flow_threads: usize,
36
37	pub task_threads: usize,
38
39	pub compute_threads: usize,
40
41	pub async_threads: usize,
42}
43
44impl Default for PoolConfig {
45	fn default() -> Self {
46		Self {
47			coordination_threads: 2,
48			flow_threads: 2,
49			task_threads: 2,
50			compute_threads: 2,
51			async_threads: 1,
52		}
53	}
54}
55
56impl PoolConfig {
57	pub fn sync_only() -> Self {
58		Self {
59			coordination_threads: 1,
60			flow_threads: 1,
61			task_threads: 1,
62			compute_threads: 1,
63			async_threads: 0,
64		}
65	}
66}