Skip to content

eframe on Windows high CPU usage due to excessive calls to glutin::context::make_not_current #4173

Open
@gerwin3

Description

@gerwin3

I noticed that my application CPU usage was much higher than expected on Windows. On a similar machine I was seeing 1%-2% usage on Linux, and around 20%-30% on Window while moving the mouse in window (just mouse movement).

After some optimization I got my rendering loop down to less than 1ms and still the CPU usage was too high. I then sampled the CPU with https://github.com/nico-abram/blondie/tree/main and this is the flamegraph that it produces:

As you can see, almost 90% of the time, it is calling the make_not_current function, which seems really excessive...

EDIT: I found in the docs here that this call flushes the rendering context so probably rendering is just very slow... Still not sure why though.

Screenshots

image

Another flamegraph with Windows Performance Analyzer (similar results):

image

This shows the call stack a bit deeper:

  • opengl32d.dll wglMakeCurrent
  • opengl32d.dll bMakeNoCurrent
  • opengl32d.dll wglMakeCurrent
  • opengl32d.dll wglMakeCurrent
  • opengl32d.dll wglMakeCurrent
  • KernelBase SetEvent

Desktop (please complete the following information):

  • OS: Windows
  • Version: egui 0.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    native-windowsRunning on native Windows OSperformanceLower CPU/GPU usage (optimize)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions