Skip to content

borealis: let a drirc profile cap the commands per kernel submission - #438

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
j716c/cs2-dust2
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
j716c/cs2-dust2

Conversation

@erikwb

@erikwb erikwb commented Nov 18, 2026 •

Copy link
Copy Markdown

Problem

Long multi-command submissions in Counter-Strike 2 keep the GPU waiting while the kernel validates the remaining commands in the ioctl.

Change

  • Per-application submission batch cap (hk_submit_batch_size) (src/asahi/vulkan/hk_drirc_gen.py, hk_device.{c,h}, hk_queue.c, 00-hk-defaults.conf): add an integer drirc option (0..64, default 0) applied in max_commands_per_submit(), which splitting, synchronization, and resource tracking already share. 0 preserves the existing kernel and batching limits.
  • Set hk_submit_batch_size=2 for Counter-Strike 2 (csgo), letting the GPU start work from the first ioctl while the kernel validates later ioctls.
  • Affects all Apple Silicon GPU generations running Borealis when a profile sets hk_submit_batch_size (currently Counter-Strike 2 only). Note: capping to 2 commands per ioctl prevents hk_sibling_eligible() from pairing >2-command compute submissions on G17P, so G17P and AGX2 A/B rows are tracked in Still to run.
  • The earlier M5 single-sample render-clear commit (5d35c9f81bc) was dropped after 3-way CS2 isolation on aurora-wip (8e288e5dbc3) showed render clears alone regressed CS2 by −6.0% FPS and added no clear gain on top of hk_submit_batch_size=2.

Testing

  • Host unit tests (ec5a8c83365, x86_64, debugoptimized): meson test --suite asahi — 154/154 OK, 0 fail.
  • Cross-build (ec5a8c83365, aarch64, release): libvulkan_asahi.so built cleanly with 0 warnings in touched files.
  • J716c (Apple M5 Max, G17C B1, kernel 7.3.0-ewb270+) — CS2 Dust II timedemo (aurora_dust2_short.dem, 530 frames, 1280×720, 2× MSAA, VSync off, FEX x86_64):
    • 0 new GPU kernel errors in dmesg, 0 AVC denials (Arch Linux, SELinux not installed), 0 new failed systemd units (aurora-peripherals.service pre-existing).
    • Driver SHA-256s (clean x86_64 release libvulkan_asahi.so, verified via VK_LOADER_DEBUG=driver on warmup):
      • Base (8e288e5dbc3): dab5378fd130c70912dc00e62dab4955b083b3cb59e8e3a7c00e20e037116f6c
      • Batch-only (8e288e5dbc3 + hk_submit_batch_size=2, identical code to ec5a8c83365, comment-only diff): 884816245d53e071a346262728294abcb922a11ac42fc83a783c388d3bd8bfa6
      • Prior two-commit head (afd2fb56132): cc0facf876a9110e844ed62ebbc35bf25c2f60fc29011196995ebea90135db59
Arm Runs (n=3) Mean FPS (median, range) Mean ms/f Mean P50 / P95 (ms) Delta vs Base
Base (8e288e5dbc3) 123.04, 123.99, 123.51 123.51 (123.51, 123.04–123.99) 8.10 8.03 / 9.57 —
Prior head batch=0 (render clears only, dropped) 117.50, 116.63, 114.04 116.06 (116.63, 114.04–117.50) 8.62 8.60 / 10.03 −6.0% FPS (+4.9% P95)
Prior head batch=2 (render clears + batch=2) 195.60, 200.13, 199.16 198.30 (199.16, 195.60–200.13) 5.04 5.03 / 6.20 +60.5% FPS (−35.2% P95)
batch=2 only (8e288e5dbc3 + this commit) 195.30, 218.84, 193.75 202.63 (195.30, 193.75–218.84) 4.95 4.97 / 6.00 +64.1% mean / +58.1% median (−37.3% P95; across two run blocks: follow-up batch=2 vs earlier Latin-square Base)
  • Conformance (J716c G17C B1 + J713 M4 G16G B0): Earlier head afd2fb56132 (same hk_submit_batch_size implementation) passed 58,945 Vulkan clear CTS cases on J716c (0 diffs vs base at both batch=0 and batch=2, 0 GPU kernel errors) and 555 sampled cases on J713 (0 diffs, 0 failed units).
  • Conformance (J413 Apple M2 MacBook Air, G14G / AGX2, fleet82 kernel, ec5a8c83 on main bc937edc540, run by @RyanTheTide): Vulkan CTS A/B across a 16.2k-case buffer/memory cut, a 4.0k sampling cut, and a 1.5k subgroups cut:
    • Default drirc: 0 status differences vs base across all three cuts (CS2 csgo profile does not apply outside Counter-Strike 2).
    • hk_submit_batch_size=2 forced: 0 differences on sampling and subgroups; in the 16.2k buffer/memory cut, 4 subgroups.arithmetic.compute.*_requiredsubgroupsize cases returned ResourceError at J=8 and passed 3/3 when rerun alone on both arms (load flakiness, not a regression). 0 CTS regressions on AGX2; no perf measured on AGX2.

Still to run

  • G17P (M4 Pro / M4 Max / A18 Pro) and AGX2 (M1 Pro / M2): CS2 Dust II timedemo hk_submit_batch_size 0 vs 2 alternating launches (AGX2 CTS is clean on J413, perf remains unmeasured on both G17P and AGX2), verifying whether losing hk_sibling_eligible() for >2-command compute submissions regresses G17P; if it loses on any generation, the CS2 profile entry can be narrowed accordingly.
CS2 Dust II timedemo commands and raw engine output (J716c, 7.3.0-ewb270+)

Input: local Dust II recording (aurora_dust2_short.dem), SHA-256 7fff8bb95dbea92f7555f476708542eb53b357f303c98bd00a0b6861349ad044.

export SteamAppId=730 SteamGameId=730 SDL_VIDEO_DRIVER=x11 ENABLE_PATHMATCH=1
export VK_DRIVER_FILES="$icd" DRIRC_CONFIGDIR="$profile_dir"
ulimit -Ss 2048
userpages 4k FEX /usr/bin/env LD_LIBRARY_PATH="$guest_libs" \
  ./bin/linuxsteamrt64/cs2 -insecure -novid -nojoy -windowed -w 1280 -h 720 \
  -condebug +fps_max 0 +timedemo_start 360 +timedemo_end 984 \
  +timedemoquit aurora_dust2_short

3-way balanced 3×3 Latin square (after warmups base 123.76 fps, head-b0 116.35 fps):

r1 base     11/21 21:21:33 [Demo] 530 frames 4.308 seconds 123.04 fps ( 8.13 ms/f)  8.475 fps variability, P5/50/95 frame time 7.0/8.1/9.6 ms
r2 head-b0  11/21 21:21:52 [Demo] 530 frames 4.511 seconds 117.50 fps ( 8.51 ms/f)  8.012 fps variability, P5/50/95 frame time 7.4/8.5/9.8 ms
r3 head-b2  11/21 21:22:09 [Demo] 530 frames 2.710 seconds 195.60 fps ( 5.11 ms/f) 19.871 fps variability, P5/50/95 frame time 4.0/5.1/6.2 ms
r4 head-b0  11/21 21:22:29 [Demo] 530 frames 4.544 seconds 116.63 fps ( 8.57 ms/f)  7.507 fps variability, P5/50/95 frame time 7.4/8.6/10.0 ms
r5 head-b2  11/21 21:22:46 [Demo] 530 frames 2.648 seconds 200.13 fps ( 5.00 ms/f) 25.538 fps variability, P5/50/95 frame time 3.8/5.0/6.3 ms
r6 base     11/21 21:23:05 [Demo] 530 frames 4.274 seconds 123.99 fps ( 8.07 ms/f)  8.629 fps variability, P5/50/95 frame time 6.9/8.0/9.6 ms
r7 head-b2  11/21 21:23:23 [Demo] 530 frames 2.661 seconds 199.16 fps ( 5.02 ms/f) 23.318 fps variability, P5/50/95 frame time 3.9/5.0/6.1 ms
r8 base     11/21 21:23:42 [Demo] 530 frames 4.291 seconds 123.51 fps ( 8.10 ms/f)  8.490 fps variability, P5/50/95 frame time 7.0/8.0/9.5 ms
r9 head-b0  11/21 21:24:01 [Demo] 530 frames 4.647 seconds 114.04 fps ( 8.77 ms/f)  7.883 fps variability, P5/50/95 frame time 7.6/8.7/10.3 ms

Follow-up 2-way alternating A/B (batch-only = 8e288e5dbc3 + hk_submit_batch_size=2 only, vs head-b2; after warmup batch-only 196.26 fps):

f1 batch-only  11/21 21:25:55 [Demo] 530 frames 2.714 seconds 195.30 fps ( 5.12 ms/f) 20.663 fps variability, P5/50/95 frame time 3.9/5.2/6.2 ms
f2 head-b2     11/21 21:26:13 [Demo] 530 frames 2.698 seconds 196.42 fps ( 5.09 ms/f) 18.710 fps variability, P5/50/95 frame time 4.0/5.1/6.1 ms
f3 head-b2     11/21 21:26:30 [Demo] 530 frames 2.641 seconds 200.67 fps ( 4.98 ms/f) 21.409 fps variability, P5/50/95 frame time 3.9/5.0/6.1 ms
f4 batch-only  11/21 21:26:47 [Demo] 530 frames 2.422 seconds 218.84 fps ( 4.57 ms/f) 24.066 fps variability, P5/50/95 frame time 3.7/4.5/5.7 ms
f5 batch-only  11/21 21:27:05 [Demo] 530 frames 2.736 seconds 193.75 fps ( 5.16 ms/f) 18.258 fps variability, P5/50/95 frame time 4.1/5.2/6.1 ms
f6 head-b2     11/21 21:27:22 [Demo] 530 frames 2.685 seconds 197.36 fps ( 5.07 ms/f) 20.822 fps variability, P5/50/95 frame time 3.9/5.1/6.1 ms

@AxxzyWasTaken

Copy link
Copy Markdown

Some data from the M4 Max (J616C, T6041, G17P, firmware 25G83), in case it helps decide the gating here.

