Repository navigation
Description
Drafted by Claude Code from measurements on this machine and posted at the owner's request. The desktop stutter is the owner's observation; the latency numbers below were measured.
Mac and installed build
- Model / board / SoC: MacBook Pro 16" M3 Pro (Nov 2023) /
apple,j516s/apple,t6030, G15S, cores enabled per cluster[9, 9] uname -r:7.2.11-14-1-ARCH- Packages:
linux-aurora 7.2.11.aurora14-1,mesa-aurora/vulkan-aurora 1:26.3.0_devel.20261031.231483.a1969111475-1,m1n1-aurora 1.6.1.aurora22-1,uboot-aurora 2026.07.aurora6-1,asahi-scripts 20261023-1,omarchy-aurora-firmware 20261014-7,omarchy 4.5.0-3,hyprland 0.56.2-7,ollama/ollama-vulkan 0.35.0-1 - Local changes: the Ollama service only, with
heap_memory_percent=0.85so a 12B model fits in the Vulkan heap. The 1B case below fits in the default heap. No kernel command-line or module changes.
Both firmware versions and provisioning
asahi,os-fw-version: 14.7asahi,system-fw-version: unknown (the literal value in/proc/device-tree/chosen/)- GPU firmware:
macOS 14.7-14.8.x stub firmware (iBoot-10151.140.19.700.2)
Reproduction, expected result, and actual result
ollama run gemma4:12b(Q4_K_M, 49/49 layers on Vulkan0) and let it generate.- Use the desktop, or measure with the probe below.
Expected: some slowdown for other GPU clients, but the compositor stays responsive, as it does on macOS with the same model.
Actual: the whole desktop stutters for as long as generation runs. Reproduced every time.
Measurement: a surfaceless GLES2 client clears and draws to a 1024×1024 FBO and calls glFinish() every ~16 ms. The table shows 300 samples per row, in ms, on AC power. Every loaded row was taken while generation was confirmed still running. "Over 8.3 ms" is the share of samples longer than one 120 Hz frame.
| Concurrent load | Context priority | p50 | p95 | max | over 8.3 ms |
|---|---|---|---|---|---|
| idle | MEDIUM | 0.84 | 1.03 | 3.47 | 0% |
| idle | HIGH | 0.83 | 1.04 | 2.52 | 0% |
gemma4:12b, CPU only (num_gpu: 0) |
MEDIUM | 1.08 | 1.81 | 3.64 | 0% |
gemma4:12b, CPU only (num_gpu: 0) |
HIGH | 1.07 | 1.65 | 4.19 | 0% |
| llama3.2:1b, Vulkan | MEDIUM | 8.82 | 12.27 | 16.04 | 56% |
| llama3.2:1b, Vulkan | HIGH | 8.39 | 12.04 | 16.54 | 52% |
| gemma4:12b, Vulkan | MEDIUM | 54.28 | 197.43 | 202.83 | 62% |
| gemma4:12b, Vulkan | HIGH | 53.43 | 191.79 | 196.86 | 63% |
The same runs on battery (balanced profile) gave the same results within noise, for example 12B MEDIUM at p50 53.9 ms and max 197 ms. So the power source is not the cause.
- The CPU-only control rules out memory pressure and CPU load. During GPU generation the CPU is about 87% idle and memory PSI is close to zero.
- The delay grows with the size of the compute work. The 12B case looks like a ~200 ms ceiling, which suggests other clients wait for a whole compute submission to finish.
- Requesting
EGL_CONTEXT_PRIORITY_HIGH_IMGmakes no material difference, althougheglQueryContextreports HIGH (0x3101) back. Hyprland also logsGot a high priority contextand has no file capabilities.
Probe source (gcc -O2 glprobe.c -lEGL -lGLESv2; ./glprobe 300 [high])
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifndef EGL_CONTEXT_PRIORITY_LEVEL_IMG
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
#endif
static double now(){struct timespec t;clock_gettime(CLOCK_MONOTONIC,&t);return t.tv_sec*1e3+t.tv_nsec/1e6;}
static int cmp(const void*a,const void*b){double x=*(double*)a,y=*(double*)b;return x<y?-1:x>y;}
int main(int argc,char**argv){
int n=argc>1?atoi(argv[1]):300; int high=argc>2&&!strcmp(argv[2],"high");
PFNEGLGETPLATFORMDISPLAYEXTPROC gpd=(void*)eglGetProcAddress("eglGetPlatformDisplayEXT");
EGLDisplay d=gpd(EGL_PLATFORM_SURFACELESS_MESA,EGL_DEFAULT_DISPLAY,NULL);
eglInitialize(d,0,0); eglBindAPI(EGL_OPENGL_ES_API);
EGLint ca[]={EGL_RENDERABLE_TYPE,EGL_OPENGL_ES2_BIT,EGL_SURFACE_TYPE,EGL_PBUFFER_BIT,EGL_NONE};EGLConfig c;EGLint nc;
eglChooseConfig(d,ca,&c,1,&nc);
EGLint xa[]={EGL_CONTEXT_CLIENT_VERSION,2,EGL_CONTEXT_PRIORITY_LEVEL_IMG,high?EGL_CONTEXT_PRIORITY_HIGH_IMG:EGL_CONTEXT_PRIORITY_MEDIUM_IMG,EGL_NONE};
EGLContext x=eglCreateContext(d,c,EGL_NO_CONTEXT,xa);
eglMakeCurrent(d,EGL_NO_SURFACE,EGL_NO_SURFACE,x);
EGLint pr=0; eglQueryContext(d,x,EGL_CONTEXT_PRIORITY_LEVEL_IMG,&pr);
GLuint tex,fb; glGenTextures(1,&tex); glBindTexture(GL_TEXTURE_2D,tex);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,1024,1024,0,GL_RGBA,GL_UNSIGNED_BYTE,0);
glGenFramebuffers(1,&fb); glBindFramebuffer(GL_FRAMEBUFFER,fb);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,tex,0);
double *v=malloc(n*sizeof(double));
for(int i=0;i<n+10;i++){double t=now();glClearColor(i%2,0.5,0.2,1);glClear(GL_COLOR_BUFFER_BIT);glFinish();double e=now()-t;if(i>=10)v[i-10]=e;usleep(16000);}
qsort(v,n,sizeof(double),cmp); int over=0; for(int i=0;i<n;i++) if(v[i]>8.3) over++;
printf("prio_req=%s reported=0x%x p50=%.2f p95=%.2f p99=%.2f max=%.2f >8.3ms=%.1f%%\n",
high?"HIGH":"MEDIUM",pr,v[n/2],v[n*95/100],v[n*99/100],v[n-1],100.0*over/n);
}Graphics or session details
- Renderer
Apple M3 Pro (G15S B1). Internal panel 3456x2234@120, scale 2. Hyprland 0.56.2. - The compute client is llama.cpp's Vulkan backend (
libggml-vulkan.so, via Ollama). Generation runs at ~12–14 tok/s for 12B and ~80 tok/s for 1B. - Power profile
balanced. Measured on both AC and battery.
Relevant error lines
There are no GPU faults, timeouts, halts or recoveries this boot: 0 matching asahi lines. These GPU boot lines may be relevant to preemption:
asahi-g15 292400000.gpu: board data: ADT performance states, 1380 MHz top (differs from the reference machine)
asahi-g15 292400000.gpu: preemption divisor Globals+0x9b0=0: 0
Related issues, pull requests, or code examples
- drm/asahi: admit authorized HIGH queues on Extended T8122 #346 says the M3 desktop lags under GPU load because the compositor's HIGH request is rejected and Mesa silently falls back to MEDIUM. This report adds a T6030 data point with sustained Vulkan compute load, not render load. Its results match the "no material HIGH advantage" finding, at much larger magnitudes than drm/asahi: admit authorized HIGH queues on Extended T8122 #346's render-load test (p99 ~200 ms vs 22 ms).
- drm/asahi: admit authorized HIGH queues on Extended T8122 #346 notes that firmware preemption is not established. The
compute_preemptmodule parameter andpreemption divisor ... = 0suggest compute preemption is off on this profile. I haven't confirmed that. - drm/asahi: back off interrupt-assisted M3 completion waits #347 changes the M3 completion-wait path. It's not tested here.
- j615 (MacBook Air 15" M3): Chrome trackpad scrolling stutters with no GPU faults logged, even at cap 5 #385 (J615 Chrome scroll stutter) may share the scheduling cause, but it reports no compute load.
No workaround tried other than CPU-only inference, which avoids the problem at a large speed cost.
What was not tested
- Compositor frame or presentation timing. The probe is a submission-to-completion proxy for another GPU client, not a scanout measurement.
- Power profiles other than
balanced. - drm/asahi: admit authorized HIGH queues on Extended T8122 #346, drm/asahi: back off interrupt-assisted M3 completion waits #347, or
compute_preemptset to a nonzero value. - GPU clock and the
asahi-m3debugfs counters during load (not read; they need root). - Other compute clients: a non-llama.cpp Vulkan or OpenCL workload.
- macOS numbers for the same probe. The macOS comparison is the owner's subjective experience.
Filed by Claude Opus 5.5 via Claude Code.
Activity
crybo-rybo commentedon Nov 6, 2026
Update after further inspection of the driver source
Drafted by Claude Code from the
integration/aurorasource (6a08a08) and this machine's boot log, posted at the owner's request.Three things in the report above pointed at the wrong code path. Corrections:
1. This machine runs the G15 backend, not the T8122 (
m3/) runtime. The boot log isasahi-g15 292400000.gpu: G15: probing (T6030 G15S)throughG15: firmware at READY, starting the backend. So #346 and #347, which change the Extended T8122 runtime indrivers/gpu/drm/asahi/m3/, would not change anything here, and them3_*module parameters do not apply. Listing them as untested candidates was a mistake.2.
compute_preemptis not a G15 control. It is defined inasahi_core.rsand read inworkqueue.rs, the classic G13/G14 path. It says nothing about preemption on T6030. Thepreemption divisor Globals+0x9b0=0: 0line comes fromg15/recovery.rs(preempt_set), which sits in the hang-recovery code; I have not yet confirmed whether that facility is usable for scheduling, only that it is not the scheduler.3. HIGH priority is refused on G15 by the shared
file.rs, not silently ignored by the engine.queue_createreturnsEINVALforDRM_ASAHI_PRIORITY_HIGHon any GPU that is not G17 (comment: "HIGH has only been run on G17; G13 and G14 keep refusing it"). Mesa falls back to MEDIUM while EGL still reports HIGH, which is the reporting gap omacom/mesa#31 targets. Separately,g15/queue.rsdocuments that priority on G15 only orders the host-side pick: "Logical queues own no firmware state ... executed in one total order across queues and VMs."Likely mechanism (from the engine's own design notes, not yet instrumented)
The module doc of
g15/engine.rsdescribes the submission model:FLIGHTSprefixes are in flight, the second only of the same VM."So a render job from another process (the compositor, or the probe above) cannot be published while a llama.cpp compute prefix is in flight; it waits for that whole prefix to retire. The stall should scale with the GPU time of one prefix, which matches the table: ~8.5 ms with the 1B model and ~50–200 ms with the 12B model, with no dependence on the requested priority. The firmware never sees two clients to arbitrate between.
If that holds, the lever is host-side: bound the compute prefix (and skip horizon folding) while another queue or VM has work pending, or otherwise give the render queue a turn between shorter compute prefixes. I am reading the engine, the retirement path and the Mesa/llama.cpp submission shape now to size that, and will post
asahi-g15/statsdebugfs numbers (idle vs. under load) to confirm the prefix and flight counts before proposing a change.crybo-rybo commentedon Nov 6, 2026
Fix proposed: #389
Posted at the owner's request; measurements by Claude Code on this machine.
The mechanism in the comment above is confirmed and a policy-only fix is up in #389,
drm/asahi: g15: budget compute flights while another VM waits. In short: whenpublish()holds a job of another VM behind published flights, the engine notes the time and, forg15_share_window_ms(500) afterwards, publishes one prefix at a time and caps a compute prefix (horizon included) atg15_share_budget_us(4000) over the queue's measured mean compute command time, never below one command. Uncontended, or with the budget set to 0, publication is unchanged. Nothing firmware-visible changes.Same probe and protocol as the table in the report, gemma4:12b generating, ms:
ASAHI_MESA_DEBUG=sync(diagnosis only)GGML_VK_MAX_NODES_PER_SUBMIT=20in the Ollama serviceThe patch alone bounds the wait to about one llama.cpp command (~6–8 ms) at no throughput cost; the sync control shows why that is the floor, since one job in flight gives the idle p50 only by leaving the GPU idle 70% of the time. Shorter llama.cpp submits (
GGML_VK_MAX_NODES_PER_SUBMIT=20, a complementary user-space setting) let the budget cut finer for a 3% eval-rate cost; by feel, the owner no longer notices stutter in normal desktop use.Limit: the kernel cannot split a single command. The patched boot's stats show one prompt-processing command of 462 ms (
compute max_us 462055), which still holds every other client for its length. Bounding prefill needs Honeykrisp to end the CDM control stream more often on G15; that is a separate follow-up for omacom/mesa. Full details, counters, build and load method, and the not-tested list are in the PR.drm/asahi: g15: budget compute flights while another VM waits
tools/asahi: g15: test the compute share budget on the host
drm/asahi: g15: budget compute flights while another VM waits
tools/asahi: g15: test the compute share budget on the host
drm/asahi: g15: budget compute flights while another VM waits
tools/asahi: g15: test the compute share budget on the host