Skip to content

drm/asahi: g17: scale base compute pool with active cores - #3833

Merged
RyanTheTide merged 1 commit into
mainfrom
perf/g17-compute-pool-core-scaling
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
perf/g17-compute-pool-core-scaling

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On 20-core M4 Pro (T6040 / J616s), Vulkan ray-tracing workloads (rt.trav, rt.rays, rt.scene) ran 5x-10x slower than macOS Metal and slower in absolute throughput than 5-core A18 Pro (Neo) on identical Mesa Borealis binaries, while non-hit BVH traversal (rt.trav miss, comb) and ordinary ALU/render scaled normally with core count.

Ray-count scaling showed rt.trav single ran at full Metal speed (~1,437 Mray/s) up to 16,384 rays (~1 wave across 20 cores) and dropped 3x-5x once multiple waves ran concurrently.

A live sweep on J616s (T6040, 20 active cores) isolated the cause to compute_blocks: T6040 inherited A18 Pro's COMPUTE_BLOCKS = 21 floor (1.05 blocks/core), whereas 5-core A18 Pro has 4.20 blocks/core and 32-core T6041 has 96 (3.00 blocks/core). Sweeping 21..80 blocks saturates cleanly at 56..60 blocks (2.8..3.0 blocks/core):

Benchmark (J616s, Mesa d4ad4a4dce) base=21 (stock) base=60 (3/core) Speedup
rt.trav single d16 564.8 Mray/s (549 us) 2,823.5 Mray/s (92.6 us) 5.00x (5.93x GPU)
rt.trav grid 2048 d16 390.0 Mray/s (805 us) 1,933.5 Mray/s (132 us) 4.96x (6.08x GPU)
rt.trav gap 64 eps=0.0001 d16 16.59 Mray/s (19.1 ms) 163.0 Mray/s (1.60 ms) 9.83x (11.9x GPU)
rt.rays coherent d16 355.7 Mray/s (843 us) 2,217.2 Mray/s (117 us) 6.23x (7.20x GPU)
rt.rays incoherent d16 336.1 Mray/s (866 us) 1,294.3 Mray/s (200 us) 3.85x (4.34x GPU)
rt.scene medium d2 74.74 fps (13.7 ms) 246.30 fps (4.07 ms) 3.30x
rt.scene solarbay d2 69.77 fps (14.5 ms) 172.90 fps (5.87 ms) 2.48x

