de37dc579b86a26c4e2dd671817f5eb039ba2f8b
2048
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
de37dc579b |
🐛 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` (
|
||
|
|
5fb5414f48 |
⚡ The viewport a draw asks for is the one the driver already has, nineteen draws in twenty
crates/reims-vgpu, Vulkan backend, both pathways (recording is shared; measured
on x86/dGPU).
Two commits' worth of reading landed first, then a third change built on it.
## What the twelve interleaved boots said about the previous two
Two pins differing only by `ShaderVariant` and `VertexBindPlan`, A,B,A,B on one
quiesced host, scored over the fast population. Per draw:
before (n=4) after (n=6)
reflect_us 0.340 [0.332..0.345] 0.021 [0.020..0.021]
sampled_us 1.911 [1.861..1.972] 1.640 [1.574..1.691]
engine_us 6.235 [6.065..6.338] 6.208 [6.033..6.283]
binds_us 2.477 [2.418..2.525] 2.636 [2.510..2.695]
draw_us/draw 13.33 [13.05..13.61] 13.03 [12.82..13.44]
present_hz 114.25 [112.90..115.40] 114.16 [113.40..115.30]
`reflect_us` −94 % and `sampled_us` −14 %, both disjoint, with `engine_us` — a
phase neither change touches — flat as the control. `binds_us` moved the *wrong*
way with ranges that touch, and the sub-column where `VertexBindPlan` removed
two set builds rose 0.04 us, which removing work cannot cause; that is
boot-to-boot spread, and its doc now says the change is unconfirmed rather than
claiming it. Frames did not move, which is what a 2.3 % per-draw change is
supposed to look like here. Both readings are recorded next to the code.
A first attempt ran the pins in sequence and read `engine_us` **+18 %** with
`gpu occupancy` up and `present_hz` down — the GPU clocking down between the
groups. Interleaving is not optional for a pin comparison on this host, and
`AGENTS.md` now carries the `pkill` rule that made the first interleaved attempt
kill its own runner.
## What this commit adds
Every batched draw re-recorded `vkCmdBindPipeline`, `vkCmdSetViewport` and
`vkCmdSetScissor` whatever its predecessor in the same command buffer had
already bound, and built two fresh `Vec`s to do it. Pipeline binding and dynamic
state are properties of a command buffer's *recording*, invalidated at
`vkBeginCommandBuffer` and not at a render pass boundary — which is what makes
skipping them legal on a path where every draw opens and closes its own pass.
`CbGraphicsState` remembers what the recording command buffer carries. The one
rule that makes it sound is that **a pipeline change clears the dynamic half**:
a pipeline declaring a state statically stops it being dynamic, this device does
not build every pipeline with the same dynamic-state list
(`STENCIL_REFERENCE` only appears on stencil pipelines), so a cached dynamic
value cannot cross a pipeline change. One line, and nobody has to answer "which
states did which pipeline declare".
The two `Vec`s become pools-owned scratch, swapped with the bound array rather
than cloned, so the comparison costs no allocation and the per-draw allocation
goes away with it.
Counted on `EngineCounters` atomics, not `note_store_route`: four route calls a
draw is four global-mutex acquisitions, which at 30 000 draws a second would
have cost more than the skips save. `dynstate_pipeline_held` is the one to read
first — it is the ceiling on the other three by construction.
`forget_pass_echo` drops this state with the echo, because they are one fact and
the new half is the dangerous one: a stale echo makes a draw skip an instrument,
a stale `CbGraphicsState` makes it skip a real `vkCmdSetViewport` on a handle a
`vkBeginCommandBuffer` has since reset.
Tests: five over the two matchers, per field and per length, because a missed
field renders the draw through its predecessor's viewport with no error
anywhere. Bit patterns and not `==`, with a test pinning that `-0.0` does not
match `0.0` — resending is always safe and the comparison may be stricter than
float equality but never looser.
Verified: `cargo test -p reims-vgpu --no-default-features
--features backend-vulkan,host-window -- --test-threads=1` — 1907+4+3+1+10+12+53
passed, 0 failed, 5 ignored. Clippy clean with `-D warnings` on the Vulkan arm
and on `--target aarch64-apple-darwin --features backend-metal`.
Not verified: this commit's own change is not booted. Its A/B and the
`dynstate_*_held` rates are the next step — if `dynstate_pipeline_held` is near
zero, consecutive draws never share a pipeline and the cache is inert.
|
||
|
|
f879e0de10 |
📝 The bracket in a pkill pattern protects one shell, and the runner that launched it is not that shell
AGENTS.md, verification section. The existing rule says to bracket one character of every `pkill -f` pattern because the shell issuing it carries the pattern in its own command line. True, and incomplete in a way that cost a chain run here: the bracket protects the *issuing* shell and nothing above it. `kb/harness/binab.sh` takes two pinned QEMU paths as argv. Both contain `reims-vgpu` after `qemu-system-x86_64`, so its own command line matches `ab.sh`'s bracketed `qemu-system-x86_6[4].*reims-vgpu`, and the first boot it starts kills its parent. The run printed one `=== round 1 arm A ===` line, wrote `MEMOABDONE`, and the systemd unit reported success — a twelve-boot A/B that produced nothing and looked finished. The rule is now stated as the fix rather than as the mechanism: a pinned path crosses as an exported variable, never as an argument, because an environment variable is not in `/proc/pid/cmdline`. Verified: no code change. Documentation only. |
||
|
|
4c5d0c902b |
⚡ The module walk two draws in one apart could not disagree about, answered once per shader
crates/reims-vgpu, runtime, both backends (the walk is backend-independent; measured on x86/Vulkan). `sampled_phase`'s `Part::Reflect` brackets two per-draw walks and its module doc already named the fix: "computing both at translate time and holding them in `m2v_cache`". On a driven macos-13 sustained-animation boot it reads 10 486 us/s over 29 944 draws — **0.35 us a draw**, 2.6 % of a ~13.3 us draw. The larger half is `spirv_bind::sampler_bindings`, a walk of **every instruction** in the module, run twice a draw (vertex and fragment) for an answer that depends on nothing but the module. It now runs once per shader variant. The smaller half — the constexpr static-sampler scan of `reflection.bindings` — is left where it is: it walks a handful of entries and its arms return typed declines the memo would have to carry. ## Why a struct and not a second cache `CachedShader::fragment_words` becomes `CachedShader::variant`, returning a `ShaderVariant` that carries the words **and** the walk of those words together, memoized on one key. That shape is the point rather than tidiness. Relocation renumbers a module's descriptor bindings, so `sampler_bindings` taken over the unrelocated words is a wrong answer for a draw that relocated them — a real sampler bound at the wrong number, with nothing to say so. The draw path took the relocation flags at line 5557 and walked the words at line 6206, four hundred lines apart, and the two agreed only because both call sites happened to be handed the same pair. With one key there is one call and the disagreement cannot be written. `(false, false)` is now a variant like any other rather than a short-circuit, because it is the one a vertex module always takes and its walk is worth caching for the same reason. ## Tests - `every_variants_sampler_bindings_are_a_walk_of_that_variants_words` — over all four flag pairs, against a fresh walk of that variant's own words. This is the drift the struct exists to prevent. - `a_variant_is_memoized_rather_than_rewalked` — `Arc::ptr_eq` on two calls, so the per-shader claim is checked and not just asserted in prose. - `test_module_with_samplers` joins `test_module_with_two_sampled_images` in `spirv_bind`, for the reason that fixture's doc already gives: the opcode numbers are constants in that file. A sampler and not a sampled image, because `sampler_bindings` partitions set 0 by pointee type and an image fixture would make the test vacuous. - `fragment_words_variants_match_direct_relocation_and_cache` renamed and repointed; it still checks the relocation itself. The first test was written asserting the fixture's own binding numbers and failed: `CachedShader::new` runs `widen_sampled_bands` over every module, so the base variant is already in the device's numbering. The assertion was wrong, not the code, and it now says so. Verified: `cargo test -p reims-vgpu --no-default-features --features backend-vulkan,host-window -- --test-threads=1` — 1902+4+3+1+10+12+53 passed, 0 failed, 5 ignored. Clippy clean with `-D warnings` on the Vulkan arm and on `--target aarch64-apple-darwin --features backend-metal`. Not verified: not booted. 0.35 us of 13.3 is 2.6 %, and the elasticity beside `VBL_REPORT_EARLY` puts that under the frame-rate noise floor — `sampled_phase`'s `reflect_us` collapsing toward zero is the reading that would confirm it, not `present_hz`. |
||
|
|
026ff43cf7 |
⚡ The pass pair costs three percent of a draw and no frames, and two sets a pipeline already knew
crates/reims-vgpu, Vulkan backend, x86/dGPU pathway. One measured verdict that
closes a candidate, one work reduction, one doc note about a pathway this host
cannot boot.
## The verdict: do not build the render-pass merge here
Twenty interleaved driven macos-13 sustained-animation boots on one pin,
quiesced, ten an arm of `REIMS_VGPU_PASS_CHURN`. Scored on the driven window
and within the fast population only:
n mean range
draw_us/draw off 7 13.33 13.01 .. 14.12
on 4 13.75 13.63 .. 13.83
present_hz off 7 113.54 111.40 ..115.80
on 4 112.83 112.00 ..113.50
Six of seven `off` boots read below every `on` boot, so the per-draw column
separates at **+3.2 %, ~0.42 us of a ~13.3 us draw**. The frame rate does not:
−0.6 %, ranges nested, exactly what a 3.2 % arm looks like at this elasticity.
`passheld_*` put the reachable share at 82 % of draws, so the merge is
0.82 x 0.42 us — ~2.6 % of per-draw CPU, ~1.5 % of frames — against a second
command buffer per batch, a rewritten submission path, and a deferred pass end
whose failure mode is a render-pass scope violation on a host with no
validation layer installed. That trade is not worth taking, and the reasoning
now sits in `env::PASS_CHURN` and beside `PassObstacles` so it is not
rediscovered. Same shape as `LAYOUT_CHURN`'s verdict and for the same reason:
it is a tiler and iGPU lever, and this project has no such host.
Recorded as non-findings so they are not read as any: the `on` arm drew 4 fast
boots of 10 against `off`'s 7, which ten boots an arm cannot separate; and one
`on` boot wedged at 5.7 Hz, excluded as slow.
## What did land: `VertexBindPlan`
Two `BTreeSet<u32>` were built per draw from `desc.vertex_attributes` — which
buffer indices feed a Constant-step attribute, and which the attribute list
names at all. Both are functions of the pipeline alone, so they move to the
memoized resolution as sorted slices searched by `binary_search`; the
population is single-digit, where a tree is a pointer chase per level. Two heap
allocations and two tree builds leave the path `chain_phase` reports as
`binds_us`, this draw path's largest column at 2.90 us a draw.
Attribute it on `bind_phase`, not on frames: the unaccounted remainder of
`binds_us` (binds_us less vertex+fragment+attrs) was 0.60 us a draw on the
reference boot and this is part of it. A change that size does not separate on
`present_hz` and this commit does not claim it does.
Tests: `the_bind_plan_separates_constant_step_from_merely_named` pins the
classification rather than the code shape — a Constant-step attribute with
`format == 0` or `stride == 0` is skipped by the draw's attribute walk and must
therefore keep the zero-copy rail, while still counting as named, because that
second set is deliberately unfiltered. `an_empty_attribute_list_names_nothing`
covers the fullscreen-pass shape.
## The arm64 note
`backend::metal::render::render_core_mrt` gets a doc section recording what
reading it establishes and nothing more: it is one `MTLCommandBuffer`, one
`MTLRenderCommandEncoder`, one `commit` and one `waitUntilCompleted` **per
draw**, against the Vulkan arm's 14.6 draws per command buffer with no wait on
the recording thread. The three costs are ranked for whoever has a Mac; no
number is claimed, because this host cannot produce one.
Verified: `cargo test -p reims-vgpu --no-default-features
--features backend-vulkan,host-window -- --test-threads=1` — 1900+4+3+1+10+12+53
passed, 0 failed, 5 ignored. Clippy clean with `-D warnings` on the Vulkan arm
and on `--target aarch64-apple-darwin --features backend-metal`.
Not verified: `VertexBindPlan` has not been booted — it is a strict work
reduction with the same answers, and the boot that would score it cannot
resolve a change this size. Nothing under `backend/metal/` is test-executed on
this Linux host.
|
||
|
|
1440e4ec2b |
🔍 The merge this device could not take locally, and the probe that prices taking it at all
crates/reims-vgpu, Vulkan backend, x86/dGPU pathway. Reading plus one
default-off probe. Nothing shipping records differently.
## What `passheld_*` read
Two driven macos-13 sustained-animation boots on the previous commit's
instrument, quiesced, sum identity exact on both families of both boots:
bucket b1 (113 Hz) b2 (59 Hz)
outside_gather 849 627 81.6% 482 542 81.4%
outside_snapshot 74 540 7.2% 42 211 7.1%
no_join 64 735 6.2% 38 004 6.4%
pass_differs 42 068 4.0% 22 878 3.9%
outside_resident_layout 10 772 1.0% 6 805 1.1%
outside_sampled_upload 102 0.0% 96 0.0%
reachable 0 0 0 0
`reachable` is **zero**, and the two boots latched opposite populations and
still agree to a tenth of a point, so this is a property of the workload and
not of a boot's pace.
Every draw the attachment transition was hiding is hiding a guest gather behind
it. A gather is a `vkCmdDispatch`, which Vulkan forbids inside a render pass
instance, so holding the pass open buys nothing on its own. `dbe9b7a2` reported
the 82 % as the size of the merge; it is the size of the merge *conditional on
the gathers moving*, and that distinction is now in the code beside the ladder.
Where they would move is recorded there too: a second command buffer per batch,
dispatches into `pre` and draws into `main`, both in one `vkQueueSubmit` with a
single compute->vertex barrier at the end of `pre` replacing the ~1.3 per-draw
barriers recorded today. That needs no lookahead, because the two buffers are
recorded in parallel rather than in order. The 8.2 % in `outside_snapshot` and
`outside_resident_layout` cannot follow — both order against a write an earlier
draw of the same batch makes, so hoisting them would put them before it.
## Why a probe before that change
The ring change is large and this device has no number for what the pass pair
it removes costs. `REIMS_VGPU_PASS_CHURN=on` records one extra empty render
pass instance per loading draw — the transition a second instance needs, then a
begin/end pair on the same pass, framebuffer and area, with no draw inside it.
Pixel-neutral by construction: `LOAD`/`STORE` preserves the attachment. Gated
on loading draws because a `CLEAR` instance replayed there would clear away the
draw's own output, and because a clearing joiner gets a different `VkRenderPass`
and could never have shared an instance anyway.
Same shape as `REIMS_VGPU_LAYOUT_CHURN`: an arm that pays a cost twice prices
it once. The extra transition is not a confound — that switch's six boots put a
full-attachment transition on this host below the boot-to-boot spread.
Verified: `cargo test -p reims-vgpu --no-default-features
--features backend-vulkan,host-window -- --test-threads=1` — 1898+4+3+1+10+12+52
passed, 0 failed, 6 ignored. Clippy clean with `-D warnings` on the Vulkan arm
and on `--target aarch64-apple-darwin --features backend-metal`.
Not verified: the probe has not been booted — its A/B is the next step. macos-13
/ x86 / Vulkan / one discrete NVIDIA host only; nothing here says what a tiler
or an iGPU pays for the same pair.
|
||
|
|
f67f89549e |
🔍 The obstacle that hid every other obstacle, read past
crates/reims-vgpu, Vulkan backend, x86/dGPU pathway. Instrument only — nothing recorded changes. `de331138`'s `passmerge_*` ladder charges each draw's *nearest* obstacle to continuing the render pass its predecessor left standing. `dbe9b7a2` read it: 82.4 % of draws land in `outside_target_layout`, and `outside_gather` is zero. That answered its own question and hid the next one. The attachment transition is the single obstacle that holding the pass open removes *by construction* — `get_or_create_pass` ends every pass at `TRANSFER_SRC_OPTIMAL` and the next draw barriers it back, so a pass that never ended never left the layout and has nothing to undo — which means the published reading says which obstacle is nearest and nothing at all about what a merge is worth. This adds the second reading. `PassObstacle` replaces the ten hand-written route strings with a type, so the two ladders cannot come apart: a new obstacle fails to compile until both spellings exist. `PassObstacle::is_pass_end_artifact` names the two variants — `TargetLayout` and `MrtLayout` — that exist only because the previous draw's pass was closed, and its doc states why exactly those two: every other obstacle is work the draw owes whatever the pass did. `passheld_*` is the same exhaustive ladder with those two removed. `passheld_reachable` is what a local merge with no lookahead could take; whichever bucket holds the rest names what would have to be hoisted. The suspect is `passheld_outside_gather` — `buffer_guest_gathers` runs 1.34 per draw and a gather is a compute dispatch, which Vulkan forbids inside a pass instance — but that is a prediction, not a reading, and this is the reading. Both families stay exhaustive over draws that reach the `vkCmdBeginRenderPass`, so each sums to `chain_phase chains` and `*_no_join` equals that count less `engine_delta batch_joins`. That identity is the check on a misplaced `note`. Verified: `cargo test -p reims-vgpu --no-default-features --features backend-vulkan,host-window -- --test-threads=1` — 1898+4+3+1+10+12+52 passed, 0 failed, 6 ignored (the wire fixtures, absent on this checkout). Clippy clean with `-D warnings` on the Vulkan arm and on `--target aarch64-apple-darwin --features backend-metal`. Not verified: no boot yet — the reading this exists for is the next step. The Metal arm compiles but none of its tests run on a Linux host. |
||
|
|
e4a725bffc |
📝 The probe this harness was told not to rank changes with is the one that separates them disjointly
Component: `scripts/gpu-load-probe/gpu-load-probe.sh` — header doc only. No behaviour change; `bash -n` clean. That probe's header opened by explaining that the sustained-animation probe had saturated: ~26 800 draws and ~76 presented frames a second whatever the device did, drain duty 0.83, and a 3.9 us/chain saving worth under 0.1 % of `draws_s`. The conclusion drawn from it — "a probe the device cannot fall behind cannot rank a device change, in either direction" — is the first thing a session reads when choosing how to measure, and it is now wrong. Both premises have moved. The presenter no longer clamps at ~41 frames a second, and the device is faster: drain duty is 0.55-0.58 and a fast-latching macos-13 boot presents 109-119 Hz. On that tree the twenty-four interleaved boots of `f1765e27`, scored over their fast boots only, separate **disjointly** on this very probe — 113.2 Hz mean against 105.5 for a device doing 20.6 % more GPU work per draw, the slowest shipping boot above the fastest slowed one — while `us/draw` overlaps across the same fourteen boots. Corrected in place rather than appended to, with the original reading kept and marked as taken on a slower device, because the *shape* of that argument is still how a saturated probe should be recognised if one ever saturates again. The second claim further down — "it remains the arm for ranking a change" for the reason "that probe reaches duty 0.83 and this one does not" — is repaired to rest on the disjointness instead, since the duty figure it cited is no longer the one that boot produces. This probe keeps its own job, which the same paragraph already stated: loading one particular rail harder than a compositing page does, which is why it is worth having even when it is not the ranking arm. Verified: `bash -n` clean. No boot — this commit changes no code and asserts no new measurement; the numbers quoted are `f1765e27`'s captures re-read in `e196a3b0`. Not verified: macos-13 / x86 / Vulkan / one discrete host. Whether the sustained probe saturates again on a future faster device is exactly the thing this doc now tells the reader to re-check rather than assume. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
dbe9b7a2b5 |
📝 This device ends every render pass ready for a read that one draw in twenty wants, and the other nineteen pay to undo it
Component: `crates/reims-vgpu` — doc at the `passmerge_*` emission in
`backend/vulkan/engine/exec.rs`. No behaviour change.
# The reading
Two driven macos-13 sustained-animation boots on `de331138`'s instrument,
quiesced host, no guest panic, both fast (`present_hz` 115.0 and 114.0). Routes
summed across every census window of each boot — `store_routes` is per-window and
the last sample is not the total:
bucket b1 b2
outside_target_layout 850 698 82.4% 871 180 82.3%
outside_snapshot 75 010 7.3% 77 740 7.3%
no_join 64 295 6.2% 66 396 6.3%
pass_differs 41 904 4.1% 43 262 4.1%
reachable 0 0 0 0
The sum identity holds exactly on both — the buckets total `chain_phase chains`
(1 031 907 and 1 058 578) and `no_join` equals that count less
`engine_delta batch_joins` to the draw. The instrument is not reporting a clean
sweep of a population it cannot see.
# What it says, which is not what was predicted
The gather was the prediction and the gather is **not** the obstacle: nothing
lands in `outside_gather`. The obstacle is a layout transition this device
creates for itself.
`get_or_create_pass` ends every pass with `final_layout = TRANSFER_SRC_OPTIMAL`,
so a present blit or a guest-page readback can read the target without
transitioning it. The `LOAD` pass then declares
`initial_layout = COLOR_ATTACHMENT_OPTIMAL`, so the next draw into the same
target barriers the image all the way back.
The trade is badly priced. `target_reads` is **1 199 a second** — the present
capture and the deferred-window flush, the only consumers the transfer-src ending
exists for — against roughly **24 000 draws a second** that immediately undo it.
On this discrete host that is a barrier and probably little else. On anything
with framebuffer compression — every iGPU, every tiler, AMD DCC, Intel CCS — it
is a decompress and a recompress of the attachment per draw, which is why this
matters more off this host than on it.
# What the reading does not say
The ladder charges each draw to its **nearest** obstacle, so `outside_gather=0`
means no draw reached the gather site with nothing recorded before it — not that
gathers are rare. `buffer_guest_gathers` is 34 564/s and they are still there,
behind the layout barrier that precedes them in record order. "82.4 % becomes
mergeable if the barrier goes" is exactly what this cannot claim; what lies
behind it is the next thing to measure, after it moves.
Verified: two boots as above, sum identity exact on both, `grep 'guest kernel
panic'` clean on both boot logs, screenshots present. `cargo doc` intra-doc link
pass — 157 warnings, unchanged, none on the two links added.
Not verified: macos-13 / x86 / Vulkan / one discrete host, sustained-animation
probe only. No frame-rate claim — this run changed nothing and was not an A/B.
The compression cost asserted for tilers and iGPUs is an argument from how those
drivers work, not a measurement; no such host has been booted.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
de331138af |
🔍 Every batched draw opens its own render pass, and nothing said how many of them had to
Component: `crates/reims-vgpu` — Vulkan engine (`backend/vulkan/engine/exec.rs` and `pools/`). Observation only: nothing branches on the new state and the pass is begun exactly as before. # Why `exec.rs` already carries the note that per-draw render passes are "the ceiling on the largest GPU-side saving this device has not taken", and `join_same_target` puts that ceiling at **23 216 of 29 541 draws a second** on a driven macos-13 sustained-animation boot — 78.6 %, all rendering into the batch's own target. The ceiling is not the answer. A draw can only continue its predecessor's pass if it also records *nothing* between the two, and this device records plenty there: gather dispatches, snapshot copies, sampled uploads and four kinds of layout barrier. `buffer_guest_gathers` is 34 564/s against 29 541 draws, so a first guess is that the gather alone closes most of the 78.6 % — but 1.17 gathers per draw is a mean, and a mean cannot say whether it is one gather on every draw or five on a fifth of them. Those are a 0 % merge and a 60 % one. On this discrete host a redundant pass is cheap; the attachment stays in VRAM and `LOAD`/`STORE` cost close to nothing. On a tiler or an iGPU each pass loads and stores the whole attachment, which is the difference between a workload that fits in memory bandwidth and one that does not — so the number is worth having before either host is available to boot. # What was added `PassEcho` (pools) records the render pass instance, framebuffer and render area the last draw opened, and the command buffer it opened them in. It is forgotten wherever that CB stops being the one a draw would record into — `begin_entry`, the batch flush, teardown — and the CB handle is compared as a second lock, because command buffer handles are recycled. `exec.rs` threads one `Option<&'static str>` through the record span. Every site that emits a barrier, copy or dispatch names itself, after whatever `continue` decides the site is a no-op for that draw. The first name wins: the question is what ended the standing pass, so the first thing recorded is the answer. It holds the route name itself rather than a tag translated later, so there is no second spelling to go an arm short. Each draw is then charged to exactly one `passmerge_*` route: `no_join`, `pass_differs`, one of nine `outside_*`, or `reachable`. The buckets are exhaustive, which is the check on the instrument rather than a scan of it: summed over a census window they equal `chain_phase chains`, and `passmerge_no_join` alone equals that count less `engine_delta batch_joins`. Verified: clippy `-D warnings` clean on all three arms (Vulkan host, Vulkan `--target x86_64-unknown-linux-gnu`, `backend-metal --target aarch64-apple-darwin`); `cargo test -p reims-vgpu --features backend-vulkan,host-window -- --test-threads=1` green, 1898 + 82 passing, no count lost. Not verified: no boot yet — the counter has not been read on a live device, so neither the distribution nor the sum identity above is confirmed. That is the next step and the reason this lands separately from anything that acts on it. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
e196a3b04a |
📝 A free-running guest pays this device back in frames, and the frame rate says so more clearly than the microseconds do
Component: `crates/reims-vgpu` — doc on `runtime::drain::census`'s
`VBL_REPORT_EARLY`, and the scoring rules in `AGENTS.md`. No behaviour change.
# The reading that was already on disk
`f1765e27` ran twenty-four interleaved driven macos-13 boots with the device
pushed 20.6 % the wrong way on purpose (`REIMS_VGPU_COMPUTE_GATHER=off`, whose
positive control was checked on every boot of the arm), and scored only which
population each boot latched into. The run also holds the answer to a different
question nobody asked it: what the *fast* boots did with the extra work.
Scored over fast boots only, driven-window medians per boot:
arm n fast present_hz mean (range) us/draw mean (range)
shipping 5 113.2 (109.8-116.3) 13.21 (12.66-14.02)
20.6 % more GPU work per draw 9 105.5 (101.4-107.7) 15.07 (13.92-16.16)
The frame rates are disjoint: the slowest shipping boot beats the fastest slowed
one. Welch t≈6.0 on n=5 vs n=9.
# Why it matters more than the 7.3 %
Two rules come out of it, and both change what a session does next.
`us/draw` **overlaps** across the same fourteen boots (14.02 against 13.92) where
`present_hz` separates them completely. The frame rate is therefore the sharper
of the two instruments, not the noisier one, and it is what a per-draw change
should be ranked by. `AGENTS.md` said the opposite — "anything normalized per
draw stays the right way to rank a change about per-draw cost" — and that is now
narrowed to attribution.
It also puts a number on the free-running branch the census doc describes.
"Work-limited" was read out of the guest's frame-scheduling contract; this makes
it a measurement, at about **0.35 frames per unit of per-draw GPU work**. That is
the sizing rule for every candidate from here: 5 % per draw is worth a boot
chain, 2 % is not measurable on this host.
Together they retire the last of the "bought microseconds and zero frames"
puzzle. Those wins were measured through a presenter that clamped at ~41 Hz. It
does not clamp now, and this run shows the frames arriving.
Verified: `cargo doc` intra-doc link pass — no new warnings (157 pre-existing,
none in the edited block; the added prose links nothing new). No boots: the
underlying twenty-four are `f1765e27`'s, re-read from their captures rather than
re-run.
Not verified: one interleaved run, macos-13 / x86 / Vulkan / one discrete host,
sustained-animation probe only. n=5 in the shipping arm is thin — the disjointness
is what carries it, not the count. The elasticity is a single point on a single
axis (GPU work per draw) and must not be assumed linear or transferred to a CPU-
side saving without measuring one.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
90ce18da7a |
📝 The 60-vs-120 split is a constant the guest defaults to and can never correct, not anything this device delivers
Component: `crates/reims-vgpu` — `runtime::drain::census` (`VBL_REPORT_EARLY`'s doc and a new `note_irq_coalesced` counter), `qemu::host_ops::enqueue`, and the boot-comparison rules in `AGENTS.md`. Six device-side hypotheses for the boot-random 60-vs-120 split have come back null this session. All six were null for one reason, now established: each was about how fast this device delivers VBL, and the guest's frame period is not derived from that. # The chain 1. The guest's compositor schedules each frame on a timer at `lastVBL + period`. Nothing in it measures VBL arrivals, divides a rate, or counts missed frames; `period` is taken verbatim from the kernel. 2. The kernel display-pipe layer ships `(lastVBL, lastVBL + fRefreshPeriod)` on every VBL notification, so `period` **is** `fRefreshPeriod`. 3. `fRefreshPeriod` is written in exactly one place, on display-mode change. It is initialised to a synthesised 1/60 s = 16 666 666 ns and only then replaced by `IOFBCurrentPixelCount * 1e9 / IOFBCurrentPixelClock`. Five early returns leave the 60 Hz default standing. 4. Those two `IOFramebuffer` properties are published only when the mode's detailed timing is marked valid, and the paravirtual framebuffer driver clears that valid bit and fills the timing with nothing — so the framebuffer layer removes both properties. Confirmed live rather than argued: over eleven driven macos-13 boots `ioreg` finds neither property on any boot — not on the 59.5-60.1 Hz ones and not on the 97.5-114.3 Hz ones. The same dump carries the detailed timing the guest built out of our timing table (pixel clock 15 848 840 000 Hz, 1920 + 10 000 by 1080 + 10 000), which works out to 8 333 332 ns, i.e. 120.00 Hz to five figures. The guest holds the inputs and the path that would use them is closed. Our 16.16 refresh encoding is confirmed correct and is not implicated. # Why it is bimodal and sticky `fRefreshPeriod` is never recomputed once set, so a boot ends on one of two values: 16 666 666 ns, where the compositor paces on it and produces exactly 60 Hz; or 0, when the first notification is sent before the mode-change path has run, which puts the next wake time in the past and lets the compositor free-run. The populations already on record are that fingerprint and nothing else: every slow boot sits in 59.5-60.5 Hz, a constant, and every fast one in 94.8-117.0 Hz, a 22 Hz spread. A paced compositor cannot vary that much; a free-running one cannot be that flat. This was visible in the data for several runs and was not read, because both populations were being summarised by a median. So the fast boots are the ones where the guest never learned a period, and the correctly-configured outcome on this pathway is the slow one. The docs say that before proposing a fix, because the obvious lever — forcing a second display-mode change, which this device owns through an offline/online cycle — would set `fRefreshPeriod` on every boot and take the good 70 % down to 60 Hz. # The counter that came with it `qemu::host_ops::enqueue` coalesces an interrupt pulse into an undelivered pulse of the same kind. That is free for a status the guest reads back and not free for an event it timestamps. `irq_coalesced_gfx` now counts it, and the first reading explains itself: 2440 coalesced against 3212 delivered on a 60 Hz boot, because a guest latched at 60 arms every 16.67 ms while this device ticks every 8.33 ms. It is a consequence of the latch rather than a cause, and it is the cheapest device-side read of which population a boot is in. Its doc states plainly that `display_vbl delivered` counts what this device wrote, not what the guest received, and that the two must not be quoted as one. Verified: 1898 lib tests plus every integration target green serially; clippy `-D warnings` clean on all three arms; `cargo doc` intra-doc link pass clean. Eleven driven macos-13 boots for the `ioreg` result, no guest panic. Not verified: no fix is landed and none is proposed here. The free-run/paced choice is a race inside the guest that this device cannot observe. Whether the same chain applies to the arm64 rail is untested and there is reason to think it differs — the guest's 60 Hz default is computed through the mach timebase with a 32-bit multiply that does not overflow at x86's 1/1 timebase and does at Apple Silicon's. macos-13 / x86 / Vulkan only. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
63d610c2c6 |
📝 A slow boot reads 10% slower per draw for a reason that has nothing to do with the device
Component: `AGENTS.md`, the boot-comparison rules. No code change. |
||
|
|
03b8205611 |
📝 The slow-latching boots are not low-clock boots, and that was the last device-side cause anyone here could name
Component: `crates/reims-vgpu` — doc on `runtime::drain::census`'s
`VBL_REPORT_EARLY`, and the exclusion list in `AGENTS.md`. No behaviour change.
|
||
|
|
f1765e271c |
📝 Making this device 20% slower did not push boots over the vsync cliff, because there is no cliff
Component: `crates/reims-vgpu` — doc on `runtime::drain::census`'s `VBL_REPORT_EARLY`, and the boot-comparison rules in `AGENTS.md`. No behaviour change. # The hypothesis worth killing A guest holding a correctly-acquired 120 Hz link ( |
||
|
|
8473b76222 |
📝 The boots that present 60 frames a second selected the 120 Hz mode, same as the ones that present 117
Component: `crates/reims-vgpu` — doc on `runtime::drain::fill_display_descriptor`, plus `kb/harness/animrefresh.sh` (gitignored) as the probe. No behaviour change. About three macos-13 boots in ten present ~60 frames a second for their whole life rather than ~100-117 ( |
||
|
|
49701ba36e |
📝 The early window that predicted the latch eight times out of eight predicts nothing, and one slow boot was the whole sample
Component: `crates/reims-vgpu` — docs on `runtime::drain::census`'s `VBL_REPORT_EARLY` and on `signal_display_refresh_classes`. No behaviour change. |
||
|
|
7e68dba216 |
📝 Forty interleaved boots say the vblank ordering does not move the latch, and that three boots in ten lose half their frame rate
Component: `crates/reims-vgpu` — doc on `runtime::drain::signal_display_refresh_classes`. No behaviour change. |
||
|
|
cad67521ea |
📝 The guest measures the rate it is served once, keeps the answer, and that one window is worth a factor of two
Component: `crates/reims-vgpu` — docs only, on `runtime::drain::census`'s `VBL_REPORT_EARLY` and on `signal_display_refresh_classes`. No behaviour change. The early-cadence instrument from |
||
|
|
982fda6d0c |
✨ The window in which the guest picks 60 Hz or 120 Hz and keeps it was over before the first census line
Component: `crates/reims-vgpu` — `runtime::drain::census::VblCensus`. An instrument only: nothing branches on the new lines and no rail changes. A macOS 13 guest latches its display link at either ~60 Hz or ~120 Hz within the first seconds of the display coming up and then holds it for the life of the boot. Which one it picks varies boot to boot on a byte-identical device, and it is worth a factor of two in presented frames, in draws and in every per-second reading taken off them — larger than any rail this device has been tuned on. Six boots of 1f36dddc's A/B split 2 fast to 1 slow on both arms. At `VBL_REPORT_EVERY` the first `display_vbl` line of a boot lands after about 1024 deliveries, roughly eleven seconds in. The guest has long since decided, so the cadence across the deciding window was not observable at all and no later line could recover it. Two captures of a fast and a slow boot on one binary differ in nothing this device logs today. So each arm's first 1024 events now report every 64 — sixteen extra lines, about half a second of resolution each, covering the first ~9 s. `VBL_EARLY_UNTIL` is declared as `VBL_REPORT_EVERY` rather than spelled 1024 a second time, so the two cadences meet exactly at the boundary and no window is measured across a change of step; a `const` assertion holds the early step a divisor of it. `hz` is computed from that step rather than from a fixed constant, which is what keeps a 64-event window and a 1024-event window the same reading. Tests: `the_vbl_census_reports_window_rate_and_separates_the_silent_arms` updated rather than worked around — it asserted "exactly one report per 1024 deliveries" and now asserts sixteen head lines that each read 125.0 Hz, which is the property that matters (the rate stays comparable across the cadence boundary). Its doc says why the count changed. The second-window assertion is untouched and still covers the ordinary cadence. Verified: 1898 lib tests plus every integration target green serially; clippy `-D warnings` clean on all three arms. Not verified: no boot has been taken with this instrument yet — the next step is to correlate early cadence against the latched rate over enough boots to band it, and one boot of each will not do that. This commit does not claim a cause for the latch, only that the evidence for one is now recordable. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
1f36dddce4 |
🐛 The vblank census printed a rate of zero whenever both its reporting arms were live, which is exactly the boot worth reading
Component: `crates/reims-vgpu` — `runtime::drain::census::VblCensus`, plus the measured result for |
||
|
|
cf77ab7e9e |
⚡ A vblank tick that found the guest between one-shot arms spent the slot it was about to ask for, halving the compositor's pace
Component: `crates/reims-vgpu` — `runtime::drain::signal_display_refresh_classes`
and its two poll arms (`signal_display_vbl_at`, `device::vbl_contended_pulse`).
x86/Vulkan and arm64 alike; nothing here is pathway-specific.
VBL is what paces the guest's compositor — WindowServer produces a frame off its
display-link callback — so the delivered rate is a ceiling on guest frame rate
however fast the present path runs.
A macOS 13 guest arms VBL **one shot at a time**: it sets bit 0 of the shared
enable word, takes the delivery, clears it inside its handler, and sets it again
when it next wants a frame. `signal_display_refresh_classes`'s own doc already
recorded the `0xc <-> 0xd` oscillation. What nothing recorded is that both
callers claimed the grid slot *before* reading that word, so a tick that sampled
the guest mid-turnaround advanced the grid timestamp and spent the slot the
guest was about to ask for. The guest re-armed a millisecond later and then
waited a further full interval, so its deliveries aliased to every other grid
point — 60 Hz out of an advertised 120.
That is the boot-to-boot regime split this repository has been classifying
around rather than explaining. Six driven macos-13 boots (the `EXTENT_NARROW`
captures, re-read for this): claims land at 117.6-118.4 Hz in every one, so the
limiter and its phase lock were never at fault. What varied is how much of that
grid reached the guest:
delivered/claimed presented frames/s draws/s
61-67 % 109 ~29 700
28-39 % 59 ~15 000
Correcting for the pre-online stretch matters when re-deriving this: `not_online`
accumulates for ~22 s before the display comes up, and dividing by the whole boot
makes a healthy 118 Hz limiter read as a broken 82 Hz one.
The fix is an ordering, not a new rail: read the enable mask first, and claim the
slot only once something is armed to receive it. It cannot deliver faster than
advertised — `claim_display_vbl` still gates every delivery on a full interval
since the last one — it only stops the device spending intervals on ticks that
deliver nothing.
The claim moved *into* the shared body rather than being reordered in each
caller. It was two lines duplicated across the locked and lock-free poll arms and
both copies carried the bug; as one line inside the body a third divergence
cannot reintroduce it. This is the same consolidation the enable-mask check
itself needed when the lock-free arm was found omitting it entirely.
Cost: the four-byte enable-mask read now happens once per poll (~240 Hz) instead
of once per claimed tick while the guest sits disarmed, off a page mapped for the
VM's lifetime.
Tests: two new, in `runtime::drain::tests`.
`a_disarmed_tick_does_not_spend_the_grid_slot` models the arm/deliver/disarm/
re-arm cycle and asserts the re-arm is served on the next poll. Verified to fail
against a hand-restored old ordering, with its own message, and to pass with it —
the probe was edited in and out rather than reverted with git.
`a_continuously_armed_guest_is_still_capped_at_the_advertised_rate` guards the
direction this change could have widened; it passes on both orderings by
construction, which is what a guard should do.
Verified: 1897 lib tests plus every integration target green serially; clippy
`-D warnings` clean on all three arms (Vulkan host, `x86_64-unknown-linux-gnu`,
and `aarch64-apple-darwin` `backend-metal`).
Not verified: no live boot yet — the A/B that would show the delivered fraction
and `present_hz` move is the next step and is not in this commit. The reasoning
is from six existing captures plus the unit model, so the mechanism is proven and
the frame-rate claim is not. arm64/Metal is untested as ever on this Linux host.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
43f005e2cb |
📝 The extent narrowing moves 12% fewer bytes across six disjoint boots and not one microsecond of GPU time
Component: `crates/reims-vgpu` — `env::EXTENT_NARROW`'s doc. No behaviour changes; the switch stays default off and every code path is untouched. `REIMS_VGPU_EXTENT_NARROW` landed in |
||
|
|
0005766b2a |
✨ Half the bytes this device gathers sit behind a shader-declared bound nothing applies, so the floor stops being asked the wrong question
Component: `crates/reims-vgpu`, x86/Vulkan pathway. New arm
`REIMS_VGPU_EXTENT_NARROW`, **default off**. No default behavior changes.
# The number
`note_extent_headroom` counts, per bind that takes the gather rail, the span it
will move and how much of it a declared object size would remove. Two driven
macos-13 sustained-animation boots, summed over each boot:
boot 1 boot 2
bext_capped_span_bytes 274.1 GB 272.9 GB
bext_would_save_bytes 274.0 GB 272.9 GB 99.97 % of the capped
bext_uncapped_span_bytes 287.3 GB 283.7 GB
gather_bytes 236.8 GB 234.9 GB
**49 % of every byte this rail moves sits behind a cap that would remove 99.97 %
of it.** The gather is ~55 % of all GPU time this device spends — established by
four `REIMS_VGPU_GUEST_IMPORT=off` boots at 6.0-6.9 GPU us/draw against eight
import-on boots at 13.7-16.0 — so this is the largest identified cut to the
largest cost in the device.
# Why it was unreachable
`ZERO_COPY_BUFFER_MIN_BYTES` is 16 KiB and it was compared against the
**narrowed** span. Essentially every declared object is 512 bytes or less (a
boot reads 1.07 M `Object` verdicts at 64 bytes or under and 1.03 M between 65
and 512, against 79 above 64 KiB), so narrowing always dropped the bind under
the floor — which would move it off the gather rail and out of the
held-resolution registry. `load_buffer_content` therefore dropped every
sub-floor cap before the rail saw it, and both narrowing counters read zero
across 2.57 million binds.
The floor is the right gate asked of the wrong length. Whether a bind is worth
the zero-copy rail is a question about the window the guest bound; how much of
that window one shader reads is a different question. So `full` now answers the
first and the narrowed span answers the second. On the default arm the two are
the same number — the caller still hands the function only caps that clear the
floor — so that line is a no-op there.
# Why this is not the attempt that was already refused
`load_buffer_content`'s doc records applying the cap to the rail *decision*: it
saved 2.2 GB a run, halved `zc_buffer_held` by pushing binds onto CPU reads, and
bought no time. This arm cannot do that. Every bind stays on the rail it was on
with the same registry entry; only the extent walked and copied moves. And that
2.2 GB was ranked on `draw_us/draw`, a CPU wall clock, before this device could
time the GPU at all — the gather is a PCIe copy and no CPU counter was going to
see it.
# Why it is off
Reading fewer bytes than a shader touches is wrong pixels with no error
anywhere, and the whole safety argument is the translator's `Object` verdict
meaning what it says. `robustBufferAccess` bounds-clamps an over-read rather
than leaving it undefined, so the failure mode is visibly wrong rather than
unsound — still wrong. It stays off until an A/B has both the `gpu_span` reading
and a screenshot.
# Verification
1895 + 82 tests pass, 6 ignored (wire fixtures, absent on a non-Apple checkout).
The cap selection is now a named function both arms go through, so the test
asserts the rule rather than restating the filter — the previous test
re-implemented the closure and could only agree with itself. Two tests: the
default arm drops every cap in the population that actually exists, and the
narrowing arm keeps exactly those while changing nothing about caps already
above the floor.
Clippy `-D warnings` clean on all three arms.
# Not verified
**The arm has not been booted.** No screenshot, no `us/draw`, no correctness
evidence of any kind for `=on` — that is the next run, and the default is
unchanged until it lands. macos-13, x86/Vulkan, discrete host only.
|
||
|
|
8c7fc027b5 |
✨ The translator now answers the extent question, and 57% of binds carry a cap nothing applies
Component: `crates/reims-vgpu`, x86/Vulkan pathway, macos-13 rail. Observation only; no bind changes what it reads. # What the `bext_*` census read The narrowing counters have always been zero, and this says why. Two driven default boots at the current translator pin: bext_object 1 179 068 57 % narrowable bext_absent 652 058 31 % no Buffer at that index (a stage_in source) bext_unbounded 249 288 12 % a pointer AIR carries no length for bext_unknown 0 0 % bext_object_le64 601 826 bext_object_le512 577 143 bext_object_gt64k 99 **`bext_unknown` is zero.** `try_buffer_zero_copy_resolved`'s doc records the blocker as reflection carrying `declared_size` but no `type_name` for 211 180 binds a boot, and says carrying the AIR argument type name would reopen ~46.5 GB of a boot's traffic. The pin is upstream HEAD (`git ls-remote` checked) and it answers now: 1.18 million `Object` verdicts a boot, and no `Unknown` at all. And every one of them is small — essentially all at 512 bytes or under, against a `ZERO_COPY_BUFFER_MIN_BYTES` of 16 KiB. So `load_buffer_content`'s `gather_cap` filter drops every cap before the gather rail sees it, the rail resolves the full span, and `read_buffer_bytes_resolved` — the arm whose doc says "this is where a narrowed bind lands" — is never reached. That is why both `zc_buffer_extent_narrowed` and `cpu_buffer_extent_narrowed` read zero on the import arm *and* on the import-off arm, where every bind should have taken the staging path. # Which leaves one number, and two prior measurements that cannot both be right `try_buffer_zero_copy_resolved` puts 67.5 % of gathered bytes on vertex-stage constant buffers. `load_buffer_content` measured applying the cap everywhere at **2.2 GB a run** saved for no change in `draw_us/draw`. This rail moves ~4.46 GB/s, so 2.2 GB a run is ~2 % of it and 67.5 % behind sub-512-byte caps would be nearly all of it. `note_extent_headroom` counts the bytes instead of arguing: for every bind that takes the gather rail, the span it will move and — where a cap exists — how much of it the cap would remove. `bext_would_save_bytes` against `gather_bytes` is the whole answer. It changes no behavior. The second reason to re-ask: that 2.2 GB was ranked on `draw_us/draw`, a CPU wall clock, before this device could time the GPU at all. The gather is a PCIe copy and about 55 % of all GPU time here, and no CPU counter was going to see it. # The import-off GPU cost, now replicated `env::GUEST_IMPORT`'s new reading held across four boots an arm and three compositing regimes, with the arms nowhere near touching: import off 6.89 6.04 6.61 6.60 GPU us/draw import on 15.37 13.72 13.84 16.03 (and 14.90, 15.26, 15.85, 13.94) Drain duty 0.66-0.82 on the copying arm against 0.36-0.64 on the import arm — the worker pays what the GPU does not. The doc now carries the replication and still confines the frame-rate claim to the single regime-matched pair. # Verification 1894 + 82 tests pass, 6 ignored (wire fixtures, absent on a non-Apple checkout). Clippy `-D warnings` clean on all three arms. Four boots read the census: two default, two `REIMS_VGPU_GUEST_IMPORT=off`. Both off boots hold the gate — `host_pointer_import=disabled_by_env`, zero `host_ram_import` lines, no `guest_ram_map_import_exceeds_heap`. # Not verified `note_extent_headroom` has not been read from a boot; it is committed so the next one produces it. macos-13, x86/Vulkan, discrete host only. |
||
|
|
43d4884b2d |
✨ The layout pair every draw pays twice is free on this host, and the census that says why the extent rail never fires
Component: `crates/reims-vgpu`, x86/Vulkan pathway, macos-13 rail. Two probes and
two findings; no shipping behavior changes.
# 1. `REIMS_VGPU_LAYOUT_CHURN` — pricing a layout transition
Every draw that loads its target barriers the colour attachment from
`TRANSFER_SRC_OPTIMAL` to `COLOR_ATTACHMENT_OPTIMAL`, and the render pass's
`final_layout` puts it back — two full-attachment transitions a draw, for a
transfer reader that arrives a few times a second against ~29 000 draws a second.
On hardware that keeps colour compression metadata that is a whole-attachment
resolve; on hardware that does not it is nothing. No counter in this device could
tell those apart, and ~83 % of batched draws share a target, so the pair looked
like the next thing to remove.
The probe adds one more round trip and removes nothing, so it is a positive
control: both layouts preserve contents, nothing is recorded between the two
barriers, and GPU time is the only thing that can move.
Six driven sustained-animation boots, one pin, interleaved:
on on on off off off
draws per frame 284.5 252.4 271.8 299.9 269.4 253.5
GPU us per draw 14.90 15.26 13.84 15.85 13.94 16.03
The arms interleave completely, and in all three regime-matched pairs the arm
doing MORE work reads LOWER — a sign an effect cannot have. Doubling this
device's per-draw layout transitions costs less than the ~5 % spread between two
boots of one binary. This host does not compress what it is asked to transfer,
which the attachment's own `TRANSFER_SRC` usage explains.
So the refactor is not taken. It would touch the barrier family that has had five
live dependency bugs, for no gain measurable here. The probe stays because "here"
is the caveat: an AMD or Intel part may answer differently, this project has none
to boot, and anyone who has one can settle it in two boots without writing code.
# 2. `bext_*` — why the buffer-extent narrowing fires zero times
Reading the same boots turned up a rail that is inert. Both narrowing counters —
`zc_buffer_extent_narrowed` on the gather rail and `cpu_buffer_extent_narrowed`
on the staging one — are **zero across a whole boot of 2.57 million buffer
binds**. That rail exists to reopen the 67.5 % of gathered bytes that are
vertex-stage constant buffers no vertex descriptor bounds, and the gather is the
largest single cost in this device (below), so a zero there is either the biggest
missed win in the tree or a workload fact. A narrowing counter at zero cannot say
which.
`reflected_buffer_extent` now counts its four outcomes at the one place the field
is read — `bext_unbounded` (a workload fact), `bext_unknown` (a translator gap),
`bext_absent` (a `[[stage_in]]` source, expected), `bext_object` (narrowable,
banded by declared size). `bext_object` firing while both `*_narrowed` counters
stay at zero would mean caps are dropped between the lookup and the rails, which
is a different bug that currently looks identical.
# 3. What the GPU clock says about the copying rails, which inverts a doc
`env::GUEST_IMPORT`'s doc measured the copying rails at 3x the per-draw CPU cost
and under half the frame rate. On the GPU's own clock they are the *cheaper* arm.
One regime-matched pair, same pin:
import off import on import on
draws per frame 249.6 252.4 253.5
window_publish fresh 59.5 59.0 59.0
GPU us per draw 6.04 15.26 16.03
drain duty 0.66 0.37 0.36
Same frames, 61 % less GPU per draw, ~1.8x the drain duty. The whole difference
is the gather: 4.46 GB/s of guest windows assembled by the GPU out of guest RAM,
at ~18 GB/s effective, which is ~55 % of all GPU time this device spends. With
the import off the CPU packs the same bytes instead.
So the arms are not fast and slow, they are which engine does the copy — and on
the iGPU column of the support matrix, where the GPU is the constraint and the
CPU is not, the trade plausibly inverts. `=off` is already the switch that takes
it. Written down so an operator on such a host knows there is a second arm worth
two boots. It is a hypothesis, not a result: this host has no iGPU.
# Verification
1894 + 82 tests pass, 6 ignored (the wire fixtures, absent on a non-Apple
checkout). Clippy `-D warnings` clean on all three arms: host Vulkan,
`--target x86_64-unknown-linux-gnu`, and `--target aarch64-apple-darwin`
`backend-metal`.
Also verified here, as AGENTS.md requires of a change touching guest-memory bind
(the heap-budget refusal at `ace9b4a5`): two `REIMS_VGPU_GUEST_IMPORT=off` boots
read `host_pointer_import=disabled_by_env`, **zero** `host_ram_import` lines — so
no bind ran past a closed gate — and no `guest_ram_map_import_exceeds_heap`, which
is the arm that would catch a withdrawn granularity being reported as a guest that
is too large. Two default boots confirm the admitting arm is unchanged:
`host_pointer_heap_mb=72150`, all four imports `fits=true ok=true`, no
`zc_buf_over_heap`, and `us/draw` 15.22/15.46 inside the band the six-boot
compute-gather chain read.
`unattributed=0` and `unread=0` in every window of all ten boots.
# Not verified
macos-13 only, x86/Vulkan only, discrete host only. The `bext_*` census has not
been read from a boot yet — it is committed so the next boot produces it. No
unified-memory, import-less or iGPU host was booted for any of this.
|
||
|
|
ace9b4a59e |
🐛 A guest larger than every heap on the host GPU imported anyway, and the kernel killed the guest for it
Component: `crates/reims-vgpu`, guest-memory rail. Vulkan only in effect — nothing under `backend/metal/` reaches `runtime::guest_ram`. # What was reported An AMD Renoir iGPU on radv/mesa 26.1.6 lost the device during boot: `radv/amdgpu: Not enough memory for command submission`, then a lost context, then a dead QEMU. `REIMS_VGPU_GUEST_IMPORT=off` fixed it. That host's roomiest memory heap is 5.34 GiB and its other is 2.67 GiB, against a guest whose RAM is larger than either. # Why it happened An import is one `VkDeviceMemory` over a whole RAMBlock, charged to one heap, and a submission that names it makes the driver keep all of it resident. On a part whose heaps are a fraction of the guest, the kernel refuses to validate the allocation and every submission referencing it fails. That surfaces as a lost device and a dead guest rather than as a slow rail, which is the worst available outcome: the copying rails work fine on that host and are the only rails on a host without the extension at all. The condition was already *detected* — `context::report_oversized_allocation` has named it on the fail channel since the heap-fit test existed — and nothing acted on it. The import went ahead and the driver decided. # What changed `caps::host_pointer::query` now also reports `heap_budget`, the largest `VkMemoryHeap::size` the device declares. The bound is derived, not chosen: an import is charged to one heap and no allocation can exceed the heap holding it, so an import longer than the roomiest heap cannot be resident in any of them. It is the maximum over heaps rather than the heap an import would land on, because the memory type is a property of the pointer and is not resolvable without one — taking the maximum makes it the widest true bound, refusing only what no heap could have held. `VkMemoryHeap::size` is core, so this needs no extension and leaves no host unbounded, which `VK_EXT_memory_budget` would. It travels to the runtime with the granularity through one call — `latch_granularity` becomes `latch_import_limits(align, budget)` — because the two have one lifetime and two calls could leave a budget standing from a device that is gone. A zero budget withdraws both rather than refusing every guest, so a backend that answers badly is not reported as a guest that is too large. `guest_ram_map::resolve` compares the *sum* of the imports against it, since all of them are live for the VM's lifetime and any submission may name any of them, and refuses the whole map with `MapRefusal::ImportExceedsHeap` when it does not fit. Refusing whole is what makes it safe: the copying rails are selected by a page having no `GuestRef`, and a partial import would leave the writeback paths holding references into one RAMBlock and none into another, which is a hard error at those sites rather than a fallback. The affected host now reaches the configuration its operator reached by hand, without being told to, and says so: `zc_buf_over_heap` in `store_routes` and `guest_ram_map_import_exceeds_heap` on the fail channel with both numbers. The `vk_caps` line carries `host_pointer_heap_mb` so the ceiling is readable from a boot log before anything fails. # Verification `cargo test -p reims-vgpu --no-default-features --features backend-vulkan,host-window -- --test-threads=1`: 1894 + 82 pass, 6 ignored (the wire fixtures, absent on a non-Apple checkout as always). Three new tests: an over-budget guest refuses by name and leaves no partial import; a guest that exactly fills the roomiest heap still imports; a zero budget withdraws the granularity. The boundary test was checked against a stubbed `>=` and fails there, so it is not vacuous. Clippy `-D warnings` clean on all three arms — host Vulkan, `--target x86_64-unknown-linux-gnu` Vulkan, and `--target aarch64-apple-darwin` `backend-metal`. # Not verified No AMD or Intel iGPU was booted: this host is discrete-only (RTX 5080, roomiest heap 72150 MiB) and cannot reach the refusing arm. The reporter's failure is reproduced from their `vulkaninfo` heap sizes and the driver error, not from a boot here. What a boot here can show is that the *admitting* arm is unchanged, and that is checked next; a live-VM result is not claimed in this commit. The bound is heap capacity and not residency, so it is a lower bound: a host that passes it can still be too full to import. That direction remains undetected and is stated in `MapRefusal::ImportExceedsHeap`'s own doc. |
||
|
|
11ab6089d9 |
📝 Six interleaved boots put the compute gather at 21% and not 24%, and the arms stay disjoint
Doc only, on `crates/reims-vgpu` (x86/Vulkan pathway, macos-13 rail).
The compute-gather default landed on four boots taken in blocks, two per arm,
which cannot tell the change from anything that drifted between the blocks. Six
more on the same pin, interleaved on/off/on/off/on/off, confirm it:
on on on off off off
draws per frame 291.2 299.3 249.4 254.5 301.4 192.6
gather regions/draw 15.6 15.4 16.1 16.4 15.0 13.4 <- control
GPU us per draw 15.64 15.55 14.56 20.51 19.59 17.50
drain duty 0.63 0.63 0.39 0.39 0.64 0.35
The worst `on` boot (15.64) still beats the best `off` boot (17.50), so the arms
are disjoint under interleaving and across three compositing regimes rather than
the one the block-ordered pair sat in. The two readings that would void the
comparison both hold: the planned region count overlaps between the arms, so
both arms did the same work, and drain duty does not rise on the dispatch arm,
which is where its +31.6 ms/s of CPU would show.
The effect is -20.6 % on the arm means, not the -24 % the block-ordered four
read. Both figures are now in `env::COMPUTE_GATHER`'s doc with the boots that
produced each, and the gate's own summary is corrected to 21 %. The default is
unchanged.
Verification: `kb/harness/gspan.py` over the six captures. `unattributed=0` and
`unread=0` in every window of every boot, so no submission went unstamped.
No code changed, so no clippy arm or test could move.
Not verified: macos-13 only, x86/Vulkan only, discrete host only. No unified
memory or import-less host was booted, and the iGPU claim in the same doc still
rests on `us/draw` as a proxy rather than on an iGPU.
|
||
|
|
10e86ab378 |
⚡ The guest buffer gather becomes a compute dispatch by default, for 24% less GPU work per draw at identical output
`crates/reims-vgpu`, x86 macOS / Linux Vulkan pathway, macos-13 rail, driven with
`scripts/sustained-animation-probe` on a quiesced host.
`REIMS_VGPU_COMPUTE_GATHER` replaces the ~13 `VkBufferCopy` regions a gathered
guest buffer window needs with one compute dispatch. It has been default **off**
for two sessions, on a reading that was sound and is now stale.
## What changed about the evidence
Every earlier reading reached for `slot_us` — the drain worker blocked on a ring
fence — because no GPU-side number existed. `gpu_span` now times the submission on
the GPU's own clock. Matched compositing regime, one pin, with the *planned*
region count carried as the control so "byte-identical output" is checkable:
```
off off on on
draws per frame 280.2 276.4 269.5 256.1
gather regions/draw 15.7 15.5 15.9 16.8 <- control, flat
GPU us per draw 18.33 18.40 13.88 14.32 -24 %
draw us per submission 266.4 264.1 195.0 203.8 -25 %
drain duty 0.56 0.58 0.55 0.37
slot_us 28.4 ms/s 22.4 9.1 6.4
window_publish fresh 105.0/s 104.5/s 110.0/s 59.0/s
```
Arms disjoint with no overlap, and both planned the same ~16 regions a draw — one
workload done for a quarter less GPU, which is what a dispatch replacing ~13
transfer regions should buy.
## Why the old rejection was right and no longer applies
It was refused for +31.6 ms/s of `record_us` on the drain worker. That worker was
saturated at duty 0.90 when that was measured. The stamp coalescing (`6783a945`)
and the preflight memo (`62dc3d7a`) have since taken ~148 ms/s off it, and duty
here is 0.55-0.58 and **does not move between the arms**. The premise the refusal
rested on was removed by two commits, which is why this is a default flip and not
a disagreement with the earlier measurement.
## Why this is quoted as GPU work and not as frames
`fresh` moves +4.8 % on the one boot where it could, and that is not the case for
the change. On this rail the guest sets the frame rate: 54 % GPU occupancy beside
duty 0.56 means neither side of the device is the pacer, so a device change cannot
show up reliably in frames however good it is — which is also the standing
explanation for five prior CPU wins that bought none.
The quantity that matters is GPU work per unit of guest work, because the support
matrix's other column is an iGPU. The same recorded commands cost roughly an order
of magnitude more there, and a workload this host runs at 54 % occupancy is one an
iGPU is hard GPU-bound on — so a 24 % cut in `us/draw` is a 24 % cut in the thing
that binds it. This host has a discrete GPU only and cannot boot an iGPU, so
`us/draw` is the closest available measurement and it is the one quoted rather than
an extrapolation.
The narrowing arm stays, because the answer is a property of the host: a discrete
GPU crossing PCIe per region and a unified-memory host writing into the same
physical pages have no reason to agree, and only the first is measured. `=off` is
one command on a host where the dispatch loses.
## Also in this commit
An observation counter that sizes the *next* GPU-side saving.
`join_same_target` / `join_other_target` splits every batched draw by whether its
target agrees with the batch it joined. It decides nothing. It exists because
`batch_fit`'s own doc records that **every batched draw begins and ends its own
render pass** — at ~27 draws a command buffer that is ~27
`vkCmdBeginRenderPass`/`EndRenderPass` pairs per submission over full-size
attachments — and a pass can only be shared between draws whose target agrees, so
this split is the ceiling on merging them and there was no number for it. It sits
in `exec` rather than in `batch_fit` because that function is deliberately pure and
testable without a device.
Verified: `cargo test -p reims-vgpu --no-default-features --features
backend-vulkan,host-window -- --test-threads=1` green, 1891 lib tests. Clippy clean
with `-D warnings` on all three arms, run separately (a `for` loop over quoted
flag strings does not word-split in zsh and reports a false error on every arm —
that is how the previous invocation in this session read as 1 error per arm with a
clean tree).
Not verified: two boots an arm, not interleaved, which is thinner than this
default deserves — a confirming interleaved chain is the next run, and the
`join_*_target` counter has not been read from a boot at all yet. No rail but
macos-13. No unified-memory or import-less host, which is exactly where the
narrowing arm might be the right default and where nothing here was measured. The
`backend-metal` tests do not run on this Linux host, and this rail does not exist
on the Metal backend.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
7aa3a19267 |
🐛 The probe stamped one submission kind in five, so its own positive control moved the frames 44% and its number 1.5%
`crates/reims-vgpu`, x86 macOS / Linux Vulkan pathway.
`gpu_span` shipped one commit ago reporting 51 % GPU occupancy on a driven
macos-13 sustained boot. It armed the *draw* command buffer. This device submits
five kinds of ring-slot command buffer and the other four carried no timestamps:
the guest-page writeback (`copy_image_level0_to_buffer`), the guest read
(`copy_image_level0_to_host_delivered`), a guest compute dispatch, and the
completion stamp's own submission.
The hole was found by a control rather than by reading the code, which is the
only reason it was found at all. `REIMS_VGPU_SCATTER_SPLIT=on` cuts every
writeback run into four sub-ranges tiling it exactly — byte-identical guest
output, 4x the copy regions, documented to halve the frame rate — so it is an arm
where the instrument *must* move. One same-regime driven boot against the pair
from the parent commit:
```
base SCATTER_SPLIT=on
window_publish fresh 104.5/s 59.0/s -44 % (reproduces)
draws 29 180/s 14 770/s
GPU us per submission 265.8 269.7 +1.5 %
GPU us per draw 17.71 18.30 +3 %
readback_split gpu_us 20.4 us/copy 16.8 us/copy
```
The documented effect reproduced and every GPU number the device had was flat, so
the probe was not measuring the rail the control moved.
Two things that could not have caught it, recorded because both look like they
should:
- **`armed`/`sealed`/`read` and `unread=0`.** They count what the probe arms. A
kind that never arms is consistent with all four reading perfectly, which they
did, in every window of every boot. Coverage counters see holes *inside* their
coverage.
- **Reading the code.** Five call sites spelled out the same
`reset_command_buffer` + `begin_command_buffer` pair by hand and the probe was
wired into one. Nothing named the other four as a population.
So the fix is structural, not another counter. `ResourcePools::begin_slot_recording`
resets, begins and arms in one call, takes the `Kind`, and is now the **only** way
a ring-slot command buffer is begun — the raw pair appears at no call site, so a
sixth kind cannot join without a stamp. `SlotSpan` carries the `Kind` in its
`Armed`/`Sealed` variants rather than beside them, so a slot that is sealed but
unlabelled is unrepresentable and a submission cannot reach `busy_us` without
reaching a kind.
The census line gains the five `*_us`/`*_n` pairs, which tile `busy_us`/`read` by
rail, plus `unattributed` — `read` minus the per-kind counts. That is the one
column that cannot agree trivially, because a submission is counted in `read`
before a kind is chosen, and it is exactly the check whose absence let a whole
kind go unstamped.
Also documented, because it invalidated a comparison in this session before the
coverage hole did: **a per-second `busy_us` is not comparable across arms.** The
guest sets the draw rate on this rail, so an arm that slows the guest lowers
`busy_us` by lowering the workload — 48 % lower above, for a rail that got more
expensive. Normalise by `draws` or by the kind's own `*_n`. The `draw_phase` and
census docs both say so now.
Verified: `cargo test -p reims-vgpu --no-default-features --features
backend-vulkan,host-window -- --test-threads=1` green, 1891 + 82, 6 ignored (the
wire fixtures, absent on this checkout). Two new tests: `the_kinds_tile_the_total`
asserts `unattributed == 0`, that the counts and microseconds sum to the totals,
*and* that the kinds are distinguished rather than merged — a version charging
everything to `Draw` passes the first three assertions and fails the last;
`every_kind_has_exactly_one_place_in_all` pins `Kind::ALL` to discriminant order,
which is the census's column order and the array index in one. Clippy clean with
`-D warnings` on all three arms.
Not verified: no boot yet on this build, so the per-kind split is unread and the
51 % occupancy figure in the parent commit stands only as a floor for draw
submissions. A batch joiner's work is charged to the kind that opened the batch —
a readback appending to a draw batch is counted as `Draw` — which is correct as
"what that submission executed" but is not a per-rail attribution;
`batch_readback_joins` is how often it happens and the doc says so.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
e9a9e7d84d |
📝 The wait every session called GPU-bound is 18 ms a second, and at 51% occupancy nothing in this device is the pacer
`crates/reims-vgpu`, x86 macOS / Linux Vulkan pathway, macos-13 rail, driven with
`scripts/sustained-animation-probe` on a quiesced host. Two boots, 42 driven
census windows each, one pinned binary.
First light for `gpu_span`, and it does not agree with the belief it was built to
check.
```
anim1 anim2
gpu_span busy_us 516.9 ms/s 512.3 ms/s -> 51 % of a second
submissions read 1 945/s 1 914/s
GPU us per submission 265.8 267.6
draws 29 180/s 28 958/s
GPU us per draw 17.71 17.69
draw_phase slot_us 32.7 ms/s 17.9 ms/s
drain duty 0.56 0.58
buffer_guest_gather_regions 453-480 000/s
```
Three readings, and the third redirects the work.
**`slot_us` is 18-33 ms a second, not 314.** `draw_phase::Phase::Slot`'s doc
measured 314 491 us/s in 2026-07 and every session since has read that column as
"the GPU is busy". It does not reproduce on this tree: the ring blocks a
twentieth as much as the GPU is occupied. That doc now carries the current pair
so the next reader does not inherit the retired one.
**The probe cross-checks against a counter it does not share code with.** `read`
equals `batch_flushes` exactly — 1 990 against 1 990 — so it is counting
submissions and not something adjacent. `armed == sealed == read` and `unread=0`
in every window of every boot, which is the coverage triple closing.
**Neither the GPU nor the drain worker is the pacer.** 51 % GPU occupancy beside
drain duty 0.56 leaves both about half idle. The guest sets the rate. That
explains the five CPU wins that bought no frames far better than "the rail is
GPU-bound" did — nothing was bound, so nothing could convert — and it means a
frame count cannot rank a device change on this rail whatever the change does.
So `busy_us` is the quantity to optimise and `present_hz` is not. 17.7 us of GPU
for one window-server compositing draw is a lot of work for a textured quad on an
RTX 5080, and the support matrix's other column is an iGPU where the same recorded
commands cost roughly an order of magnitude more — a workload this host runs at
51 % occupancy is one an iGPU is hard GPU-bound on. The dev host has no iGPU, so
`busy_us` is the closest thing to an iGPU measurement available here: a change
that lowers it at identical `draws`, `buffer_guest_gather_regions` and bytes is an
iGPU win whether or not this host's frames notice.
Also measured, and reported as the poor A/B vehicle its own doc says it is: two
`gpu-load-probe layers=24&boxes=6` boots came back at 25.4 % and 41.7 %
occupancy, duty 0.34 and 0.54, 7 860 and 15 086 draws/s. Same binary, same rail,
same probe, back to back. Do not rank anything on that load; the sustained probe
reproduced to 1 % across the same pair of slots.
Verified: clippy clean with `-D warnings` on the `backend-vulkan,host-window` arm
(doc-only change to `draw_phase`, doc-only to `gpu_span`; no behaviour touched, so
the other two arms are unaffected and were green on the parent commit). Four
driven boots, no guest kernel panic in any `boot-stdout.log`, `dev=1` throughout.
Not verified: any rail but macos-13, and any host but this one. `busy_us` has not
been read on a unified-memory or import-less host, which is where its per-draw
figure matters most and where this device cannot boot. No attribution *within*
`busy_us` yet — which part of a submission's 266 us is the gather, the render pass
or the writeback is the next question and is answered by ablation, not by more
timestamps.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
ad34265e6c |
✨ The largest phase in this device is a wait nobody has timed, so the submission stamps its own GPU span
`crates/reims-vgpu`, x86 macOS / Linux Vulkan pathway (the gather, scatter and
submission rails this measures are Vulkan-only; the Metal arm has no equivalent
and is untouched beyond compiling).
`draw_phase::Phase::Slot` is the drain worker blocked in `begin_entry` because
the ring slot it wants has an unsignaled fence. Its own doc measured 314 491
us/s of it against 2 525 us/s of actual preparation, and ~425 us per
`ring_retire_blocks`. Five sessions have read that column as "the GPU is busy",
concluded the rail is GPU-bound, and explained five CPU wins that bought zero
frames with it.
It had never been measured. Before this commit the device wrote GPU timestamps
in exactly one place — the composite readback copy — and nothing anywhere timed
a *draw* on the GPU's own clock. `slot_us` is wall clock whose content is
unattributed, and its two readings call for opposite fixes: a submission that
genuinely executes for 425 us wants less GPU work per draw (the gather's 427 000
transfer regions a second, or the writeback's scatter), while one that executes
in far less wants submission shape, and `RING_DEPTH`'s own doc already suspects
the second ("It was submit/fence-bubble-bound, not GPU-compute-bound") on a
workload many changes ago.
So a draw command buffer now stamps itself. `DrawSpanProbe` is a timestamp pair
per ring slot — the slot is the key because the slot's fence is exactly the event
that makes its pair readable, and `begin_entry` already retires a slot before
reusing it. `gpu_span_arm` resets the pair and writes TOP_OF_PIPE right after
`vkBeginCommandBuffer`, on the arm that *opens* a command buffer only: a batch
joiner appends to one already armed, and re-arming would move the top stamp past
draws the batch had recorded and read as a fast submission rather than a broken
one. `gpu_span_seal` writes BOTTOM_OF_PIPE as the last command before the buffer
ends, from the per-draw submit in `exec` and from `batch_flush` for a deferred
one — the latter against `self.cur`, which is still the batch's slot because
`begin_entry` flushes before it advances. `gpu_span_read` runs inside
`retire_slot` immediately after the fence wait, which is both the first moment
the queries are available and the only thing that returns the slot to `Idle`.
The census line is `gpu_span busy_us busy_max_us read armed sealed unread`,
beside `draw_phase`. It is a tiling and not a sample: `busy_us` and the derived
`slot_us - busy_us` sum to the wait, which is the property that made the drain
worker's CPU split answer unambiguously. Its own coverage is on the line because
a zero has three causes — a quiet GPU, a host that writes no timestamps, or an
arm/seal/read triple that did not close — and `armed`, `armed - sealed` and
`unread` separate them. `unread` is zero by construction and a non-zero reading
is a defect in the ring's ordering, not a knob.
Two things the code gets right that the existing readback probe does not:
- `timestampValidBits` is honoured. Vulkan permits a queue family to write fewer
than 64 meaningful bits and leaves the rest **undefined**, so a raw
`bottom - top` on such a host is a difference of two drivers' scratch bits.
Both operands are masked and the result masked again, which also makes a wrap
a wrap: 32 valid bits at a 1 ns tick wraps every 4.3 s, which a per-second
census crosses regularly.
- The pool is sized from `RING_DEPTH` rather than a hand-written number, and a
test asserts the slot bases tile it exactly.
`REIMS_VGPU_GPU_SPANS=off` narrows it away entirely — no query created, reset,
written or read, and no census line rather than a zero. Default on because two
timestamps per submission is ~4 000 a second against the readback rail's
existing three per composite, and because a reading nobody has to ask for is the
one that gets read. It stays a switch because a timestamp is a pipeline flush
point on some hardware, so an A/B ranking submission shape should take it out on
both arms and say so.
Also: `COMPUTE_GATHER` was missing from `env::ALL`, so the boot line has been
silent about the arm of the one switch here whose two arms are byte-identical
implementations of one copy — a `COMPUTE_GATHER` A/B could not be told from a
pair of default boots by reading the log afterwards, which is the "compare arms,
not pins" trap with the evidence removed. Both it and `GPU_SPANS` are in the list
now.
Verified: `cargo test -p reims-vgpu --no-default-features --features
backend-vulkan,host-window -- --test-threads=1` green, 1889 + 82 across the
harnesses, 6 ignored (the wire fixtures, absent on this checkout as always).
Seven new tests: three on the window's take-and-clear and sum-versus-high-water
behaviour, four on the probe's mask arithmetic — full width, undefined high
bits, a wrap inside the valid width, and the pool tiling the ring. Clippy clean
with `-D warnings` on all three arms (`backend-metal` via `--target
aarch64-apple-darwin`, `backend-vulkan,host-window` bare and via `--target
x86_64-unknown-linux-gnu`).
Not verified: nothing from a live boot yet — no reading of `busy_us` against
`slot_us` exists, on any rail, which is the next step and the whole point of the
change. The `backend-metal` tests do not run on this Linux host. Not measured on
a host whose queue family reports fewer than 64 valid timestamp bits; the
arithmetic for that case is unit-tested and unobserved.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
52c8edf198 |
📝 The preflight memo holds on all six drivers, and its identity check is demonstrably not vacuous
Pathway: x86 macOS / Linux Vulkan. Documentation only — the rail coverage
`62dc3d7a` and `a1394426` were missing.
Six x86 rails, one undriven boot each, `pin-pmemo`:
macos-11 dev=1 ssh=1 dock=1 sd=184 panic=0
macos-12 dev=1 ssh=1 dock=1 sd=147 panic=0
macos-13 dev=1 ssh=1 dock=1 sd=127 panic=0
macos-14 dev=1 ssh=1 dock=1 sd=215 panic=0
macos-15 dev=1 ssh=1 dock=1 sd=242 panic=0
macos-26 dev=1 ssh=1 dock=1 sd=125 panic=0
Every rail composited (`sd` >100) and none panicked, so skipping the AIR resolve
on a memo hit does not strand any of the six guest drivers waiting on a
translation.
THE COUNTER READING IS THE INTERESTING PART
macos-11 ready=2353 absent= 617 stale= 0 79 % hit
macos-12 ready=1613 absent= 951 stale= 0 63 %
macos-13 ready= 930 absent= 919 stale= 0 50 %
macos-14 ready= 906 absent=1137 stale=19 44 %
macos-15 ready= 838 absent=1610 stale= 0 34 %
macos-26 ready=5415 absent=2146 stale=23 72 %
Two things, and the second is why this is a `:memo:` and not a footnote.
**The 99.83 % in `a1394426` is a steady-state number, not a universal one.** An
undriven boot is a cold memo plus the pipeline churn of app launch, and it hits
34-79 %. That is the population this optimisation does not serve, does not need
to, and should not be claimed over.
**`stale` is not always zero.** macos-14 and macos-26 replace pipelines during
boot; the three-entry identity check catches it and falls back to the full
preflight, exactly as designed. That matters more than the hit rate: a
comparison that returned zero on every rail under every condition would be
indistinguishable from one that *could never fire*, and a guard that cannot fire
is the failure mode this session already found once — `PendingStamp::discharges`
reads zero because the case it covers does not arise on this workload. This one
demonstrably fires on real guest behaviour and then declines the entry, which is
the evidence that the memo's correctness argument is load-bearing rather than
decorative.
VERIFIED
- Six-rail undriven sweep as above, binary pinned so the tree could not be
rebuilt mid-sweep.
- Clippy `-D warnings` clean on backend-vulkan,host-window.
NOT VERIFIED
- **Undriven boots.** They prove each driver composites and that the fallback
path is taken when the identity moves; they do not prove the 60 ms/s saving
reproduces on any rail but macos-13, which is the only one driven.
- Whether a driven macos-14 or macos-26 boot keeps `stale` non-zero once the
desktop settles, which is the reading that would say whether those drivers
churn pipelines steadily or only at launch.
- The arm64/Metal pathway, which has no boot at all.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
a13944265f |
📝 The preflight memo hits 99.83% and takes 60 ms/s off the drain worker
Pathway: x86 macOS / Linux Vulkan, exec preflight. Documentation only — the boot
`62dc3d7a` said it did not have.
Two driven macos-13 `blur=40` boots, `pin-pmemo`, same rail and probe as the
previous pin:
preflight_memo_ready 716 427 / 708 872
preflight_memo_absent 1 207 / 1 428 99.83 % hit
preflight_memo_stale 0 / 0
before after
preflight ms/s ~76 15.19 / 14.99 -80 %
air ms/s 53.90 / 54.23 0.00 / 0.00
cache ms/s 16.30 / 16.60 0.00 / 0.00
refs ms/s 6.24 / 6.23 6.21 / 6.10 control, held
refs_us/call 0.41 / 0.42 0.39 / 0.40 control, held
pipes/s 12 353 /12 147 13 008 /12 802 same band
op0x37 us/packet 101.2 94.34 / 94.43
duty 0.81 0.80 / 0.79
**~60 ms/s off the one thread every guest packet serializes through**, and the
prediction in `62dc3d7a` — "most of `air`'s 54 ms/s, if refs hit the memo" —
holds. It was worth stating as a prediction because the last one made here was
falsified: `6783a945` predicted `batch_flushes` would fall and it did not move.
`cache` collapsing alongside `air` is neither a second win nor a regression: it
only ever ran on a miss, so it tracks the hit rate by construction. `refs` runs
for every packet regardless and is the control that says the two pins are
comparable — it held to within 2 %, as did `pipes/s`.
**`preflight_memo_stale` is 0 across 1.4 million asks.** That is the reading that
matters for the identity check rather than for the saving: on a steady desktop
the three object-list entries never move, which is exactly what the module doc's
correctness argument predicts. A non-zero reading here would be worth
investigating rather than shrugging at, and now there is a baseline to notice it
against.
ONE INSTRUMENT ARTIFACT, RECORDED SO IT IS NOT READ AS A LOSS
`sum vs preflight_us` falls to ~0.41. The three timed sub-spans now cover almost
nothing, while the memo check that replaced them is inside `preflight_us` and
outside all three. That is the tiling no longer tiling its subject — the
identity was a property of the old shape — not 59 % of the span going missing.
Anyone re-splitting this should time `translations_ready` itself.
WHERE THE RESIDUE STANDS AFTER THIS SESSION
Same rail, same probe, `unnamed in drain` and `duty`:
start of session 270 ms/s duty 0.84
after stamp coalescing 227 ms/s duty 0.81
after this 171 ms/s duty 0.79
**-37 % of the drain residue**, on a thread that was 84-90 % busy.
VERIFIED
- Two driven boots as above; both `ok`, neither panicked.
- Clippy `-D warnings` clean on backend-vulkan,host-window.
NOT VERIFIED
- **Frames.** `present_hz` reads 15.60 / 15.25 against 14.80, which is in the
noise of this dial across pins and is **not** claimed as a win. No CPU saving
on this rail has moved frames yet; the guest paces.
- These are between-pin comparisons, not an A/B on one binary. The controls held,
which is the strongest available check, but `REIMS_VGPU_PIPELINE_MEMO=off`
would also take the *draw* path off the memo and so cannot isolate this change.
- Any rail other than macos-13, and the arm64/Metal pathway.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
62dc3d7a3d |
✨ The preflight can ask the draw path's own memo instead of re-reading every shader out of guest memory
Pathway: x86 macOS / Linux Vulkan, exec preflight. Behavior change, gated by the existing `REIMS_VGPU_PIPELINE_MEMO`. THE COST `0571d725` left `ExecPhase::Preflight` at ~76 ms/s, of which `air` is **54 ms/s at 4.3 us a pipeline ref over 12 700 refs a second** — three guest-memory resolves per ref (the pipeline descriptor, then a descriptor and a blob read for each of the two stages) to ask one question: are these two shaders already translated? `pipeline_resolve`'s memo already knows. It is keyed `(task_id, pipeline_ref)`, it holds the two `Arc<CachedShader>` a successful resolution produced, and it validates by re-reading the three object-list entries — **~0.6 us**. WHY A MEMO HIT IS A SOUND ANSWER TO THE PREFLIGHT'S QUESTION Three facts, and the middle one is the load-bearing one: 1. An entry is only ever filed after a successful `resolve_uncached`, and it holds that resolution's shaders — so **an entry existing means those shaders were translated**. 2. **The m2v translate cache is unbounded and nothing evicts it.** Its only removal is `forget_if_transient`, which drops a transient *failure* so it can be retried. A shader translated once is translated for the life of the process. 3. So even when this memo's own `MEMO_CAPACITY` evicts the entry before the draw reaches it, the draw's `translate_cached_reflected` finds the shader ready. The eviction costs the resolve, never the translation — which is the whole thing the preflight exists to keep off the drain thread. The identity check is the *same* three entry reads `resolve` makes, with the same two documented gaps — a descriptor or an MTLB rewritten in place. Those gaps are not widened by asking here, because the draw that follows performs the identical check: a guest that could fool this one already fools that one. `translations_ready` returns `false` when the memo is off, so `REIMS_VGPU_PIPELINE_MEMO=off` takes the preflight back down its full path along with every chain. No new switch: this is the same memo, the same correctness argument and the same escape hatch, asked a second question. COUNTERS `preflight_memo_ready` / `_absent` / `_stale`, deliberately **not** folded into the `pipe_memo_*` set. They are a different caller asking a different question, and summing the two would double-count every pipeline that a healthy packet shows to both the preflight and the draw. TESTS `an_absent_memo_entry_is_never_reported_ready` pins the direction that matters. A wrong `false` costs the resolve this is trying to save; a wrong `true` tells a packet its shaders are translated when nothing has translated them, and the draw then meets an untranslated pipeline with the packet already committed. Probed by inverting the absent arm to `true` — the test fails on exactly that assertion — and the file restored by copying it back, not with git. VERIFIED - 1882 tests pass (+1), `--test-threads=1`, backend-vulkan,host-window. - The new test fails without the guard, as above. - Clippy `-D warnings` clean on backend-vulkan,host-window and on `--target aarch64-apple-darwin --features backend-metal`. NOT VERIFIED - **No boot.** The predicted saving is most of `air`'s 54 ms/s, and the reading that decides it is `preflight_memo_ready` against `_absent` plus `air_us/pipe` — if refs miss the memo as often as they hit, this buys nothing. A prediction in `6783a945` about `batch_flushes` was falsified by its boot, so this one is worth no more than that one was until measured. - Frames, which no CPU saving on this rail has moved yet. - The arm64/Metal pathway: this path is `backend-vulkan`-gated. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
c1ffc3f5d9 |
📝 The stamp coalescing holds on all six guest drivers, and the layout repairs pair 1:1 on the three rails that fire them
Pathway: x86 macOS / Linux Vulkan. Documentation only — the rail coverage that
`6783a945` and `71462a94` were both missing.
WHY A SWEEP AND NOT ANOTHER MACOS-13 BOOT
`6783a945` changed *when* a completion becomes visible to the guest and was
measured on macos-13 alone. Six rails are six Apple GPU drivers with six stamp
patterns, and this is precisely the class of change that can be correct on one
and stall another — failing as a frozen desktop rather than as a decline, so no
counter would report it and `dev=1` would still read green.
macos-11 dev=1 ssh=1 dock=1 sd=184 panic=0
macos-12 dev=1 ssh=1 dock=1 sd=147 panic=0
macos-13 dev=1 ssh=1 dock=1 sd=131 panic=0
macos-14 dev=1 ssh=1 dock=1 sd=215 panic=0
macos-15 dev=1 ssh=1 dock=1 sd=281 panic=0
macos-26 dev=1 ssh=1 dock=1 sd=126 panic=0
`sd` is the field that answers it — host-window standard deviation, ~38 for the
boot screen and >100 for a composited desktop. Every rail cleared 126, so every
one put a picture up rather than sitting on a stamp it was still waiting for.
`stamp_write_forward` runs 345-1815 a boot across the six, so the coalesced write
lands on every driver and not only the one it was tuned against. No rail
panicked, including macos-26, which panics on roughly a third of *driven* boots
for reasons predating this — one clean undriven boot of it is not a rate and is
not claimed as one.
THE LAYOUT REPAIRS, AND A COUNTING MISTAKE WORTH RECORDING
`71462a94` provisioned a neutral texture for every statically-used sampled-image
binding the guest left empty, and it had never been observed on a rail that
fires. macos-14/15/26 do; macos-13 does not.
macos-13 unbound=0 substituted=0
macos-14 unbound=3 substituted=3
macos-15 unbound=2 substituted=2
macos-26 unbound=3 substituted=3
Paired 1:1 on every rail, each substitution carrying the same `pipe=` and `t=` as
the violation it answers.
The first pass at this reported 5/3/4 unbound against 3/2/3 substituted and
looked like a hole — three declared-unbound descriptors going unrepaired. It was
a `grep -c` for the bare reason name, which matches **both** the fail line and
the `store_routes` counter key of the same name on the OFF-channel census line.
`AGENTS.md` says a counter and a fail line count different things; this is what
that looks like when you forget, and it fails in the direction that manufactures
a defect. Matching `reason=` rather than the bare name is the fix.
VERIFIED
- Six-rail undriven sweep as above, one boot each, binary pinned so the tree
could not be rebuilt mid-sweep.
- Clippy `-D warnings` clean on backend-vulkan,host-window.
NOT VERIFIED
- **These are undriven boots.** They prove the desktop composites on each driver;
they do not prove the 88 ms/s saving reproduces there. An undriven boot
measures an idle device, and only macos-13 has been driven.
- macos-26's panic rate under drive, which needs at least six boots to band and
is unchanged business from before this session.
- The arm64/Metal pathway, which has no boot at all.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
0571d72576 |
📝 Removing the AIR copies bought 5%, not 71%, and the guest resolves are the rest
Pathway: x86 macOS / Linux Vulkan, exec preflight. Documentation only — the boot
`332b310e` said it did not have.
Two driven macos-13 boots either side of the change, same rail, same probe, with
`refs` and `cache` as controls:
with copies borrowed
air_us/pipe 4.34 / 4.30 4.06 / 4.17 -4.7 %
refs_us/call 0.41 / 0.40 0.41 / 0.42 control
cache_us/pipe 1.30 / 1.31 1.33 / 1.36 control
pipes/s 12 650/12 786 12 353/12 147
Both controls held, so the delta is attributable to this change rather than to
the two builds differing elsewhere — which matters here because there is no env
switch for it and the comparison is between pins, the weaker form. `pipes/s`
came in a little lower, which is why the normalized `air_us/pipe` is the reading
quoted and `air` in ms/s is not.
**Two allocations and two memcpys of a shader blob are ~0.2 us of a 4.3 us
resolve.** The commit that made the change argued they were "pure waste" at
~25 400 a second, and they were waste — but the waste was 5 %. The other 4.1 us
is the three guest-memory resolves the function still does: the pipeline
descriptor, then a descriptor and a blob read for each of the two stages.
That is worth recording precisely because the change was *correct and obviously
so* and still only bought a twentieth of the span. Obviousness is not magnitude.
WHAT IS LEFT, AND WHY IT IS NOT IN THIS COMMIT
~50 ms/s comes off only by not resolving at all — a memo of `(task_id,
pipeline_ref)` already confirmed translated. The fact that makes it soundable
was found while reading for the copy removal and is now written down next to
`PreflightPart`: **the m2v cache is unbounded and nothing evicts it.** Its only
removal is `forget_if_transient`, dropping a transient failure so it can be
retried, so an `Entry::Ready` is Ready for the life of the process and the sole
staleness is the guest repointing a ref at different AIR.
Its failure mode is bounded but not free: `translate_cached_reflected` falls
through to a synchronous translate on a miss, so a stale memo would not lose
guest work — it would run an AIR-to-SPIR-V translation inline on the drain
thread with the device lock held, which is exactly what the asynchronous
preflight exists to avoid. The invalidation has to be designed against the
object-deletion paths, and that is a change to make deliberately rather than at
the end of a long session.
ALSO FIXED
`load_render_mtlb_pair`'s doc linked `[load_render_air_pair]`, which the previous
commit deleted — a live intra-doc link to a symbol that no longer exists, the
one class of `cargo doc` finding that is real rot. It is now named in prose.
Confirmed with the intra-doc pass: no unresolved link to it remains, and the
warnings that do remain are the pre-existing cfg-gated and `//!`-bare-name
classes `AGENTS.md` describes.
VERIFIED
- 1881 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`.
- `cargo doc` intra-doc link pass, as above.
- Two driven boots as quoted.
NOT VERIFIED
- Frames. Neither boot was compared for `present_hz` against a paired arm, and
on this rail every CPU saving so far has bought zero — a 2.5 ms/s saving on an
850 ms/s thread is far below anything that probe could resolve.
- The compute preflight, which loads its MTLB by a different route and still
copies nothing either way.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
332b310e95 |
✨ The preflight copied both AIR blobs 25 000 times a second to hand a digest bytes it drops
Pathway: x86 macOS / Linux Vulkan, exec preflight. Behavior-preserving.
WHAT THE SPLIT SAID
`e1e1d242` split `ExecPhase::Preflight` three ways. Two driven macos-13
`blur=40` boots, medians over 71 and 72 windows, `sum vs preflight_us` = 0.98:
air 53.90 / 54.23 ms/s 4.34 / 4.30 us per pipeline ref <- 71 %
cache 16.30 / 16.60 ms/s 1.30 / 1.31 us per pipeline ref
refs 6.24 / 6.23 ms/s 0.41 / 0.40 us per call
pipes/s 12 650 / 12 786
`refs` — the second full `render::decode` of the stream, which the commit adding
the split named as a plausible owner because `walk_stream` decodes the same
records immediately afterwards — is **8 %**. That is the fifth nomination this
session's tiling has retired, after `decode_packet`, the root-FIFO ring reader,
the per-command-buffer allocation, and the claim that the stamp flushed the draw
batch.
The cost is `air`: resolving each pipeline's AIR out of guest memory, 12 700
times a second at a very tight 4.3 us (min 4.12, median 4.34 — a fixed-shape
cost, not a tail).
WHAT THIS COMMIT REMOVES
`load_render_air_pair` did three guest resolves and then `to_vec`'d **both** AIR
blobs. Its consumer is `m2v_cache::ensure_cached_async`, which takes `&[u8]`,
digests it to build the cache key, and retains nothing unless the lookup misses.
On a boot where every shader is already translated — which is the steady state,
since that cache is unbounded and nothing evicts — both copies are pure waste:
two allocations and two memcpys per pipeline ref, **~25 400 a second**, for
bytes that are hashed and dropped.
`load_render_mtlb_pair` returns the containers and lets the caller borrow
through `extract_air`, which already returns `&[u8]`.
The copying variant is **deleted rather than kept beside it**, because the
preflight was its only caller — there is no second consumer that needs owned
bytes, and leaving both would be two spellings of one resolve with the slower one
still reachable.
An MTLB whose AIR will not extract now `continue`s at the preflight, which is the
same disposition the old code reached by a different route: `load_render_air_pair`
turned an extract failure into a `DrawPreparationDecline` that the caller also
`continue`d on. Both are the "deterministic missing plan input" the surrounding
comment describes — normal execution reports it precisely and there is no
asynchronous work to await.
WHAT IT DOES NOT DO, AND THE MUCH LARGER LEVER IT LEAVES
This removes the copies, not the three guest resolves, so it claims only part of
the 54 ms/s and the boot has not said how much.
The larger lever is a **memo**: skip the whole resolve for a `(task_id,
pipeline_ref)` already confirmed translated. What makes that tractable is a fact
found while reading for this change — **the m2v cache is unbounded and nothing
evicts it**; the only removal is `forget_if_transient`, which drops a transient
*failure* so it can be retried. So an `Entry::Ready` is Ready for the life of the
process, and the only staleness is the guest repointing a ref at different AIR.
Its failure mode is also bounded: `translate_cached_reflected` falls through to a
synchronous translate on a miss, so a stale memo costs an inline translation on
the drain thread rather than losing guest work. That is still a real regression —
holding the device lock through an AIR-to-SPIR-V translation is exactly what the
async preflight exists to avoid — so the memo needs its invalidation designed
against the object-deletion paths and is not being rushed in behind this.
VERIFIED
- 1881 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`.
- The dead-code lint is what proved the copying variant had exactly one caller.
NOT VERIFIED
- **No boot.** The saving is unmeasured; `air_us/pipe` at 4.3 us is the number
it has to move, and it may move very little if the three guest resolves
dominate the copies.
- The compute preflight, which loads its MTLB by a different route and was left
alone.
- The arm64/Metal pathway: this whole path is `backend-vulkan`-gated.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
e1e1d242ae |
✨ Split the speculative preflight three ways, because it is the largest cost outside the encode and three unlike things happen in it
Pathway: x86 macOS / Linux Vulkan, exec path. Instrument only; no behavior change. `43b4438d` measured `ExecPhase::Preflight` at **74.6 ms/s**, the largest span in this device outside `encode_draw_chain` and ~10 % of the whole drain worker. It is speculative work — it re-derives per exec packet whether metal2vulkan already holds every pipeline the streams reference, so a packet defers whole rather than half-executing. Three unlike things happen inside it, and one number cannot say which costs: - `Refs` — `render_pipeline_refs` / `compute_translation_inputs`: `iter_segments` plus a full `render::decode` of every record in the stream. That is the *same* walk `walk_stream` makes immediately afterwards, done twice because the answer has to be complete before any record runs. - `Air` — `load_render_air_pair`, and the compute path's `load_compute_pipeline` + `load_mtlb`: resolving each pipeline's AIR out of guest memory. - `Cache` — `ensure_cached_async`, which builds its key by digesting the whole AIR blob (`ShaderId::render` -> `air_key`) and then takes the cache's global lock. Twice per render pipeline, once per kernel. Any of the three could plausibly own the 74.6 ms/s and they have completely different fixes: a second decode pass, a guest-memory read, or an O(AIR bytes) hash under a mutex. Nominating one and timing it is the mistake this session has now watched fail four times — `decode_packet`, the root-FIFO ring reader, and the per-command-buffer allocation were all confidently named and came in at 0.3 %, 0 % and 2 %. `pipes` counts the distinct pipeline refs each scan resolves, which is the denominator every per-pipeline figure needs: `air_us / pipes` is what one AIR resolve costs, and `pipes / preflight_n` is how many refs the average packet re-derives. Without it a large `Air` cannot be told from many cheap resolves. The three sum to `preflight_us` on the `exec_phase` line, and `analyze.py` prints that ratio, so a mis-attributed site shows up as an identity failure before it shows up as a wrong ranking. WHAT THIS DELIBERATELY DOES NOT DO It does not memoize anything. The scan exists so a packet cannot half-execute, which is guest work lost silently rather than a decline, and the translation store is a **cache** — "we checked this stream last time" is not on its own a licence to skip, because an entry can be evicted and a pipeline ref can be reused after a task deletes and recreates. Whatever the split says, the fix has to be keyed on something that cannot go stale, and this commit's only job is to say which of the three is worth designing that for. VERIFIED - 1881 tests pass, `--test-threads=1`, backend-vulkan,host-window. - Clippy `-D warnings` clean on backend-vulkan,host-window and on `--target aarch64-apple-darwin --features backend-metal`. - `analyze.py` still reads the four `pin-exec` logs captured before these fields existed. NOT VERIFIED - No boot at this commit. All three spans are unmeasured. - The compute preflight's restructure into `and_then` preserves behavior by inspection — both arms `continue` on a `None` exactly as the `let ... else` chain did — but no boot has exercised it, and this workload's compute traffic is light (`computes=0` on every window of the boots so far), so a boot may not exercise it either. That is a real gap and not a formality. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|
|
43b4438dbc |
📝 The largest non-draw cost in this device is a speculative scan, and the copying rails run at 46% of the frame rate
Pathway: x86 macOS / Linux Vulkan. Documentation only — the boot `a5ab7526` said
it did not have, plus the copying-rail coverage that has been open since the
handoff.
WHERE THE EXEC RESIDUE IS
`sum` against `op0x37_us` is **0.999**, so the five spans account for the
function and the split is arithmetic rather than an argument. Driven macos-13,
import available, 74 windows, medians:
finish 639.6 ms/s (contains draw_us)
preflight 74.6 ms/s <- largest span outside the encode
walk 45.7 ms/s
header 6.7 ms/s
load 3.7 ms/s
finish - draw ~26 ms/s
**The largest non-draw cost in this device is `ExecPhase::Preflight`** — the
speculative scan asking whether metal2vulkan already holds every pipeline the
streams reference, so a packet defers whole rather than half-executing. Pure CPU
lookup work, once per exec packet, ~10 % of the whole drain worker.
`Load` is **2 %**. The structural read that preceded this instrument nominated
the per-command-buffer `vec![0u8; len]` and GVA copy as the likely dominant cost.
It is not. That is the third nomination this tiling method has retired, after
`decode_packet` and the root-FIFO ring reader.
`Header` — the derived leftover — is 6.7 ms/s. Small, which is the reassuring
reading rather than a boring one: the cost sits in spans that were named, not in
a corner nobody thought to list. Had it been large, the search would have moved
somewhere no candidate considered, and that is the property the leftover exists
to provide.
THE COPYING RAILS, MEASURED FOR THE FIRST TIME
Same binary, `REIMS_VGPU_GUEST_IMPORT=off`, two boots each arm interleaved. This
host has one VGA device and it is an NVIDIA RTX 5080, so no boot here reaches
those rails by hardware and a green boot on it says nothing about them.
**The gate held.** `host_pointer_import=disabled_by_env` exactly once per boot,
`guest_ram_map_no_backend_import` ~1 000 times, and `sampled_guest_imports` and
`buffer_guest_imports` **zero in every one of 77 and 75 windows** — against
non-zero on the import-on arm, which is what makes that zero evidence rather
than an absent counter. No panics. The desktop renders correctly on both arms.
import on import off
present_hz 14.80 6.80 / 6.85
duty 0.81 0.91 / 0.92
draw_us per draw 41.4 us 126.3 / 127.8 us
op0x37 per packet 101.2 us 265.7 / 267.2 us
exec_phase finish 639.6 ms 810.9 / 821.1 ms
**Under half the frame rate and 3x the per-draw cost**, with the entire
difference landing in `Finish` — the writeback copies. That is the rail working:
on a host that cannot import, the copy is the point, and the guest observes the
same pixels. It stays a performance difference, which is what the support matrix
requires of it.
Stated narrowly, because the temptation is to call this the iGPU number and it is
not: this measures the **no-import-available** column of the memory/import
matrix. A unified-memory host *with* the extension binds a `GuestSlice` directly
and is the fastest cell, not this one. Nothing here ran on Intel or AMD hardware,
and this host cannot.
Both readings go next to the code they explain — the split on `ExecPhase`, the
rail cost on `env::GUEST_IMPORT` — rather than into `AGENTS.md`, which is for
what changes an agent's actions.
VERIFIED
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`.
- Four driven boots as above; screenshots compared between arms.
NOT VERIFIED
- The arm64/Metal pathway, which has no boot at all. `Preflight` is
`backend-vulkan`-gated and will read zero there by construction.
- Any rail other than macos-13, and any probe other than this one.
- Actual Intel or AMD hardware, for the reason stated above.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
a5ab752698 |
✨ Tile the inside of EXEC_INDIRECT2, because it is the whole of the dispatch and draw_us names only the encode
Pathway: x86 macOS / Linux Vulkan, exec path. Instrument only; no behavior
change.
WHY THIS ONE FUNCTION
The per-opcode split in `cb718e5f` was decisive in a way the "~24 arms" framing
had not prepared for. Two driven macos-13 `blur=40` boots:
op0x37 EXEC_INDIRECT2 754-775 ms/s 7 703-7 812 packets ~98 us/packet
op0x06 DISPLAY_TRANSACTION2 14.6-16.8 ms/s
op0x35 SYNCHRONIZE_RESOURCES 8.4-9.7 ms/s
the other eleven opcodes under 3.3 ms/s combined
So `proc_us` is one opcode. `draw_us` names 585 ms/s of it and names it
**narrowly**: `DrainPhase::Draw` wraps `encode_draw_chain` alone, inside the
per-draw loop in `finish_stream`. Everything else — the command-buffer load, the
translation preflight, every record `walk_stream` decodes, the draw-request setup
and result handling around each encode — is untimed, and after the stamp
coalescing it is **the whole of the remaining drain residue at ~197 ms/s**.
FIVE SPANS, AND THE LAST ONE IS THE POINT
`ExecPhase`: `Load`, `Preflight`, `Walk`, `Finish`, `Header`.
- `Load` — the per-command-buffer loop: a `vec![0u8; len]` and a
`read_task_gva_by_id` each, so a GVA resolve and a copy out of guest memory,
sized by the guest.
- `Preflight` — the speculative scan asking whether metal2vulkan holds every
referenced pipeline, so a packet defers whole rather than half-executed.
- `Walk` — `walk_stream`: every record of every segment decoded and its bind
bookkeeping applied. The device's inner loop.
- `Finish` — `finish_stream`: clears, ICB executes, draw list, per-draw loop.
**Contains `draw_us`**, so `finish - draw` is the setup and result handling
around the encode, which is what `analyze.py` prints.
- `Header` — **the leftover, derived rather than measured**: the function's own
elapsed clock minus the four spans this call recorded. Header parsing, the
resource-table decode, `consume_resource_table`, and any corner nobody thought
to list all land here instead of vanishing.
That last choice is the whole method. Wrapping the header parse would have left a
gap for anything not on the list, and a gap is exactly how three sessions came to
believe the residue was `decode_packet` — it was 0.3 % of it. A derived leftover
cannot leave a gap: the five sum to `op0x37_us` on the `drain_ops` line by
construction, so either a span owns the cost or `header_us` does and the search
moves.
`measured_ns` is a **local** sum of this call's spans, not the census's running
totals. Subtracting the census would subtract the whole window from one call; the
subtraction is saturating regardless, because an underflow would print as a
colossal `header_us` rather than as the zero it means. Both return paths that can
reach it — the normal one and the deferred-translation one — close the tiling.
MEASUREMENT COST
Four `Instant::now()` pairs per exec packet, plus two per stream for walk/finish.
At ~7 800 exec packets a second that is ~0.5 ms/s against the 197 ms/s being
measured, and it lands identically in both arms of any A/B taken with it.
VERIFIED
- 1881 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`. The Metal arm
matters here: `Preflight` is `backend-vulkan`-gated and the Metal arm binds
`translation_pending` to a constant, so the accumulator had to stay used on
both.
- `analyze.py` still reads the six `pin-coal` logs, captured before these fields
existed — the new reader is its own family.
NOT VERIFIED
- No boot at this commit. Every span added here is unmeasured; the point is that
the next boot cannot come back ambiguous.
- The arm64/Metal pathway, which has no boot at all. `Preflight` will read zero
there by construction, not because the work is free.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
f310240969 |
📝 The stamp waits that hold are cross-channel, so the guard is not broken and the fix is not the one I wrote down
Pathway: x86 macOS / Linux Vulkan, drain worker. Documentation only.
`258522ee` recorded that `PendingStamp::discharges` fires zero times while
`packet_stamp_wait_held` more than doubled, and guessed at a cause: that the
comparison of `stamp_slot_index(wait.index)` against the masked
`CHILD_REG_STAMP_INDEX` might be comparing two encodings of one slot. It told the
next reader to measure before changing the line.
The measurement was already in the boot's own log, which prints both sides:
packet_stamp_wait_unmet opcode=0x37 ch1 index=2 awaited=0xe current=0xa
packet_stamp_wait_unmet opcode=0x6 ch5 index=1 awaited=0x5 current=0x3
packet_stamp_wait_unmet opcode=0x22 ch2 index=4 awaited=0x1 current=0x0
packet_stamp_wait_unmet opcode=0x3b ch2 index=1 awaited=0x19 current=0x15
Channel 1 waits on slot 2, channel 5 on slot 1, channel 2 on slots 4 and 1.
**They are waiting on slots other channels write.** The encodings agree fine;
the guard answers only the drain's own slot, by construction and by its own doc,
so it declines exactly the case this workload produces and covers one the
workload does not. It is not broken.
The mechanism is nesting: `process_child_packet` can reach `drain_other`, so
channel B's drain runs inside channel A's and A's latched stamps sit in A's stack
frame where B cannot see them. Answering a wait from them would be correct for
the same reason answering from the local latch is — the drain thread is
single-threaded, so a latched stamp is work that finished before the waiting
packet was decoded — but it needs the latch hoisted into `DeviceState` keyed by
channel.
**It is not being hoisted, and the reason is a number.** The extra holds are
2 836 over a 45 s boot, each costing a re-drain of a few microseconds — call it
0.2 ms/s, against the 88 ms/s the coalescing itself bought and the ~197 ms/s
still sitting unattributed inside `EXEC_INDIRECT2`. Touching `DeviceState` to
chase a fifth of a millisecond is the wrong order of work. The finding is
recorded because a guard that fires zero times should say why it does.
The wrong suspicion is deleted rather than left beside the right one, because a
plausible cause sitting in a doc comment is what the next session reads first.
VERIFIED
- Clippy `-D warnings` clean on backend-vulkan,host-window.
- The quoted lines are from `/tmp/cs/coal1/on3/fail.log`, one of the six boots
in `258522ee`.
NOT VERIFIED
- That the same-channel case this guard does cover ever arises on any workload.
It measured zero here, which is a fact about this probe and not about the
contract, so the guard stays.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
258522eef1 |
📝 Stamp coalescing removes 88 ms/s of a saturated thread, buys no frames, and the guard I wrote for it fires zero times
Pathway: x86 macOS / Linux Vulkan, drain worker. Documentation only — the
measurement `6783a945` said it did not have.
THE A/B
`REIMS_VGPU_STAMP_COALESCE`, three boots an arm, interleaved on one binary
(`pin-coal`), driven macos-13 `blur=40`. **All six landed in one compositing
regime** — 995.0 to 998.9 draws a presented frame — which is the check that has
to pass before any other number is comparable. No boot panicked; both arms
render the same desktop.
coalesced per packet on/off
gpu_stamps 5 777 309 399 0.019
stamp_n 7 395 319 342 0.023
stamp_us 266 691 3 911 894 0.068
stamp ms/s 5.9-6.8 77.1-97.2
unnamed in drain 224-231 314-317
duty 0.80-0.81 0.89-0.90 0.897
slot_us 29 049 37 874 0.767
ring_retire_blocks 6 204 21 967 0.282
present_hz 15.05 14.90 1.010
**The arithmetic closes.** The stamp span fell 90.3 ms/s and the whole drain
residue fell 88.6 ms/s — agreement to 2 %, which is the statement that the time
was removed rather than relocated. `proc - draw - compute` says the same from
the other side at **197 against 201 ms/s, unchanged**.
That number nearly went the other way. Compared against the *previous pin*,
`proc - draw` looked like it had grown 155 -> 199 ms/s, which would have meant
the saving was fake and something had merely moved. Within the controlled A/B
the two arms are 197 and 201. The growth was a between-build difference, and
reading it as a result is the mistake the one-binary A/B exists to prevent.
WHAT IT BUYS, STATED NARROWLY
Headroom, not frames. Duty 0.90 -> 0.81 on the same work, `slot_us` -23 %,
`ring_retire_blocks` -72 % — the drain worker holds the device lock less and the
guest's vCPU blocks on it less. `present_hz`/`offered_hz` move +1 %, which is
nothing: this is the fourth CPU win on this rail to buy zero frames, and the
standing reading is that the guest paces.
A PREDICTION IN `6783a945` THAT THE BOOT FALSIFIED
That commit argued the stamp was what flushed the draw batch — `batch_flushes`
equalled `batch_opens` at 1.58 draws a flush, and
`write_stamp_after_guest_writes` appends to the open batch and then flushes it.
Removing 98 % of the stamps should therefore have let the batch accumulate.
**It did not.** `batch_flushes` is 314 474 against 318 631, ratio 0.987, at 1.90
draws a flush against 1.85. The batch is flushed by something else and the stamp
was riding along with a flush that was going to happen anyway. The claim is
retired in the `PendingStamp` doc so the next reader does not inherit it; what
flushes the batch is now an open question and not a settled one.
AND A GUARD THAT DOES NOT WORK
`PendingStamp::discharges` exists so a packet waiting on the slot its own drain
is holding is answered from the latch instead of from the stale word in guest
RAM. On the coalesced arm it fired **zero times**, while
`packet_stamp_wait_held` **more than doubled** — 5 073 against 2 237 — carrying
`setup_calls` up 47 % in re-drains.
Those two readings together say the comparison never matches, so the packets it
was written for fall through to the stale word. Not a correctness failure: every
`break` flushes the pending stamp, so a held packet's retry finds the word, no
frame was lost and the holds are 1.5 % of 330 083 packets. But it is ~2 800
avoidable round trips a boot behind a guard that reads as working, which is worse
than no guard.
The suspicion — and it is only that — is the slot encoding: `discharges`
compares `stamp_slot_index(wait.index)` against the same masking of
`CHILD_REG_STAMP_INDEX`, and a wait naming its slot differently than that
register does would make the equality unsatisfiable. The doc says to **measure
which slots each side names before touching the comparison**, because this whole
residue has already cost three sessions of nominating a cause and fixing it
unmeasured.
VERIFIED
- 1881 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`.
- Six driven boots as above; screenshots compared between arms.
NOT VERIFIED
- Anything outside macos-13 and this probe. One rail, one workload.
- The arm64/Metal pathway, which has no boot at all.
- `REIMS_VGPU_GUEST_IMPORT=off` — the copying rails a host without the
host-pointer import is forced onto have not been run against this change, and
a capable host never exercises them.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
6783a94576 |
✨ A drain of one channel stamps one slot, so it submits one command buffer and not eleven
Pathway: x86 macOS / Linux Vulkan, drain worker. Behavior change on the child
FIFO's completion-stamp path, switched by `REIMS_VGPU_STAMP_COALESCE`.
THE MEASUREMENT THAT ASKED FOR THIS
`cb718e5f` split the drain residue's `regs` span three ways. Two driven macos-13
`blur=40` boots (`pin-split`), medians over 74 and 75 census windows:
tailrd 0.49 / 0.48 ms/s 59 / 58 ns per op
headwr 1.00 / 0.99 ms/s 128 / 127 ns per op
stamp 92.29 / 98.59 ms/s 12266 / 13334 ns per op
sum vs regs_us = 1.00 on every window
The two accesses that really are four-byte guest word accesses cost **1.5 ms a
second between them**. The stamp is **98.4 % of the span at 12.3 microseconds a
packet**, because `write_stamp` is not a word write: on the Vulkan arm it takes
the engine lock, binds the guest RAM reference, records a barrier and a
`cmd_update_buffer`, reserves a timeline value, and **submits a command buffer**.
`engine_delta` says the same thing from the other side, and this is the part that
generalizes past the stamp:
batch_opens=6812 batch_joins=3934 batch_flushes=6812 batch_flush_draws=10746
**`batch_flushes` equals `batch_opens` exactly, at 1.58 draws a flush.** The draw
batch exists to amortize submits across draws and was never allowed to
accumulate any, because `write_stamp_after_guest_writes` appends to the open
batch and then flushes it. Every packet's stamp flushed whatever draws had
gathered.
WHAT THE CONTRACT LICENSES
Two facts, neither of them a heuristic:
1. **A stamp wait is `>=`, not `==`.** `StampWait::satisfied_by` is
`current.wrapping_sub(self.value) as i32 >= 0`, so a wait on V is discharged
by any value at or past V in wrapping-signed order. Intermediate values need
never appear.
2. **A drain of one channel stamps one slot.** `stamp_index` is read once from
the channel's register block *before* the loop, so every packet in a
`drain_child_fifo` call writes the same slot. A run of writes to one slot is
observable only through its greatest value unless the guest samples between
them.
So `drain_child_fifo` now latches each packet's completion stamp into a
`PendingStamp` and writes once, after the loop. A driven boot averages **11.6
packets per drain call** (`packets` ~6400/s over `setup_calls` ~550-600/s), so
this removes roughly ten submissions in eleven.
THE TWO HAZARDS IT HAD TO DISPOSE OF, AND HOW
**A wait on the slot the drain is holding.** `note_packet_stamp_waits` reads the
word out of guest RAM, which is now stale by exactly the stamps this drain has
latched. A later packet in the same drain waiting on that slot would read the old
value, return `Hold`, and park the channel against a stamp this device is itself
sitting on — a deadlock introduced by the coalescing rather than by the guest. It
now consults the latch first, and answering from it is not a shortcut: packets
are processed in order on this thread, so a latched stamp is work that finished
before the waiting packet was decoded. Counted as `packet_stamp_wait_met_pending`
so the reliance is measurable rather than assumed.
**A latched stamp that never lands.** Every `break` in that loop falls through to
one site after it, which is why one flush is enough — a drain that stops on a
held stamp, a deferred translation, a decode fault or a host-action yield owes
what it latched exactly as one that ran the ring dry does. Leaving one unwritten
is a guest waiting on a word that never arrives, and its own deadline is a
second, so it would present as a stall rather than a hang.
`PendingStamp::latch` keeps the **maximum in wrapping-signed order**, not the
last value seen. For a well-formed guest those are the same value; taking the
maximum means this device cannot publish a slot going backwards even if a
regressing stamp arrives, which would unsatisfy a wait the guest had already been
told was met.
The main FIFO is unchanged and passes `None`: it stamps per packet and its slot
is not fixed across a drain, so neither fact above holds there. It also executed
zero times on this workload.
SWITCH
`REIMS_VGPU_STAMP_COALESCE=off` restores the per-packet arm on the same binary,
because a change to *when* a completion becomes visible fails as a stall or a
stutter rather than as a decline, and both arms have to be reachable for one A/B.
Off is a refusal and never a permission — one write per packet is strictly more
work than one per drain, and the coalesced arm needs no capability the per-packet
arm does not.
VERIFIED
- 1881 tests pass (+2), `--test-threads=1`, backend-vulkan,host-window.
- Both new tests fail without the change. `a_coalesced_stamp_keeps_the_latest_
value_across_the_u32_wrap` was probed by stubbing `latch` to last-write-wins
and fails on the regressing-stamp assertion; the file was restored by copying
it back, not with git.
- Clippy `-D warnings` clean on all three arms.
- `scripts/feature-matrix`: all supported arms compile, warnings=0, lib count
1881 (was 1879).
NOT VERIFIED
- **No boot.** Nothing here is measured on a guest yet: not the saving, not the
frame rate, and not that the desktop still composites. That is the next step
and it is an A/B against `=off` on one binary.
- Whether `batch_flushes` actually falls and whether the draw batch then
accumulates. The prediction is that it does and that the win is larger than the
92 ms/s the stamp span itself carries, but a prediction is not a reading.
- The arm64/Metal pathway. The coalescing is backend-independent but `write_stamp`'s
GPU rail is `backend-vulkan`-gated, so the saving is expected to differ there
and no Apple host has booted it.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
cb718e5f38 |
✨ The residue is the stamp and the dispatch, and the two spans three sessions chased are 6% of it
Pathway: x86 macOS / Linux Vulkan, drain worker. Instrument only; no behavior
change.
WHAT THE TILING ANSWERED
`b03b2559` covered `drain_child_fifo` end to end with five spans instead of
nominating a fourth candidate. Two driven macos-13 `blur=40` boots
(`qemu-system-x86_64-pin-tile`), medians over the busy windows of each:
outside child fifo 0.02 ms/s <- the loop is covered; nothing hides
residue (unnamed in drain) 270 ms/s, inside drain_us 849 at duty 0.84
proc - draw - compute 155 ms/s 57 % 24 us/packet
regs 97 ms/s 36 % 5055 ns/op
ring 16 ms/s 6 % 1266 ns/read
decode 0.7 ms/s 0.3 % 117 ns/packet
setup 0.19 ms/s 0.07 % 0.33 us/call
The second boot reproduces every column (`regs` 88-105 ms/s, `ring` 15-16,
`proc - draw` ~165) across its 18 busy windows.
So `decode_packet` and the ring reader — the two candidates the previous two
sessions nominated from reading the code, one of which was the wrong function
entirely — are **6.3 % of the residue between them**. That is what `share of
unnamed` has been reporting at 0.06 and it is now explained rather than merely
observed. Both are retired; do not re-open either.
WHY THIS COMMIT SPLITS THEM FURTHER RATHER THAN FIXING ANYTHING
Two spans carry 93 % of the residue and neither is yet attributable to a site.
**`regs` is not register traffic.** The span was added expecting three cheap
guest word accesses a packet: the `CHILD_REG_TAIL` read, the `CHILD_REG_HEAD`
writeback, the completion stamp. It measured **5055 ns an access, 25x** what a
four-byte `address_space_read` costs, with a distribution running 65 ns at the
low end to 59 us at the high — which no word access has. `write_stamp` is the
candidate: on the Vulkan arm it tries `stamp_word_ordered_on_gpu` first, which
resolves a guest RAM reference and *submits a command buffer*, and falls through
to a blocking settle when that declines. But that is a reading of the code, and
readings of the code are 0-for-3 here, so this commit measures it instead:
`regs_ns` splits three ways by `RegsOp`, emitted beside the total so
`tailrd + headwr + stamp == regs` is checkable on the line itself.
**`proc - draw` is 24 us a packet against a decode that costs 117 ns**, over a
match with ~24 arms of which exactly one has ever been timed. Nothing says
whether that 155 ms is one arm or spread across all of them, so `proc_ns` now
splits by opcode onto its own `drain_ops` line under `drain_duty`.
THE OPCODE TABLE IS SIZED BY THE CONTRACT, NOT BY A SLOT COUNT
First draft was an associative table of 48 slots with a probe and a dropped-entry
counter. That is the bound class AGENTS.md warns about — a hand-picked capacity
that can be one short — so it was replaced with direct indexing over
`0..=CHILD_OP_MAX`, taking the width from `crate::model::CHILD_OP_MAX` rather
than from a count of the arms that happen to exist. There is no overflow left to
count: every opcode the guest can legally send has a slot, and one above the
maximum lands in `above_max`, which is a decoder result rather than a table
result since decode refuses those long before here.
`ProcOpTable` is its own type only because `#[derive(Default)]` stops at
32-element arrays and this is 65 wide. That is the entire cost of deriving the
bound instead of picking it.
`RegsOp` is a type rather than an index for the same reason the rest of the
crate's own vocabulary is: the consumer gets an exhaustiveness check, and the
integer appears once, in `label()`.
MEASUREMENT COST
Unchanged from `b03b2559` — the same four `Instant::now()` pairs a packet, now
attributed rather than aggregated. The opcode table adds one bounds-checked
index and two relaxed adds per packet.
VERIFIED
- 1879 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on all three arms: backend-vulkan,host-window;
`--target x86_64-unknown-linux-gnu` with the same features; and
`--target aarch64-apple-darwin --features backend-metal`.
- `analyze.py` still reads a log captured before these fields existed — the new
readers are their own families, so the tiling block prints unchanged on the
two `pin-tile` logs.
NOT VERIFIED
- No boot at this commit. Which of the three accesses carries the 97 ms/s, and
which opcodes carry the 155 ms/s, are both unmeasured — that is what the next
boot is for.
- The arm64/Metal pathway. `write_stamp`'s GPU rail is `backend-vulkan`-gated,
so the `Stamp` reading is expected to differ there and nothing has booted it.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
b03b255946 |
✨ Tile the whole child-FIFO loop rather than sample it at a third point, because naming a candidate from reading the code is 0-for-2
Pathway: x86 macOS / Linux Vulkan, drain worker. Instrument only; no behavior
change.
THE PROBLEM WITH THE LAST TWO INSTRUMENTS
`drain_us` is 830-920 ms a second at duty 0.83-0.91 on a driven macos-13
`blur=40` boot, against `draw_us` 543-598. The 275-319 ms/s difference is a
third of the one thread every guest packet serializes through, and it is named
by nothing.
Two commits tried to name it by reading the code first and timing the candidate
second. `1937db0c` timed `decode_packet` and `read_ring_bytes`; the boot put
them at **0.2 % of the residue between them**, and one of the two was the wrong
function entirely — `read_ring_bytes` serves the root FIFO and executed zero
times, which `8ae8e9d5` repaired by adding the same timer to the child FIFO's
reader. Both candidates read convincingly in prose and neither was the cost.
So this stops proposing candidates. Instead of a third guess it tiles
`drain_child_fifo` end to end, so the answer is arithmetic rather than a
nomination:
setup + N x ( regs + ring x2 + decode + proc )
Five spans, and they cover one iteration of the loop with nothing between them:
- `proc_us` — the whole `process_child_packet` dispatch, all ~24 arms. It
contains `draw_us` and `compute_us`, which name themselves on the same census
line, so `proc - draw - compute` is the dispatch's own per-opcode cost.
- `regs_us` / `regs_ops` — the guest register traffic every packet pays around
the dispatch: the `CHILD_REG_TAIL` read at the top of the loop, the
`CHILD_REG_HEAD` writeback, and the completion stamp. Three accesses a packet
that no phase has ever counted.
- `setup_us` / `setup_calls` — the per-call prologue: three register reads,
`ensure_child_ring`, and the `page_gpas.clone()` the loop reads its ring
through.
`ring_us` and `decode_us` already existed and complete the tiling.
WHAT THIS BUYS THAT A THIRD CANDIDATE WOULD NOT
The subtraction now closes. `analyze.py` grows an `outside child fifo` row —
`drain_us` less the tail, the boundary and all five spans — and that row is the
instrument's real output. A small one means the residue is inside this loop and
the five spans say which part. A large one means the cost is not in the child
FIFO at all and the search moves to the main FIFO, the mapper, or the pending
loop, none of which any candidate so far has even considered. Either way the
next step is read off the line rather than argued for.
COST OF THE MEASUREMENT
Four extra `Instant::now()` pairs a packet, ~40 000 a second at the observed
8 000 packets/s. A vDSO `clock_gettime` is ~20-25 ns, so ~1 ms/s against a
275-319 ms/s residue — under half a percent of the thing being measured, and it
lands identically in both arms of any A/B taken with it.
Nanoseconds, not microseconds, for the reason the existing pair documents:
`regs_ns` fires three times a packet and each sample is a handful of guest word
accesses, so `as_micros()` would truncate nearly every one to zero and report a
rail that runs 24 000 times a second as free.
VERIFIED
- 1879 tests pass, `--test-threads=1`, backend-vulkan,host-window.
- Clippy `-D warnings` clean on backend-vulkan,host-window and on
`--target aarch64-apple-darwin --features backend-metal`.
NOT VERIFIED
- No boot at this commit. Every span added here is unmeasured; the point of the
commit is that the next boot cannot come back ambiguous, not that it has come
back.
- The arm64/Metal pathway. `drain_child_fifo` is backend-independent so the
spans exist there too, but nothing has booted them.
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|
|
8ae8e9d5e9 |
🐛 The ring reader I timed is the one that never runs, and the hot FIFO has its own
Pathway: x86 macOS / Linux Vulkan, drain worker. Instrument only. |
||
|
|
1937db0c36 |
✨ The third of the drain worker named by nothing gets a per-packet split, because the residue scales with draws and every packet pays two ring reads and a decode
Pathway: x86 macOS / Linux Vulkan, drain worker. Instrument only — no behaviour change. `tail_us`/`boundary_us` closed the two spans after `Device::drain` returns and found them near-empty (1.5 ms/s and 0), which localized the residue to inside `runtime::drain::drain_pending` and no further. There is no `Instant::now` anywhere in either FIFO function, so nothing inside it could be ranked. Three driven macos-13 sustained-animation boots at |
||
|
|
71462a94c8 |
🐛 The draw path leaves the same layout hole, on three rails and every boot, and the guard that found it only counted
Pathway: x86 macOS / Linux Vulkan, render path. Companion to |
||
|
|
25051457a3 |
🐛 A compute kernel that samples a texture the guest never bound left a hole in the layout, and one driver divides by it
Pathway: x86 macOS / Linux Vulkan, compute dispatch. Reported from a user's host: QEMU killed by SIGFPE (rc=136) on an Intel Iris Xe / Mesa 26.1.5 guest session, the fault inside vkCreateComputePipelines on the drain thread, under `ObjectCaches::get_or_create_compute_pipeline`. WHAT IS WRONG Vulkan requires the pipeline layout to contain a descriptor for every resource the module *statically uses*. The descriptor set layout this device builds is assembled from what the guest bound (`exec_compute.rs`'s `LayoutKey`), so a texture the kernel samples and the guest left empty is absent from the layout entirely — not an unwritten slot in it. `kb/frag-descriptor-unbound-is-a-real- violation.md` established that population on the *draw* path and named the repair; this is the same defect on the compute path, and it is not merely undefined. Mesa's ANV sizes its own binding array to `max_binding + 1`, zero-fills every number the layout did not declare, and then scores each used binding as `(use_count << 7) / binding->array_size` when it picks binding-table slots (`anv_nir_apply_pipeline_layout.c`, `anv_CreateDescriptorSetLayout`). A hole under a used binding divides by zero. `vkCreateComputePipelines` therefore does not return an error — the host process dies inside it and takes the VM with it. There is no validation layer in this tree and no status to inspect, so nothing downstream could have reported this. WHAT CHANGED - `spirv_bind::sampled_image_bindings` — the texture analogue of the sampler walk that already existed. Class from the SPIR-V type, never the binding number: `OpTypeImage` with `Sampled` 1 and `Dim` not `SubpassData`. - `spirv_bind::declared_binding_numbers` — the class-blind candidate sweep the backstop asks `descriptor_static_use` about. - `runtime::compute_exec` provisions a neutral 1x1 transparent texture for every sampled-image binding the module statically uses and the guest left empty, mirroring the neutral-sampler pass a few lines below it. Reported on the fail channel as `compute_neutral_sampled_image_unbound`, because it is a repair that succeeded and the reliance has to stay measurable. - `exec_compute::used_binding_absent_from_layout` refuses the dispatch if any used binding is still absent when the layout is built, as `ComputeExecutionDecline::UsedBindingAbsentFromLayout`. Expected to stay at zero; it is the backstop for a class the repair above does not cover, and losing one dispatch is the only outcome left that keeps the VM alive. Only `Used` is provisioned. `DeclaredUnused` is legal to omit and must stay omitted or the census that separated the two populations cannot tell them apart; `Ambiguous` is two variables on one binding, which is its own defect and is not repaired by picking one. `descriptor_static_use` answers `NotDeclared` for anything that is not a `UniformConstant` descriptor, so a storage buffer — whose root that walk cannot resolve — is never refused on a guess. VERIFIED - 1878 tests pass, `--test-threads=1`, backend-vulkan,host-window. Three new: the two walks partition set 0; the class-blind sweep vs the use test; the neutral pass fills the used binding and not the declared-unused one; the backstop refuses by number and admits the legal layout. - Probed: stubbing the `is_violation` filter out of the neutral pass fails the test, so it discriminates rather than merely running. - Clippy `-D warnings` clean on all three arms (backend-vulkan+host-window, the same with an explicit x86_64-unknown-linux-gnu target, and backend-metal under --target aarch64-apple-darwin). The three new items are `backend-vulkan`-gated; the Metal arm found that and it is now honest. - The reflection was checked against the actual reporting shader by an independent parser, not against itself: it declares set 0 bindings 1-10 (storage buffers), 32 (storage image), 33-38 (sampled images) and 160 (sampler), and every one of them is statically used. The reporting host's own log shows the guest wrote 3 of the 6 sampled images, and the fault operand resolves to `binding[33].array_size` — the first used binding with no layout entry, which is exactly this defect. NOT VERIFIED - No live boot. This is a Linux/Vulkan host-side layout fix; the machine that reproduces it is an Intel iGPU and this dev host has no Intel GPU, so the SIGFPE itself cannot be re-triggered here. The repair is verified by test and by the driver's own published source, not by a boot. - Whether the guest's kernel depended on the contents of the textures it did not bind. The neutral texture is transparent and 1x1; a kernel that queries its size gets 1x1. The fail line is what makes that reliance findable later. - The draw path carries the same defect (2-3 firings a boot on rails 14, 15 and 26 per the kb note) and is NOT fixed here. - No throughput measurement. The neutral images are 4 bytes each and only materialize when the guest under-binds. Co-Authored-By: Claude <noreply@anthropic.com> |