ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
782 stars 69 forks source link

Game uses 3 gigs of RAM in the menu #1561

Open hifi opened 6 years ago

hifi commented 6 years ago

Your system information

Please describe your issue in as much detail as possible:

I don't remember the game taking so much RAM before just to boot up. Now starting the game to main menu consumes 40% of my 8 gigs of RAM and it takes noticeably longer to boot up the game, it started around the Dust 2 update and I hadn't upgraded from Fedora 26 to Fedora 27 at that point yet.

Steps for reproducing this issue:

  1. Start game into menu
  2. Measure process RAM use
zootboy commented 6 years ago

I don't know anything about the internals of CS:GO, but on my machine it seems to use about the same amount of RAM in the menu or in-game (for me, about 2.6 GiB). That seems to suggest that it is just pre-allocating the RAM on launch, which isn't unreasonable for a game engine to do. Better to find out early that you don't have enough RAM than to start a game and meet the OOM killer.

hifi commented 6 years ago

That may very well be the case. It would be nice to get a confirmation it's actually using all of that memory when in-game as with 8 gigs of RAM and a lot of things open my system starts swapping earlier than before which hurts performance overall.

Although I find it peculiar an e-sports title uses around as much RAM as DOOM (2016) on Wine and it even loads up quite a bit faster than CS:GO.

kiroma commented 6 years ago

Most Source engine titles on Linux use tcmalloc, an alternative of malloc which functions as a library to allocate memory. Malloc is the default library which features no extraordinary features, but doesn't use up any excess memory. Tcmalloc faster than malloc, especially with multicore applications, but it creates an enormous overhead. For dynamic arrays, the overhead can reach 200% from my testing.

Other than that, Intel drivers may be an issue as well, I hadn't been able to launch a single modern Source engine game on my intel iGPU without running into OOM. I'm not sure why is that, it's probably an issue with Mesa.

zootboy commented 6 years ago

@hifi I don't understand your comparison. Both Doom 2016 and CS:GO are modern 3D FPS games. I would honestly be more surprised if they didnt use similar amounts of resources.

According to the Steam store page, CS:GO on Linux requires a minimum of 4 GiB of RAM. Assuming 1 GiB of that is for the OS / DM / WM / etc., the game is expecting to use ~3 GiB of RAM. About what we've both seen. So if you don't have at minimum 3 GiB of RAM free, you're going to start swapping.

It may help to turn down the vm.swappiness sysctl parameter. It usually defaults to something pretty high, causing early swapping when it may not be necessary. I set mine to 10 on my laptops and 1 on my desktop (16 GiB of RAM).

From your gist, it looks like you're using a discrete AMD graphics card, so I don't think the iGPU issues are relevant here.

tmewett commented 6 years ago

I'm getting this too, using the latest Mesa drivers on my AMD card. Not sure I buy the preallocation thing, as I go as high as 3.8 GB in game, which is quite high for a minimum spec of 4 GB... Contrast that to my friend running Windows, who is using 1.8 GB in-game (on Cache), and 800 MB on launch, compared to my 3 GB.

This has always been an issue to some degree, I've commented on threads just like this before. Valve has reduced the usage quite well in the past but it seems to come back occasionally. Hope this can be resolved for good!

davidw-valve commented 6 years ago

How are you measuring how much memory the game is taking? On startup, top reports "RES" memory usage of ~1GB on the system I am testing on. Note that "VIRT" is likely to be much higher but this is unimportant.

zootboy commented 6 years ago

I did another quick test on my system. Indeed, on first launch, the memory usage (RES) is ~1.3 GiB. Once a match is launched, it rises to the ~3 GiB RES I saw in my earlier tests. Returning to the menu leaves this memory allocated, so subsequent match <-> menu transitions have almost no effect on the reserved RAM.

This all seems reasonable to me.

hifi commented 6 years ago

Launching the game also takes really long while it climbs steadily to 3 GB RES. I don't know if it's a Ryzen bug but occasionally my system gets into non-responsive state when CS:GO is open and I see kswapd0 at ~8% CPU usage apparently moving things around from/to swap.

Here's a snippet from top when CS:GO is cold booted into main menu:

 PID  USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                 
 9527 hifi      20   0 4941032 3.050g  10500 S   4.0 39.1   1:37.26 csgo_linux64
hifi commented 6 years ago

@davidw-valve Is there anything to be done here? For unrelated reasons I switched from Fedora to Ubuntu (bionic) and it seems to be worse now. Still RX 480 and now on Mesa 17.3.3.

Cold boot main menu

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
20561 hifi      20   0 5169836 3.838g 191608 S  10.3 49.3   0:57.15 csgo_linux64

Casual Dust 2

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
20829 hifi      20   0 6113524 4.400g  52104 R 106.9 56.5   4:57.14 csgo_linux64

Menu after a few minutes of Dust 2

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
20829 hifi      20   0 6184120 4.517g  54532 S  11.6 58.0   7:52.84 csgo_linux64

The relative increase of memory usage seems to be what's to be expected (map, models etc.) but the initial memory usage seems really high and open source AMD driver specific. It still takes a long time for the game to start up while it fills up my RAM.

koutsie commented 5 years ago

welcome to panorama.

hifi commented 5 years ago

This issue was reported before panorama was released.