Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion crates/sof-observer/src/app/config/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::{num::NonZeroUsize, path::PathBuf};
use super::{read_bool_env, read_env_var};
use crate::{
framework::{DerivedStateReplayBackend, DerivedStateReplayDurability},
runtime::{DerivedStateReplayConfig, DerivedStateRuntimeConfig, ShredTrustMode},
runtime::{
DerivedStateReplayConfig, DerivedStateRuntimeConfig, RuntimeDeliveryProfile, ShredTrustMode,
},
};

fn read_optional_bool_env(name: &str) -> Option<bool> {
Expand Down Expand Up @@ -34,6 +36,22 @@ pub fn read_runtime_current_thread() -> bool {
read_bool_env("SOF_RUNTIME_CURRENT_THREAD", false)
}

pub fn read_runtime_delivery_profile() -> RuntimeDeliveryProfile {
let Some(value) =
read_env_var("SOF_RUNTIME_DELIVERY_PROFILE").filter(|value| !value.trim().is_empty())
else {
return RuntimeDeliveryProfile::default();
};
RuntimeDeliveryProfile::from_config_value(&value).unwrap_or_else(|| {
tracing::warn!(
value,
default = RuntimeDeliveryProfile::default().as_str(),
"unknown runtime delivery profile; using default"
);
RuntimeDeliveryProfile::default()
})
}

pub fn read_runtime_core() -> Option<usize> {
read_env_var("SOF_RUNTIME_CORE").and_then(|value| value.parse::<usize>().ok())
}
Expand Down
81 changes: 48 additions & 33 deletions crates/sof-observer/src/app/runtime/entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,44 @@ pub(crate) enum RuntimeEntrypointError {
Runloop { reason: String },
}

pub(crate) fn run() -> Result<(), RuntimeEntrypointError> {
run_with_hosts(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
fn profiled_default_plugin_and_extension_hosts() -> (PluginHost, RuntimeExtensionHost) {
let profile = read_runtime_delivery_profile();
(
profile.plugin_host_builder().build(),
profile.extension_host_builder().build(),
)
}

fn profiled_default_hosts() -> (PluginHost, RuntimeExtensionHost, DerivedStateHost) {
let (plugin_host, extension_host) = profiled_default_plugin_and_extension_hosts();
(
plugin_host,
extension_host,
DerivedStateHost::builder().build(),
)
}

fn profiled_default_plugin_host() -> PluginHost {
read_runtime_delivery_profile()
.plugin_host_builder()
.build()
}

fn profiled_default_extension_host() -> RuntimeExtensionHost {
read_runtime_delivery_profile()
.extension_host_builder()
.build()
}

pub(crate) fn run() -> Result<(), RuntimeEntrypointError> {
let (plugin_host, extension_host, derived_state_host) = profiled_default_hosts();
run_with_hosts(plugin_host, extension_host, derived_state_host)
}

pub(crate) fn run_with_plugin_host(plugin_host: PluginHost) -> Result<(), RuntimeEntrypointError> {
run_with_hosts(
plugin_host,
RuntimeExtensionHostBuilder::new().build(),
profiled_default_extension_host(),
DerivedStateHost::builder().build(),
)
}
Expand All @@ -33,7 +59,7 @@ pub(crate) fn run_with_extension_host(
extension_host: RuntimeExtensionHost,
) -> Result<(), RuntimeEntrypointError> {
run_with_hosts(
PluginHostBuilder::new().build(),
profiled_default_plugin_host(),
extension_host,
DerivedStateHost::builder().build(),
)
Expand All @@ -42,11 +68,8 @@ pub(crate) fn run_with_extension_host(
pub(crate) fn run_with_derived_state_host(
derived_state_host: DerivedStateHost,
) -> Result<(), RuntimeEntrypointError> {
run_with_hosts(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
derived_state_host,
)
let (plugin_host, extension_host) = profiled_default_plugin_and_extension_hosts();
run_with_hosts(plugin_host, extension_host, derived_state_host)
}

pub(crate) fn run_with_hosts(
Expand Down Expand Up @@ -204,21 +227,16 @@ fn pin_runtime_thread_if_requested() {
}

pub(crate) async fn run_async() -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
DerivedStateHost::builder().build(),
None,
)
.await
let (plugin_host, extension_host, derived_state_host) = profiled_default_hosts();
run_async_with_hosts(plugin_host, extension_host, derived_state_host, None).await
}

pub(crate) async fn run_async_with_plugin_host(
plugin_host: PluginHost,
) -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts(
plugin_host,
RuntimeExtensionHostBuilder::new().build(),
profiled_default_extension_host(),
DerivedStateHost::builder().build(),
None,
)
Expand All @@ -229,7 +247,7 @@ pub(crate) async fn run_async_with_extension_host(
extension_host: RuntimeExtensionHost,
) -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts(
PluginHostBuilder::new().build(),
profiled_default_plugin_host(),
extension_host,
DerivedStateHost::builder().build(),
None,
Expand All @@ -240,13 +258,8 @@ pub(crate) async fn run_async_with_extension_host(
pub(crate) async fn run_async_with_derived_state_host(
derived_state_host: DerivedStateHost,
) -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
derived_state_host,
None,
)
.await
let (plugin_host, extension_host) = profiled_default_plugin_and_extension_hosts();
run_async_with_hosts(plugin_host, extension_host, derived_state_host, None).await
}

pub(crate) async fn run_async_with_hosts(
Expand Down Expand Up @@ -313,9 +326,10 @@ async fn run_async_with_hosts_and_optional_shutdown(
pub(crate) async fn run_async_with_kernel_bypass_ingress(
packet_ingest_rx: ingest::RawPacketBatchReceiver,
) -> Result<(), RuntimeEntrypointError> {
let (plugin_host, extension_host) = profiled_default_plugin_and_extension_hosts();
run_async_with_hosts_and_kernel_bypass_ingress(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
plugin_host,
extension_host,
DerivedStateHost::builder().build(),
None,
packet_ingest_rx,
Expand All @@ -330,7 +344,7 @@ pub(crate) async fn run_async_with_plugin_host_and_kernel_bypass_ingress(
) -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts_and_kernel_bypass_ingress(
plugin_host,
RuntimeExtensionHostBuilder::new().build(),
profiled_default_extension_host(),
DerivedStateHost::builder().build(),
None,
packet_ingest_rx,
Expand All @@ -344,7 +358,7 @@ pub(crate) async fn run_async_with_extension_host_and_kernel_bypass_ingress(
packet_ingest_rx: ingest::RawPacketBatchReceiver,
) -> Result<(), RuntimeEntrypointError> {
run_async_with_hosts_and_kernel_bypass_ingress(
PluginHostBuilder::new().build(),
profiled_default_plugin_host(),
extension_host,
DerivedStateHost::builder().build(),
None,
Expand All @@ -358,9 +372,10 @@ pub(crate) async fn run_async_with_derived_state_host_and_kernel_bypass_ingress(
derived_state_host: DerivedStateHost,
packet_ingest_rx: ingest::RawPacketBatchReceiver,
) -> Result<(), RuntimeEntrypointError> {
let (plugin_host, extension_host) = profiled_default_plugin_and_extension_hosts();
run_async_with_hosts_and_kernel_bypass_ingress(
PluginHostBuilder::new().build(),
RuntimeExtensionHostBuilder::new().build(),
plugin_host,
extension_host,
derived_state_host,
None,
packet_ingest_rx,
Expand Down
4 changes: 2 additions & 2 deletions crates/sof-observer/src/app/runtime/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub(super) use crate::{
framework::{
CheckpointBarrierReason, DatasetEvent, DerivedStateHost, DiskDerivedStateReplaySource,
FeedWatermarks, InMemoryDerivedStateReplaySource, ObservedRecentBlockhashEvent, PluginHost,
PluginHostBuilder, RawPacketEvent, ReorgEvent, RuntimeExtensionDispatchMetrics,
RuntimeExtensionHost, RuntimeExtensionHostBuilder, ShredEvent, SlotStatusEvent,
RawPacketEvent, ReorgEvent, RuntimeExtensionDispatchMetrics, RuntimeExtensionHost,
ShredEvent, SlotStatusEvent,
},
ingest,
reassembly::dataset::DataSetReassembler,
Expand Down
Loading
Loading