PGO training corpus does not exercise WebGL, so WebGL draw-call-heavy pages run slower in PGO builds
Categories
(Firefox Build System :: General, defect)
Tracking
(Not tracked)
People
(Reporter: pmenzel+bugzilla.mozilla.org, Assigned: pmenzel+bugzilla.mozilla.org)
References
Details
Attachments
(1 file, 1 external file)
|
2.85 KB,
application/gzip
|
Details |
Steps to reproduce
Access https://webglsamples.org/aquarium/aquarium.html and run it.
Actual results
The PGO build is slower than the non-PGO build. (It is also much slower than Chromium (bug 1902867).)
Expected results
PGO build should be faster.
build/pgo/index.html has no page that issues WebGL draw calls. In a profile trained with it, ClientWebGLContext::UniformData and QueueParamTraits<Span<const UniformDataVal>>::Read have all-zero counts and ClientWebGLContext::UseProgram runs 4 times, so PGO optimizes the WebGL command path as cold. On the WebGL Aquarium (15,000 fish) with AMD Radeon Pro WX 5100, the official PGO build is slower than an LTO build without PGO: about 38 against 40 fps.
| Assignee | ||
Updated•21 days ago
|
| Assignee | ||
Comment 1•21 days ago
|
||
No page in the PGO training corpus issues WebGL draw calls. In a profile
trained with it, ClientWebGLContext::UniformData and
QueueParamTraits<Span<const UniformDataVal>>::Read never run and
ClientWebGLContext::UseProgram runs 4 times, so PGO optimizes the WebGL
command path as cold code. On the WebGL Aquarium the official PGO build
is slower than an LTO build without PGO.
draw-calls.html draws a few hundred small objects per frame on a WebGL 1
and a WebGL 2 canvas, with the state changes a scene library makes, and
posts pgoBenchmarkDone after 1200 frames. Under Xvfb with llvmpipe it
reaches 1000 to 1200 frames within extendedTimeout.
Local Linux x86-64 builds with cross-language LTO and PGO, trained like
run-profileserver.sh, without -> with this patch, WebGLSamples pages on
X11, vsync off, mean of 5 alternating runs:
AMD WX 5100 NVIDIA RTX 2080
aquarium, 15,000 fish (fps) 38.2 -> 46.7 +22% 68.8 -> 80.2 +17%
aquarium, 30,000 fish (fps) 37.6 -> 43.3 +15%
multiple-views (fps) 826 -> 995 +20%* 699 -> 749 +7%
dynamic-cubemap (fps) 889 -> 1002 +13%* 948 -> 997 +5%
lots-o-objects (objects
at 50 fps, vsync on) 3921 -> 5361 +37%* 6841 -> 8641 +26%
- an earlier version of the page (no stop after 1200 frames) on an
older main
Speedometer 3 does not change (15 rounds, t = 0.7 and 1.3).
Updated•21 days ago
|
| Assignee | ||
Comment 2•21 days ago
|
||
AI disclaimer: Drafted with claude-opus-5.5 and reviewed by me.
More details on the measurements behind D340304.
Training cost. On a 256-thread build node, profile generation took 9:54 min with the patch against 7:49 min without (+2:05). The measured builds trained with a version of the page that ran until extendedTimeout (2 min, about 1070 frames). The page now stops after 1000 frames or at extendedTimeout, whichever comes first, so it adds at most about 2 minutes.
Profile counts for ClientWebGLContext::UniformData (llvm-profdata show --counts): 0 with the stock corpus, 2,064 with talos glterrain added, 6.9 million with this patch, 18.9 million with the aquarium itself.
Training page alternatives. Same main (2b71df5bf2e0), only the corpus differs: stock / + glterrain / + this page (earlier version, trained for the full 2 minutes) / + aquarium. Mean of 5 alternating runs, vsync off except lots-o-objects:
| Page | AMD Radeon Pro WX 5100, i7-7700 | NVIDIA RTX 2080, i7-9700 |
|---|---|---|
| Aquarium, 15,000 fish (fps) | 37.9 / 42.4 / 46.5 / 52.2 | 67.1 / 74.7 / 81.3 / 87.3 |
| Aquarium, 30,000 fish (fps) | – | 36.4 / 39.4 / 43.4 / 46.6 |
| multiple-views (fps) | 826 / 907 / 995 / 967 | 688 / 718 / 738 / 739 |
| dynamic-cubemap (fps) | 889 / 956 / 1002 / 998 | 916 / 960 / 994 / 980 |
| lots-o-objects (objects at 50 fps) | 3921 / 4721 / 5361 / 5361 | 6921 / 7881 / 8681 / 8481 |
glterrain (one draw call per frame) recovers about half of the gain. With the aquarium corpus, pages that draw little per frame (blob, city, field, sprites, grid-tower) did not change, and no WebGL page got slower.
Speedometer 3, 15 rounds each, with the page against without: 15.19 against 15.03 under Xvfb (t = 0.7) and 19.62 against 19.45 on the NVIDIA machine (t = 1.3). No suite is
significantly slower. The largest slowdowns with the page are TodoMVC-jQuery +1.1% (t = 1.5) and TodoMVC-JavaScript-ES6-Webpack-Complex-DOM +1.3% (t = 1.3) on the NVIDIA machine.
Chromium, on the NVIDIA machine in the same alternating runs as the D340304 table (Firefox main → with the patch / Chromium 156):
| Page | Firefox | Chromium |
|---|---|---|
| Aquarium, 15,000 fish (fps) | 68.8 → 80.2 | 112.0 |
| Aquarium, 30,000 fish (fps) | 37.6 → 43.3 | 57.5 |
| multiple-views (fps) | 699 → 749 | 1682 |
| dynamic-cubemap (fps) | 948 → 997 | 1571 |
| lots-o-objects (objects at 50 fps) | 6841 → 8641 | 2001 to 9001 (3 runs 8201 to 9001, 2 runs 2001) |
glterrain (one draw call per frame) recovers about half of the gain. With the aquarium corpus, pages that draw little per frame (blob, city, field, sprites, grid-tower) did not change, and no WebGL page got slower.
Speedometer 3, 15 rounds each, with the page against without: 15.19 against 15.03 under Xvfb (t = 0.7) and 19.62 against 19.45 on the NVIDIA machine (t = 1.3). No suite is significantly slower. The largest slowdowns with the page are TodoMVC-jQuery +1.1% (t = 1.5) and TodoMVC-JavaScript-ES6-Webpack-Complex-DOM +1.3% (t = 1.3) on the NVIDIA machine.
Chromium, on the NVIDIA machine in the same alternating runs as the D340304 table (Firefox main → with the patch / Chromium 156):
| Page | Firefox | Chromium |
|---|---|---|
| Aquarium, 15,000 fish (fps) | 68.8 → 80.2 | 112.0 |
| Aquarium, 30,000 fish (fps) | 37.6 → 43.3 | 57.5 |
| multiple-views (fps) | 699 → 749 | 1682 |
| dynamic-cubemap (fps) | 948 → 997 | 1571 |
| lots-o-objects (objects at 50 fps) | 6841 → 8641 | 2001 to 9001 (3 runs 8201 to 9001, 2 runs 2001) |
On the AMD machine Chromium reached 58 fps on the aquarium against 38.2 → 46.7, but with vsync on, so it may be held back by the display's refresh rate. The patch closes only part of the gap in bug 1902867. In earlier profiling of the aquarium on the AMD machine with non-PGO builds, two other causes stood out: the default webgl.out-of-process.shmem-size (100 KB) makes the command buffer flush more than 10 times per frame, and 1 MB took the aquarium from 38.3 to 41.7 fps; and Firefox disables Mesa’s glthread on X11/EGL (bug 1670545), which took it on to 44.5 fps when enabled.
Method. A local copy of WebGLSamples served over HTTP, a fresh profile per run, 1920x1080 window, 8 s warm-up and 10 s measured (lots-o-objects: 20 s and 20 s), builds alternating. vsync off: layout.frame_rate=0 in Firefox, --disable-gpu-vsync --disable-frame-rate-limit in Chromium. Both browsers render on the GPU through the system OpenGL driver (radeonsi; NVIDIA 580.178.04): Firefox calls it directly from its GPU process, Chromium through ANGLE’s OpenGL backend.
| Assignee | ||
Comment 3•21 days ago
|
||
Sorry, some parts are double in the last comment.
Comment 4•21 days ago
|
||
This is a very interesting find! There's plenty of canvas2d in the training corpus, which does use WebGL internally. but uses WebGLContext directly, not ClientWebGLContext.
Can we do a mach try perf run for speedometer 3 and "graphics and media" categories on all platforms?
| Assignee | ||
Comment 5•21 days ago
|
||
Can we do a mach try perf run for speedometer 3 and "graphics and media" categories on all platforms?
Sure, but unfortunately, as a new code contributor I do not have the necessary permissions yet. Could you please do this?
Comment 6•21 days ago
|
||
It would also be good to file a follow up about potentially adding it to the Android PGO corpus too (as unfortunately it's implemented separately)
Comment 7•18 days ago
•
|
||
Here's a perfcompare: https://perf.compare/compare-results?baseRev=af3e5588b967e5a531ddcac42e23c183a6221b94&baseRepo=try&newRev=ea7546899d69bacdb1d84e075973d04bdd283ab0&newRepo=try&initialized=1&framework=1&framework=13
I expect most of the changes it's detected are just noise. But good to confirm it hasn't regressed something important like speedometer.
The Linux and macOS motionmark-webgl scores get a huge improvement, fantastic! By curiously the windows score slightly regresses. I've triggered some performance profiles which can hopefully show why.
Comment 8•18 days ago
•
|
||
I think the lack of motionmark-webgl improvement on windows is because PGO profile generation runs on a device without GPU acceleration so the testcase fails to run.
ERR: DisplayD3D.cpp:103 (rx::CreateRendererD3D): Failed to create D3D renderer: Could not create D3D11 device.
ERR: Display.cpp:1596 (egl::Display::initialize): ANGLE Display::initialize error 12289: No available renderers.
JavaScript warning: http://localhost:8888/webgl/draw-calls.html, line 254: Failed to create WebGL context: WebGL creation failed:
- tryANGLE (FEATURE_FAILURE_WARP_FALLBACK)
- Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS)
Comment 9•17 days ago
|
||
Bug 2091474 will run Windows PGO training on a GPU, allowing webgl content to run. After which this should give the expected improvement on windows too
| Assignee | ||
Comment 10•17 days ago
|
||
Awesome that Windows PGO training is going to run on a GPU.
Also, thank you for the try runs. Just for the record, as it’s clear that it’s often hard to compare. I tried to reproduce the Linux offscreencanvas_webcodecs regressions locally with your two try builds, and could not.
The CI numbers. PerfCompare’s 50 replicates per side are 10 talos jobs, each value counted five times, so the High confidence is overstated. Each job also ran on a different machine. For offscreencanvas_webcodecs_worker_webgl_av1 the three fastest base jobs (2.76 to 2.80 ms) ran on t-linux64-ms-119, -123 and -132, and no new job ran on those machines. Without them the difference is +1.3 % instead of +2.2 %.
Local runs. I used the shippable builds of both pushes (af3e5588b967 and ea7546899d69) and the talos package of the base build, running base and new alternately:
- Xvfb (llvmpipe), AMD EPYC 7763, 8 streams each pinned to 4 cores of their own NUMA node: 136 pairs
- X11 on an NVIDIA GeForce RTX 2080 (driver 580.178.04), Intel Core i7-9700: 14 pairs
- X11 on an AMD Radeon Pro WX 5100 (radeonsi, Mesa 26.2.4), Intel Core i7-7700: 13 pairs
Mean of the paired relative differences, new against base (time per frame, lower is better; MotionMark is a score, higher is better):
| Test | CI (linux2404-64-shippable) | Xvfb, 136 pairs | RTX 2080, 14 pairs | WX 5100, 13 pairs |
|---|---|---|---|---|
| offscreencanvas_webcodecs_worker_webgl_av1 | +2.23 % | +0.08 % (t = 0.6) | +0.28 % (t = 1.9) | −0.11 % (t = −0.4) |
| offscreencanvas_webcodecs_main_webgl_av1 | +1.98 % | +0.04 % (t = 0.3) | +0.27 % (t = 1.8) | +0.24 % (t = 0.5) |
| offscreencanvas_webcodecs_worker_webgl_h264 | +4.33 % | +0.39 % (t = 2.1) | +0.65 % (t = 1.1) | +0.23 % (t = 0.3) |
| offscreencanvas_webcodecs_main_webgl_h264 | −1.89 % | +0.45 % (t = 2.5) | +0.08 % (t = 0.2) | −0.37 % (t = −0.6) |
| offscreencanvas_webcodecs_worker_webgl_vp9 | +0.03 % | −0.28 % (t = −1.4) | +0.19 % (t = 0.5) | −0.39 % (t = −0.7) |
| offscreencanvas_webcodecs_main_webgl_vp9 | −0.22 % | −0.24 % (t = −1.3) | +0.45 % (t = 0.8) | +0.43 % (t = 1.3) |
| motionmark_webgl | +23.8 % | +15.5 % (t = 209) | +26.7 % (t = 45) | +39.0 % (t = 69) |
So the patch may cost these tests up to about 0.5 %, but not the 2 to 4 % from CI. MotionMark WebGL improved in every one of the 163 pairs.
| Assignee | ||
Comment 11•17 days ago
|
||
Description
•