🐛 The census line named its fields by hand and had fallen thirty-five counters behind the vocabulary
`crates/reims-vgpu`, Vulkan pathway, observability only — no product behaviour
changes and no guest-visible path is touched.
## What was wrong
`engine_counters!` generates the atomic struct, the snapshot, the reset and the
delta from one list of names, precisely so a counter cannot half-exist. The
line that *prints* them was not generated: `census::emit_engine_delta` carried a
hand-written format string naming 58 fields, against a vocabulary of 102.
So 44 counters were incremented correctly by product code and printed nowhere.
Nine of those are legitimately absent — they are absolute high-waters that
`registry_pressure` prints beside the prose explaining each — leaving **35 rate
counters that no boot could be asked for**. A counter in that state reads
exactly like a code path that never runs, which is this module's own documented
trap for a missing `delta_since` arm, one step further along.
That cost real work: a twelve-boot interleaved A/B was running to read the four
`dynstate_*_held` counters and could not have answered its own question, because
all four were among the 35. It was stopped rather than finished.
## What changed
- `engine_counters!` gains a fourth group, `pool_levels`, holding the nine
high-waters and instantaneous levels. It is merged from `ResourcePools` like
`pool_sourced`, but `delta_since` now **carries these through unchanged**
rather than subtracting: a high-water minus an earlier high-water is not a
high-water, and it reads as a plausible zero once the true maximum is behind
the window.
- The macro generates `CounterSnapshot::delta_fields`, one `(name, value)` per
rate counter in declaration order, `pool_levels` excluded.
- `emit_engine_delta` walks that instead of naming anything. The line now
carries every rate counter, 94 fields, and cannot drift from the vocabulary
again — this is "derive, don't duplicate and compare" from `AGENTS.md`, with
the second spelling deleted rather than checked.
Putting a level in the wrong group is now the only way to get it onto the
per-interval line, and that is a visible edit rather than an omission. Field
names and `name=value` spelling are unchanged, so any parser keyed on those is
unaffected; the field *count* per line rises from 58 to 94.
## What this measured
One driven macos-13 boot (rail macos-13, sustained-animation probe, 35 s, host
quiesced, `rm`'d fail log, `vk_caps` confirms exactly one boot in the log, no
`guest kernel panic` in the boot's stdout). 88 census windows, 1 019 548 chains,
1 016 068 batched draws at 14.8 draws/CB.
The question the stopped run existed to answer, now answerable:
| counter | share of `chain_phase chains` |
|---|---|
| `dynstate_pipeline_held` | 75.9 % |
| `dynstate_viewport_held` | 75.9 % |
| `dynstate_scissor_held` | 71.2 % |
So `pools::CbGraphicsState` (5fb5414f) is **not inert**: three draws in four
join a command buffer already carrying their pipeline and viewport, and skip
both. `viewport_held` equals `pipeline_held` exactly in every one of the 88
windows, which is the cache's own construction — a pipeline change clears the
viewport — rather than a coincidence.
Note this refines 5fb5414f's "nineteen draws in twenty": that figure was the
per-draw map, and 75.9 % is the share reused *across draws of one command
buffer*, which is the narrower and more honest denominator.
`dynstate_stencil_held` is 0 in all 88 windows. It is out of *stencil* draws,
and this workload issues none, so that is a null denominator and not a defect —
it is not evidence about the stencil arm either way.
## Population, and what was not verified
This was a **paced 60 Hz boot** (`present_hz` 60.0-60.3 tracking `offered_hz`
exactly, `busy_fence=0`), i.e. the slow population. The hold shares are ratios
of counts and counts survive that, but no per-draw timing is quoted from it and
none should be. No A/B was run: this commit changes what is printed, not what
is done, so there is nothing to score.
Not verified: the arm64/Metal pathway (no Apple host — the change is in
`backend-vulkan`-gated code and the Metal arm compiles), and the copying rails
under `REIMS_VGPU_GUEST_IMPORT=off` (untouched by this change).
## Checks
- `cargo test -p reims-vgpu --no-default-features --features
backend-vulkan,host-window -- --test-threads=1`: 1989 passed, 0 failed. The
2 ignored are the gitignored wire fixtures on a non-Apple checkout.
- clippy `-D warnings` clean on all three arms: `backend-metal` via
`--target aarch64-apple-darwin`, and `backend-vulkan,host-window` both
default-target and via `--target x86_64-unknown-linux-gnu`.
This commit is contained in:
1 parent
5fb5414f48
commit
de37dc579b
2 files changed
+75
-93
No files matched your search
@@ -2,14 +2,14 @@
|
||||
//!
|
||||
//! # The vocabulary is declared once
|
||||
//!
|
||||
//! [`engine_counters!`] takes the counter names and generates the five things
|
||||
//! [`engine_counters!`] takes the counter names and generates the six things
|
||||
//! that used to spell them out separately: the atomic [`EngineCounters`], the
|
||||
//! plain-`u64` [`CounterSnapshot`], and the three whole-vocabulary walks
|
||||
//! [`EngineCounters::snapshot`], [`EngineCounters::reset`] and
|
||||
//! [`CounterSnapshot::delta_since`].
|
||||
//! plain-`u64` [`CounterSnapshot`], and the four whole-vocabulary walks
|
||||
//! [`EngineCounters::snapshot`], [`EngineCounters::reset`],
|
||||
//! [`CounterSnapshot::delta_since`] and [`CounterSnapshot::delta_fields`].
|
||||
//!
|
||||
//! Writing seventy names five times is how a counter silently stops working, and
|
||||
//! neither failure mode is a compile error or a log line:
|
||||
//! Writing a hundred names six times is how a counter silently stops working,
|
||||
//! and none of the failure modes is a compile error or a log line:
|
||||
//!
|
||||
//! * missing from `reset` — the counter reports a lifetime total into a reader
|
||||
//! that asked for a window, so a per-second rate reads as monotonically rising;
|
||||
@@ -17,22 +17,39 @@
|
||||
//! is indistinguishable from "this path never ran". That is the
|
||||
//! "an event count is not a state" trap in `AGENTS.md` with the count itself
|
||||
//! broken.
|
||||
//! * missing from the emitted line — the counter is correct and nobody can read
|
||||
//! it, which is the same thing from the outside. This is the one that actually
|
||||
//! happened: `engine_delta` named its fields by hand and had fallen **35
|
||||
//! counters** behind the vocabulary, so a run built to read four of them
|
||||
//! measured nothing and reported a clean zero. `delta_fields` is generated for
|
||||
//! that reason, and the emitter now walks it instead of naming anything.
|
||||
//!
|
||||
//! All five lists were checked against each other before this collapse and all
|
||||
//! five agreed, so the macro changes no behaviour. What it changes is that they
|
||||
//! can no longer disagree.
|
||||
//!
|
||||
//! The three groups are a real distinction, not a formatting one. `windowed` is
|
||||
//! The four groups are a real distinction, not a formatting one. `windowed` is
|
||||
//! zeroed by `reset()`; `cumulative` deliberately survives it, because a
|
||||
//! device-loss count is a fact about the boot and not about the measurement
|
||||
//! window, and only `reset_all()` clears it; `pool_sourced` has no atomic at all
|
||||
//! and is merged in from `ResourcePools` by `engine::counter_snapshot`.
|
||||
//!
|
||||
//! `pool_levels` is merged in the same way as `pool_sourced` but is not a rate:
|
||||
//! every field in it is an absolute high-water or an instantaneous level, so
|
||||
//! subtracting two readings of one yields nonsense that reads as a plausible
|
||||
//! zero. That is why the group exists rather than a comment saying so —
|
||||
//! `delta_since` carries these through unchanged, `delta_fields` omits them, and
|
||||
//! `census::emit_registry_pressure` prints them absolute beside the prose that
|
||||
//! says how each is read. Putting a level in the wrong group is now the only way
|
||||
//! to get it onto the per-interval line, and that is a visible edit rather than
|
||||
//! an omission.
|
||||
//!
|
||||
//! # A field with no named reader is not dead
|
||||
//!
|
||||
//! [`CounterSnapshot`] is consumed only by the integration tests in `tests/`.
|
||||
//! No product code reads it and no log line emits it, so a sweep for "fields
|
||||
//! nobody references" reports most of this struct. Twenty-seven of the
|
||||
//! [`CounterSnapshot`] is named field-by-field only by the integration tests in
|
||||
//! `tests/`; the census reaches it through the generated `delta_fields`, which
|
||||
//! mentions no name. So a sweep for "fields nobody references" still reports
|
||||
//! most of this struct. Twenty-seven of the
|
||||
//! seventy-one came back that way. Do not act on that sweep: the struct derives
|
||||
//! `Debug` and every assertion in those tests prints the *whole* snapshot on
|
||||
//! failure (`"...: {d:?}"`), so the unasserted fields are the diagnostic context
|
||||
@@ -90,6 +107,7 @@ macro_rules! engine_counters {
|
||||
windowed { $($(#[$wm:meta])* $win:ident,)* }
|
||||
cumulative { $($(#[$cm:meta])* $cum:ident,)* }
|
||||
pool_sourced { $($(#[$pm:meta])* $pool:ident,)* }
|
||||
pool_levels { $($(#[$lm:meta])* $lvl:ident,)* }
|
||||
) => {
|
||||
/// Process-wide product-path counters (resettable for tests).
|
||||
#[derive(Debug, Default)]
|
||||
@@ -105,6 +123,7 @@ macro_rules! engine_counters {
|
||||
$($(#[$wm])* pub $win: u64,)*
|
||||
$($(#[$cm])* pub $cum: u64,)*
|
||||
$($(#[$pm])* pub $pool: u64,)*
|
||||
$($(#[$lm])* pub $lvl: u64,)*
|
||||
}
|
||||
|
||||
impl EngineCounters {
|
||||
@@ -116,6 +135,7 @@ macro_rules! engine_counters {
|
||||
$($win: self.$win.load(Ordering::Relaxed),)*
|
||||
$($cum: self.$cum.load(Ordering::Relaxed),)*
|
||||
$($pool: 0,)*
|
||||
$($lvl: 0,)*
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,13 +155,47 @@ macro_rules! engine_counters {
|
||||
/// This reading minus an earlier one, field by field. Saturating
|
||||
/// because a `reset` between the two readings makes `earlier`
|
||||
/// larger, and a window of "no work" must read 0 rather than wrap.
|
||||
///
|
||||
/// `pool_levels` fields are **carried through unchanged**, not
|
||||
/// subtracted: a high-water mark minus an earlier high-water mark is
|
||||
/// not a high-water mark, and it reads as 0 for the rest of a boot
|
||||
/// once the true maximum is behind the window. So the difference of
|
||||
/// two readings still holds the level, and a caller that prints one
|
||||
/// gets the answer rather than a plausible zero.
|
||||
pub fn delta_since(&self, earlier: &CounterSnapshot) -> CounterSnapshot {
|
||||
CounterSnapshot {
|
||||
$($win: self.$win.saturating_sub(earlier.$win),)*
|
||||
$($cum: self.$cum.saturating_sub(earlier.$cum),)*
|
||||
$($pool: self.$pool.saturating_sub(earlier.$pool),)*
|
||||
$($lvl: self.$lvl,)*
|
||||
}
|
||||
}
|
||||
|
||||
/// Every field that is a **rate** — one `(name, value)` pair per
|
||||
/// counter that means "this many since the last reading", in
|
||||
/// declaration order.
|
||||
///
|
||||
/// This is what `runtime::drain::census` prints as `engine_delta`,
|
||||
/// and it exists so that line cannot drift from the vocabulary. It
|
||||
/// used to be a hand-written format string naming its fields twice,
|
||||
/// and it had silently fallen 35 counters behind: a name added to
|
||||
/// this macro got a field, a reset and a delta, and then printed
|
||||
/// nowhere. That reads exactly like a path that never runs, which is
|
||||
/// the same trap this module's docs describe for a missing
|
||||
/// `delta_since` arm, one step further along — and it cost a
|
||||
/// twelve-boot A/B run that could not answer its own question,
|
||||
/// because the four counters it was built to read were among them.
|
||||
///
|
||||
/// `pool_levels` is excluded on purpose. Those are absolute
|
||||
/// high-waters, they are not per-interval, and `registry_pressure`
|
||||
/// prints them beside the prose that says how to read each one.
|
||||
pub fn delta_fields(&self) -> Vec<(&'static str, u64)> {
|
||||
vec![
|
||||
$((stringify!($win), self.$win),)*
|
||||
$((stringify!($cum), self.$cum),)*
|
||||
$((stringify!($pool), self.$pool),)*
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -604,6 +658,9 @@ engine_counters! {
|
||||
target_free_allocs,
|
||||
target_recycle_admits,
|
||||
target_recycle_cap_drops,
|
||||
}
|
||||
|
||||
pool_levels {
|
||||
/// High-water mark of the non-pinned resident population, in slots.
|
||||
///
|
||||
/// The demand, with no ceiling to read it against: this population is
|
||||
|
||||
@@ -2665,89 +2665,14 @@ fn emit_engine_delta() {
|
||||
};
|
||||
let d = now.delta_since(&prev.unwrap_or_default());
|
||||
*prev = Some(now);
|
||||
crate::observe::off(format!(
|
||||
"engine_delta creates={} allocs={} batch_opens={} batch_joins={} batch_flushes={} \
|
||||
batch_flush_draws={} batch_readback_joins={} readbacks={} readback_bytes={} render_post_wait_skips={} \
|
||||
target_reads={} target_read_bytes={} gpu_stamps={} pipeline_misses={} \
|
||||
shader_misses={} shader_hits={} shader_digest_hits={} shader_hash_words={} \
|
||||
pass_misses={} layout_misses={} sampler_misses={} \
|
||||
sampled_cache_hits={} sampled_identity_hits={} sampled_cache_hit_bytes={} \
|
||||
sampled_cache_misses={} sampled_reuploads={} \
|
||||
sampled_reupload_bytes={} sampled_gathers={} sampled_gather_bytes={} \
|
||||
sampled_gather_skips={} sampled_gather_skip_bytes={} \
|
||||
sampled_guest_imports={} sampled_guest_import_bytes={} \
|
||||
sampled_gather_unvouched={} sampled_gather_unretained={} \
|
||||
draw_cover_full={} draw_cover_loaded_full_scissor={} \
|
||||
draw_cover_loaded_partial_scissor={} \
|
||||
buffer_guest_imports={} buffer_guest_import_bytes={} \
|
||||
buffer_guest_gathers={} buffer_guest_gather_bytes={} \
|
||||
buffer_guest_gather_regions={} \
|
||||
buffer_gather_dispatches={} buffer_gather_declined={} \
|
||||
buffer_bind_reuses={} \
|
||||
buffer_snapshot_binds={} \
|
||||
guest_write_linear={} guest_write_rects={} guest_write_regions={} \
|
||||
guest_write_dispatches={} guest_write_scatter_declined={} \
|
||||
seed_uploads={} seed_upload_bytes={} \
|
||||
ring_retire_blocks={} target_evicts={} desc_pool_grow={} gen_mismatch={}",
|
||||
d.creates,
|
||||
d.allocs,
|
||||
d.batch_opens,
|
||||
d.batch_joins,
|
||||
d.batch_flushes,
|
||||
d.batch_flush_draws,
|
||||
d.batch_readback_joins,
|
||||
d.readbacks,
|
||||
d.readback_bytes,
|
||||
d.render_post_wait_skips,
|
||||
d.target_reads,
|
||||
d.target_read_bytes,
|
||||
d.gpu_stamps,
|
||||
d.pipeline_misses,
|
||||
d.shader_misses,
|
||||
d.shader_hits,
|
||||
d.shader_digest_hits,
|
||||
d.shader_hash_words,
|
||||
d.pass_misses,
|
||||
d.layout_misses,
|
||||
d.sampler_misses,
|
||||
d.sampled_cache_hits,
|
||||
d.sampled_identity_hits,
|
||||
d.sampled_cache_hit_bytes,
|
||||
d.sampled_cache_misses,
|
||||
d.sampled_reuploads,
|
||||
d.sampled_reupload_bytes,
|
||||
d.sampled_gathers,
|
||||
d.sampled_gather_bytes,
|
||||
d.sampled_gather_skips,
|
||||
d.sampled_gather_skip_bytes,
|
||||
d.sampled_guest_imports,
|
||||
d.sampled_guest_import_bytes,
|
||||
d.sampled_gather_unvouched,
|
||||
d.sampled_gather_unretained,
|
||||
d.draw_cover_full,
|
||||
d.draw_cover_loaded_full_scissor,
|
||||
d.draw_cover_loaded_partial_scissor,
|
||||
d.buffer_guest_imports,
|
||||
d.buffer_guest_import_bytes,
|
||||
d.buffer_guest_gathers,
|
||||
d.buffer_guest_gather_bytes,
|
||||
d.buffer_guest_gather_regions,
|
||||
d.buffer_gather_dispatches,
|
||||
d.buffer_gather_declined,
|
||||
d.buffer_bind_reuses,
|
||||
d.buffer_snapshot_binds,
|
||||
d.guest_write_linear,
|
||||
d.guest_write_rects,
|
||||
d.guest_write_regions,
|
||||
d.guest_write_dispatches,
|
||||
d.guest_write_scatter_declined,
|
||||
d.seed_uploads,
|
||||
d.seed_upload_bytes,
|
||||
d.ring_retire_blocks,
|
||||
d.target_evicts,
|
||||
d.desc_pool_grow,
|
||||
d.gen_mismatch,
|
||||
));
|
||||
// Generated from the counter vocabulary rather than named here, so this line
|
||||
// cannot fall behind it again; see `CounterSnapshot::delta_fields`.
|
||||
let mut line = String::from("engine_delta");
|
||||
for (name, value) in d.delta_fields() {
|
||||
use std::fmt::Write as _;
|
||||
let _ = write!(line, " {name}={value}");
|
||||
}
|
||||
crate::observe::off(line);
|
||||
emit_registry_pressure(&now);
|
||||
emit_draw_phase();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user