WGPU backend transition: performance, issues and suggestions
In 0.34, the default eframe backend was changed from glow to wgpu (#5889 seems to hint it's going to become the only one eventually). This switch has introduced issues and changed the performance characteristics of the resulting binaries, which this post aims to track and detail. The goal is also to identify beaking changes or other aspects that may likewise cause friction.
All meaurements are exclusively taken in Windows, and specifically relate to the example provided here: https://docs.rs/eframe/latest/eframe/fn.run_simple_native.html
Representing the previous default experience users may be accustomed to and acting as a baseline, 0.33.3 is also compared alongside glow and wgpu in 0.34.
In accordance with #7886 as well as my own testing, disabling default features seems to currently be required to use the glow backend. This is going to affect the results though, so all testing was conducted for consistency with default features disabled.
COMPILE TIMES
These results are for a full compilation after deleting the /target folder, averaged over 3 runs.
Actual numbers depend on CPU performance, but the general trend should remain consistent across different hardware.
| Profile | 0.33.3 | glow | wgpu |
|---|---|---|---|
| Release | 19.59s | 30.87s | 42.30s |
| Release + LTO | 30.10s | 58.78s | 1m 40s |
BINARY SIZE
| Profile | 0.33.3 | glow | wgpu |
|---|---|---|---|
| Release | 13.9 MB | 17.7 MB | 27.7 MB |
| Release + LTO | 4.44 MB | 5.62 MB | 11.3 MB |
MEMORY USAGE
The Afterburner data refers to the decrease in system total after the app is closed. Working Set and Private Bytes were provided by System Informer. Every measurement is a rounded average of a few runs with ± 2 MB error.
RAM
| Measurement | 0.33.3 | glow | wgpu VK | wgpu DX12 | wgpu GL |
|---|---|---|---|---|---|
| Task Manager | 31 MB | 31 MB | 90 MB | 142 MB | 26 MB |
| Afterburner | 56 MB | 51 MB | 130 MB | 173 MB | 53 MB |
| Working Set | 53 MB | 54 MB | 129 MB | 176 MB | 53 MB |
| Private Bytes | 137 MB | 137 MB | 438 MB | 400 MB | 140 MB |
VRAM
| Measurement | 0.33.3 | glow | wgpu VK | wgpu DX12 | wgpu GL |
|---|---|---|---|---|---|
| Afterburner | 31 MB | 31 MB | 265 MB | 215 MB | 31 MB |
UNCAPPED PERFORMANCE
Averaged over 50 samples or so with a 500ms polling rate. Samples usually fall within a ±3% range. Results are CPU-bound.
| Measurement | 0.33.3 | glow | wgpu VK | wgpu DX12 | wgpu GL |
|---|---|---|---|---|---|
| Idle | 3140 fps | 3050 fps | 3680 fps | 2280 fps | 1200 fps |
| Mouse movement (1khz) | 2170 fps | 2100 fps | 2800 fps | 1950 fps | 920 fps |
INPUT LATENCY
~2 frames in glow and ~3 frames in wgpu at 120hz + vsync. Details in the comments.
https://github.com/user-attachments/assets/98798164-763b-4b49-90cb-84236071c734
STARTUP TIMES
No formal tests yet but from preliminary tests in a "real" app, they're not great and very inconsistent. Whereas glow is consistently pretty quick (100~300ms), wgpu can take anywhere from 1 to about 7 seconds, which is significantly worse and very obvious from a user's standpoint. This behavior is still under investigation but doesn't seem to affect the simple program used for the other tests much.
UNSUPPORTED FEATURES, BREAKING CHANGES, GENERAL FRICTION
- support for 8x multisampling is not automatically enabled in Vulkan and DX12, even when the hardware is capable of it;
- window transparency is seemingly not supported at all in wgpu's DX12 and OpenGL backends, or at the very least requires extra steps I'm not aware of;
- the intuitive vsync field in NativeOptions only works for glow, a more complex setup is required for WGPU;
- max texture size is 8192 by default in WGPU whereas glow has it set at 32768. While it is possible to manually increase it, it's not exactly a seamless process. (The image loaders are memory-limited in both scenarios to 512MB = ~134Mpx, but that's due to the
imagecrate, I think) - there's also this issue with the default Vulkan backend (can also happens in glow under specific circumstances; more testing required):
https://github.com/user-attachments/assets/955c8711-e85d-4eba-986e-3cd1ca9bc43c
Source: emilk/egui