#[cfg(feature = "external")] use crate::Pacer; #[cfg(not(feature = "iouring-network"))] use crate::network::tokio::{Config as TokioNetworkConfig, Network as TokioNetwork}; #[cfg(feature = "iouring-storage")] use crate::storage::iouring::{Config as IoUringConfig, Storage as IoUringStorage}; #[cfg(not(feature = "iouring-storage"))] use crate::storage::tokio::{Config as TokioStorageConfig, Storage as TokioStorage}; use crate::{ BlobLayout, BlobVersion, BufferPool, BufferPoolConfig, Clock, Error, Execution, Handle, METRICS_PREFIX, Name, SinkOf, StreamOf, child_label, network::metered::Network as MeteredNetwork, prefixed_name, process::metered::Metrics as MeteredProcess, signal::Signal, storage::metered::Storage as MeteredStorage, telemetry::metrics::{ CounterFamily, GaugeFamily, Metric, Register, Registered, Registry, add_attribute, raw, task::Label, validate_label, }, utils::{self, Panicker, signal::Stopper, supervision::Tree}, }; #[cfg(feature = "iouring-network")] use crate::{ iouring, network::iouring::{Config as IoUringNetworkConfig, Network as IoUringNetwork}, }; use commonware_macros::{select, stability}; #[stability(BETA)] use commonware_parallel::Rayon; use commonware_utils::{NZUsize, sync::Mutex, sys_rng}; use governor::clock::{Clock as GClock, ReasonablyRealtime}; use rand_core::{Rng, TryCryptoRng, TryRng}; #[stability(BETA)] use rayon::ThreadPoolBuilder; use std::{ convert::Infallible, env, future::Future, net::{IpAddr, SocketAddr}, num::NonZeroUsize, ops::RangeInclusive, panic::{AssertUnwindSafe, catch_unwind, resume_unwind}, path::PathBuf, sync::Arc, time::{Duration, SystemTime}, }; use tokio::{ runtime::{Builder, Handle as RuntimeHandle}, sync::Notify, }; #[cfg(feature = "iouring-network")] cfg_if::cfg_if! { if #[cfg(test)] { // Use a smaller ring in tests to reduce `io_uring_setup` failures // under parallel test load due to mlock/resource limits. const IOURING_NETWORK_SIZE: u32 = 128; } else { const IOURING_NETWORK_SIZE: u32 = 1024; } } #[derive(Debug)] struct Metrics { tasks_spawned: CounterFamily