Skip to content

borealis: give pending timestamp copies carriers where stamps are host-published - #1561

Merged
DjDeveloperr merged 3 commits into
aurora-wipfrom
feat/borealis-g17-stamp-copy-carriers
Dec 3, 2026
Merged

DjDeveloperr merged 3 commits into
aurora-wipfrom
feat/borealis-g17-stamp-copy-carriers

Conversation

@erikwb

@erikwb erikwb commented Dec 2, 2026 •

Copy link
Copy Markdown

What: On kernels that publish command timestamps on the host (DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS), a timestamp-copy launch reads a stamp whose writer may not have retired yet, so the kernel holds it—and every later compute command—until the host has published that stamp. Pending timestamp copies (such as two leading stamps ahead of every stream, a second end stamp of a render, or stamps after an open pass-merge candidate) now become timestamp-only carriers of their own when flushed, each ordered after what the copy would have read and after the preceding carrier. Eligible pending copies flush into carriers before the next compute stream opens, and copies of a leading stamp also before the next non-merged render pass, so begin stamps stay ahead of the work they measure and GPU zone durations never collapse. Copies of a render's end stamp stay pending when another render follows (they already have its value) and share one launch, as on the base; pass-merge candidacy stays intact until non-merging work opens, and long carrier runs, intervening appends to an open stream, or cases where a later timestamp was placed without flushing keep the single value-copy launch.

