Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher uses 100% of a CPU core in a busy loop (Linux) #92

Open
amylizzle opened this issue Jun 20, 2023 · 16 comments
Open

Launcher uses 100% of a CPU core in a busy loop (Linux) #92

amylizzle opened this issue Jun 20, 2023 · 16 comments
Labels
bug Something isn't working

Comments

@amylizzle
Copy link

amylizzle commented Jun 20, 2023

Using Steam to start the launcher - the launcher busy loops a full core. Steam overlay is disabled.

I attached strace to see what it was up to. Basically just this 100s of times a second:

recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
epoll_wait(204, [{events=EPOLLIN, data={u32=0, u64=8589934592}}], 1, 604595037) = 1
read(205, "\0", 4)                      = 1
read(205, 0x7fffe510fe80, 4)            = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(202, {msg_namelen=0}, 0)        = -1 EAGAIN (Resource temporarily unavailable)
@RundownRhino
Copy link

RundownRhino commented Sep 3, 2023

Having the same issue on the zipped 0.22.1.0 launcher from the site, no Steam involved, on Linux Mint 21.2.
A perf flamegraph shows only a lot of libnvidia-glcore calls. Maybe a dotnet trace would be more enlightening but I don't know offhand how to do one.
I think it may be an Avalonia problem, something like AvaloniaUI/Avalonia#5192 or AvaloniaUI/Avalonia#5785 - but both of these are closed.

@PJB3005 PJB3005 added the bug Something isn't working label Oct 21, 2023
@TsjipTsjip
Copy link

I cannot seem to reproduce this with the Flatpak build. (flatpak list reports this as Version 0.23.0, running on Ubuntu 22.04 LTS)

@amylizzle
Copy link
Author

Can confirm it's still happening for me on Ubuntu 23.04, steam installed by via apt, everything updated to latest, steam overlay disabled.

image

@Visne
Copy link
Member

Visne commented Nov 1, 2023

