Wings 3D Development Forum
High CPU usage when doing camera orbit. - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Bug Reports (https://www.wings3d.com/forum/forumdisplay.php?fid=12)
+--- Thread: High CPU usage when doing camera orbit. (/showthread.php?tid=2980)

Pages: 1 2


High CPU usage when doing camera orbit. - Bram - 01-22-2021

UPDATE: Just moving the mouse will make CPU usage shoot through the roof. It does not have to be in camera orbit mode.

Originally, I thought this issue was caused by my mouse, but it is a CPU load issue.

When I orbit my scene (middle click mouse button) then as I move my mouse, I see my CPU load shoot up, exceeding 100% for beam.smp

As I halt my movements (while remaining in the orbit mode) the CPU load drops to 0, and it shoots up again, as I start moving my mouse again.

This video shows the issue (with the high load from the desktop capture, beam.smp stays at 80% or so in this video, but I've seen it go 100+ without the desktop capture. And it goes to 0 if I stop moving my mouse.)




Version: 2.2.6.1

OS: Ubuntu 20.10

GPU: RTX 3070

CPU: Xeon 8-core.

GL: 4.6.0 NVIDIA 460.32.03


RE: High CPU usage when doing camera orbit. - micheus - 01-22-2021

I hope dgud can take a look this.


RE: High CPU usage when doing camera orbit. - Bram - 01-22-2021

From what I can see, the cycles are spent in erl_drv_ calls.




RE: High CPU usage when doing camera orbit. - dgud - 01-22-2021

Can this be related to mouse update rate?

We had a thread about that here which I can't find now, I don't have any backpressure of
how fast the mouse events are generated, they are sent async from gui thread to erlang,
which generates to much work.

I don't really know how to solve that, both wx (the erlang wrapper lib) and wings in its current state are designed to work with async event model. So I don't have an easy fix.

The only fix was to reduce the mouse polling rate. Micheus you had some links?

EDIT: Also since corona I don't have access to a (non virtual) linux machine, so testing on linux is hard for me.


RE: High CPU usage when doing camera orbit. - micheus - 01-22-2021

Thanks for the help dgud.

Quote:The only fix was to reduce the mouse polling rate. Micheus you had some links?
Yeah. We had three situations which making the dpi adjustment fixed problems on Linux:
- Mouse Skipping
- Linux noticeably smoother on AMD
- Jerky mouse on Linux

Since I noticed you have a new mouse, the high DPI can really be the case. Maybe you don't need to look for another mouse. Smile

For some hardware there is a driver app to help with that. Would this "linux driver" help you: How to change mouse DPI?


RE: High CPU usage when doing camera orbit. - Bram - 01-22-2021

I tried mouse polling rate of 500Hz instead of 1000Hz, same issue. I will try again, with lower settings.

It will also try to run wings w vsync off, to see if that helps.

To really fix this problem, it would help if wings or wx could batch process a whole bunch of movements before continuing redrawing the ui.

In psuedo code:
Code:
While ( mouse move available )
    Read event
    Update mousepos
Update viewport
Draw viewport

In my own code, c and c++, I used sdl2 for io and the standard approach is to process all events until there are no more, and then update/draw a single frame.


RE: High CPU usage when doing camera orbit. - Bram - 01-22-2021

The high CPU rate is unrelated to the mouse polling rate, I have determined.

I changed my razor mouse to poll at 125Hz instead of 1000Hz, with the following results:
  • The mouse stutter is gone!
  • The CPU usage by beam.smp is still very high as soon as you move the mouse, regardless whether the polling rate is 125 or 1000. Just the fact that you generate mouse events makes the CPU usage go high.



RE: High CPU usage when doing camera orbit. - micheus - 01-22-2021

Bram, did you have this kind of problem with the previous version of Ubuntu?
I search around and there were other complains about this issue with other versions like 18.04 and even 20.04


RE: High CPU usage when doing camera orbit. - Bram - 01-22-2021

Quote:I search around and there were other complains about this issue with other versions like 18.04 and even 20.04

I only have two machines w 20.10 here, but I doubt it depends on OS version.

I see the CPU usage rise on mouse-movement on both machines, although my 8-core Xeon is affected more than my 4-core Haswell.


RE: High CPU usage when doing camera orbit. - micheus - 01-22-2021

It's interesting that we don't notice that on Windows. The CPU usage indeed increases on mouse movement, but far away to make the CPU reach 100%.

In the fractional scaling added to Ubuntu 20.04 (link) they supposedly improved this:
Quote:Fractional scaling doesn't currently work when using the proprietary Nvidia drivers though!

There's also improved performance. There's lower CPU usage for window and overview animations, JavaScript execution, mouse movement and window movement (which also has lower latency now).