//! Demonstrator: show what the inference_thread_count tracing event //! emits in production, across all eight (workload, on_battery, //! gpu_offloaded) tuples. //! //! Run with: //! cargo run -p magnotia-core --example tuning_log_demo //! //! Output is to stderr (tracing's default). Each unique tuple emits //! exactly one INFO line; subsequent calls with the same tuple are //! silenced by the per-process log-once cache. use lumotia_core::tuning::{inference_thread_count, Workload}; fn main() { tracing_subscriber::fmt() .with_env_filter("lumotia_core=info") .with_target(true) .with_writer(std::io::stderr) .init(); let cores = num_cpus::get_physical(); let logical = num_cpus::get(); eprintln!("Host: {cores} physical / {logical} logical cores\n"); for (label, override_value) in [ ("AC override", Some("ac")), ("Battery override", Some("battery")), ("No override (real sysfs probe)", None), ] { match override_value { Some(v) => std::env::set_var("MAGNOTIA_POWER_STATE_OVERRIDE", v), None => std::env::remove_var("MAGNOTIA_POWER_STATE_OVERRIDE"), } // Cache invalidation so the live probe re-runs each section. // Override paths bypass the cache anyway; this is for the // no-override block that actually hits sysfs. eprintln!("--- {label} ---"); for &(workload, gpu) in &[ (Workload::Llm, false), (Workload::Llm, true), (Workload::Whisper, false), (Workload::Whisper, true), ] { let n = inference_thread_count(workload, gpu); let w = format!("{workload:?}"); eprintln!(" {w:>8} gpu_offloaded={gpu:>5} -> {n} threads"); } eprintln!(); } }