It's not using a lot of CPU for me on Arch Linux, but strace does show a lot of EAGAIN (Resource temporarily unavailable) spam. Avalonia 11.0.4 doesn't seem to change that (see #110, maybe you can try that?)

@PJB3005
Copy link
Member

PJB3005 commented Nov 1, 2023

strace really is not a meaningful tool for debugging performance issues. Use dotnet-trace or some perf GUI if you want to actually figure out what's using the CPU.

@crazybrain23
Copy link

crazybrain23 commented Nov 5, 2023

I got the CPU usage down to near 0% by commenting removing <Style.Animations> from ThemeDungSpinnder.xaml, which suggests the problem is with that animation. This comment from an issue is what inspired me to try this, but obviously something needs to be done to keep the animation, but stop it using CPU when hidden.

@Visne
Copy link
Member

Visne commented Nov 7, 2023

I can't reproduce this even when a spinner is visible.

A perf flamegraph shows only a lot of libnvidia-glcore calls.

This makes me wonder if it's NVIDIA related, I'm on AMD.

@amylizzle
Copy link
Author

I am on an nvidia system also.

@amylizzle
Copy link
Author

I am no longer seeing this bug. Latest client, nvidia driver version 535.161.07.

@crazybrain23
Copy link

I still have this bug, Launcher version 0.26.0, Nvidia driver version 550.54.14-5.

@crazybrain23
Copy link

image

strace really is not a meaningful tool for debugging performance issues. Use dotnet-trace or some perf GUI if you want to actually figure out what's using the CPU.

$ dotnet-trace report SS14.Launcher_20240320_185845.nettrace topN -n 10
Top 10 Functions (Exclusive)                                                  Inclusive           Exclusive           
1.  LowLevelLifoSemaphore.WaitNative(class Microsoft.Win32.SafeHandles.Saf    36.1%               36.1%               
2.  WaitHandle.WaitOneNoCheck(int32)                                          18.18%              18.18%              
3.  EventSource.DoCommand(class System.Diagnostics.Tracing.EventCommandEve    9.09%               9.09%               
4.  Missing Symbol                                                            9.09%               9.09%               
5.  X11PlatformLifetimeEvents.HandleRequests()                                9.09%               9.09%               
6.  X11PlatformThreading.RunLoop(value class System.Threading.Cancellation    9.09%               9.04%               
7.  GlxGlPlatformSurface+RenderTarget+Session.Dispose()                       8.24%               8.14%               
8.  LowLevelSpinWaiter.Wait(int32,int32,int32)                                0.22%               0.22%               
9.  Thread.Sleep(int32)                                                       0.19%               0.19%               
10. ServerCompositionContainerVisual.Update(class Avalonia.Rendering.Compo    0.2%                0.13%

@Visne Visne reopened this Mar 21, 2024
@PJB3005
Copy link
Member

PJB3005 commented Mar 21, 2024

Can I see that in a flamegraph form of some kind?

@nikthechampiongr
Copy link
Contributor

nikthechampiongr commented Mar 21, 2024

I cannot reporduce this issue. Running 6.8.1-zen1-1-zen kernel on endeavouros and an amd gpu so this might just be a problem with nvidia drivers?

@Arthri
Copy link

Arthri commented Apr 9, 2024

I apologize if this is the wrong thread, however, I am experiencing this issue on Windows 10 (22H2 build 19045.4046)

Hardware and Software Specifications
APU - AMD Radeon(TM) Vega 8 Graphics - Primary/Integrated
VRAM - 1024 MB - DDR4 1333 MHz
Graphics - AMD Radeon(TM) Vega 8 Graphics
Graphics Manufacturer - Built by AMD
Usable Memory Size - 1024 MB
Core Clock - 1101 MHz
Memory Type - DDR4
Memory Clock - 1333 MHz
Memory Bit Rate - 2.67 Gbps
Total Memory Bandwidth - 21 GByte/s
Bus Type - PCI
Current Bus Settings - PCI
APU - AMD Radeon(TM) Vega 8 Graphics - Primary/Integrated
VRAM - 1024 MB - DDR4 1333 MHz
Driver Version - 23.10.01.45-230626a-393367C-AMD-Software-Adrenalin-Edition
AMD Windows Driver Version - 31.0.21001.45002
Direct3D API Version - 12.1
Vulkan™ API Version - 1.3.250
OpenCL™ API Version - 2.0
OpenGL® API Version - 4.6
Direct3D® Driver Version - 9.14.10.01526
Vulkan™ Driver Version - 2.0.270
OpenCL® Driver Version - 31.0.21001.45002
OpenGL® Driver Version - 23.06.230411_6f40c97
2D Driver Version - 8.1.1.1634
UI Version - 2023.0626.1405.1980
AMD Audio Driver Version - 10.0.1.27
Driver Provider - Advanced Micro Devices, Inc.
Windows Edition - Windows 10 Professional (64 bit)
Windows Version - 22H2
CPU - AMD Ryzen 3 2200G with Radeon Vega Graphics - 4 Cores
RAM - 8 GB
Model - AMD Ryzen 3 2200G with Radeon Vega Graphics
Processor Speed - 3.49 GHz
Cores - 4
Threads - 4
RAM - 8 GB

The launcher and loader consumes anywhere from 30% to 50% of my CPU (tested on Wizard's Den Lizard (EU West) Server) on average, doing anything from connecting to standing still in a round
image

This is a stark contrast from DreamSeeker which averages below 20% CPU (tested on Paradise Station)

Performance Profile of Loader from Visual Studio
image

It appears that 60% of the CPU is used by native code and therefore not caught by Visual Studio, however, the rest of the 40% that was caught was mostly spent on threading callbacks

@PJB3005
Copy link
Member

PJB3005 commented Apr 9, 2024

That seems unrelated. For the game client I see no reason to suspect anything is amiss other than "maybe we should optimize the CPU usage". For the launcher itself that seems a little high but without more info I can't do anything.

It appears that 60% of the CPU is used by native code and therefore not caught by Visual Studio, however, the rest of the 40% that was caught was mostly spent on threading callbacks

What you are saying doesn't really make sense, sorry.

@crazybrain23
Copy link

Can I see that in a flamegraph form of some kind?

Stock unmodified code: SS14.Launcher_20240414_035817.speedscope.json
With the dung spinner animation disabled: SS14.Launcher_20240414_040243.speedscope.json

Can be explored in https://www.speedscope.app/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants