Repository navigation
borealis: give pending timestamp copies carriers where stamps are host-published - #1561
Conversation
…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>
DjDeveloperr
left a comment
There was a problem hiding this comment.
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_copyat 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. WithoutCOMPUTE_NO_QUERY_ACCESSthe recorded result is unchanged. - Local merge of this head with
e4346bdb3a55(treebe473848143e), native x86-64, Fedora 44 clang, asserts on: builds.hk_sync_stamps_test1272/1272,hk_query_oq_test226/226,hk_query_no_access_testok,agx_tests1971 passed and 1 skipped (same as base). asahi + poly + vulkan suites: 463 ok, 1 fail, 1 skipped on both base and merge. The failure wasborealis-sync-runneron 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>
|
@DjDeveloperr Both findings are addressed in
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
left a comment
There was a problem hiding this comment.
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
stamprunstable (same 2x32should be back at base,cbs 2x32/3x32at 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).
|
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 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
left a comment
There was a problem hiding this comment.
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.
J700 (MacBook Neo, A18 Pro, G17P B1) at
|
| 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.lightd1 was 3.3 % slower on head (103.713 → 107.135 µs). The bar in the recipe isus_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) ofcompute.lightd1 and d8 andrender.lightd1, 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.lightd1 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.lightd1 base 0.578 µs, head 0.739 µs; d8 12.411 µs on both;render.lightd1 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 (
stamprunsrender 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.
|
Where this stands at Still open is the two-stamp render comparison:
If both show |
|
Hardware verification on J773g (Apple Mac mini M4, Environment
1. Three-arm
|
| 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% |
|
J714s (Apple M5 Pro / T6050 / G17S B1) verification on exact head Setup
1. CTS (
|
| 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.
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:
94f04fbeaa7c(one commit by DjDeveloperr over29a55378fdb: no carrier between two renders) merged intoaurora-wip80a0ac5d0cdd: asahi + poly + vulkan Meson suites 465 ok, 0 failed, 1 skipped;hk_sync_stamps_test1541/1541. The hardware rows below are at29a55378fdb; therender same 2×32lines are what that commit addresses and need a new run at94f04fbeaa7c.29a55378fdb(against merge-baseaurora-wip3146ce4726a, host unit tests):hk_sync_stamps_test1381/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_test226/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, andagx_testsall pass.29a55378fdbvs base3146ce4726a, Vulkan CTS A/B (query_pool.*,pipeline.*.timestamp.*,synchronization{,2}.basic.*,api.buffer_marker.*, 19,414 cases each, plainaurora-silicon/linuxmaindaily kernel7.3.0-daily2+, no out-of-tree kernel PRs):mainkernel speed A/B (7.3.0-daily2+, cleanaurora-wip3146ce4726avs exact head29a55378fdb, withoutlinux#3443/#3991ormesa#1556/#1557):stamprunsmulti-CB render stamp runs (J716c, G17C):render cbs 2×324639.8 → 1311.8 µs CPU median (3.54× faster / -71.7%, GPU span 4334.2 → 996.9 µs);render cbs 3×324614.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).stamprunsmulti-CB render stamp runs (J713, G16G):render cbs 2×325074.0 → 3037.5 µs CPU median (1.67× faster / -40.1%, GPU span 4638.6 → 2421.2 µs);render cbs 3×325111.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).7.3.0-daily2+,cur-fex-main-vkmain): base3146ce4726a55.56 FPS (min 46.10, p99 23.0 ms, 0 faults) vs head29a55378fdb55.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 plainmain).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
vkCmdWriteTimestamp2recorded 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,vkEndCommandBuffergave the leading stamp a timestamp-only carrier and launchedlibagx_copy_timestampsright behind it in the same submission. That launch recorded the carrier's stamp as a query range it reads, sohk_query_stamps_conflict()droppedDRM_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()andhk_sync_flush_stamp_copies_as_carriers()convert up toHK_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.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 bypasshk_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 viastamp_copy_must_copy, and overflow copies queued after a fullHK_SYNC_STAMP_CARRIER_RUNcarrier run also lockstamp_copy_must_copyso they stay a value-copy launch of the final carrier.stamp_carrier_launch()keepskind_override = HK_SYNC_STAMPandpin_cs = trueacross its executable scratch store so the carrier is never replaced or reclassified, andhk_g17p_meta_fill_addr()preservescmd->state.cs.descriptors.root.csso a pre-dispatch carrier cannot overwritebase_group,group_count_addr, orgrid_helper_sparse_map_addr.hk_cs_create_at()or mid-batch instamp_copies_carry()setsVK_ERROR_OUT_OF_HOST_MEMORYon the command buffer rather than silently dropping remaining timestamps.Evidence
Host unit tests at
29a55378fdb:hk_sync_stamps_test: 1381 tests, 0 failureshk_query_oq_test: 226 tests, 0 failureshk_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-VK7ba03cdac7ae, base3146ce4726avs head29a55378fdb, plainaurora-silicon/linuxmaindaily kernel7.3.0-daily2+):stamprunsA/B (base3146ce4726avs head29a55378fdb, plain7.3.0-daily2+, 50 iters, 0 bad values):render cbs 2×32render cbs 3×32render same 2×32render same 64×1render same 1024×1render cbs 2×32render cbs 3×32render same 2×32render same 64×1render same 1024×1(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 buffersrender 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, cleanaurora-wip3146ce4726avs exact head29a55378fdb):3146ce4726aa2582dc94b9629a55378fdbd9def9479ddb