doitsujin / dxvk

Vulkan-based implementation of D3D8, 9, 10 and 11 for Linux / Wine
zlib License
12.87k stars 830 forks source link

Performance loss at some situations #1271

Closed weter11 closed 4 years ago

weter11 commented 4 years ago

Hi! There strange bug, and I don't find something like this. Its a problem with performance in some games. One of them is Resident Evil 2 Remake. Problem is in that when you load a game in police hall performance is very bad (50-60% of usual). How to reproduce: Load save, first level, police hall. Take a herbal or spray and after you take that performance is restored. GPU load is always 100%. Maybe it is not related to DXVK, but this game don't want start with wine D3D and crash with VKD3D at creating pipeline, maybe at least on my system. Also something like this happened in The evil within, when you first load save all is good, go to main menu and load it in second time and you'll see half of the performance, sometimes this happened even when you close current game process and go to menu and menu is lagging.

Software information

Resident Evil 2 Remake, set any graphical settings, it is not important for bug, at high settings half performance lost, at low 35-40%.

System information

Log files

re2_d3d11.log re2_dxgi.log before_touching_spray_2019-12-11_18-17-20 after_touching_spray_2019-12-11_18-18-07

doitsujin commented 4 years ago

Seems like you're running out of VRAM since your GPU only has 2GB. This is not a bug, and should be solved by reducing texture quality and closing any applications running in the background (especially web browsers). Also, try disabling hardware acceleration in Steam to free up a bit.

weter11 commented 4 years ago

Okay. Set 960x540. Снимок экрана_2019-12-11_18-51-59 Снимок экрана_2019-12-11_18-52-40 Снимок экрана_2019-12-11_18-53-40 1 - Menu 2 - before spray 3 - after spray XFCE environment Ubuntu 19.10.

doitsujin commented 4 years ago

The game still eats >2GB, while some of that is system RAM, most of it isn't. It's just not enough to run heavy games like this with DXVK.

weter11 commented 4 years ago

On the graph only 15-30% VRAM in a game. Not a RAM. And for what reason performance changed w/o any other changes than touching that spray? Yes on my system this games on RE Engine working 1.5-3x slower than on windows. Problem in XFCE?

doitsujin commented 4 years ago

The game might be creating some new textures, recreate render targets for no reason, whatever. Games do that all the time.

According to the DXVK hud it peaked at 2.5GB total memory usage, which even when taking sysmem into account is probably more than the 2GB your card has, and of that 2GB, DXVK can probably only use 1.0-1.5GB. The high PCIe bus saturation is a further indication that it streams a lot of data from system memory because it can't allocate any more VRAM.

Case in point; there are no such issues at all on my 8GB RX 480.

weter11 commented 4 years ago

So, in hud it register what VRAM it need now? And if it can't allocate because of lack that number, it uses RAM instead? When I set the game to windowed mode it uses 36% RAM and when perfomance was changed, allocated memory by the game not changed at all. But looking at graph, when performance restored it uses 2-2.5x more VRAM. So what is usual VRAM overhead for DXVK, if the game need for example 3GB VRAM on Windows, DXVK need another 3GB for its stuff?

weter11 commented 4 years ago

I apologize for the incorrect information. As it turns out, Psensor registered MX150 memory as utilization.memory from nvidia-smi and misled me that VRAM is not used. While nvidia-smi honestly showed that memory is fully used: Total, free, used 2002 MiB, 1 MiB, 2001 MiB. DXVK HUD Allocated, used 2451 MiB, 2074 MiB Maybe problem with such games as DMC5 & RE2 coming from X-server overhead and in Wayland all is ok(system use 200MiB VRAM), because for what reason such slowdowns compared to Windows. In DMC5 on some FMVs framerate drop from 30fps in menu to 3-6fps in FMV, but in DMC5 changing resolution to 960x540 eliminate most of such stutters, but sometimes its still happened. And there no any video for this games on YT that compare performance on a good GPU like GTX 1070 or RX480 Win vs Linux, maybe 2-3x less performance is normal for this games on Linux.

K0bin commented 4 years ago

The problem isn't X11 or Wayland overhead (Windows surely uses 200mb of VRAM too). The problem is that Windows is a lot better at managing that vram than Linux, especially with a Nvidia GPU.

weter11 commented 4 years ago

But for what reason such slowdown? I set graphics to minimal, resolution to 640x360, scale 60% and allocated, used memory still the same DXVK HUD Allocated, used 2430 MiB, 2040 MiB Before touching spray 18fps, after 65fps! Allocated, used memory not changed. GPU load always 100%. And for comparison we can look at FlightlessMango channel where he compare on his very unoptimized Nvidia 1080Ti Shadow of the Tomb Raider. And linux port 99% compared to DX12 and DXVK 92% to DX11, stuttering nearly identical on both systems. Problem in managing VRAM? Thats all? Okay I really don't want to create flood. If its only on my unoptimized system, than close this thread. I really don't know how investigate where the problem now, maybe in future some good idea will come.

K0bin commented 4 years ago

But for what reason such slowdown?

The reason is that if you run out of VRAM, DXVK will put stuff into normal RAM. It's much slower for the GPU to access normal RAM compared to VRAM.

Windows works the same way but is a bit smarter about moving resources from VRAM to RAM and back to minimize the performance hit.

No, this can't be improved in DXVK. I suggest you reduce the texture quality.

weter11 commented 4 years ago

Finally I know now what is the limit. So, I disable desktop effects and restart system. Now system use as only as 53 MiB VRAM. And start the game in same 640x360. And... DXVK HUD Allocated, used 2270 MiB, 2030 MiB and before touching spray 78fps, after 80fps. So I increase resolution to 1366x768 DXVK HUD Allocated, used 2460 MiB, 2080 MiB And the same stutter. resolution 720x450 DXVK HUD Allocated, used 2360 MiB, 2040 MiB. and before touching spray 58fps, after 60fps. Always fps increase by 2-4%. So, before it allocate 2400MiB all is okay, after - stuttering. Is it possible manually limit allocated memory to 2360 MiB at any resolution for testing purposes?

doitsujin commented 4 years ago

Of course it is, but that would make the game crash ;) In other words - no, it obviously is not. A game uses as much memory as it needs.

Now DXVK's memory management could also use some work to mitigate the problem, but I have no plans to touch that until things calm down a little since there's a very high risk of introducing regressions. Likewise, memory management on Nvidia's Linux driver isn't quite as good as it is on windows.

You have to expect somewhat higher hardware requirements compared to Windows, and having an extra GB of VRAM won't hurt (fwiw your system barely meets the stated minimum requirements of this game, if at all).

Neodamode commented 4 years ago

I've run into the same issue with another game. It runs fine but FPS drop to 10 or less after entering and exiting the menu in places where more VRAM is being used, and it does not recover.

Does this happen with AMD cards as well (that meet the minimum requirements)? And would all Nvidia cards with the minimum VRAM face the same problem (like if I swap a GT 1030 for a GTX 1050)?

weter11 commented 4 years ago

Yes, its the main question now. I want to sell my current notebook & buy something with GTX 1660Ti, such notebooks now cost only a bit more than my current notebook 2 years ago. Its sad that AMD still can't introduce something comparable to Intel 6C/12T & Nvidia 1660Ti. 5500M 4GiB VRAM & 20-40% less performance and the same price. I'm waiting gaming Amd notebook for 3 years now and don't want wait another 3 for zen2+RX5700. And next year with PS5 era coming games would need even more video memory than now. So, waiting for a patch, that would be somewhere in the future. Thanks for explanation some DXVK stuff & support.

K0bin commented 4 years ago

Does this happen with AMD cards as well

The problem also exists with AMD cards to a degree. AMD drivers on Linux do a much better job at memory management. It should be less severe on AMD but you should try getting something with at least 4GB of VRAM. TBH you pretty much need more than 4GB of VRAM on Windows too for modern games and it's certainly not gonna get better with new games.

And start the game in same 640x360. And...

Reducing the rendering resolution has very little effect on VRAM. You have to reduce texture quality.

gardotd426 commented 4 years ago

Yes, its the main question now. I want to sell my current notebook & buy something with GTX 1660Ti, such notebooks now cost only a bit more than my current notebook 2 years ago. Its sad that AMD still can't introduce something comparable to Intel 6C/12T & Nvidia 1660Ti. 5500M 4GiB VRAM & 20-40% less performance and the same price. I'm waiting gaming Amd notebook for 3 years now and don't want wait another 3 for zen2+RX5700. And next year with PS5 era coming games would need even more video memory than now. So, waiting for a patch, that would be somewhere in the future. Thanks for explanation some DXVK stuff & support.

Here's the thing @weter11, you don't even come close to the minimum system requirements for that game, even on Windows. Game-debate.com and a couple other sites are great tools if you want to see if you're capable of running a game or not. You simply enter in your hardware, and it shows an awesome little graph indicating where your cpu, gpu, and ram measure up releative to both the recommended and minimum requirements. And unfortunately, your gpu only hits THIRTEEN percent of the recommended requirements, and only 40 percent of the minimum. That means that even under the absolute best circumstances, running the game in Windows, with everything on the lowest settings and a terribly low resolution, with absolutely no extra background processes, you still just flat-out will not be able to get that game to run in any way that's at all playable. I know that sucks, but I got a barely used 4GB RX 580 for 90 dollars on ebay, and they have 8gb models for like 95-100 all the time. Get you one of those, or an rx 570, and you'll be able to run any game there is pretty much at 1080p, most of them you'll even be able to run on high settings.

Here, look for yourself at your card vs the minimum requirements

misyltoad commented 4 years ago

\n

weter11 commented 4 years ago

gardotd426, its not PC GTS150 with 1GiB GDDR3, its mobile variant of GT 1030 with 2GiB GDDR5. If you think that this games unplayable, you a little bit wrong, there are 3 or 4 videos on YT, also on a small notebook screen 720p still looks good. I am not PC, but mobile gamer enthusiast and game translator. Reducing the rendering resolution maybe really don't have a big effect & texture quality on a lowest possible settings on my hardware, but that extra 100MiB needed VRAM at higher resolution change all gameplay. Joshua-Ashton ok.