Godot: content and performance¶
Profiling, loading and freeing resources and nodes, asset import, data and saving, and localization. Renderers, shaders, materials and level of detail are in Rendering and shaders, and frame budgets and save-data versioning are in Game development.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
- 7 General optimization tips (Godot docs): how to measure performance, find the bottleneck and optimise it, including CPU versus GPU bottlenecks.
- 7 CPU optimization (Godot docs): CPU profilers, caches, the performance trade-offs of each scripting language, threads, the cost of large scene trees, and physics.
- 6 Exporting packs, patches, and mods (Godot docs): delivering DLC, patches and mods as PCK or ZIP files, and the security risks of loading them.
Key rules¶
Profiling, loading and memory¶
- 7
GODOT-26Profile on every target platform during development, not only in the editor: run a debug export with Deploy with Remote Debug, and use the debugger's Profiler for script time, the Visual Profiler for CPU and GPU rendering time, and the Monitors for memory and object counts. The Profiler doesn't measure C# scripts, so profile C# code with JetBrains Rider and dotTrace or with Visual Studio. This appliesGAMEDEV-12andGFX-3. (Godot, Debugger panel, The Profiler, Overview of debugging tools: Deploy with Remote Debug, General optimization tips) - 7
GODOT-27Preload only what a script always needs, and load levels and other large or optional content in the background withResourceLoader.load_threaded_request(), behind a loading screen, becauseload()blocks the thread until the resource has loaded. Load imported assets only throughload()orResourceLoader, neverFileAccess, which reads them in the editor but fails in the exported game. (Godot, Logic preferences: loading vs. preloading, Background loading, Import process) - 7
GODOT-28Free nodes you no longer need withqueue_free(): unlikeRefCountedobjects such as Resources, nodes aren't freed automatically, andremove_child()only takes a node out of the tree. Detaching a node to re-attach it later is fine while you keep a reference to it. Watch the orphan node count in the debugger's Monitors for nodes that leak. (Godot, Object, Node.queue_free, Node.remove_child, CPU optimization: SceneTree, Performance, orphan node count)
Asset import¶
- 6
GODOT-29Import 3D textures as VRAM Compressed with mipmaps, which Detect 3D sets automatically, and 2D textures, especially pixel art, as Lossless; if the project needs other settings, change the defaults project-wide in Project Settings > Import Defaults. VRAM compression usually cuts video memory use by a factor of 4 to 6, but shows noticeable artifacts in 2D. This appliesGFX-13. (Godot, Importing images: compress mode, Detect 3D, Import process: changing default import parameters) - 6
GODOT-30Change imported 3D models in the modelling tool where you can, then in the import settings, and make any other change in an inherited scene, because Godot re-imports the whole scene whenever the source file changes. (Godot, Import configuration, scene inheritance)
Data and saving¶
- 7
GODOT-12Model designer-edited game data as custom Resource classes saved as.tresfiles. A loaded resource is one cached instance that every user shares, so setresource_local_to_sceneorduplicate()it before changing it per instance. (Godot, Resources, Resource.resource_local_to_scene, Godot interfaces) - 7
GODOT-13Write saves and settings touser://, and don't decode objects (allow_objects) from files that players can edit or share.res://is usually read-only in an exported game, and decoded objects can run code. (Godot, File paths in Godot projects, Saving games, FileAccess.get_var, game development: save data)
Localization¶
- 7
GODOT-15Localize with Godot's translation system: add CSV or gettext PO translations under Project Settings > Localization, look up text withtr()andtr_n()or a Control's automatic translation, fill named placeholders withString.format(), and switch languages withTranslationServer.set_locale(). This appliesI18N-1,I18N-2andI18N-3. Turn on pseudolocalization in the advanced Project Settings, under Internationalization, to find untranslated and overflowing text (I18N-14). (Godot, Internationalizing games, Localization using gettext, Pseudolocalization, TranslationServer)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 5 GUT, Memory Management: GUT lists the orphan nodes each test leaves behind, and
assert_no_new_orphans()fails a test that creates nodes it doesn't free. Partly checksGODOT-28. - 5 gdUnit4, Orphan nodes: counts the orphan nodes each test creates and reports them as warnings in the test report. Partly checks
GODOT-28.