SauceLLC / sauce4zwift

Sauce for Zwift™
GNU General Public License v3.0
106 stars 26 forks source link

High CPU usage on v1.1.2 #105

Open Helioth opened 7 months ago

Helioth commented 7 months ago

After updating today to v1.1.2, Sauce is using about 80% CPU, Zwift about 10%. Hiding minimap decreases usage to about 15%. Settings are 30fps and 50% quality. Was running fine on the previous version.

mayfield commented 7 months ago

Can you open "Stats for Nerds" from the Settings panel and see see what process is using the CPU?

EDIT: Just saw your mention of minimap, which I assume is the Sauce Map window. You might try enabling GPU Rendering if you haven't already. I think think this is likely just because the new version has a "demo" mode that spins the map when idle, so it maybe drawing more CPU when idle than before, but most especially if you are having to use the CPU for rendering.

Helioth commented 7 months ago

Upon closer inspection using Stats for Nerds, it appears it is due to the Nearby Athletes window. CPU usage is quite low for some time, then skyrockets for a while, and finally somehow goes back to almost zero, then ramps up again etc. I have 20 seconds refresh intervals. This behavior didn't show up with the previous version, even though I was on tempus fugit with about 20k people on Watopia and crossing pace partners from time to time. And btw, I'm indeed on software rendering. Didn't find where to enable GPU for rendering, either in Sauce of in nVidia control panel.

image

image

image

mayfield commented 7 months ago

GPU enable is under Settings -> General

[image: image.png]

Looks like your mem heap usage is pretty high, is this high CPU only after Sauce has been up for a while and been in high occupancy situations like a fondo race or other popular world?

And to help level set for me, what kind of CPU do you have and what is the refresh rate of your primary monitor?

JM

On Thu, Jan 25, 2024 at 11:37 AM Helioth @.***> wrote:

Upon closer inspection using Stats for Nerds, it appears it is due to the Nearby Athletes window. CPU usage is quite low for some time, then skyrockets for a while, and finally somehow goes back to almost zero, then ramps up again etc. I have 20 seconds refresh intervals. This behavior didn't show up with the previous version. And btw, I'm indeed on software rendering. Didn't find where to enable GPU for rendering, either in Sauce of in nVidia control panel.

image.png (view on web) https://github.com/SauceLLC/sauce4zwift/assets/2826215/927b9af0-2fc5-4142-886e-c1d7e2cd083f

image.png (view on web) https://github.com/SauceLLC/sauce4zwift/assets/2826215/32809dcc-da53-44d7-8ad9-c4d2f3240014

image.png (view on web) https://github.com/SauceLLC/sauce4zwift/assets/2826215/23349de4-d001-445b-afdd-7c0cd4742499

— Reply to this email directly, view it on GitHub https://github.com/SauceLLC/sauce4zwift/issues/105#issuecomment-1910774493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCANECO5VMIPXYEWS4ZMLYQKQ73AVCNFSM6AAAAABCJFX5W2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJQG43TINBZGM . You are receiving this because you commented.Message ID: @.***>

Helioth commented 7 months ago

Very high CPU comes only after about 5 minutes. Backend service memory usage slowly goes up and has reached about 3.5 GB after one hour.

Monitor is at 144 Hz, but Zwift FPS is caped at 55 FPS using Nvidia control panel. CPU is i7 6700 @3.4 GHz, GPU is GTX 1060 6GB.

I will let you know today how this runs on a less populated world after a long ride with GPU enabled.

EDIT: been observing the CPU usage for a few hours during a 220 participants fondo. The same behaviour for Nearby Athletes window occurs, however with a much lower CPU usage peak which makes it unnoticeable unless watching the stats. It seems there may be some bit of code that is highly nonlinear in the number of nearby users. It appears as well there is some sort of positive correlation between Nearby Athletes Window CPU usage and GPU Bridge CPU usage : peak CPU usages tend to occur about during similar periods of time. It seems for the major CPU peaks to occur there must be really a lot of riders around as this is much less pronounced elsewhere Tempus Fugit.

mayfield commented 7 months ago

The 144Hz is probably not helping the nominal CPU usage case. I don't know if you can limit that with your nvidia tools but it might help. However the crux issue of Nearby using tons of CPU seems like the problem. I'm guessing it's in a tight loop of some kind, can you go to that window when it's in this state and hit F12 to bring up the devtools? Then check out the Console tab and see if it's filled with errors. If that seems clean perhaps go to the the Performance Tab and record a short profile (5 to 10 seconds). You can export the contents of this and email them to me or just send a screenshot if you see something obviously wrong.

JM

On Sat, Jan 27, 2024 at 12:10 AM Helioth @.***> wrote:

Very high CPU comes only after about 5 minutes. Backend service memory usage slowly goes up and has reached about 3.5 GB after one hour.

Monitor is at 144 Hz, but Zwift FPS is caped at 55 FPS using Nvidia control panel. CPU is i7 6700 @3.4 GHz, GPU is GTX 1060 6GB.

I will let you know today how this runs on a less populated world after a long ride with GPU enabled.

— Reply to this email directly, view it on GitHub https://github.com/SauceLLC/sauce4zwift/issues/105#issuecomment-1913047447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCANF2JPZUOCSMD2RJLGDYQSSAHAVCNFSM6AAAAABCJFX5W2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGA2DONBUG4 . You are receiving this because you commented.Message ID: @.***>

Helioth commented 7 months ago

Here we go.

I was able to reproduce the behaviour and capture the log, even though this time it didn't reach the same level of CPU utilization. There was no error in the Console tab.

I recorderd 4 bursts of 5 seconds :

A first observation is the logs related to abnormal behaviour are about ten times bigger than the logs recorded during normal behaviour.

For reference, there were about 18k online on Watopia and I was riding Tempus Fugit.

Log files: Profile-abnormal-28mins.zip Profile-abnormal-54mins.zip Profile-normal-32mins.zip Profile-normal-60mins.zip

Two screen captures showing memory usage and positive correlation between GPU Bridge and Nearby Athletes when in normal / abnormal state.

After 53 minutes : image

After 62 minutes : image