spark_runtime/progress.rs
1// SPDX-License-Identifier: AGPL-3.0-only
2
3//! Structured startup-progress events for the Atlas TUI.
4//!
5//! Call sites next to the existing human-readable log lines emit ADDITIONAL
6//! `debug!`-level events under the dedicated [`TARGET`]. They are invisible on
7//! the plain-log path at the default `info` filter — the grepped output the
8//! benchmark rigs depend on does not change by a byte — while the TUI's
9//! capture layer enables this target unconditionally and decodes the typed
10//! fields.
11//!
12//! Discriminated by the `ev` field:
13//! `phase` — `phase` (0..=11), `name`
14//! `preflight` — `disk_gb`, `free_gb`
15//! `shard_start` — `shard` (1-based), `total`, `name`
16//! `shard_done` — `shard`, `total`, `used_gb`, `free_gb`
17//! `layer` — `layer` (0-based highest loaded), `total`
18//! `ready` — `port`
19
20/// Tracing target the TUI capture layer filters on. Keep in sync with
21/// `spark-server/src/tui/capture_layer.rs`.
22pub const TARGET: &str = "atlas::tui::progress";
23
24/// A named startup phase has begun. `phase` is the serve() phase index.
25pub fn phase(phase: u8, name: &str) {
26 tracing::debug!(target: "atlas::tui::progress", ev = "phase", phase, name);
27}
28
29/// Weight-load preflight: total on-disk GB (the overall-bar denominator).
30pub fn preflight(disk_gb: f64, free_gb: f64) {
31 tracing::debug!(target: "atlas::tui::progress", ev = "preflight", disk_gb, free_gb);
32}
33
34/// A safetensors shard load has started.
35pub fn shard_start(shard: usize, total: usize, name: &str) {
36 tracing::debug!(target: "atlas::tui::progress", ev = "shard_start", shard, total, name);
37}
38
39/// A shard finished; GPU memory snapshot alongside.
40pub fn shard_done(shard: usize, total: usize, used_gb: f64, free_gb: f64) {
41 tracing::debug!(
42 target: "atlas::tui::progress",
43 ev = "shard_done",
44 shard,
45 total,
46 used_gb,
47 free_gb
48 );
49}
50
51/// Layer-build progress (sampled by the weight loaders).
52pub fn layer(layer: usize, total: usize) {
53 tracing::debug!(target: "atlas::tui::progress", ev = "layer", layer, total);
54}
55
56/// The server is listening; startup is complete.
57pub fn ready(port: u16) {
58 tracing::debug!(target: "atlas::tui::progress", ev = "ready", port);
59}