What would be best Practices for Optimizing Performance in Godot 4?

I’m currently working on a project in Godot 4 and I’m looking for tips on optimizing performance.

In general, you should only bother with optimizations once you actually have a problem. Something running below the targeted performance for that specific device.

The documentation has a selection of methods you can use to achieve that: Performance — Godot Engine (stable) documentation in English

Do be careful not to fall into the “premature optimization” trap, spending days rewriting code just to increase FPS from 172 to 180.

1 Like

you can use static methods if any class_name is defined. Many methods doesn’t require to be “local”, for instance - if you’ve got a function that calculates path
from-to and then updates target position. Which as said may has many pointers and variables or mb one time callables with binds.

and looks like func move_to(start, end)->void:
static variant could be static func _move_to(actor, start, end)->void:
Static funcs are not belong to exact instance that could reduce memory usage drastically. In instance you could use a shortcut function
func move_to(start, end)->void: _move_to(self, start, end)

no need to keep large callable for every instance, just small self reference to static variant.
this is not the same as .bind() which creates exact copy of callable with defined arguments

1 Like