#[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}; #[cfg(feature = "external")] use crate::Pacer; use crate::{ child_label, network::metered::Network as MeteredNetwork, prefixed_name, process::metered::Metrics as MeteredProcess, signal::Signal, storage::metered::Storage as MeteredStorage, telemetry::metrics::{ add_attribute, raw, task::Label, validate_label, CounterFamily, GaugeFamily, Metric, Register, Registered, Registry, }, utils::{self, signal::Stopper, supervision::Tree, Panicker}, BufferPool, BufferPoolConfig, Clock, Error, Execution, Handle, Name, SinkOf, Spawner as _, StreamOf, Supervisor as _, METRICS_PREFIX, }; #[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::ThreadPool; use commonware_utils::{sync::Mutex, NZUsize}; use futures::future::Either; use governor::clock::{Clock as GClock, ReasonablyRealtime}; use rand::{rngs::OsRng, CryptoRng, RngCore}; #[stability(BETA)] use rayon::{ThreadPoolBuildError, ThreadPoolBuilder}; use std::{ env, future::Future, net::{IpAddr, SocketAddr}, num::NonZeroUsize, path::PathBuf, sync::Arc, time::{Duration, SystemTime}, }; use tokio::runtime::{Builder, Runtime}; use tracing::{info_span, Instrument}; use tracing_opentelemetry::OpenTelemetrySpanExt; #[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