ljbade's picture

Compiz + OpenTK = high CPU

I am using Ubuntu 9.04.

Whenever I turn on Compiz while a OpenTK GL window is open (both in the examples and my own project) the CPU load for the thread's core goes to 100%. This makes the whole system very unresponsive.

Turning off Compiz (using metacity) the CPU drops to a few % and everything is smooth.

Haven't had this problem with any other OpenGL app/library.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

What video card / drivers are you using? Is vsync enabled in Compiz or the driver options (or both?) If you run the FBO sample in Examples.exe (comes with OpenTK), what is the reported FPS in each case (compiz on and off)?

My guess is that this is VSync related: right now, OpenTK relies on VSync to reduce CPU usage, which doesn't seem to work that well with Compiz. One possible workaround is to place a System.Threading.Thread.Sleep(1) right after the call to SwapBuffers.

ljbade's picture

From NVIDIA settings GUI:
Vendor: NVIDIA Corporation
Renderer: GeForce Go 7300/PCI/SSE2
Version: 2.1.2 NVIDIA 180.44

I have vsync turned off in compiz settings manager.
In the program high CPU occurs with both VSyncMode.Off and .On

The FBO example has interesting results.
With compiz off I get ~60 fps, but smooth ie number changes every frame.
With compiz on I still get ~60 according to top left text, but I obviously do not get that as number changes between 1 to 4 times a second.

Using System.Threading.Thread.Sleep(1) makes the system much more responsive (acceptable level), but still noticeably slower/jerkier, and still uses 50-70% of one core (compared to 1-5% with compiz off).

the Fiddler's picture

Thanks, I just installed Ubuntu 8.10 on my laptop, which uses a 8400Go, and I'll try to trace the issue.