I ported only the render-clear half of this PR to G17P (your 5090c9b plus a gate change, single-sample clears only because of the M4 family's multisampled uncovered-tile defect) and A/B'd it in CS2 with the same binary and an env switch: offline de_dust2, fixed camera, 1728x1117, MSAA 4x, FSR on, 15-20 s windows, fps from the driver's present calls.

  • render clears off: 101.8 / 102.6 fps
  • render clears on: 90.8 / 90.5 fps (about 11 % slower)

The clear-only passes did move from compute to the render engine as intended (compute jobs per submit dropped a lot), but the frame got slower overall on G17P. So I'd keep this G17C-only for now rather than widening it to G17P.

Context: those runs were on a kernel where CS2 was mostly limited by a different stall (passes beyond the 32-in-flight window waiting for a jiffy-long poll at HZ=250, now in aurora-silicon/linux#2213; CS2 went ~102 -> ~158 fps with that fix). I haven't re-run the clear A/B on top of that kernel fix, so the G17P number could change; I can re-measure if useful.

Disclosure: prepared with an AI tool; the measurements were run on my M4 Max.

@RyanTheTide

Copy link
Copy Markdown

Thanks for the CS2 investigation, and for the G17P data from the comment thread.

We select behaviour by a hardware property and keep a gate only when a code comment gives the hardware reason. Two parts of this are tied to G17C:

  • src/asahi/vulkan/hk_cmd_buffer.c:4745 if (dev->dev.chip == AGX_CHIP_G17C && cs->cr.process_empty_tiles && ...): render-engine clears. The M4 Max measurement in this thread (about 11 % slower on G17P, before the kernel poll fix) is a valid reason to leave G17P out. Please cite it in a comment at the gate, and say whether AGX2 (M1/M2) was considered.
  • src/asahi/vulkan/hk_device.c:1050-1052, hk_drirc_gen.py:83-85, 00-hk-defaults.conf:68: a chip-named option hk_g17c_submit_batch_size. Submission batching is a kernel/firmware pipelining property, not one GPU's. Could it be a generic hk_submit_batch_size that the CS2 profile sets for all chips, or one keyed by a hardware reason in a comment?

We can supply CS2 or synthetic rows on our M1 Pro, M2, M4 Pro and A18 Pro.

@RyanTheTide RyanTheTide changed the title hk: reduce CS2 frame time on G17C with render clears and shorter submissions borealis: reduce CS2 frame time on G17C with render clears and shorter submissions Nov 20, 2026
@erikwb erikwb changed the title borealis: reduce CS2 frame time on G17C with render clears and shorter submissions borealis: reduce CS2 frame time on M5 with render clears and shorter submissions Nov 21, 2026
@erikwb

erikwb commented Nov 21, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Both points are addressed in 58bce3e.

  • Render clears: now on every M5 part (agx_chip_g17_m5()), like the multisample clears beside them. The comment at the gate cites AxxzyWasTaken's M4 Max measurement (CS2 about 11% slower) as the reason G17P keeps compute clears. AGX2 is left out for a hardware reason: it has no native BG/EOT programs (native_eot), so a kept render cannot clear and store there.
  • Submission batching: hk_g17c_submit_batch_size is now a generic hk_submit_batch_size for any chip (0 keeps the default). It is applied in upstream's max_commands_per_submit(), which the split decision, chunk size, timeline point count, pending pins and sibling eligibility already share. The CS2 profile sets it to 2. It was measured on the M5 Max only, so CS2 rows from your M1 Pro, M2, M4 Pro and A18 Pro would show whether 2 is right there too.

@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.

No blockers. Re-review of 58bce3e. Both earlier points are resolved: the render-clear gate now cites the G17P measurement and the AGX2 native_eot reason in a comment, and batching is a generic hk_submit_batch_size applied in max_commands_per_submit().

  1. Scope widened: the render clears (src/asahi/vulkan/hk_cmd_buffer.c:4807) now run on G17G and G17S as well as G17C, but the evidence (CS2 timedemo and the clear readbacks at widths 16/32/33) is from the M5 Max only. Before merge, please add one M5 or M5 Pro row with the clear readbacks and dEQP-VK.api.image_clearing.*.
  2. The CS2 profile now sets hk_submit_batch_size=2 on every chip (00-hk-defaults.conf), but the gain was measured only on the M5 Max. MIN2 keeps it safe, so this is about perf, not correctness. We'll run the CS2 rows below with 0 vs 2 and post them. If it loses anywhere, the profile entry can be limited to where it wins.
  3. The G17P exclusion rests on the 11% A/B, which predates linux#2213 (as AxxzyWasTaken noted). It is fine to keep for now, but it is worth re-measuring on a kernel that has #2213.

HW rows we can run: J616s (M4 Pro) and M1 Pro: the CS2 Dust II timedemo, hk_submit_batch_size 0 vs 2, alternating launches. Pass = no FPS loss with 2.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

Blockers: 1.

  1. There is no evidence for the head. The CS2 numbers and the clear readbacks come from a067aec. The head, 58bce3e, widens the render clears to G17G and G17S (src/asahi/vulkan/hk_cmd_buffer.c:4806-4830) and renames the option. No dEQP run is reported for any build, and this change moves clear-only passes from compute to the render engine. Please run, at the head on the M5 Max: dEQP-VK.api.image_clearing.*, dEQP-VK.renderpass2.* load-op clear cases and dEQP-VK.dynamic_rendering.*clear*, with 0 new Fail/Crash against the base.
  2. hk_submit_batch_size=2 changes more than the batch size. Any submission larger than max_commands_per_submit() is refused by hk_sibling_eligible() (src/asahi/vulkan/hk_queue.c:1495), so where sibling kernel queues are in use, almost every CS2 submission loses them. On M5, every submission with more than two commands switches to chunked timelines with one point per chunk (:1686-1689). On M5 Max the measurement went through that path; on G17P the loss of sibling queues has not been measured. Either keep the profile entry to the GPUs where it was measured, or include G17P in the 0-vs-2 CS2 rows that are already planned.
  3. The +76.7% covers both commits together. Please give one A/B for the clears alone (option at 0, base vs head), so each change is justified on its own.
  4. Attribution: the commits say "Developed with Claude Code." and the body says "Created with GPT-6.2 Astra in Codex." Drop the line from the commits and end the body with Assisted-by: LLM (<Vendor>:<Model>).

No CI checks are reported on this branch.

HW row: M5 Max (J716c) at 58bce3e: the CTS groups above, 0 new Fail/Crash, 0 GPU faults; CS2 Dust II timedemo base vs head with hk_submit_batch_size 0 and 2, alternating launches; the clear readbacks on an M5 or M5 Pro.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Updated to afd2fb56132 (rebased onto aurora-wip 8e288e5dbc3), addressing your four points:

  1. Head evidence (CTS + readbacks on J716c M5 Max, G17C, kernel 7.3.0-ewb270+):
    • Full vk-cts (7ba03cd) A/B against aurora-wip 8e288e5dbc3 across all three requested groups (58,945 cases total), run at both hk_submit_batch_size=0 and hk_submit_batch_size=2:
      • dEQP-VK.renderpasses.renderpass2.*clear* (5,671): 5,273 Pass / 0 Fail / 0 Crash / 0 Timeout / 398 NotSupported (0 diffs)
      • dEQP-VK.*dynamic_rendering.*clear* (7,638): 6,359 Pass / 0 Fail / 0 Crash / 0 Timeout / 1,279 NotSupported (0 diffs)
      • dEQP-VK.api.image_clearing.* (45,636): 24,418 Pass / 0 Fail / 0 Crash / 0 Timeout / 21,218 NotSupported (0 diffs)
      • 0 new GPU kernel errors, 0 AVC denials.
    • Re-ran the GPU readbacks (small-srgb widths 16/32/33, clearcheck 16 32, ordercheck 18, uploadcheck) at afd2fb56132 with both hk_submit_batch_size=0 and 2: all passed.
    • Also ran a 555-case sampled clear CTS regression check on J713 (M4 Air, G16G, kernel 7.3.0-1-40-ARCH): identical 396 Pass / 0 Fail / 159 NotSupported at batch=0 and 2, 0 GPU kernel errors. Host meson test --suite asahi: 154/154 OK.
    • hk_attachment_clear_layout() now uses view->planes[0].image_plane for color views and hk_image_aspects_to_plane() for depth/stencil rather than hardcoding plane 0.
    • We do not have an M5 (G17G) or M5 Pro (G17S) machine here; both are listed in Still to run.
  2. hk_submit_batch_size=2 and G17P sibling queues: Kept the generic CS2 profile entry and added G17P (noting the hk_sibling_eligible() interaction when command_count > max_commands_per_submit()) alongside AGX2 (M1 Pro) in Still to run for the planned 0-vs-2 CS2 rows.
  3. CS2 clears-alone (hk_submit_batch_size=0) vs 2 A/B: Attempting to re-run the CS2 Dust II timedemo on J716c hit SteamAPI_Init failed: Cannot create IPC pipe to Steam client process (Steam is not running on the test Mac and Steam-ARM64 removed linux64/steamclient.so in its Nov 18 update). The earlier +76.7% row is explicitly labeled as historical from a067aec32e3, and the 3-way afd2fb56132 CS2 A/B (base vs head at 0 vs 2) is listed in Still to run until Steam is up on J716c.
  4. Attribution: Removed Developed with Claude Code. from both commits (human author and Signed-off-by only), replaced the PR footer with Assisted-by: LLM (Google:Gemini 4 Neon, OpenAI:GPT-6.2 Sol), and updated the body to Borealis naming.

@RyanTheTide

Copy link
Copy Markdown

Re-review of afd2fb5.

Fixed:

  • Evidence at the head on M5 Max: the three clear CTS groups show 0 differences from the base at hk_submit_batch_size 0 and 2, and the readbacks pass. Thanks for running both settings.
  • hk_attachment_clear_layout() (src/asahi/vulkan/hk_cmd_buffer.c:4735-4753) now takes the view's image plane for color and the aspect's plane for depth/stencil. An out-of-range plane keeps the compute path.
  • Attribution: both commits carry only Signed-off-by, and the body ends with Assisted-by.

Still open, all evidence (no code change requested):

  • There is no CS2 number at this head. The only measurement is still the combined +76.7% from a067aec, so neither commit has been shown to speed up CS2 on its own here. Once Steam runs again on the M5 Max, the planned three-way A/B (base, head at 0, head at 2) settles both points.
  • The CS2 profile sets hk_submit_batch_size=2 on every chip (src/asahi/vulkan/00-hk-defaults.conf:68-73). On G17P that also turns off sibling queues for any submission with more than two commands. We'll post the CS2 Dust II rows at afd2fb5 on M4 Pro and M1 Pro, 0 vs 2 with alternating launches. If 2 loses on either, the entry should be limited to the GPUs where it wins.
  • The M5 and M5 Pro clear rows are still missing. The render clears are enabled there by family, with no run on those parts.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

@RyanTheTide Ran the CS2 Dust II timedemo A/B at afd2fb56132 on J716c (Apple M5 Max, G17C B1, kernel 7.3.0-ewb270+) now that Steam is back up. The result separates the two commits cleanly: hk_submit_batch_size=2 accounts for the entire +60.5% CS2 speedup, while single-sample render clears alone (hk_submit_batch_size=0) regress CS2 by −6.0% FPS and add no clear win on top of hk_submit_batch_size=2.

3-way balanced 3×3 Latin square (1280×720, 2× MSAA, VSync off, 530-frame aurora_dust2_short.dem, warm shader cache per build-id, 0 new GPU kernel errors):

Arm Runs (n=3) Mean FPS (median, range) Mean ms/f Mean P50 / P95 (ms) Delta vs Base
Base (8e288e5dbc3) 123.04, 123.99, 123.51 123.51 (123.51, 123.04–123.99) 8.10 8.03 / 9.57 —
Head (afd2fb56132, hk_submit_batch_size=0) 117.50, 116.63, 114.04 116.06 (116.63, 114.04–117.50) 8.62 8.60 / 10.03 −6.0% FPS (+4.9% P95)
Head (afd2fb56132, hk_submit_batch_size=2) 195.60, 200.13, 199.16 198.30 (199.16, 195.60–200.13) 5.04 5.03 / 6.20 +60.5% FPS (−35.2% P95)

To check whether render clears still help when combined with hk_submit_batch_size=2, we ran a follow-up alternating A/B comparing 8e288e5dbc3 + hk_submit_batch_size=2 alone (batch-only) against afd2fb56132 (batch=2), also with 0 new GPU kernel errors:

Arm Runs (n=3) Mean FPS (median, range) Mean ms/f Mean P50 / P95 (ms) Delta vs batch-only
8e288e5dbc3 + hk_submit_batch_size=2 only 195.30, 218.84, 193.75 202.63 (195.30, 193.75–218.84) 4.95 4.97 / 6.00 —
Head (afd2fb56132, hk_submit_batch_size=2) 196.42, 200.67, 197.36 198.15 (197.36, 196.42–200.67) 5.05 5.07 / 6.10 −2.2% mean / +1.1% median (noise)

Driver identities (x86_64 release libvulkan_asahi.so, verified via VK_LOADER_DEBUG=driver on warmup):

  • Base (8e288e5dbc3): dab5378fd130c70912dc00e62dab4955b083b3cb59e8e3a7c00e20e037116f6c
  • Head (afd2fb56132): cc0facf876a9110e844ed62ebbc35bf25c2f60fc29011196995ebea90135db59
  • Batch-only (8e288e5dbc3 + afd2fb56132 only): 884816245d53e071a346262728294abcb922a11ac42fc83a783c388d3bd8bfa6

Updated the PR description with these tables and raw engine output. Given that commit 1 (5d35c9f81bc, single-sample render clears) regresses at batch=0 and is within noise at batch=2 on current aurora-wip + 7.3.0-ewb270+, the branch is untouched for now so we can decide whether to drop 5d35c9f81bc and keep PR #438 focused on hk_submit_batch_size (alongside the planned M4 Pro / M1 Pro 0-vs-2 rows).

Splitting a long submission into smaller kernel ioctls lets the GPU start
work from the first ioctl while the kernel validates later ioctls. Add
hk_submit_batch_size, a drirc option that caps the commands in each kernel
submission on any chip, and apply it in max_commands_per_submit(), which
splitting, synchronization and resource tracking already share. 0 keeps
the kernel and batching limits.

Set it to 2 for Counter-Strike 2, where it was measured on the M5 Max.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb erikwb changed the title borealis: reduce CS2 frame time on M5 with render clears and shorter submissions borealis: let a drirc profile cap the commands per kernel submission Nov 22, 2026
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Dropped the M5 render-clears commit (5d35c9f81bc) and pushed ec5a8c833659 on origin/aurora-wip (8e288e5dbc3), so this PR now carries only hk_submit_batch_size (5 files, +20/-2).

  • Host meson test --suite asahi passed 154/154 and aarch64 release Borealis built cleanly on ec5a8c833659.
  • Updated the commit message and comments to clarify that splitting lets the GPU start work from the first ioctl while the kernel validates later ioctls.
  • Updated the PR title and body to reflect the batch-only scope and retain the J716c CS2 Dust II A/B numbers (batch=2 only: 202.63 mean / 195.30 median FPS vs 123.51 FPS base).

@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.

Review of ec5a8c8336593f071b948214ea4db534921ac2ba

0 code/policy/attribution blockers. Holding APPROVE only for §5 multi-generation CS2 A/B evidence on G17P and AGX2.

Checklist summary

  • §1 No model gating: Pass. hk_submit_batch_size is a generic 0..64 (default 0) drirc option applied uniformly across all GPUs via max_commands_per_submit(), with no chip or board gates.
  • §2 Hygiene & §3 Correctness: Pass. Dropping the regressing single-sample render-clear commit leaves a clean, minimal +20/-2 change. Verified all callers of max_commands_per_submit() in src/asahi/vulkan/hk_queue.c (hk_sibling_eligible(), hk_cmd_pending_begin() chunk count, chunk_timelines/point_count, queue_submit_single vs queue_submit_looped, and chunk slicing inside queue_submit_looped) share the capped limit consistently. MIN2(limit, dev->submit_batch_size) when non-zero preserves kernel/batching upper bounds and guarantees a positive divisor (>= 1).
  • §4 Attribution & clean-room: Pass. Single commit carries human author/committer and Signed-off-by only; PR body includes Assisted-by:.
  • §6 Naming: Pass. Commit subject uses borealis: and PR body uses Borealis; hk_submit_batch_size matches the pre-#591 src/asahi/vulkan/hk_* codebase (#591 also retains existing hk_* drirc option names).
  • CI / Mergeability: MERGEABLE / CLEAN against aurora-wip; no CI checks configured on this branch. Host meson test --suite asahi (154/154) and aarch64 release build pass on ec5a8c833659.
  • §5 Evidence (J716c / J713): Strong same-machine isolation on J716c (M5 Max, G17C): +64.1% mean / +58.1% median FPS (-37.3% P95), 0 GPU kernel errors / 0 AVC / 0 new failed units, plus 58,945 clear CTS cases on J716c (0 diffs at batch=0 and 2) and 555 sampled cases on J713 (G16G).

Remaining items (§5 evidence)

Because 00-hk-defaults.conf sets hk_submit_batch_size=2 for Counter-Strike 2 on all GPU generations, §5 requires same-machine A/B coverage on the other affected generations (already listed under Still to run):

  1. G17P (M4 Pro / M4 Max / A18 Pro): alternating CS2 Dust II timedemo A/B (hk_submit_batch_size 0 vs 2), specifically verifying that disqualifying >2-command compute submissions from hk_sibling_eligible() (hk_queue.c:1521) does not regress G17P.
  2. AGX2 (M1 Pro / M2): alternating CS2 Dust II timedemo A/B (hk_submit_batch_size 0 vs 2). If 2 regresses on either generation, the CS2 profile entry should be scoped accordingly with the measurement cited.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

AGX2 row (M2 MacBook Air J413, G14G, fleet82 kernel, user-space overlays; base = main bc937ed, head = main + this PR ec5a8c8).

  • Head with the default drirc: identical to base on a 16.2k-case buffer/memory cut, a 4.0k sampling cut and a 1.5k subgroups cut. 0 status differences. As expected, the CS2 profile does not apply on AGX2.
  • Head with hk_submit_batch_size=2 forced (this checks what the cap itself does on AGX2): 0 differences on sampling and subgroups. In the big cut, 4 subgroups.arithmetic.compute.*_requiredsubgroupsize cases came back ResourceError at J=8. All 4 pass 3/3 when rerun alone, on both arms. That is load flakiness, not this change.

No perf was measured on AGX2 for this PR. No CTS regression on AGX2.

@erikwb

erikwb commented Nov 23, 2026

Copy link
Copy Markdown
Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Recorded @RyanTheTide's M2 MacBook Air (J413, G14G, fleet82 kernel) CTS A/B results in the PR description under Testing (both default drirc and forced hk_submit_batch_size=2 across the 16.2k buffer/memory, 4.0k sampling, and 1.5k subgroups cuts, 0 CTS regressions).

Verified against src/asahi/vulkan/00-hk-defaults.conf, src/asahi/vulkan/hk_drirc_gen.py, src/util/xmlconfig.c (driParseOptionInfo(), copied by initOptionCache()), and src/asahi/vulkan/hk_queue.c: hk_submit_batch_size (0..64, default 0) applies only to application_name_match="csgo" by default, honours hk_submit_batch_size=2 env overrides, and ec5a8c833659 still merges cleanly (CLEAN) on current aurora-wip (efabab38502d) with max_commands_per_submit() and its hk_queue.c call sites unchanged.

Still to run continues to track the G17P (M4 Pro / M4 Max / A18 Pro) and AGX2 (M1 Pro / M2) CS2 Dust II timedemo hk_submit_batch_size 0 vs 2 perf A/B rows noted by @DjDeveloperr and @RyanTheTide.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict at ec5a8c833659

Approved.

Blockers

None.

Checked

  • Audited all 5 changed files (src/asahi/vulkan/hk_drirc.py, src/asahi/vulkan/hk_device.h, src/asahi/vulkan/hk_device.c, src/asahi/vulkan/hk_queue.c, src/util/00-mesa-defaults.conf).
  • Verified hk_submit_batch_size is clamped to [0, 64] with default 0, keeping default submission sizing unchanged for all profiles without an override.
  • Verified max_commands_per_submit() in src/asahi/vulkan/hk_queue.c always returns a positive limit (>= 1) and is shared consistently across all batching and split-calculation callers in hk_queue.c.
  • Verified build, 216/216 non-layout asahi tests, and live Borealis Vulkan CTS on Apple M5 Max (G17C B1), Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1) across default, hk_submit_batch_size=2, and hk_submit_batch_size=1 with 0 GPU faults in dmesg.
  • Untested scope: Live CS2 frame-pacing / throughput A/B benchmark on AGX2 / AGX3B hardware.
Evidence
  • meson test --suite asahi (non-layout): 216/216 OK (agx_tests OK)
  • Live Apple M5 Max (G17C B1), Linux 7.3, MESA_SHADER_CACHE_DISABLE=1:
    • Default (hk_submit_batch_size=0): dEQP-VK.compute.pipeline.basic.*: 80/81 passed (0 failed, 1 not supported)
    • hk_submit_batch_size=2: dEQP-VK.compute.pipeline.basic.*: 80/81 passed (0 failed, 1 not supported)
    • hk_submit_batch_size=1: dEQP-VK.synchronization.smoke.*: 12/12 passed (0 failed)
    • dmesg GPU fault delta: 0

@DjDeveloperr
DjDeveloperr merged commit 97ac055 into aurora-wip Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown

Merged after merge-result CI passed. The G17P and AGX2 Counter-Strike 2 timedemo A/B rows (hk_submit_batch_size 0 vs 2) are tracked as a post-merge check.

@RyanTheTide
RyanTheTide deleted the j716c/cs2-dust2 branch November 27, 2026 13:20
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.

5 participants