Performance drop - investigation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GameVisitor

Hey all,

I am trying to narrow a performance drop in my game upon reloading the same scene,
first couple of time it runs perfectly 60 fps (on Android phone) then suddenly after reloading the same scene goes down to 40 or <30 fps…

I have seen this post about using the profiler, and similarly to @wombatstampede I have mostly cubes with simple boxshape collision shapes but couldn’t find the issue.

Is this value an indicator that the physic engine is taking too much time ?
Notice the frame% measure used…

Greatly appreciating for any suggestion / tip.

I was getting this error:

Expected 'shader_type' at the beginning of shader.

and as explained here and here it is due to the project setting for choosing Multi-Threaded. i changed it but didn’t get much benefit.

Also read this (speed up 3D), this (programming efficiency) and this (A good source to learn developing more performant applications) but so far no clear vision on how to proceed…

GameVisitor | 2019-04-09 19:07

I know my laptop is a bit old and without a proper graphic card, however, i still find it hard that this strip down simple project runs at 30 / 35 FPS… can anyone shed any light here ? I am pretty sure i have a bad setting somewhere in my project (lights?) but can’t seem to find it…

I feel this scene is more complex but runs better

Thx in advance

GameVisitor | 2019-09-15 17:58

One thing I noticed is that I have some kind of memory leak, by using OS.get_static_memory_peak_usage upon each scene reload :

11-16 23:30:58.821  4089  4141 I godot   : >>get_static_memory_peak_usage : 85379546
11-16 23:31:13.943  4089  4141 I godot   : >>get_static_memory_peak_usage : 94335419
11-16 23:31:33.258  4089  4141 I godot   : >>get_static_memory_peak_usage : 124551535

I am using the official custom loader sample described here modified as described in this thread

GameVisitor | 2019-11-16 22:21

Past midnight and I can confirm it is not a memory leak issue, as i have been creating more objects :frowning:

when I reloaded the scene with less objects the memory dropped again:

11-17 00:39:33.313  8226  8270 I godot   : >>get_static_memory_usage: **83924139**
11-17 00:39:43.311  8226  8270 I godot   : >>get_static_memory_usage: 92806671
11-17 00:39:58.810  8226  8270 I godot   : >>get_static_memory_usage: 124548567
11-17 00:40:04.342  8226  8270 I godot   : >>get_static_memory_usage: 147223431
11-17 00:40:20.643  8226  8270 I godot   : >>get_static_memory_usage: **85769939**
11-17 00:40:26.162  8226  8270 I godot   : >>get_static_memory_usage: 92511395
11-17 00:40:30.532  8226  8270 I godot   : >>get_static_memory_usage: **85619939**

GameVisitor | 2019-11-16 22:46

:bust_in_silhouette: Reply From: GameVisitor

Here is an interesting comment about Godot 3D performance

Finally, Godot 3 in general does not have any fancy culling system beyond frustrum culling. That is, if you look a a wall, what’s behind that wall is STILL rendered.

Also, it is known that the current 3D engine isn’t perfect in terms of performance. Some areas have a lot of room for optimization, and it’s been acknowledged by devs. The renderer is being rewritten into Vulkan for 3.2 and more rewrites and features are coming for 4.0, so it’s likely performance will improve in the future.

:bust_in_silhouette: Reply From: GameVisitor

I still didn’t fix it, but testing with godot 3.1 instead of 3.0.6 made a perceivable difference.

Many reloads are needed in order to feel the drop + the drop is about 40 fps instead of 30, so it might be a bug in my code, but the engine version does matter too.

PS: godot 3.1 works like a charm on my old laptop were as 3.0.6 is too damn heavy !
(CPU reaching 80 degrees)

Also, made this other project change in 3.2 and gained almost 15 FPS:

Display -> Window -> Stretch -> Mode -> 2D (instead of viewport)