decentraland / godot-explorer

10 stars 10 forks source link

Perfomance metrics and research about freeing used memory #401

Closed leanmendoza closed 3 months ago

kuruk-mm commented 3 months ago

Almost all the memory consumption was due to the Texture Sizes. We had 4k textures with more than 40mb in the VRAM, without any sense.

I did some tests with the following steps

  1. Open Godot
  2. Go to Genesis City
  3. Wait to load everything

And the results were:

Without any resize: image

Resizing to 256x256 all the textures from fetch_texture image

Resizing to 256x256 all the textures from fetch_texture and all textures in GLTFs image

With this result. We implemented a Texture Quality Setting, to have multiple quality of texture with the following table QUALITY MAX SIZE
LOW 256x256
MEDIUM 512x512
HIGH 1024x1024
SOURCE INFxINF

To free memory, we added a reference counter to all the resources, and when they have not been accessed for the last 30 seconds, and the reference count is just retained by the cache, we release them.

All that work is in the following PR: https://github.com/decentraland/godot-explorer/pull/414