Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% CPU usage since the update to wgpu 0.20 #5092

Open
EmbersArc opened this issue Sep 8, 2024 · 12 comments
Open

100% CPU usage since the update to wgpu 0.20 #5092

EmbersArc opened this issue Sep 8, 2024 · 12 comments
Assignees
Labels
bug Something is broken egui-wgpu performance Lower CPU/GPU usage (optimize)

Comments

@EmbersArc
Copy link
Contributor

EmbersArc commented Sep 8, 2024

Describe the bug

Any egui app uses 100% CPU when redrawing since commit 814ad07, the wgpu 0.20 update.

To Reproduce
Steps to reproduce the behavior:

  1. Run e.g. cargo run --bin hello_world
  2. Move the cursor
  3. The CPU usage of the egui process goes up to 100%

Expected behavior

Only a fraction of the CPU usage as observed before the wgpu update.

Screenshots

Desktop

  • OS: Arch Linux 6.10.8-arch1-1 (64-bit)
  • X11 with NVIDIA 560.35.03
@EmbersArc EmbersArc added the bug Something is broken label Sep 8, 2024
@EmbersArc
Copy link
Contributor Author

I did some bisecting and the offending wgpu PR seems to be gfx-rs/wgpu#4967.

@emilk emilk added egui-wgpu performance Lower CPU/GPU usage (optimize) labels Sep 9, 2024
@emilk emilk added this to the Next Major Release milestone Sep 9, 2024
@Wumpf
Copy link
Collaborator

Wumpf commented Sep 9, 2024

egui is already on wgpu 22.0, so unless there is reason to believe this is fixed on wgpu main (which pr fixes it?) this is completely unrelated

@EmbersArc
Copy link
Contributor Author

Switching to wgpu trunk does not fix it yet unfortunately.

@jleibs
Copy link
Contributor

jleibs commented Sep 10, 2024

@jleibs I can try to repro this locally

@EmbersArc
Copy link
Contributor Author

For what it's worth, this is not related to egui directly. I can also reproduce it with the wgpu boids example, i.e. with cargo run --release --bin wgpu-examples boids. gfx-rs/wgpu#6067 seems related although it mentions lag and not CPU usage.

@jleibs
Copy link
Contributor

jleibs commented Sep 10, 2024

I can also repro this on Arch w/ 560.35.03.

I am running through Wayland. On wayland native I don't see the issue, but I do when using xorg-xwayland.

@EmbersArc can you confirm you're running X11 native and not wayland+xwayland?

@jleibs
Copy link
Contributor

jleibs commented Sep 10, 2024

On wayland, the boids example runs at 4400 fps using 30% CPU.
On X-wayland, the boids example runs at 80 fps using 100% CPU.

@EmbersArc
Copy link
Contributor Author

@EmbersArc can you confirm you're running X11 native and not wayland+xwayland?

Yes this is on X11 native.

@cwfitzgerald
Copy link
Contributor

cwfitzgerald commented Sep 10, 2024

Howdy, wgpu maintainer here. We really will need a bit more information on the performance usage here. Would it be possible to take a performance profile to understand where the cpu is spending its time? Vulkan swapchain sync is mildly cursed, so even after the rewrite we may be still doing it subtly wrong.

@Wumpf
Copy link
Collaborator

Wumpf commented Sep 11, 2024

@jleibs and me will dive a bit deeper into this either this or next week (we work at the same company and while I'm not as knowledgeable as @cwfitzgerald in this area, I know a few things about wgpu from being a maintainer myself 😄, making this easier)
From what we learned so far this is very related to the latest Nvidia drivers as there has been a lot of changes on how they handle vsync. But I also suspect that there's some subtleties in wgpu still.

@jleibs
Copy link
Contributor

jleibs commented Sep 16, 2024

Also because I happened to turn on the other computer I'll note that I also see this on:

  • OS: Ubuntu 22.10
  • X11 with Nvidia 535.54.03

So, it does not appear unique to the more recent 560-series drivers.

@Wumpf
Copy link
Collaborator

Wumpf commented Sep 20, 2024

Apparently the validation layer has some interaction with this as well, we should make sure that we try release versions and debug versions with disabled validation, see
gfx-rs/wgpu#5756 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui-wgpu performance Lower CPU/GPU usage (optimize)
Projects
Status: No status
Development

No branches or pull requests

5 participants