Skip to main content

fallow_engine/
thread_pool.rs

1//! Shared Rayon pool construction for analysis workloads.
2
3/// Worker stack size for analysis thread pools.
4///
5/// Recursive AST extraction and analysis overflow the default Rayon worker
6/// stack on deeply nested sources, so every pool that runs analysis work must
7/// be built with this size. The CLI global pool and the programmatic per-call
8/// pools share this builder so embedders cannot drift.
9pub const WORKER_STACK_SIZE: usize = 16 * 1024 * 1024;
10
11/// Rayon pool builder preconfigured with the analysis worker stack size.
12#[must_use]
13pub fn worker_pool_builder(threads: usize) -> rayon::ThreadPoolBuilder {
14    rayon::ThreadPoolBuilder::new()
15        .num_threads(threads)
16        .stack_size(WORKER_STACK_SIZE)
17}