luxtorpeda-dev/luxtorpeda

Investigate VRAM Optimization

Closed this issue · 8 comments

Linux Distribution

NixOS/Flatpak

Luxtorpeda Version

65.0.1

Bug description

The new Godot UI makes Luxtorpeda use an incredible amount of VRAM. Over half a gig. For someone like me with an Nvidia GTX 1060 3GB this is a problem.

Steps To Reproduce

  1. Run a game with Luxtorpeda.
  2. Observe the memory usage with a tool such as nvtop for nvidia.

Expected Behavior

Luxtorpeda should use less resources so the game can use them instead.

Additional Context

During my testing I ran into a problem with Gothic 1 where it wouldn't start because I was out of VRAM. I used nvtop to discover that my xorg process was using up all my VRAM, and then I restarted Steam and that VRAM usage went away. I don't yet know if there's a memory leak in the new Steam or perhaps if testing all these games with Luxtorpeda is using up VRAM and not freeing it after.

Edit: I don't think this has anything to do with Luxtorpeda. I'm launching games that don't use Luxtorpeda and the RAM usage is still going up, about 50MB of VRAM per game launch that is never freed unless Steam is shut down.

Relevant log output

No response

Looking at radeontop (im using an amd gpu), I do see a fair amount of GPU memory being used by the Godot UI. This may be due to godot itself, as my UI is pretty simple (really just a grouping of 2D UI), but I'll investigate.

A memory leak like you describe sounds like something wrong on your system, like you mentioned.

I'll look into possible solutions. It may be that I can exit the godot UI once a game starts, although the main issue there is that if there's an error that should be displayed, the UI will no longer be available, so that may require some additional investigation.

I looked into it a bit and I discovered a few things:

  • Switching from GLES3 to GLES2
  • Lowing Directional Shadow and Shadow Atlas

Other performance tweaks could include:

  • Switching to Low Processor Mode

The VRAM usage of Godot is approximately half as much as before with these options.

Also, having the UI close after launching could at least be an option for advanced users who are able to get the log from the terminal if they need it.

I've created a PR that should have a build for testing shortly if you can try it out, this so far is mainly about adding those godot optimizations: #221

I did also check the godot debugger vram report, and my project is only using about 3mb of vram, which says the rest must be in godot somewhere.

Let me know how that goes and if you still need a close UI once game starts option with that. Thanks!

It's using about 267MiB of VRAM with that test build.

It's better, but with both Steam and Luxtorpeda and other overheads combined I'm hitting about 25%-50% of my available VRAM before I even start the game and Luxtorpeda is the biggest contributor.

Another idea I had was running OpenGL in software rendering mode, this would prevent Godot from using any VRAM. I tested the below options and it seems to work performantly and accurately.

__GLX_VENDOR_LIBRARY_NAME=mesa
GALLIUM_DRIVER=llvmpipe
MESA_LOADER_DRIVER_OVERRIDE=llvmpipe
LIBGL_ALWAYS_SOFTWARE=1

Other software drivers include softpipe and swr but I had best results with llvmpipe.

Interesting, I could probably add a env variable like LUX_SOFTWARE_RENDERING that if set would enable those items on the launch of the client. That could cause some confusion with the actual game though, as I believe it inherits those same variables.

It may be easier just to close the client once the game launches, as an by default off config option. This would have a downside of needing to look into the logs, but would free up vram when necessary.

Let me know what you think of this change: #222

I added the config variable that'll close the client as soon as the game launches. It's defaulted to false.

I ran this build of luxtorpeda with success. This, combined with the optimizations from before puts luxtorpeda in a much better place for people with low VRAM graphics cards.

Also, I haven't done any benchmarks but anecdotally the launch time between selecting the option and the game starting seems to be faster with this option enabled.

Great, that's good to hear!

I've released this as a new version here: https://github.com/luxtorpeda-dev/luxtorpeda/releases/tag/v65.1.0

Let me know if you need anything else