Perma macosx 15 opt toolkit/components/ml/tests/browser/browser_ml_native.js | This test exceeded the timeout threshold. It should be rewritten or split up. If that's not possible, use requestLongerTimeout(N), but only | single tracking bug
Categories
(Core :: Machine Learning: On Device, defect, P5)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr140 | --- | unaffected |
| firefox-esr153 | --- | unaffected |
| firefox155 | --- | unaffected |
| firefox156 | --- | unaffected |
| firefox157 | --- | fixed |
| firefox158 | --- | fixed |
People
(Reporter: intermittent-bug-filer, Assigned: padenot)
References
(Regression)
Details
(Keywords: intermittent-failure, intermittent-testcase, regression, Whiteboard: [collect_confirm_failure])
Attachments
(2 external files)
Filed by: agoloman [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer?job_id=589830361&repo=autoland&task=WBk6atfKRd66sQUiGoeJuA.0
Full log: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/WBk6atfKRd66sQUiGoeJuA/runs/0/artifacts/public/logs/live_backing.log
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - TEST-PASS | toolkit/components/ml/tests/browser/browser_ml_native.js | test_ml_smoke_test_llama_golden_text - Greedy output hash matches the pinned golden hash - "a59803f3d1c9d983f14c54fadbe9de3b73a1053780f01bc7768fa2bc498f6005" == "a59803f3d1c9d983f14c54fadbe9de3b73a1053780f01bc7768fa2bc498f6005"
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - Leaving test test_ml_smoke_test_llama_golden_text
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - checking for open popups
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - Buffered messages finished
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - TEST-UNEXPECTED-FAIL | toolkit/components/ml/tests/browser/browser_ml_native.js | This test exceeded the timeout threshold. It should be rewritten or split up. If that's not possible, use requestLongerTimeout(N), but only as a last resort. Test ran for 100s, limit was 45s (timeout factor 1).
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - GECKO(4485) | MEMORY STAT vsizeMaxContiguous not supported in this build configuration.
[task 2026-09-02T20:22:43.037+00:00] 20:22:43 INFO - GECKO(4485) | MEMORY STAT | vsize 406902MB | residentFast 481MB | heapAllocated 165MB
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - checking for open sidebars
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - checking window state
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - Not taking screenshot here: see the one that was previously logged
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - TEST-UNEXPECTED-FAIL | toolkit/components/ml/tests/browser/browser_ml_native.js | profile uploaded in profile_browser_ml_native-2.js.json
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - Not taking screenshot here: see the one that was previously logged
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - TEST-UNEXPECTED-FAIL | toolkit/components/ml/tests/browser/browser_ml_native.js | finished in 100230ms
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - TEST-INFO took 100242ms
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - GECKO(4485) | Completed ShutdownLeaks collections in process 4485
[task 2026-09-02T20:22:43.038+00:00] 20:22:43 INFO - TEST-START | Shutdown
Updated•2 months ago
|
Comment 1•2 months ago
|
||
Set release status flags based on info from the regressing bug 1940906
| Comment hidden (Intermittent Failures Robot) |
Updated•2 months ago
|
Comment 3•2 months ago
|
||
| bug-fix | ||
Root cause: every llama.cpp engine creation costs a near-constant ~11.0s on macOS aarch64. In the job from comment 0, all 13 llama recordEngineCreationSuccessFlow durations were 11.00s ±0.03s (onnx engines in the same job: 2-130ms). browser_ml_native.js creates 9 llama engines, hence ~100s. The initial run and the retry both took exactly 100s, so this is deterministic rather than intermittent.
Where the 11s goes: we ask for CPU-only inference (n_gpu_layers: 0, LlamaCppPipeline.mjs:150), but llama.cpp still attaches every GPU device to the model — llama_prepare_model_devices() pushes all GGML_BACKEND_DEVICE_TYPE_GPU devices into model->devices independently of n_gpu_layers (third_party/llama.cpp/src/llama.cpp:127,199) — and llama_context then initializes a backend for each of them (src/llama-context.cpp:271-278). On Apple Silicon that is Metal, so ggml_metal_init() runs newLibraryWithSource: over the 8055-line embedded ggml-metal.metal and eagerly builds ~1279 compute pipeline states (ggml/src/ggml-metal/ggml-metal.m:1051, 1187+). That cost is per-process, and the test tears down the engine process between tasks, so we pay it 9 times for zero benefit. It doesn't show on Windows/Linux (no Metal) or macosx1015 (Metal init fails fast there — see the comment in GpuOffloadUsable, LlamaBackend.cpp:99). ggml logs its own compile time, but GGML_LOG_INFO is routed to MOZ_LOG, which is off in CI — hence 11s of total silence in the log.
Suggested real fix — don't hand llama.cpp any GPU device when we're CPU-only. In LlamaBackend::Reinitialize, after setting n_gpu_layers:
// llama.cpp attaches all GPU devices to the model regardless of
// n_gpu_layers, and llama_context initializes a backend for each one; on
// macOS that compiles ggml's Metal shader library and pipeline states for
// nothing.
static ggml_backend_dev_t sNoDevices[1] = {nullptr};
if (modelParams.n_gpu_layers <= 0) {
modelParams.devices = sNoDevices;
}
(devices is documented as "NULL-terminated list of devices to use for offloading", include/llama.h:292.) This is worth doing beyond the test: it's ~11s of startup latency on every Apple Silicon llama.cpp engine today.
Stopgap to green the tree first: requestLongerTimeout(3) in browser_ml_native.js (100s against a 135s budget).
Heads-up: browser_ml_utf8_codepoint.js ran 44.2s of the 45s budget in that same job (4 llama engines, no requestLongerTimeout) — it's the next perma-orange from the same cause.
I did not attach a patch: this is macOS/Apple-Silicon-specific and I can't build or run mochitests on that platform here, so the fix above is unverified and needs a try push.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
Comment 4•2 months ago
|
||
| bug-fix | ||
Two corrections/additions to comment 3; the recommended fix is unchanged.
Correction: the eager pipeline-state count is 425, not the ~1279 I quoted (I miscounted GGML_METAL_KERNEL_TYPE_ string occurrences rather than GGML_METAL_ADD_KERNEL invocations). The MSL handed to newLibraryWithSource: is ~466 KiB — ggml-metal.metal + ggml-common.h + ggml-metal-impl.h concatenated by generate_metal_embed.py.
Why the OS shader cache doesn't amortize this (the obvious objection — otherwise only the first engine would be slow, not all 13): LlamaRunner is gated to the inference content process (LlamaRunner.cpp:696-701), which uses SandboxPolicyContent.h. That policy allows the com.apple.MTLCompilerService mach-lookup (line 323) but grants no shader-cache write — the only userCacheDir grant is FontRegistry (lines 264-266) and there is no file-issue-extension rule. Compare SandboxPolicyHWInference.h:133-150, which deliberately grants bundleIDCacheDir read/write and file-issue-extension for com.apple.metalfe/com.apple.gpuarchiver "for the MTLCompilerService process" — but that profile only applies to the HW_INFERENCE utility process. So the comment in generate_metal_embed.py ("compiled on first run and then cached by the OS") does not hold here: nothing is cached, and every fresh inference process pays full price. The test calls EngineProcess.destroyMLEngine() after every task, so all 9 engines are cold.
Cheap confirmation, one job: re-run with MOZ_LOG=GeckoMLLlamaBackendNative:5. ggml logs its own timing — you should see ggml_metal_load_library: using embedded metal library, metal shader compiled from source in N ms (ggml-metal.m:1058), then 425 loaded kernel_... lines filling the ~11s. There is also already an MLEngine:llama.cpp "Initialize" profiler marker around the whole thing (LlamaCppPipeline.mjs:188-192).
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
| Comment hidden (Intermittent Failures Robot) |
| Comment hidden (Intermittent Failures Robot) |
| Comment hidden (Intermittent Failures Robot) |
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 9•2 months ago
|
||
| Comment hidden (Intermittent Failures Robot) |
| Assignee | ||
Comment 11•2 months ago
|
||
| Comment hidden (Intermittent Failures Robot) |
| Comment hidden (Intermittent Failures Robot) |
Comment 14•2 months ago
|
||
Comment 15•2 months ago
|
||
| bugherder | ||
Comment 16•2 months ago
|
||
The patch landed in nightly and beta is affected.
:padenot, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox157towontfix.
For more information, please visit BugBot documentation.
| Comment hidden (Intermittent Failures Robot) |
| Assignee | ||
Comment 18•2 months ago
|
||
Valentin, while my mistake made the failure perma, I believe this can also happen on Beta that doesn't have the Metal code and also on Windows, maybe something worth glancing at. The frequency is nowhere near perma though.
https://searchfox.org/firefox-beta/source/third_party/llama.cpp/ggml/src
https://searchfox.org/firefox-main/source/third_party/llama.cpp/ggml/src
Comment 19•2 months ago
|
||
Thanks Paul, I filed https://bugzilla.mozilla.org/show_bug.cgi?id=2071288 to attempt to solve the intermittent
| Comment hidden (Intermittent Failures Robot) |
Comment 21•2 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Large regression when using llama.cpp on macOS (only).
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: yes
- Steps to reproduce for manual QE testing: Use the summarizer: it should be as fast as before
- Risk associated with taking this patch: low
- Explanation of risk level: We're just reverting back to the previous tried and true code, this was only in nightly for a few days.
- String changes made/needed?: none
- Is Android affected?: no
| Assignee | ||
Comment 22•2 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D324021
Updated•2 months ago
|
Updated•2 months ago
|
Comment 23•2 months ago
|
||
| uplift | ||
Updated•2 months ago
|
Updated•2 months ago
|
Comment 24•2 months ago
|
||
Hello! Unfortunately, I cannot reproduce this issue on macOS 15 aarch or macOS 26 aarch using the affected Firefox 157.0a1 (2026-09-09). I tried several different articles on Wikipedia by holding down the left mouse button on a link, and the key points are displayed pretty quickly for me.
The only time I noticed this being slower was with new profiles during the initial setup on affected builds. On the latest Nightly 158.0a1 (2026-09-21), this appears to be faster.
Am I missing some steps here? Thank you!
Updated•1 month ago
|
| Assignee | ||
Updated•1 day ago
|
Description
•