Tested:

  • Head 94f04fbeaa7c (one commit by DjDeveloperr over 29a55378fdb: no carrier between two renders) merged into aurora-wip 80a0ac5d0cdd: asahi + poly + vulkan Meson suites 465 ok, 0 failed, 1 skipped; hk_sync_stamps_test 1541/1541. The hardware rows below are at 29a55378fdb; the render same 2×32 lines are what that commit addresses and need a new run at 94f04fbeaa7c.
  • Exact head 29a55378fdb (against merge-base aurora-wip 3146ce4726a, host unit tests): hk_sync_stamps_test 1381/1381 pass (including all 6 GPU zone placement patterns A–F across G17S/G17C/G17G/G17P × exact/legacy = 48/48, G16G placement, mid-pass splits, open-stream append + barrier closure, carrier pinning, and mid-batch OOM), hk_query_oq_test 226/226 pass, hk_query_no_access, hk_query_reset, hk_tess_batch, hk_sync_prior, hk_host_flush, hk_pack, hk_render_pack, borealis-sync-runner, and agx_tests all pass.
  • Exact head 29a55378fdb vs base 3146ce4726a, Vulkan CTS A/B (query_pool.*, pipeline.*.timestamp.*, synchronization{,2}.basic.*, api.buffer_marker.*, 19,414 cases each, plain aurora-silicon/linux main daily kernel 7.3.0-daily2+, no out-of-tree kernel PRs):
    • J716c (M5 Max, G17C): 19,386 pass / 0 fail / 28 not supported, 0 diffs, 0 GPU errors.
    • J713 (M4, G16G): 19,316 pass / 0 fail / 98 not supported, 0 diffs, 0 GPU errors.
    • J313 (M1, G13G): 19,145 pass / 0 fail / 269 not supported, 0 diffs, 0 GPU errors.
  • Plain main kernel speed A/B (7.3.0-daily2+, clean aurora-wip 3146ce4726a vs exact head 29a55378fdb, without linux#3443/#3991 or mesa#1556/#1557):
    • stampruns multi-CB render stamp runs (J716c, G17C): render cbs 2×32 4639.8 → 1311.8 µs CPU median (3.54× faster / -71.7%, GPU span 4334.2 → 996.9 µs); render cbs 3×32 4614.2 → 1677.2 µs (2.75× faster / -63.7%); long runs unchanged (render same 64: 244.4 → 239.7 µs, 1024: 2157.6 → 2170.0 µs).
    • stampruns multi-CB render stamp runs (J713, G16G): render cbs 2×32 5074.0 → 3037.5 µs CPU median (1.67× faster / -40.1%, GPU span 4638.6 → 2421.2 µs); render cbs 3×32 5111.7 → 4038.4 µs (1.27× faster / -21.0%); long runs unchanged (render same 64: 524.6 → 514.4 µs, 1024: 1628.2 → 1631.0 µs).
    • Cyberpunk 2077 2.5 T2 (2560×1600 High, J716c, plain 7.3.0-daily2+, cur-fex-main-vkmain): base 3146ce4726a 55.56 FPS (min 46.10, p99 23.0 ms, 0 faults) vs head 29a55378fdb 55.69 FPS (min 47.20, p99 22.9 ms, 0 faults): +0.13 FPS (+0.23%), 0 GPU faults (no regression from extra pending timestamp writers on plain main).

Risk: two-way door · Macs whose kernel publishes timestamps on the host (M4, M4 Pro/Max, M5 Pro/Max/Ultra, MacBook Neo; M3/M3 Pro where host-published). Other Macs are unchanged.

Not yet: M4 Pro/Max, M5 Pro/Ultra, and MacBook Neo hardware (not in this lab).

Details
  • Every vkCmdWriteTimestamp2 recorded before any stream of a command buffer waits as a leading stamp (hk_sync_state::lead_ts) for the first stream; a second leading stamp becomes a pending copy of it. With nothing else in the command buffer, vkEndCommandBuffer gave the leading stamp a timestamp-only carrier and launched libagx_copy_timestamps right behind it in the same submission. That launch recorded the carrier's stamp as a query range it reads, so hk_query_stamps_conflict() dropped DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS, stalling the compute queue until the carrier retired and the host published its stamp. The same held for a render's second end stamp and stamps after an open pass-merge candidate.
  • hk_sync_flush_stamp_copies() and hk_sync_flush_stamp_copies_as_carriers() convert up to HK_SYNC_STAMP_CARRIER_RUN (8) pending copies into timestamp-only carriers when stamps are host-published, outside a render pass instance, outside internal resolves, with no pinned stream, with no pending start timestamp, not preceded by a full carrier run, when no later timestamp or intervening work locked the batch (!stamp_copy_must_copy), and while every pending copy still sits at the current stream tail (stamp_copies_current()). Each carrier waits for the commands the copy would have read and for the preceding carrier, preserving recording order without touching query memory.
  • Placement and ordering safety:
    • Before opening the next non-stamp compute/graphics stream (hk_cmd_buffer_get_cs_general()) or, for copies of a leading stamp, non-merged render pass (hk_sync_begin_rendering()), hk_sync_flush_stamp_copies_as_carriers() emits eligible pending copies into carriers ahead of the new work so begin stamps stay before the work they measure and end stamps can ride on the work stream itself. Compatible pass merges bypass hk_sync_begin_rendering(), keeping pass-merge candidacy intact.
    • stamp_copies_current() enforces as a hard invariant that pending copies never convert into carriers after intervening non-carrier work. Appending non-stamp work to an already-open earlier compute stream locks pending copies via stamp_copy_must_copy, and overflow copies queued after a full HK_SYNC_STAMP_CARRIER_RUN carrier run also lock stamp_copy_must_copy so they stay a value-copy launch of the final carrier.
    • stamp_carrier_launch() keeps kind_override = HK_SYNC_STAMP and pin_cs = true across its executable scratch store so the carrier is never replaced or reclassified, and hk_g17p_meta_fill_addr() preserves cmd->state.cs.descriptors.root.cs so a pre-dispatch carrier cannot overwrite base_group, group_count_addr, or grid_helper_sparse_map_addr.
    • Stream allocation failure in hk_cs_create_at() or mid-batch in stamp_copies_carry() sets VK_ERROR_OUT_OF_HOST_MEMORY on the command buffer rather than silently dropping remaining timestamps.
Evidence

Host unit tests at 29a55378fdb:

  • hk_sync_stamps_test: 1381 tests, 0 failures
  • hk_query_oq_test: 226 tests, 0 failures
  • hk_query_no_access, hk_query_reset, hk_tess_batch, hk_sync_prior, hk_host_flush, hk_pack, hk_render_pack, borealis-sync-runner, agx_tests: all pass (11/11 suites)

Vulkan CTS A/B (aurora-cts-ab, dEQP-VK 7ba03cdac7ae, base 3146ce4726a vs head 29a55378fdb, plain aurora-silicon/linux main daily kernel 7.3.0-daily2+):

Machine Cases Base Pass Head Pass Fail NotSupported Diffs GPU errors (head)
J716c (M5 Max, G17C) 19,414 19,386 19,386 0 28 0 0
J713 (M4, G16G) 19,414 19,316 19,316 0 98 0 0
J313 (M1, G13G) 19,414 19,145 19,145 0 269 0 0

stampruns A/B (base 3146ce4726a vs head 29a55378fdb, plain 7.3.0-daily2+, 50 iters, 0 bad values):

Machine Pattern Base CPU med (µs) Head CPU med (µs) Delta Base GPU span (µs) Head GPU span (µs)
J716c (G17C) render cbs 2×32 4639.8 1311.8 -71.7% (3.54×) 4334.2 996.9
J716c (G17C) render cbs 3×32 4614.2 1677.2 -63.7% (2.75×) 4319.1 1303.7
J716c (G17C) render same 2×32 908.1 1310.7 +44.3% 529.4 991.2
J716c (G17C) render same 64×1 244.4 239.7 -1.9% 0.0 0.0
J716c (G17C) render same 1024×1 2157.6 2170.0 +0.6% 1880.2 1885.9
J713 (G16G) render cbs 2×32 5074.0 3037.5 -40.1% (1.67×) 4638.6 2421.2
J713 (G16G) render cbs 3×32 5111.7 4038.4 -21.0% (1.27×) 4665.1 3452.2
J713 (G16G) render same 2×32 1801.6 3031.7 +68.3% 1064.5 2435.6
J713 (G16G) render same 64×1 524.6 514.4 -1.9% 121.7 122.5
J713 (G16G) render same 1024×1 1628.2 1631.0 +0.2% 1231.6 1229.8

(In render same 2×32, 32 render-pair copies in a single command buffer previously batched into one end-of-CB copy launch and now flush into individual pre-render carriers to keep each zone begin stamp ahead of the next render; across separate command buffers render cbs, eliminating the per-CB host-publish drain cuts latency 3.54× on J716c and 1.67× on J713.)

Cyberpunk 2077 2.5 T2 (2560×1600 High, J716c, plain 7.3.0-daily2+, cur-fex-main-vkmain, run-ab.py, clean aurora-wip 3146ce4726a vs exact head 29a55378fdb):

Arm Build SHA-256 Avg FPS Min FPS p99 Compute busy Faults
base 3146ce4726a a2582dc94b96 55.56 46.10 23.0 ms 96% 0
head 29a55378fdb d9def9479ddb 55.69 (+0.13 / +0.23%) 47.20 22.9 ms 96% 0

…t-published

Where the kernel publishes command timestamps on the host
(DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS), a timestamp-copy launch reads
stamps whose writers may not have retired yet. It then gets no
DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS, and the kernel holds it, and every later
command of the compute queue, until the writers retire and the host has
published their stamps.

Two stamps recorded ahead of every stream of a command buffer hit this every
time: the first becomes a carrier at the end of the command buffer, and the
second a copy of it launched right behind, in the same submission. The copy
always waits for the carrier to retire on the host, and the compute work of
the next submissions queues behind it. A second end stamp of a render, or a
stamp after the open pass-merge candidate, is copied the same way.

When such copies are flushed, give each copied stamp a timestamp-only
carrier of its own instead, ordered after the commands the copy would have
read and after the carrier before it. A carrier touches no query word, so it
keeps DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS and waits only on the GPU; its stamp
is written when it completes, after its source, so the values stay ordered.
A later timestamp outside a render pass (and not on an open pass-merge
candidate) flushes pending copies into carriers before placing itself so the
carriers cannot latch after it; if a later timestamp is placed without
flushing pending copies first (inside a render pass, on an open pass-merge
candidate, or as an unordered start stamp), those pending copies stay value
copies of their sources so timestamp order is never reversed. Copies left by
a full run of carriers, more copies than such a run, copies inside a render
pass instance and copies into a pinned stream also keep the launch, so a
long run of stamps still costs a few commands.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners December 2, 2026 22:54

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 552e5e9f1747 against aurora-wip e4346bdb3a55. One thing needs fixing before this merges: a pending copy can now be stamped after work that was recorded later than it, so GPU zones that start on that stamp read about zero.

What breaks

Today a pending copy takes the value of an earlier stamp, so it does not matter when the launch runs. With this PR the copy becomes a carrier at flush time, and the flush happens at the next stamp or at the end of the command buffer. Any dispatch or render recorded in between has already run by then. Timestamp order stays correct (I found no case where Q0 <= Q1 <= Q2 inverts), but the stamp no longer marks its recorded place, which the code around it takes care to keep ("keep the stream boundary so the stamp stays at the recorded position").

I added six cases to test-hk-sync-stamps.c, each with a begin stamp, some work, and an end stamp, then built the same file on base and on the merge. Host-published stamps on, G17S/G17C/G17G/G17P, exact and legacy priors (8 runs per case):

Case Base: begin stamp This PR: begin stamp
A. Q0, Q1 (begin), dispatch, Q2 (end) command 1, work is command 2 command 3, after the work (2); end is 4
B. Q0, Q1 (begin), render, Q2 (end) vertex end of the render carrier that waits for that render (barrier[VDM] = 1)
C. render (pass-merge candidate), Q0 (its end), Q1 TOP_OF_PIPE (begin), dispatch, Q2 (end) end of the render compute command 2, after the dispatch (1)
D. C with ALL_COMMANDS and a render to compute barrier end of the render compute command 2, after the dispatch (1)
E. more than 8 stamps in a row, dispatch, end carrier 9, work is 10 command 12, after the work
F. two stamps inside one render, dispatch, end end of the render compute command 2, after the dispatch (1)

Base: 48/48 in place. This PR: 0/48, and the end stamp is the very next carrier, so each zone is one empty carrier long. B is a hard wait in the command's barriers; in the others the carrier is submitted behind the dispatch on the same compute queue (a submission with timestamps never goes to a sibling queue). C is the usual "render zone, then compute zone" profiler pattern. E also contradicts the commit message ("copies left by a full run of carriers ... keep the launch"): they only keep it until the next work is recorded. The CTS A/B cannot see any of this because it checks order, not durations. The PR's own test asserts case A (pending copy gets a carrier before later stamp).

Suggested fix

Convert only while nothing but timestamp carriers was recorded since the copied stamp; otherwise keep the launch. I tried that locally (not pushed):

static bool
stamp_copies_current(struct hk_cmd_buffer *cmd)
{
   const struct hk_sync_state *st = &cmd->sync;
   struct hk_cs *cs = last_stream(cmd);
   if (cmd->current_cs.cs && cmd->current_cs.cs != cs)
      return false;
   while (cs && cs->type == HK_CS_CDM && (cs->sync.kind & HK_SYNC_STAMP) &&
          cs->timestamp.end.handle)
      cs = cs->node.prev == &cmd->control_streams
              ? NULL
              : list_entry(cs->node.prev, struct hk_cs, node);
   if (!cs)
      return true;
   for (unsigned i = 0; i < st->stamp_copy_count; ++i) {
      if (cs->timestamp.end.handle != st->stamp_copies[i].src.handle ||
          cs->timestamp.end.offset_B != st->stamp_copies[i].src.offset_B)
         return false;
   }
   return true;
}

Called from stamp_copies_as_carriers(), it puts all 48 cases back in place. The two leading stamps with nothing else in the command buffer, the candidate flushed at the end, and the 8/9 limit still behave as in this PR. Only the three new assertions that expect the late stamp fail (leading stamp on the render, copy a carrier, pending copy gets a carrier before later stamp, carriers stay ordered with respect to dispatch and each other). Giving the copies their carriers before the next dispatch or render opens would also work and keeps more of the gain.

Also needed: a speed row on a plain main kernel

It does not need linux#3443 or linux#3681 to be correct: on main, a compute command with NO_QUERY_ACCESS links to earlier publications and does not wait on the host, the same path as the carriers from #1368. Speed there is not shown. Main links every command to every pending publication it covers (EnqueueOrdering::build()), and each carrier is one more pending timestamp writer, up to 8 where there was one launch that drained the queue. The only FPS numbers are on a stack with linux#3443 and linux#3991, plus #1556 and #1557, at ca0d10ca4bea, which is not on GitHub, so I can't check what changed since then and can't credit the +2.6 % to this PR alone. Please add base against head on one main kernel without those PRs (J716c is enough; say which kernel the CTS A/B used too). Not required for the fix, but #1368 measured a cost on the M4 for runs of stamps, so a J713 number would help.

Checked

  • Read: both flush points, stamp_copy_must_copy at every place a later stamp lands, the run limit, waits of the carriers (resets, sources, carrier chain), query reset and result copy (query_cs() flushes first), secondaries (replayed into the primary, so the same state), the feature gate. No ordering or wait problem found beyond the above. Without COMPUTE_NO_QUERY_ACCESS the recorded result is unchanged.
  • Local merge of this head with e4346bdb3a55 (tree be473848143e), native x86-64, Fedora 44 clang, asserts on: builds. hk_sync_stamps_test 1272/1272, hk_query_oq_test 226/226, hk_query_no_access_test ok, agx_tests 1971 passed and 1 skipped (same as base). asahi + poly + vulkan suites: 463 ok, 1 fail, 1 skipped on both base and merge. The failure was borealis-sync-runner on both (a loaded build host) and it passes on both when run alone.
  • No conflict with #1556 (373807d07ec8) or #1557 (8227ed7ab9b5).
  • Not run: hardware.

When pending timestamp copies were only converted to timestamp-only
carriers at the next timestamp or command-buffer end, any compute
dispatch or render recorded in between could execute ahead of the
carrier, moving the begin stamp past the work and collapsing GPU zone
durations toward zero. Copies left by a full carrier run could also
convert later once new work ended the trailing carrier run.

Flush eligible pending timestamp copies into timestamp-only carriers
before opening the next compute stream or non-merged render pass
(hk_sync_flush_stamp_copies_as_carriers()), keeping pass-merge
candidacy intact until non-merging work opens. Also guard carrier
conversion in stamp_copies_as_carriers() with stamp_copies_current(),
internal_active, and pending_start_ts checks, lock pending copies to a
value-copy launch when intervening work appends to an already-open
compute stream or follows a full carrier run, keep HK_SYNC_STAMP and
pin_cs across stamp_carrier_launch(), preserve root.cs across
hk_g17p_meta_fill_addr() so pre-dispatch carriers cannot clobber
dispatch parameters, and record VK_ERROR_OUT_OF_HOST_MEMORY if stream
allocation fails mid-batch.

Update and expand the timestamp unit tests to cover all six GPU zone
placement patterns (leading stamps before dispatch or render,
pass-merge candidate with TOP_OF_PIPE or ALL_COMMANDS + barrier before
dispatch, >8-stamp carrier run overflow before dispatch, and in-pass
copies before dispatch), G16G placement, mid-pass splits, open
independent compute streams across a render and barrier closure,
carrier launch pinning, and mid-batch allocation failure.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb

erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Author

@DjDeveloperr Both findings are addressed in 29a55378fdb (pushed forward-only on top of 552e5e9f1747):

  1. Late carrier placement / GPU zone collapse (all 6 cases A–F fixed, 48/48 in place):

    • Eligible pending stamp copies now flush into timestamp-only carriers before the next compute stream (hk_cmd_buffer_get_cs_general()) or non-merged render pass (hk_sync_begin_rendering()) opens via hk_sync_flush_stamp_copies_as_carriers(), while compatible pass merges still bypass hk_sync_begin_rendering() so pass-merge candidacy stays intact until non-merging work opens.
    • stamp_copies_as_carriers() now also enforces stamp_copies_current(), !internal_active, and !pending_start_ts.handle so copies can never convert after intervening work (including mid-pass splits or an open compute stream reused across a render, which locks stamp_copy_must_copy). Full-run overflow copies (stamp_carrier_run_full) now also set stamp_copy_must_copy = true so Case E keeps its value-copy launch of carrier 9 rather than converting later.
    • stamp_carrier_launch() keeps kind_override = HK_SYNC_STAMP and pin_cs = true across its scratch store, hk_g17p_meta_fill_addr() preserves cmd->state.cs.descriptors.root.cs so a pre-dispatch carrier cannot clobber base_group/group_count_addr, and mid-batch stream allocation failure records VK_ERROR_OUT_OF_HOST_MEMORY.
    • Added all six cases A–F (test_host_published_zone_placement() in src/asahi/vulkan/tests/test-hk-sync-stamps.c) across G17S/G17C/G17G/G17P × exact/legacy (48/48), plus G16G cases D/F, mid-pass splits, open-compute-across-render + barrier closure, carrier pinning, and mid-batch allocation failure: hk_sync_stamps_test 1381/1381 pass, hk_query_oq_test 226/226 pass, and all 11 host test suites (hk_sync_prior, hk_query_no_access, hk_query_reset, hk_tess_batch, hk_host_flush, hk_pack, hk_render_pack, borealis-sync-runner, agx_tests) pass.
  2. Plain main kernel speed A/B and CTS kernel (7.3.0-daily2+, clean aurora-wip 3146ce4726a vs exact head 29a55378fdb, no linux#3443/#3991 or mesa#1556/#1557):

    • CTS A/B ran on the plain aurora-silicon/linux main daily kernel (7.3.0-daily2+), 19,414 cases each: J716c 19,386 pass / 0 fail / 0 diffs / 0 GPU errors; J713 19,316 pass / 0 fail / 0 diffs / 0 GPU errors; J313 19,145 pass / 0 fail / 0 diffs / 0 GPU errors.
    • stampruns A/B on 7.3.0-daily2+:
      • J716c (G17C): render cbs 2×32 4639.8 → 1311.8 µs (-71.7%, 3.54× faster), render cbs 3×32 4614.2 → 1677.2 µs (-63.7%, 2.75× faster); single-CB render same 2×32 908.1 → 1310.7 µs (pre-render carriers instead of one end-of-CB copy launch); long runs unchanged (64×1: 244.4 → 239.7 µs, 1024×1: 2157.6 → 2170.0 µs).
      • J713 (G16G): render cbs 2×32 5074.0 → 3037.5 µs (-40.1%, 1.67× faster), render cbs 3×32 5111.7 → 4038.4 µs (-21.0%, 1.27× faster); render same 2×32 1801.6 → 3031.7 µs; long runs unchanged (64×1: 524.6 → 514.4 µs, 1024×1: 1628.2 → 1631.0 µs).
    • Cyberpunk 2077 2.5 T2 (2560×1600 High, J716c, plain 7.3.0-daily2+, cur-fex-main-vkmain): base 3146ce4726a 55.56 FPS (min 46.10, p99 23.0 ms) vs head 29a55378fdb 55.69 FPS (min 47.20, p99 22.9 ms), +0.13 FPS (+0.23%), 0 GPU faults.

The PR body has been updated with the new head SHA, plain-kernel tables, and CTS kernel details.

Flushing pending timestamp copies ahead of every render pass instance puts
a compute carrier between two renders for each end stamp followed by a
begin stamp. The carrier waits for the first render and the second
render's end stamp waits for the carrier, so every render zone boundary
crosses engines twice. One command buffer of 32 renders with two stamps
after each got slower than without the carriers: 908 -> 1311 us on a
J716c and 1802 -> 3032 us on a J713 (the pull request's numbers).

Such a copy does not need a carrier to stay in place: it copies the end
stamp of the render before it, which is where it was recorded. Leave it
pending when a render opens. The render between keeps the batch on one
launch at the end (stamp_copies_current()), as without this series. Copies
of a leading stamp, and copies that a compute stream follows, still get
their carriers first, and a copy at the end of the command buffer still
becomes one, which is what the one-render-per-command-buffer patterns
gain from.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 29a55378fdb2 and pushed one small commit on top, 94f04fbeaa7c. Approved at 94f04fbeaa7c; both points from the last review are closed. It merges once the exact-head rows below are in, because my push moved the head past your rows.

1. Begin stamp after its work: fixed. I ran my original six cases (not your port of them), 48 runs each: base 4f2853ac8250 48 in place, 552e5e9f1747 0, 29a55378fdb2 48, 94f04fbeaa7c 48.

2. Speed on a plain main kernel: shown, with one regression that I fixed. render same 2x32 is slower than aurora-wip itself, not only than the earlier head (the base column is 3146ce4726a): 908 -> 1311 us on the J716c and 1802 -> 3032 us on the J713, so about 13 us and 38 us for each boundary between two renders. That is the normal shape of a per-pass GPU profiler: with 40 render zones in a frame it is 0.5 ms and 1.5 ms. The flush ahead of each render pass puts a compute carrier between two renders; the carrier waits for the first one, and the second one's end stamp waits for the carrier. For 6 renders with two stamps each, the recorded commands are:

carriers copy launches cross-engine waits
base 0 1 1
29a55378fdb2 6 0 11
94f04fbeaa7c 0 1 1

(G16G, G17P, G17S, G17C, exact and legacy priors, pass-merge candidates and in-pass stamps alike.) These copies don't need a carrier to stay in place: they copy the end stamp of the render before them, which is where they were recorded. So the commit flushes before a render only when the copies are of a leading stamp. Unchanged: your lead, dispatch and end-of-command-buffer carriers. One render with two stamps per command buffer (render cbs) records the same commands as your head, and (render, dispatch) zone pairs keep the gain (6 copy launches on base; none here, for 6 more carriers).

I don't treat #1368's accepted cost for dispatch pairs as covering this: there the game gained 4.5 %, here Cyberpunk is +0.23 % (noise) and the gain in render cbs doesn't need that flush.

3. root.cs in hk_g17p_meta_fill_addr(): can't change other meta paths. The function returns an error first on anything but native AGX3 and G18G, so G13, G14 and the M5 parts never get there; on G16G and G17P its callers are event writes, immediate query writes, query resets, the in-pass marker stamp and the carrier itself. Every dispatch entry point rewrites base_group, group_count_addr and the sparse map before use, constant_data_addr is written again for every dispatch, the fill uses push constants and no descriptor set, and hk_meta_end() already marked the root dirty. The only visible change is the fix you describe (a carrier flushed inside a dispatch no longer clobbers that dispatch's parameters); the leading-stamp flush had the same problem on base.

Checked. 94f04fbeaa7c merged into aurora-wip 80a0ac5d0cdd (tree ae7dcae4e613), native x86-64, Fedora 44 clang, asserts on: asahi + poly + vulkan suites 465 ok, 0 failed, 1 skipped; agx_tests 1971 passed, 1 skipped. hk_sync_stamps_test 1541/1541 (1381 of yours plus 160 new), hk_query_oq_test 226/226 (both on the merge with 4f2853ac8250). Your head alone, merged the same way: 465 ok, 0 failed, 1 skipped. No conflict with the current tip. Read: both new flush points, the append lock, the save/restore of the recording flags, the pinned carrier store, allocation failure. Hardware: not run.

Rows at 94f04fbeaa7c, base 3146ce4726a

  • Yours: J716c and J713, the same 19,414-case CTS A/B and the stampruns table (same 2x32 should be back at base, cbs 2x32/3x32 at your numbers). J313 needs no new run: it doesn't report the feature and returns before the changed line.
  • Ours: J714s (query, timestamp, sync, event and buffer-marker CTS plus GPUBench with timestamps on), J700 (the same CTS and GPUBench, no regression).

@DjDeveloperr
DjDeveloperr dismissed their stale review December 3, 2026 00:52

Fixed: case A-F placement at 29a5537, plain-kernel numbers posted; approved at 94f04fb.

@erikwb

erikwb commented Dec 3, 2026

Copy link
Copy Markdown
Author

We carry this PR in our unified portable daily Mesa build across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103).

Giving pending timestamp copies carriers where stamps are host-published cuts timestamp query overhead on G17 (3.54x faster on stampruns on J716c) without breaking pass merging or ordering.

Verified across J716c, J713, and J313 (including Cyberpunk 2077 2.5 T2 at 60.14 FPS on J716c and Vulkan CTS smoke across all three Macs) with zero GPU faults.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The render follow-up leaves copies of the previous render’s end stamp pending while still flushing leading stamps before the next pass. The carrier path is limited to host-published timestamps, checks that the copy still belongs at the tail, and preserves source and carrier ordering. The expanded host suite covers the ordering cases. The revised two-stamp render hardware comparison remains pending.

@DjDeveloperr

Copy link
Copy Markdown

J700 (MacBook Neo, A18 Pro, G17P B1) at 94f04fbeaa7c: PASS, after a pre-registered re-run of one test

Ran on a trial kernel, not on stock: Edge 7.3.0-50 (kernel build ID 6a1d4325295f…, aurora.ko 096c87892c77…), which reports COMPUTE_NO_QUERY_ACCESS (bit 30 set, feature word 0x0000397a6001fc07). The J700's stock kernel 7.3.0-41 doesn't report it (0x0000007a2001fc06), so the changed line isn't reached there and no stock row would have tested it. Same boot for base and head, userspace only. Base is the merge base 3146ce4726a1; both arms are cross-builds with identical options (Mesa e1602a97ce53 / ed4412a83417). SLC on.

Part Result
CTS, the recipe's list (26,335 cases) 26,335 on both arms: 26,312 Pass, 23 NotSupported, 0 status differences
GPUBench us_per_submit, 6 ABBA slots, bar 2 % render.light d1 1.0011 (the row to watch), render.light d16 1.0003, compute.light d1 1.0124, compute.light d8 0.9904: all inside the bar
Kernel log 0 GPU-side lines, 0 WARN

First timed result, and the re-run

  • In the first run the timestamped pass of compute.light d1 was 3.3 % slower on head (103.713 → 107.135 µs). The bar in the recipe is us_per_submit, but the timestamp path is what this PR changes, so I re-ran it with a rule fixed beforehand: 10 ABBA/BAAB rounds (20 slots per arm) of compute.light d1 and d8 and render.light d1, timed and untimed. The rule: the head's timed median is not above the base by more than the base spread of the pooled windows and not by more than 2 %.
Test First run, timed Re-run, timed (95 %) Re-run, untimed Rule
compute.light d1 103.713 → 107.135 (1.0330) 107.089 → 107.296 (1.0019, 0.9976 to 1.0114) 1.0024 met
compute.light d8 29.252 → 28.930 (0.9890) 29.417 → 29.427 (1.0004, 0.9977 to 1.0016) 1.0000 met
render.light d1 (control) 139.471 → 139.665 (1.0014) 139.548 → 139.509 (0.9997, 0.9942 to 1.0103) 0.9997 met
  • compute.light d1 sits on two speed levels (about 103 and 107 µs) that follow the place in the round, and the 3.3 % was the head landing on the slow one more often. In the re-run 15 of 20 base slots and 16 of 20 head slots are on the slow level (Fisher p 1.0). No frequency cap or active cooling in either arm's windows.

The cost of a stamp, for the trade you decide

  • Timed minus untimed per submission: compute.light d1 base 0.578 µs, head 0.739 µs; d8 12.411 µs on both; render.light d1 within noise. Divided by the 2 timestamp writes GPUBench makes per submission, that's 0.289 → 0.369 µs per write for d1.
  • This is an upper bound on a stamp copy's cost. I can't give a cost per copy: from the PR's source, this workload isn't expected to make a pending copy, and the copies per submission can't be read from the numbers.
  • The gains the PR lists (stampruns render cbs 2x32: J716c 3.54×, J713 1.67×) were not measured here.

What went wrong, and isn't hidden: the first kit's verdict was FAIL for two reasons. One was the timed test above. The other was its own "boot not as it was" check, which compared a process list that included its own sort; there was no change in the boot (0 fault lines, 0 WARN). The re-run kit excludes its own processes and the boot matched before and after.

Not covered: the stock kernel, and other GPU generations.

@DjDeveloperr

Copy link
Copy Markdown

Where this stands at 94f04fbeaa7c: the J700 row is in (PASS), and the PR merged onto the current aurora-wip together with #1557 passes the host suites (466 ok, 0 failed; hk_sync_stamps_test 1541/1541).

Still open is the two-stamp render comparison: render same 2x32 should be back at base. The 02:17 comment doesn't name a head or give a table, so it doesn't settle that.

  • J714s (same chip as the J716c) is next in our queue, with the CTS list and stampruns.
  • J773g (same chip as the J713) runs the same after its sleep tests.

If both show same 2x32 within noise of base, we take them in place of the J716c and J713 rows and merge. Your stampruns table at this head would do the same, whichever comes first.

@DjDeveloperr

Copy link
Copy Markdown

Hardware verification on J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2 / 26B123): PASS.

Environment

  • Kernel: 7.3.0-j773g-s2r4007a+ (boot_id=0e47e587-c53c-4f3f-a7a7-8b41c667cc62; main cff875630c61 + non-GPU #4007/#4031, zero GPU diff from main)
  • Arms (libvulkan_asahi.so):
    • base (3146ce4726a1): sha256: e1602a97ce5353c01ba8ea295c30b3d64ad8e5d0c4c9348c5a842c60d891e36f
    • parent (29a55378fdb2, positive control): sha256: d1314128a0e1f24f3060195b908d1d85a14cb0d6bd1056baeb9168a7f6e05ffb
    • head (94f04fbeaa7c): sha256: ed4412a8341767e3eec05fd82d3f94e9ddf65739d7eeea6e16a59a84874dfd1b

1. Three-arm stampruns positive control (50 iters/round, interleaved, real VDM draw, separate reset_cb)

Using a separate reset_cb so cmd->current_cs.cs == NULL entering the render passes reproduces parent 29a55378fdb2's same-CB regression (+69.3% at 2×32, +122.7% at 3×32, GPU job_cmds doubling/tripling) and confirms head 94f04fbeaa7c eliminates it while keeping the multi-CB win (all bad=0, 0 GPU faults):

Case (rounds) base med (µs / GPU / cmds) parent med (µs / GPU / cmds) head med (µs / GPU / cmds) parent vs base head vs base
render same 2x32 (3) 1684.67 / 454.92 / 1974 2852.22 / 2474.25 / 3770 1699.13 / 458.62 / 1974 +69.3% +0.86% (-40.4% vs parent)
render same-inpass 2x32 (5) 1685.40 / 456.83 / 1972 2852.03 / 2467.42 / 3772 1687.72 / 458.08 / 1972 +69.2% +0.14% (-40.8% vs parent)
render same-inpass 3x32 (3) 1693.32 / 457.83 / 1972 3771.47 / 3327.12 / 5628 1707.69 / 458.83 / 1972 +122.7% +0.85% (-54.7% vs parent)
render cbs 2x32 (3) 5055.84 / 4694.38 / 3772 2920.23 / 2523.42 / 3770 2890.30 / 2564.96 / 3770 -42.2% -42.8%
render cbs 3x32 (3) 5059.59 / 4712.21 / 3772 3809.22 / 3476.62 / 5570 3800.74 / 3464.79 / 5570 -24.7% -24.9%

2. Vulkan CTS (deqp-vk, 2 workers, 26,335 timestamp/query/sync cases)

  • base: 26,234 Pass / 101 NotSupported / 0 Fail (130 s; jobs 70068 -> 115454, recoveries 0, hang_kills 0)
  • head: 26,234 Pass / 101 NotSupported / 0 Fail (128 s; jobs 115454 -> 160839, recoveries 0, hang_kills 0)
  • 0 status diffs, 0 GPU faults/recoveries/hang kills.

3. gpubench-vk --timestamps on (ABBA × 3, n=6/6, sha256: 3dc7d52bdc32b07f7c39dc111bb694c2b0b65896d48ea5a08bc44952e34de11a)

Test base us_per_submit / timed / gpu_us head us_per_submit / timed / gpu_us Delta (us_per_submit)
render.light queue d=1 134.12 / 136.87 / 10.96 µs 132.66 / 136.06 / 10.92 µs -1.09%
render.light queue d=16 52.65 / 52.51 / 19.67 µs 52.21 / 52.15 / 18.92 µs -0.84%
compute.light queue d=1 116.96 / 118.43 / 1.58 µs 117.79 / 118.51 / 1.58 µs +0.70%
compute.light queue d=8 28.89 / 28.54 / 1.54 µs 28.63 / 28.43 / 1.54 µs -0.91%

@DjDeveloperr

Copy link
Copy Markdown

J714s (Apple M5 Pro / T6050 / G17S B1) verification on exact head 94f04fbeaa7c vs base 3146ce4726a1 + positive control 29a55378fdb2 — PASS.

Setup

  • Kernel: 7.3.0-m5-pr67 (boot_id=8225dbe8-1cc8-440e-aca0-6fbc8a7b927d, reports DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS bit 30, features=0x00003d3e7cfe7c07).
  • Native J714s ICDs (-Dplatforms=x11,wayland):
    • base (3146ce4726a1): libvulkan_asahi.so 32a72efc5066
    • parent (29a55378fdb2, control): libvulkan_asahi.so 7718776bc505
    • head (94f04fbeaa7c): libvulkan_asahi.so b93a405c5f89

1. CTS (26,335 cases, headless WSI, --procs 2)

  • base (44.66s) vs head (44.61s): 26,304 Pass / 31 NotSupported / 0 Fail / 0 diffs across query_pool, pipeline_statistics_query, timestamp, occlusion_query, and synchronization render/compute query suites. 0 GPU faults.

2. GPUBench (--timestamps on --verify, ABBA × 3, bad_ok=0, 0 GPU faults)

Case Base (us_per_submit / timed) Head (us_per_submit / timed) Delta
render.light d1 130.11 / 130.21 µs 130.21 / 130.17 µs +0.08% / -0.03%
render.light d16 25.51 / 37.75 µs 25.51 / 37.79 µs +0.03% / +0.11%
compute.light d1 116.58 / 115.43 µs 114.68 / 114.39 µs -1.63% / -0.90%
compute.light d8 14.95 / 26.78 µs 14.94 / 26.83 µs -0.01% / +0.19%

3. stampruns-v5 3-Arm Interleaved Benchmark (10 slots/arm, 50 iters/slot, separate reset_cb, all bad=0, 0 GPU faults)

Case Base (3146ce4726a1) Parent control (29a55378fdb2) Head (94f04fbeaa7c)
render same-inpass 2x32 1068.57 µs (gpu 647.80) 1362.79 µs (+27.53% / gpu +45.62%) 1062.87 µs (-0.53% / gpu -5.23%)
render same-inpass 3x32 1043.42 µs (gpu 620.50) 1747.45 µs (+67.47% / gpu +119.09%) 1015.69 µs (-2.66% / gpu -2.45%)
render same 2x32 1068.49 µs (gpu 618.29) 1360.97 µs (+27.37% / gpu +57.39%) 1050.86 µs (-1.65% / gpu -2.40%)
render cbs 2x32 4684.66 µs (gpu 4398.73) 1460.36 µs (-68.83% / gpu -75.43%) 1467.05 µs (-68.68% / gpu -77.99%)
render cbs 3x32 4688.66 µs (gpu 4396.62) 1821.31 µs (-61.15% / gpu -68.79%) 1823.08 µs (-61.12% / gpu -69.78%)

Positive control reproduces the exact parent regression (+27.4% to +67.5% CPU / +45.6% to +119.1% GPU) on all three same / same-inpass cases; head restores base latency (-0.53% to -2.66%) while keeping the full -68.7% / -61.1% cbs win with 0 bad timestamps and 0 GPU faults.

@DjDeveloperr
DjDeveloperr merged commit dcb5211 into aurora-wip Dec 3, 2026
@DjDeveloperr
DjDeveloperr deleted the feat/borealis-g17-stamp-copy-carriers branch December 3, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants