vvvv / VL.StandardLibs

A collection of standard libraries for vvvv including VL.Stride, VL.Skia, VL.ImGui, msgpack.org[VL]
https://visualprogramming.net
GNU Lesser General Public License v3.0
39 stars 15 forks source link

manage work load #299

Open gregsn opened 3 years ago

gregsn commented 3 years ago
tebjan commented 3 years ago

Also, background FPS to lower fps when vvvv not in focus.

tebjan commented 3 years ago

I've asked @eideren for some advice on this, as he has done quite some work on the Stride thread pool and he was so kind to work on a way to control the thread pool better. Also some comments:

Dispatcher.MaxDegreeOfParallelism might also help but it doesn't guarantee that limit when other threads dispatches as well (which it already does in certain cases but you might not hit those) I could also setup a way to switch to a less wasteful mode for the threadpool, right now it does waste more cycles to ensure that the engine get access to those threads as fast and often as possible, not sure how useful that would be given that end-users prefer the game to keep priority access to those resources

@tebjan If your goal is to have a sort of power saving mode, forcing a lower thread count won't really solve the crux of your issue. I personally would enable vsync or set Game.WindowMinimumUpdateRate to a sane value first, something like TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 60), this will ensure that heavier scenes still runs at a decent rate while lighter scenes don't take that much resources.

Then set Game.TreatNotFocusedLikeMinimized to true and verify that Game.MinimizedMinimumUpdateRate is at a fairly low frequency to reduce the amount of resources the engine uses while it doesn't have focus. Finally you can reduce Dispatcher.MaxDegreeOfParallelism while I work on providing a way to have a sort of power saving mode for the thread pool

Yes, we already cap the fps, we drive Stride with our own mainloop... I'll try the MaxDegreeOfParallelism property

@tebjan https://github.com/stride3d/stride/pull/984 Set ThreadPool.Instance to a new instance with a specific amount of threads and dispose of the previous one. I didn't provide any way to dynamically set the amount without disposing the object as it's kind of a nightmare to implement and would add more overhead for each threads