nros_node/config.rs
1//! Build-time configurable constants.
2//!
3//! Values are set via environment variables at build time.
4//! See build.rs for env var names and defaults.
5
6include!(concat!(env!("OUT_DIR"), "/nros_node_config.rs"));
7
8/// phase-271 — default arena bytes for a per-entry executor holding `cbs`
9/// callback slots. Scales the build-time [`ARENA_SIZE`] (which is sized for the
10/// default [`MAX_CBS`]) linearly by `cbs`, so a per-entry [`ExecutorSizing`] with
11/// a caller-chosen `cbs` gets the same per-slot arena budget the global default
12/// used — a fat entry (more callbacks) gets a larger arena, a lean one a smaller
13/// one — without a workspace-global `NROS_EXECUTOR_ARENA_SIZE`. Floored at the
14/// full default so no per-entry executor is ever smaller than a single-slot
15/// build would have been (the arena is a worst-case upper bound; over-provision
16/// is safe, under-provision fails entity creation).
17///
18/// [`ExecutorSizing`]: crate::executor::ExecutorSizing
19pub const fn arena_size_for(cbs: usize) -> usize {
20 let scaled = (cbs * ARENA_SIZE).div_ceil(if MAX_CBS == 0 { 1 } else { MAX_CBS });
21 // Never below one default slot's worth so a tiny `cbs` still has headroom for
22 // the base overhead the derivation folds into `ARENA_SIZE`.
23 let floor = ARENA_SIZE.div_ceil(if MAX_CBS == 0 { 1 } else { MAX_CBS });
24 if scaled < floor { floor } else { scaled }
25}