brunoherbelin / vimix

Live Video Mixer
GNU General Public License v3.0
260 stars 25 forks source link

High GPU usage by GUI #17

Closed lukors closed 1 year ago

lukors commented 3 years ago

I'm experimenting with using a laptop without a dedicated graphics card with Vimix. I can currently run a maximum of 4 1080p/30 videos before I start dropping frames, or 9 at 720p/30. This is good for my use at 720p, but for 1080p I want more headroom.

It looks like my bottleneck is the integrated GPU since that hits 100% at the same time as I start dropping frames.

I have tested to run many VLC instances to see if the performance issues come from decoding many 1080p videos for some reason. I got to 9 VLC instances before my computer crashed, and I wasn't running into any bottlenecks at that point, so this tells me that my computer is able to handle the decoding.

When starting Vimix my GPU usage goes up to ~80%, I'm guessing this comes from rendering the GUI. Would it be possible to optimize this? That would most likely enable me to run more sources.

lukors commented 3 years ago

I've looked into this some more, and have come to the conclusion that any application with an imgui-type interface uses up this amount of GPU on this computer. Running more than one imgui-type interface does not increase the GPU usage linearly. Using one is ~80%, using 2 is ~84%. This might just be how this GPU behaves.

This is what I'm doing:

In the end this might just turn out to be unsolvable. If that's the case I'm hoping it will be possible for me to build a custom retained UI for Vimix.

brunoherbelin commented 3 years ago

Hi Can you tell me if the framerate is v-synched to 60Hz ? (open the Metrics in vimix) If it is not the case, this would definitely explain why GPU is to the roof... Updating or fixing GPU drivers would solve it.

lukors commented 3 years ago

I checked it and yes it's vsynced. :)

I tried a lighter desktop manager (lxqt), and the GPU usage was the same.

Got a response from the company, they asked for some logs and hopefully they can let me know if this is the expected performance of this GPU.

lukors commented 3 years ago

The company I bought the computer from says this is expected performance, and I can't find any information about it online. So I guess this is just how it is!

I'm assuming moving Vimix away from immediate mode GUI is off the table. Maybe later on I'll try building something to get around this issue, when it's possible to do that with headless mode and the API.

brunoherbelin commented 3 years ago

Please try with latest source or edge/latest snap under linux: I implemented a patch to add a software framerate limiter when the v-sync is disabled : Screenshot-20210115184709-626x586 After restart, PFS should not raise above 60 (probably 30fps), and potentially this would also limit CPU usage.

lukors commented 3 years ago

The frame rate limiter doesn't seem to work on my computer.

I tried commit a3e121d6a0635f7df730af7b6d6a85d54ef000cb which looked like the one where this feature was first working: 0 4

I also tried the most recent commit 5262b8ae291b3e9ecbb363b5d98351e38c9c40c0 and it had the same issue: 0 5

lukors commented 3 years ago

I'll reopen this for now since the software frame limiter doesn't seem to work on my computer.

lukors commented 3 years ago

I saw a new commit that made changes to how the software frame limiter works, so I tried that and it works now.

The GPU usage is about the same though.

Closing this again because there's nothing else to do with this issue.

brunoherbelin commented 3 years ago

Yes, I did change the FPS software limiter implementation, but didn't have time to inform you.. Happy that this feature now works!

It is weird that the usage would not change: with FPS software limiter, the process is literally in sleep before starting next frame (aka. C call to usleep(), a low level process instruction). Maybe the Intel GPU usage monitors is not very acurate neither...

Thank you for having contributed to making this better in vimix !

lukors commented 3 years ago

Yeah it is weird, but the performance monitor also seems to line up with reality because it can be correlated with fan speed and heat development. I guess this is how this GPU works.

I will wait for headless mode and see how it works without a gui. Thanks for trying to improve my situation! :)

OlegoroV commented 3 years ago

Although VSync is on and Refresh rate is 60 fps, GPU usage and temperature are much higher than in GLMixer. I have laptop with NVidia 960M

lukors commented 3 years ago

I'll reopen the issue for you so it doesn't get lost as easily.

brunoherbelin commented 3 years ago

There is an important difference which you might appreciate if you are in need for higher performance under linux: the snap is, by definition, a virtual machine running an old version of ubuntu (18.04) inside your own ubuntu (can be 20.04 or whatever). This is the power of snap: it works for all users.

BUT, as a normal consequence, the snap does not use the latest libraries nor many system-specific hardware acceleration. OpenGL, as a standard, is supported (thankfully!!), but specific Nvidia or other GPU decoding cannot be detected.

I am hopeful that the upcoming snaps will integrate a Core20 (not fully approved yet, and thus not supported for snap distribution) will possibly improve this. But I cannot be sure.

Thus, for those in need of performance, I strongly advise to compile vimix from source. https://github.com/brunoherbelin/vimix/blob/master/README.md gives the instructions. Thanks for giving your feedback on these instructions if they are not complete or incorrect.

OlegoroV commented 3 years ago

Followed this instruction. GPU temperature is still too high.

BTW. Addition to dependencies for compiling: non Gnome based distrib needs also "libgtk-3-dev" with all its' dependencies.

OlegoroV commented 3 years ago

Oh! And also ordinary user have to install git

brunoherbelin commented 3 years ago

The README was updated: https://github.com/brunoherbelin/vimix/blob/master/README.md