Fix

  • Add COMPUTE_BLOCKS_PER_CORE = 3 in drivers/gpu/drm/asahi/g17/fw/freelist.rs (matching MULTI_CLUSTER_RENDER_BLOCKS_PER_CORE = 3 and 32-core T6041's 96-block compute pool).
  • Add base_blocks(base, active_cores) in drivers/gpu/drm/asahi/g17/fw/compute_pool.rs and use it in required_blocks(), scaling linearly with active cores while keeping COMPUTE_BLOCKS (21) as the floor and preserving any larger static floor (such as 40-core T6041's 160 blocks).
    • 5/6-core A18 Pro: unchanged (21 blocks)
    • 16-core T6040: 48 blocks (3/core)
    • 20-core T6040: 60 blocks (3/core)
    • 32-core T6041: unchanged (96 blocks)
    • 40-core T6041: unchanged (160 blocks)
    • M5: unchanged (ComputeCapacity::M5)
  • Add KUnit suite asahi_g17_compute_pool covering floor preservation, core-count scaling, SCS scratch additions, invalid shapes, and overflow/bounds checks.

Tested: KUnit suite asahi_g17_compute_pool (apple-build-kunit) + live J616s compute_blocks sweep (21..80, 0 GPU faults); exact-SHA J616s hardware qualification row (gate + s2idle + Vulkan RT CTS + full gpubench-rt-vk + gpubench-vk compute/render control) running now and will be posted below.
Risk: two-way · M4 Pro (T6040) — increases base compute free-list pool from 21 to 48/60 MiB on 16/20-core T6040 only (service_compute_pools and place_lower handle reclamation/pressure cleanly); 5/6-core A18 Pro, 32/40-core T6041, and M5 keep identical pool sizes.

G17P compute pools reserve per-core shader-context scratch (SCS) pages
on top of a base free-list block count. Leaving the base at the 5-core
A18 Pro floor (21 blocks = 1.05 blocks/core on 20-core T6040) starves
concurrent USC private-memory and SCS allocations once more than one
wave is active, throttling 20-core ray-tracing traversal and ray-query
compute by 5x-10x.

Scale the base compute pool linearly with active cores at three 1 MiB
blocks per core (matching MULTI_CLUSTER_RENDER_BLOCKS_PER_CORE and
32-core T6041's 96-block pool), floored at COMPUTE_BLOCKS (21) and
preserving any larger static floor (such as 40-core T6041's 160 blocks).
Add KUnit coverage for base_blocks() and required_blocks().

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners December 1, 2026 20:11
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 852ce265: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 852ce265
Conflicts ok none
PR text ok Risk: two-way · M4 Pro (T6040) — increases base compute free-list pool from 21 to 48/60 MiB on 16/20-core T6040 only (servicecomputepools and placelower handle reclamation/pressure cleanly); 5/6-core A18 Pro, 32/40-core T6041, and M5 keep identical pool sizes.

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-template PR body lacks Tested or Risk (bot) labels Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware qualification row — J616s (20-core M4 Pro, T6040) at exact head 852ce265059e1

  • Build: 7.3.0-aurora-g17cpool+ built from exact PR head 852ce265059e1fd3ada5d832c4575bff585068fd, one-shot non-default BLS boot (aurora-gpu-perf-g17cpool), saved Stage 2 (1.0.0b17) and /boot/dtb untouched.
  • Userspace: mesa-aurora-vulkan-drivers-26.3.0-30.fc45.aurora.aarch64 (Borealis, Mesa d4ad4a4dce), gpubench-rt-vk & gpubench-vk (20261122-gpu-perf).
  • System gate: Enforcing, failed=0, speakerguardd-v2 active, oops=0, avc=0, dart_faults=0, gpu_faults=0 (pre- and post-test), s2idle 2/2 PASS (rtc1 0 -> 1 -> 2, Wi-Fi associated + gateway ping OK).
  • Vulkan CTS: dEQP-VK.compute.pipeline.basic.* 79/79 PASS, 0 Fail (2 Not supported).
  • Non-RT compute/render control (gpubench-vk): compute.light d1/d4 = 107.76 / 21.42 us, compute.heavy d1/d4 = 427.35 / 297.62 us, render.light d1/d4 = 119.22 / 39.11 us (neutral, 0 regressions).
  • Ray-tracing benchmarks (gpubench-rt-vk --timestamps on) vs saved Edge (933f8226, base=21) and same-device macOS Metal:
Benchmark Saved Edge (base=21) PR #3833 (852ce265059e1) Speedup macOS Metal (J616s) Linux / Metal
rt.scene raster d2 — 745.00 fps — 723.80 fps 1.03x
rt.scene light d2 — 3,228.03 fps — 2,849.53 fps 1.13x
rt.scene medium d2 74.74 fps 246.00 fps 3.29x 268.70 fps 0.92x
rt.scene solarbay d2 69.77 fps 171.60 fps 2.46x 187.00 fps 0.92x
rt.scene heavy d2 — 70.36 fps — 72.44 fps 0.97x
rt.scene extreme d2 — 14.11 fps — 13.20 fps 1.07x
rt.rays coherent d16 355.7 Mray/s 2,210.31 Mray/s 6.21x 1,939.0 Mray/s 1.14x
rt.rays incoherent d16 336.1 Mray/s 1,290.54 Mray/s 3.84x — —
rt.trav miss d16 4,907.5 Mray/s 5,007.68 Mray/s 1.02x 1,035.5 Mray/s 4.84x
rt.trav single d16 568.1 Mray/s 2,811.12 Mray/s 4.95x 1,320.7 Mray/s 2.13x
rt.trav comb 16 d16 1,499.4 Mray/s 2,808.76 Mray/s 1.87x 1,650.7 Mray/s 1.70x
rt.trav grid 128 d16 444.1 Mray/s 2,161.34 Mray/s 4.87x 1,311.6 Mray/s 1.65x
rt.trav grid 2048 d16 371.4 Mray/s 1,950.63 Mray/s 5.25x 1,912.6 Mray/s 1.02x
rt.trav gap 64 eps=0.01 d16 43.63 Mray/s 409.40 Mray/s 9.38x 215.7 Mray/s 1.90x
rt.trav gap 64 eps=0.0001 d16 16.03 Mray/s 163.00 Mray/s 10.17x 216.1 Mray/s 0.75x
rt.trav gap 64 eps=0.125 d16 1,449.9 Mray/s 2,472.05 Mray/s 1.71x 2,969.2 Mray/s 0.83x
rt.asbuild blas/refit/tlas d1 — 70.76 / 365.10 Mtri/s, 1.71 Minst/s — — —
  • Restore: plain reboot returned to saved 7.3.0-aurora-edge (aurora-edge-933f8226, boot_success=1, next_entry empty, saved BLS/GRUB/Stage 2/cmdline byte-identical, all trial files removed, Enforcing, failed=0, speakerguardd-v2 active).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 1, 2026

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at 852ce26

Checked: base_blocks = max(base, 21, 3cores) with a checked multiply. For every non-M5 part the scaled floor is at or above the old 21 blocks, so no pool gets smaller. Larger static floors (160 on 40-core) are kept. required_blocks now converts the scaled base to bytes with checked_mul and adds the SCS extra afterwards, so the extra is not scaled. The E2BIG ceiling is PAGE_LIST_SIZE / (0x1008) = 1024 blocks, and 32 cores plus 791-page scratch stays far below it. The only caller is compute_capacity (runtime.rs:3150): M5 returns early, and other parts grow the pool on demand through ensure_compute, so the larger floor only costs memory on owners that submit compute. KUnit cases match the hand arithmetic (20 cores 791 pages: 60 + ceil(20*803/256)=63). CI green; exact-head J616s row PASS.

Follow-ups (not blocking): each compute owner on a 16/20-core T6040 now reserves 48/60 MiB of compute blocks, up from 21. Record the per-owner footprint with many compute clients (for example a browser plus a game) in a later perf note.

@RyanTheTide
RyanTheTide merged commit 9d47520 into main Dec 1, 2026
13 of 15 checks passed
@RyanTheTide
RyanTheTide deleted the perf/g17-compute-pool-core-scaling branch December 1, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant