✨ 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.
This commit is contained in:
Anees Iqbal committed 2026-08-11 19:54:38 +03:00
1 parent 43d4884b2d
commit 8c7fc027b5
2 files changed
+57 -2

No files matched your search

+15 -2
View File
@@ -96,8 +96,21 @@
/// cannot test and it is written here so an operator on an iGPU knows there is a
/// second arm worth two boots.
///
/// One matched pair, one rail, one regime. The unmatched boots are not quoted
/// because `fresh` is not comparable across compositing regimes.
/// One matched pair for the frame rate; the per-draw GPU cost has since
/// replicated across **four boots an arm and three compositing regimes**, and the
/// arms do not come close to touching:
///
/// ```text
/// import off 6.89 6.04 6.61 6.60
/// import on 15.37 13.72 13.84 16.03 (and 14.90, 15.26, 15.85, 13.94)
/// ```
///
/// Drain duty runs 0.66-0.82 on the copying arm against 0.36-0.64 on the import
/// arm, which is the same trade seen from the other side: the worker pays what
/// the GPU does not.
///
/// The frame-rate half stays a single matched pair, because `fresh` is not
/// comparable across compositing regimes and only one pair matched.
pub const GUEST_IMPORT: &str = "REIMS_VGPU_GUEST_IMPORT";
/// Verbose per-draw logging on top of the always-on fail sink.
@@ -2868,6 +2868,46 @@ fn bound_buffer_content(
/// 512), so that condition is rarely met and the rail is close to inert — which
/// is the honest outcome, not a bug to tune around. On the CPU read the cap is
/// free: that bind was reading the whole window uncached either way.
/// Charge one bind that took the gather rail to the extent-headroom split: how
/// many of the bytes this rail is about to move a declared object size would
/// have removed.
///
/// # The question two prior measurements leave open
///
/// `try_buffer_zero_copy_resolved`'s doc puts 67.5 % of a boot's gathered bytes
/// on vertex-stage constant buffers that no vertex descriptor bounds, and says
/// the way to reopen them is for the translator to answer whether the bind is a
/// bounded reference or an indexable pointer. **It now answers.** A driven
/// macos-13 boot at the current pin reads `bext_unknown=0` against
/// `bext_object=1 179 068` — and every one of those objects is small, 601 826 at
/// 64 bytes or under and 577 143 between 65 and 512.
///
/// `load_buffer_content`'s own doc measured the other side: applying the cap
/// everywhere saved **2.2 GB a run** and cost half the held resolutions, for no
/// change in `draw_us/draw`. Both cannot be true of one workload. 2.2 GB a run
/// is ~2 % of what this rail moves, and 67.5 % of the bytes sitting behind caps
/// of 512 bytes or less would be nearly all of it.
///
/// So this counts the bytes rather than arguing about them, without changing
/// what any bind does. `bext_would_save_bytes` against `gather_bytes` is the
/// whole answer, and `bext_capped_span_bytes` beside `bext_uncapped_span_bytes`
/// says how much of the traffic even has a cap to apply.
///
/// The other 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. The gather is a PCIe copy
/// and about 55 % of all GPU time here, and no CPU counter was ever going to
/// see it.
fn note_extent_headroom(extent_cap: Option<u64>, span: u64) {
let Some(cap) = extent_cap else {
crate::runtime::drain::note_store_route_n("bext_uncapped_span_bytes", span);
return;
};
crate::runtime::drain::note_store_route_n("bext_capped_span_bytes", span);
if cap < span {
crate::runtime::drain::note_store_route_n("bext_would_save_bytes", span - cap);
}
}
fn load_buffer_content<M: HostMemory + HostOps>(
state: &mut DeviceState,
host: &mut M,
@@ -2893,6 +2933,7 @@ fn load_buffer_content<M: HostMemory + HostOps>(
{
let content = bound_buffer_content(bound);
crate::runtime::drain::note_store_route("zc_buffer_held");
note_extent_headroom(extent_cap, bound.span);
note_gather_freshness(state, task_id, buffer_ref, offset, gather_cap, bound);
return Some(content);
}
@@ -2908,6 +2949,7 @@ fn load_buffer_content<M: HostMemory + HostOps>(
{
let content = bound_buffer_content(&bound);
// Before the insert, which takes `state` mutably and moves `bound`.
note_extent_headroom(extent_cap, bound.span);
note_gather_freshness(state, task_id, buffer_ref, offset, gather_cap, &bound);
state
.bound_buffers