Files
Lumotia/crates/core/examples/tuning_log_demo.rs
Jake 089349d966
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled
agent: lumotia-rebrand — rust workspace crates magnotia-* -> lumotia-*
Phase 2 of the rebrand cascade. Renames all 9 workspace crates from
magnotia-* to lumotia-* plus the src-tauri binary crate name:

- magnotia-ai-formatting   -> lumotia-ai-formatting
- magnotia-audio           -> lumotia-audio
- magnotia-cloud-providers -> lumotia-cloud-providers
- magnotia-core            -> lumotia-core
- magnotia-hotkey          -> lumotia-hotkey
- magnotia-llm             -> lumotia-llm
- magnotia-mcp             -> lumotia-mcp
- magnotia-storage         -> lumotia-storage
- magnotia-transcription   -> lumotia-transcription
- magnotia                 -> lumotia (src-tauri binary)
- magnotia_lib             -> lumotia_lib (src-tauri lib target)

Crate directories (crates/audio/ etc.) stay as-is; only the Cargo.toml
[package] name field changes plus all consumer module imports
(magnotia_core -> lumotia_core, etc.).

Remaining magnotia_* references at this point are intentional and
scoped to later phases: tracing targets (Phase 4), DB setting keys
magnotia_preferences/magnotia_history (Phase 5).

cargo build --workspace passes. cargo test --workspace: 330 pass, 0 fail.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 08:48:09 +01:00

51 lines
1.8 KiB
Rust

//! 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!();
}
}