Repository navigation
gallium/tc: run a frontend flush inline when the driver thread is idle - #981
Conversation
glFlush and glFinish reach tc_flush() as PIPE_FLUSH_ASYNC flushes. With a driver that provides create_fence, tc queues them to the driver thread even when that thread has nothing left to do, so the submission waits for the thread to wake up first. A caller that waits on the work next (glFenceSync + glFlush + glClientWaitSync, glFinish) pays that wakeup on every round trip. When every flushed batch has already executed, take the synchronous path instead: run the unflushed calls and the driver flush on the calling thread, as tc already does for a synchronous flush. A busy driver thread still gets the batch queued behind its own work, and the memory-limit flushes issued while recording stay asynchronous. Signed-off-by: Diljit Singh <hey@djdev.me>
…asahi Running an idle frontend flush on the calling thread removes the driver thread's wakeup from every glFlush/glFinish round trip, but its effect on throughput depends on what the driver does after tc. zink hands the batch to its own submit thread. With several frames in flight on Borealis, executing those flushes on the application thread cost zink GPU-bound throughput (transfer.ops copy_b2i and multi-draw indirect at four frames in flight) even though its single-frame round trips got much faster. Add threaded_context_options::inline_idle_flush and enable it only for asahi, where the inline flush is a gain at every depth measured. Other drivers keep the asynchronous flush. Signed-off-by: Diljit Singh <hey@djdev.me>
satchlj
left a comment
There was a problem hiding this comment.
Verdict at ea44b8564f4e
APPROVED — clean opt-in threaded_context_options::inline_idle_flush path scoped to asahi, full release+assert Meson suite green, and live Apple M5 Max native Asahi GL + Zink GLES3/GLES31 conformance verified at exact head.
Blockers
None.
Checked
- Full diff audit of all 4 changed files (
src/gallium/auxiliary/util/u_threaded_context.c,src/gallium/auxiliary/util/u_threaded_context.h,src/gallium/drivers/asahi/agx_pipe.c,src/gallium/drivers/asahi/tests/test-agx-threaded-context.c; +48/-7) across both commits (3422dea7ee93,ea44b8564f4e, both signed off withSigned-off-by:). - Verified internal memory-limit flushes (
tc_invalidate_buffer,tc_buffer_unmap,tc_texture_unmap) passfrontend = falseso they stay asynchronous; deferred flushes (PIPE_FLUSH_DEFERRED) stay untouched; non-asahidrivers (includingzink) keepinline_idle_flush = false. - Merged
ea44b8564f4ecleanly ontoorigin/aurora-wip(5e183ceaeb2c), built aarch64 release with assertions (-Dbuildtype=release -Db_ndebug=false), and ranmeson test --suite asahi --suite poly: 199/199 PASS (0 failed), includingtest-agx-threaded-contextcovering the inline idle async flush path. - Live Apple M5 Max (G17C B1) verification against private prefix (
MESA_SHADER_CACHE_DISABLE=true,0GPU faults/timeouts):- Native Asahi GL:
dEQP-GLES3.functional.fence_sync.*11/11,dEQP-GLES3.functional.flush_finish.*5/5,dEQP-GLES3.functional.buffer.write.basic.*72/72,dEQP-GLES31.functional.synchronization.in_invocation.*20/20 (108/108 PASS, 0 fail). - Zink GL (
MESA_LOADER_DRIVER_OVERRIDE=zink):dEQP-GLES3.functional.fence_sync.*11/11,dEQP-GLES3.functional.flush_finish.*5/5 (16/16 PASS, 0 fail).
- Native Asahi GL:
- Untested scope: Did not re-run
gpubench-gllatency benchmarks locally (exact-head ABBA/BAAB tables for native Asahi GL and Zink GL are already reported in the PR description).
Evidence
- Merge base:
origin/aurora-wip5e183ceaeb2c+ea44b8564f4e→ cleanortmerge (fd801ee21ea). meson test -C /tmp/b64-bld981 --suite asahi --suite poly:Ok: 199, Fail: 0.- Renderer strings verified from private prefix:
Apple M5 Max (G17C B1)/OpenGL ES 3.2 Mesa 26.3.0-devel (git-fd801ee21e)andzink Vulkan 1.4(Apple M5 Max (G17C B1) (AURORA_BOREALIS)). - Combined live M5 Max GLES3/GLES31 + Zink conformance: 124/124 Pass, 0 Fail.
|
Second-generation J773g (Apple M4, G16G B0) hardware row: PASS at Ran on the booted
Both paths passed the 1080p postfx readbacks at 1× and 4× MSAA and the Zero GPU faults, timeouts, or recoveries during the row. The boot ID stayed the same, |
Summary
When
gallium/tchas no pending driver-thread batches, execute a frontendPIPE_FLUSH_ASYNCflush inline on the calling thread instead of waking the idle driver thread — gated behind a newthreaded_context_options::inline_idle_flushdriver option enabled only onasahi(ea44b8564f4e).3422dea7ee93):gallium/tc: run a frontend flush inline when the driver thread is idleea44b8564f4e):gallium/tc: make the inline idle flush a driver option, enable it on asahi— leaveszink(which already submits inline via merged#982) and other Gallium drivers on async flush so Zink GPU-bound throughput at depth 4 is completely unaffected.Note on the earlier
3422dea7ee93numbers: the previously reported nativetransfer.ops mipchaind1 (62.7 -> 73.9) andcopy_b2id1 (37.3 -> 40.7) figures were GB/s (higher is better) mislabeled asµs. Inµs/submit, both are large wins (-15.62%and-8.63%).Verification at exact head
ea44b8564f4eb59ad3ec9aeb432f14af776897e7--suite asahi194/0, drm-shimasahi-{g13g,g16g,g17p}-threaded-contextPASS;agent-policy.shclean; clean merge tree againstaurora-wip00a73680e009(#982merged).J700,G17P B1), kernel7.3.0-41, release build (-Db_ndebug=true, emptyBUILD-DIFF.patch), private ICD prefix, shader cache disabled.B(ea44b8564f4e):libgalliumsha2569834dcf1ebcc8337e36d4c66d878a6856b9c90bda3ef978ac21a6e2feae52,libvulkan_asahi.sosha2561b0e4bafe16916e2bd01807faa234d250f46dbec84ccc14360306f1303d1a7ef.D(1107a4201c37,ea44b8564f4e+ merged#9826493d421d0ed):libgalliumsha256ca8210d073f6deaa9eaf5e76d3adf4da34f7d9c496e89eb0ab10d4bae4cbdd1f,libvulkan_asahi.sosha25617df42969e1f614547e67d513cfd1e92d3dca558217e29269853ab90e98015b7.Balanced
ABBA+BAAB(explicit discarded warm-up per build/workload, 216 records across 27 rows; 0 regressions — worst pooled delta+0.65%)Native Asahi GL (
Acedf24806bcvsBea44b8564f4e)compute.lightcompute.lightrender.light trirender.light tritransfer.ops clear_16mtransfer.ops clear_16mtransfer.ops mipchaintransfer.ops mipchaincompress.bw rgba32f 1440pcompress.bw rgba32f 1440ptransfer.ops copy_b2itransfer.ops copy_b2icompress.bw storage 1440pcompress.bw storage 1440prender.draws 1024 directrender.draws 1024 directrender.draws 4096 mdirender.draws 4096 mdiZink GL (
C#9826493d421d0edvsD#981+#9821107a4201c37)compute.lightcompute.lightrender.draws 4096 mdirender.draws 4096 mdirender.light tritransfer.ops copy_b2itransfer.ops copy_b2itransfer.ops mipchaintransfer.ops mipchainConformance & Health (
ea44b8564f4e)dEQP-GLES3: 5,150 Pass / 69 NotSupported / 1 QualityWarning / 0 Fail.dEQP-GLES31: 1,356 Pass / 15 NotSupported / 0 Fail (6,591 total cases, 0 Fail).gpubench-gl --verify: 9/9status=ok,check.valid=trueon all 3 transfer readbacks.