Repository navigation
borealis: prune retired exact priors and prefer fragment barriers - #1216
Conversation
On queues using exact historical ordinals (M5 and HAL200), last_absolute and tail ordinals remain nonzero indefinitely after the referenced submission has retired on the GPU. For example, a single earlier HK_SYNC_GFX_MEM render leaves a stale prior_ta[VDM] ordinal on thousands of subsequent renders, preventing DRM_ASAHI_RENDER_FRAGMENT_BARRIERS and forcing M5 renders onto the staged render path. - Record a 64-entry ring on hk_sync_queue mapping each submission's timeline point to its submitted VDM/CDM ordinals, and advance retired_ord[sq] whenever completed advances from drmSyncobjQuery() or the cached queue signalled_value. - Prune retired ordinals (<= retired_ord[sq]) to 0 in last_absolute, tail, and resolved prior/prior_ta fields before computing ta_split. - Prefer DRM_ASAHI_RENDER_FRAGMENT_BARRIERS over DRM_ASAHI_RENDER_STAGE_PREFIXES when the vertex half has no render prefix and an unchanged compute prefix, preserving identical ordering with a smaller render command eligible for direct kernel publication. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Verdict at Blockers None. Checked
Still owed before merge
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at c01fe0c8628f9ab301606dab62c0e89a6f79c546
Blockers: none in the code.
To finish:
- Merge
aurora-wip. The PR conflicts insrc/asahi/vulkan/hk_sync.c. #1144 (load_hazard_frag(), the newrecent_conflict(..., frag_only)signature) added functions right afterhk_sync_submit_needs_completed(), where this PR addshk_sync_submit_has_unretired_priors(),sync_advance_retired()andsync_record_retired(). Keep both sides, with this PR's three functions first so theload_hazard_frag()block stays directly aboverecent_conflict(). I gated that resolution locally (numbers below). - A J714s row at the new head. The Tested section's kits were built on
fa8970cda14f, which is an older ancestor (the head's parent isb200715b4841), and the GTA V numbers are stacked with another PR. The conflict is in a touched file, so the post-merge head needs its own row. - The J700 (HAL200) synchronization CTS row listed under Not yet. Pruning runs on every
exact_priorqueue, not only M5.
Checked:
- Retirement bookkeeping.
sync_record_retired()runs aftersubmitted[]is raised and storesqueue->drm.timeline_value, whichqueue_submit_recordings()has already raised bypoint_countfor this submission.retired_ordonly moves for entries withpoint <= completed, andcompletedis the cachedsignalled_valueor a freshdrmSyncobjQuery(), so it is a real lower bound. The host-flush ordinal (hk_sync_host_flush_prefix()doessubmitted[CDM]++after resolve) falls into the next ring entry, which only delays pruning.hk_queue_restart_sync()memsets the wholehk_sync_queue, so the ring andretired_ordreset with a new kernel queue. All of it, including the per-stream prune, sits insideexact_priorblocks, so legacy queues are untouched. Empty submissions passcompleted = 0and record nothing. - Pruning only drops waits on work that has finished.
last_absolute/tailat or belowretired_ordgo to 0 before resolving, and the per-streamprior/prior_taprune runs beforeta_split. Ordinals of the current submission are abovesubmittedand are never pruned. FRAGMENT_BARRIERSselection.m5_frag_barriers_onlyonly turns off the two M5 staged forms. The existing genericFRAGMENT_BARRIERSbranch then fires, since its conditions are a superset. On HAL200 nothing changes:g17p_stagedalready requires the compute halves to differ, and the new flag requires them to be equal. The flag is selected byDRM_ASAHI_FEATURE_FRAGMENT_BARRIERS, a kernel capability, so no new gate. Nit: them5_prefix is misleading for a capability-selected flag.- Non-blocking:
hk_sync_submit_has_unretired_priors()is true after almost every submission on an exact queue (submitted > retired_ordas soon as anything is in flight), so this adds adrmSyncobjQuery()ioctl to nearly every submit there. The GTA V numbers show no cost, but a cheaper test (any nonzerolast_absolute/tailaboveretired_ord) would skip it when nothing is left to prune. - Non-blocking test gaps (mutations below): removing the per-stream
prior/prior_taprune, or changing the queue-level<= retto< ret, is not caught. A cross-submit case where the attachment ring hands back an already-retired exactprior_ta, plus a boundary case at exactlyretired_ord, would cover both.
Evidence
- Local x86 drm-shim gate (stands in for CI): head merged into
aurora-wip5ab97d0f2c60with the resolution above (local merge792dfbcc2c00, not pushed).meson test --suite asahi --suite poly: 338 Ok / 0 Fail, the same as theaurora-wiptip (338 / 0).hk_sync_prior_test: 3574 checks / 0 failures (tip 3566, plus the 8 new checks). - Mutations on the merged tree: dropping the
sync_advance_retired()call gives 2 failures (caught). Dropping the per-streamprior/prior_taprune gives 0 failures (not caught).<=changed to<in thelast_absolute/tailprune gives 0 failures (not caught). - Rows: J714s M5 Pro (G17S) on kits from base
fa8970cda14f, not this head and not the post-merge head: missing at head. J700 G17P: missing.
|
J700 (MacBook Neo, G17P B1, HAL200) at
|
Signed-off-by: DjDeveloperr <hey@djdev.me>
Exact-head J714s verification (
|
| Check | Target | Result |
|---|---|---|
meson test --suite asahi (Assert, -Db_ndebug=false) |
J714s (7.3.0-m5-cdirect16) |
214/214 PASS (0 warnings in touched files) |
meson test --suite asahi (Release, -Db_ndebug=true) |
J714s (7.3.0-m5-cdirect16) |
214/214 PASS |
VK CTS dEQP-VK.synchronization.op.single_queue.barrier.*vertex* |
J714s (7.3.0-m5-cdirect16) |
258/258 PASS (0 failed) |
VK CTS dEQP-VK.synchronization2.op.single_queue.barrier.*vertex* |
J714s (7.3.0-m5-cdirect16) |
509/509 PASS (0 failed) |
gpubench-vk render.pass_chain (passes=14, res=tiny) |
J714s (7.3.0-m5-cdirect16) |
indep d=4: 39.46 -> 17.83 us/pass (2.21x / -54.8%, gpu_us 489.4 -> 237.2 -51.5%); indep d=1: gpu_us 216.3 -> 123.8 (-42.8%); all_bar d=4: 39.79 -> 29.33 us/pass (-26.3%), valid=True, status=ok |
| GPU health | J714s (7.3.0-m5-cdirect16) |
0 GPU faults, online=1, crashed=0, quarantined=0 |
Note: the merge conflict against current aurora-wip (5ab97d0) is a single adjacent-function placement in src/asahi/vulkan/hk_sync.c (load_hazard_frag() from #1144 next to exact_prior_completed(), zero logic overlap).
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 12a93c9c17c07ca4db02034125dc576500bf0eab
Blockers: none in the code. Rows are owed at this head: J700 (G17P) and J714s (M5). The rows at c01fe0c8628f were run on base b200715b4841, before #1144. The merge hand-resolves hk_sync.c, which this PR touches, and it brings #1144's fragment-only tile-hazard path (load_hazard_frag(), vf[]) into the same submit code where this PR prunes priors and prefers fragment barriers. That combination has not run on hardware. A short repeat of the render.pass_chain d4 rows and the sync/barrier/self_dep CTS subset on both Macs is enough.
Checked: this is a resolution review of the aurora-wip merge 12a93c9c17c0 (git show --remerge-diff) and of how the two sides combine.
- The conflict. It is a placement conflict only.
hk_sync_submit_has_unretired_priors(),sync_advance_retired()andsync_record_retired()from this PR sit before aurora-wip'sload_hazard_frag()and therecent_conflict()comment. No logic changed on either side. - Pruning against #1144. The prune in the submit loop zeroes
prior[sq]/prior_ta[sq]only when they are<= retired_ord[sq].retired_ordonly advances insync_advance_retired()from timeline points<= completed. So it drops waits only on work that has already finished, whether #1144 routed the hazard to the fragment-onlyvf[]or to the fullv[]. Theta_splitrecompute after it still keeps the vertex half at least as strict as the fragment half. - Merge. The head merges cleanly into aurora-wip
fffdc5c7c634.
Evidence
Local drm-shim gate (x86 clang, release + asserts, meson test --suite asahi --suite poly):
- aurora-wip
fffdc5c7c634: Ok 338, Fail 0 - aurora-wip
fffdc5c7c634+12a93c9c17c0(clean merge, tree2cf7ec712d17): Ok 338, Fail 0;test-hk-sync-priorpasses
|
|
|
|
What: Prune already-retired exact VDM/CDM ordinals from
hk_sync_queueusing a 64-entry timeline-to-ordinal ring, and preferDRM_ASAHI_RENDER_FRAGMENT_BARRIERSoverDRM_ASAHI_RENDER_STAGE_PREFIXESwhen the vertex half has no render prefix and an unchanged compute prefix.Why
On queues using exact historical ordinals (M5 and HAL200),
last_absoluteandtailordinals remain nonzero indefinitely after the referenced submission retires on the GPU. A single earlierHK_SYNC_GFX_MEMrender leaves a staleprior_ta[VDM]ordinal on thousands of subsequent renders (measured up to27,710renders behind, median6,268in GTA V), preventingDRM_ASAHI_RENDER_FRAGMENT_BARRIERSand forcing M5 renders onto the staged render path instead of direct kernel publication.Summary of changes
hk_sync.h,hk_sync.c): Record each submission's(timeline_point, submitted[VDM], submitted[CDM])in a 64-entry ring onhk_sync_queue(zeroed automatically byhk_queue_restart_sync()). Whencompletedadvances, raiseretired_ord[sq]monotonically and prune retired ordinals (<= retired_ord[sq]) to0inlast_absolute,tail, and resolvedprior/prior_tafields before computingta_split.hk_queue.c): Startcompletedfromqueue->drm.signalled_valueand refresh viadrmSyncobjQuery()whenhk_sync_submit_has_unretired_priors(queue)holds.FRAGMENT_BARRIERS(hk_queue.c): WhenDRM_ASAHI_FEATURE_FRAGMENT_BARRIERSis available and the vertex half has no render prefix (barrier_ta[VDM] == NONE,prior_ta[VDM] == 0,ta_command_prior[VDM] == 0) with an unchanged compute prefix, emitDRM_ASAHI_RENDER_FRAGMENT_BARRIERSinstead ofDRM_ASAHI_RENDER_STAGE_PREFIXES.test-hk-sync-prior.c): Added retired-prior pruning tests covering unretiredHK_SYNC_GFX_MEM, partial retirement (prior_ta[VDM]pruned while live fragmentprior[VDM]keepsta_split), and full retirement clearing both priors andta_split.Testing
All hardware tests run on J714s (Apple M5 Pro, G17S, kernel
7.3.0-m5-cdirect16, baseaurora-wipfa8970cda14f, isolated Mesa kits, 0 GPU faults, 0 kernel errors):--suite asahi):-Db_ndebug=false, GCC 16.1.1): 214/214 PASS (0 warnings in touched files)-Db_ndebug=true): 214/214 PASScts1471/deqp-vk):dEQP-VK.synchronization.op.single_queue.barrier.*vertex*: 258/258 PASS (0 failed)dEQP-VK.synchronization2.op.single_queue.barrier.*vertex*: 509/509 PASS (0 failed)dEQP-VK.query_pool.occlusion_query.*: 434/434 PASS (0 failed, 7 not supported)gpubench-vkrender.pass_chain(passes=14, res=tiny 60x33, RGBA16F, all CRCsvalid=True):kind=all_bar,depth=4:40.89 -> 20.53 us/pass(2.00x,-49.8%);depth=1gpu_us:206.9 -> 125.5 us(-39.3%)kind=indep,depth=4:40.58 -> 18.67 us/pass(2.17x,-54.0%);depth=1gpu_us:196.7 -> 125.6 us(-36.1%)kind=frag_bar,depth=4:40.89 -> 31.24 us/pass(-23.6%)3024x1964,ResScalingType=0,HK_FRAME_ANATOMY_TS=none):prior_ta[VDM]lag (median6,268/ max27,710-> median0/ max56, same-frame live only).P0=55.68 P1=51.33 P2=51.91 P3=57.09 P4=54.48FPSP0=55.76 P1=51.71 P2=51.84 P3=56.87 P4=55.11FPS (+1.2%P4,+0.7%P1, 0 GPU faults)Not yet
Risk: two-way door · shared Borealis sync path;
retired_ord[sq]only advances for timeline points confirmed complete (point <= completed) via the queue's monotonic syncobj timeline, so live dependencies are never dropped.