Godot: Performance issues 3.2.3 rc4

Created on 25 Aug 2020  路  20Comments  路  Source: godotengine/godot

Godot version:
3.2.3 rc4

PC, API:
Windows 10 64bit, ryzen 1700x, nvidia geforce gtx 1070, gles3

Issue description:
Performance issues in 3.2.3 rc4 compaired to 3.2.2 stable.

I am making a big 2D, physics and graphics heavy game, that uses pretty much everything Godot has to offer and some more.

After some testing i see a huge performance diffirence compaired to 3.2.2.

The heaviest rooms went from 60-100+ fps to 30-60.

3.2.2:
3-2-2

3.2.3 rc4:
3-2-3rc4

bug regression core

Most helpful comment

I test with my own project. Is a bullet hell - twin stick shooter in a advanced development state with 3.2.2 and 3.2.3 RC4. I can have 1000 bullets on screen, a ton of characters with a large scene trees.... same fps in both versions (more or less, some randomized things don麓t allow me to measure fps between different gameplays)

  • _I use_ several tilemaps with collisions in every level scene, animated textures inside that tilemaps, Y-Sort, KinematicBody2D, CanvasLayer, Label, RichTextLabel with RichTextEffect, Area2D (with polygons and shapes), Navigation2D, Raycast2D, Sprite, AnimatedSprite, AudioStreamPlayer2D, one unique "add" canvas material and other common things .....

  • _I never use_ for performance reasons: Light2D with a mode different that "mix", Particles and any Environment. I think that i do not draw any Polygon2D but i麓m not sure now, the project is sized barely out of my control and can have any polygon in some scene made time ago. I do not use any Shader.

My project is GLES2, only GDScript. Using batch rendering, single thread for rendering and single thread for physics, nvidia rect flicker workaround -> on, pixel snap, no filter in shadows (I do not use shadows), no other filters, no hdr.

Opening the project in 3.2.2 and 3.2.3 RC4 has not made any automatic change in project.godot or other file, so i don麓t need to revert any git change (in case someone else is encouraged to try the new versions with their project to test performance changes).

I can confirm that a project with the characteristics I describe above doesn麓t have any measurable performance regression between 3.2.2 and 3.2.3 RC4. I can maintain (inside a "bullet shower" with a node count of +2000 nodes in scene) 200-400 fps in a i5-3330CPU 3.00GHZ (2015) and 100 fps in a i3 lenovo laptop. Tested in 3.2.2-stable and 3.2.3 RC4 compilation from godotengine.org. Tested in windows 7 64 bit.

All 20 comments

Can you provide an MRP for other users to try to reproduce?

You can also try bisecting the regression by trying all the earlier 3.2.3 betas and RCs. (Make sure to backup your project before opening them in an older or newer version.)

@clayjohn I cant :/ Ive got huge scenes only, packed with tons of stuff. The rooms are enabled/disabled completely by activator areas and are parts of huge levels. Everything uses visabilty enablers and other methods to optimize. So practically, only the things on screen are active and relevant. In this current room are some light2ds and occluders, static and kinematic objects 2d and a lot of Area2Ds and RayCast2Ds, tilemaps, particles,shaders and ofcourse some sprites and polygons2d. Some stuff is animated by AnimationPlayers, Tweens and Timers are used too, as you can see, and ofcourse the simple ui using basic Godot nodes.

So basically, its pretty much impossible for me to simply tell what part of the new Godot build causes the performance issues, since i didnt do the changes myself.

I just wanted to let you guys know, something went wrong.

@Calinou working on my game pretty much 24/7. Just passing by to tell - there are some problems. I can surely try out the other RCs though and tell you how it went.

Thank you.

In order for us to help you we need to be able to pinpoint what went wrong. This typically requires, at the very least, an MRP. But if you can test multiple releases and pinpoint which release caused the regression we may be able to deduce what is causing your performance issue.

Right now we can't really do anything at all which is unfortunate for everyone.

Ok, so ive just tested rc1-3. Same issue.

Thank you!

So that means the issue like came in between 3.2.2 and RC1.

@clayjohn i also tested 3.2.3 beta 1 just now, same issues there too

Changes between 3.2.2 and 3.2.3 beta 1: https://github.com/godotengine/godot/compare/3.2.2-stable...89f57ae12244f3269c9e3fe4684e16ec1fd2c989

As others mentioned, without having access to any scene that can reproduce the issue, we can't debug further ourselves, so we'll need your help to dig deeper. If you can share the project privately with some contributors, or extract one of the heavy scenes in a standalone project you could share, this would help a ton to pinpoint the regression.

Can you use the engine profiler to see what is taking up frame time in 3.2.3 beta 1 that wasn't doing it in 3.2.2?

Alternatively, if you can compile the engine from source, can you bisect between 3.2.2-stable and 89f57ae12244f3269c9e3fe4684e16ec1fd2c989 (the commit for 3.2.3 beta 1)?

What kind of features do you use for rendering and physics? (CC @madmiraal as there are a couple 2D physics changes in 3.2.3 beta 1 like de284ea5d22b2d5ca15dd22be993afe1b04c4f7c.)

@akien-mga according to the profiler, physics time, audio thread, physics process and my own physics functions, which determine when objects should move and when not etc, have higher frame times compaired to 3.2.2.

For physics i pretty much only use kinematic objects 2D -> move_and_slide and the only heavy thing i use for rendering are lights2d. The amount of physics objects which are moved at once can be pretty high though, dozens of them, sometimes up to around 100.

Generally the game is pretty well optimized and doesn't usually dipp below 50 fps even on weak pcs, on my pc it runs between 90-400 fps for the most time.

Thanks to the test i just did for the performance comparison between the Godot builds i was able to optimise some more and squeez out around 15 more fps on the lowest frames. :)

So, after some hours of testing i could narrow the issue down to one element. Those press machines you see in the gifs. When the animations are playing i get horrible fps, as soon as they stop fps just skyrocket. I tested a lot of other stuff and places in the game on 3.2.3 rc4. Overlall the performance seems decent, maybe even better compaired to 3.2.2. I thought the problem might be in the particle effect, and turned them down a huge amount. No luck though.

I think the issue might be the audio.

animationscreen

As you can see, the animations of those press machines play multiple sounds. The room contains around 80 of them.

Hmm, well i guess it had something to do with collisions, i tested another Room, with around 40 of those press machines, and had good-great fps over there on 3.2.3 rc4. So i started optimizing and reworking the scene of press machine, since i realized, the only big diffirence between those rooms was, that in one room the machines were hitting against tilemaps, mostly not even touching them, while in the room with poor performance, they were hitting towards each other. So i slapped two flyes with one hit, i fixed the collision problems of objects that are being pressed by them AND it fixed the performance issues on 3.2.3 rc4. So the performance issues definitely have something to do with the physics changes.

Edit: well, nope. I generally optimised my game even better through testing, but after running the same room on 3.2.2 again, i see a gap of 30-40 fps between it and RC4. :'(

there are a couple 2D physics changes in 3.2.3 beta 1 like de284ea.

de284ea ensures that changes to collision layers and collision masks are applied. Are you making a lot of changes to collision layers and collision masks?

The only other physics 2D change I can find is ccdfaf2, which removes items from the Area callback list one at a time instead of all together. Do you have a lot of Area2Ds that the KinematicBody2Ds (or other Area2Ds) are entering and leaving?

@madmiraal i pretty much don't change collision layers/masks. Yes, i do have a huge amount of Area2Ds hanging on KinematicBody2Ds as an extra detection layer for some stuff. Pretty much every object, especially player, uses a ton of Area2Ds and RayCast2Ds for diffirent puposes.

It would be surprising if Map::erase() was that inefficient that it was the source of the problem. It would require a lot of Areas or Bodys entering and leaving each Area each frame, and it's no less efficient than Map::insert() that is ultimately used to add them each frame.

Still, replacing monitored_areas and monitored_bodies' Maps with Lists, would make it faster, and List would be a better data structure for these queues. However, that will require a bit of refactoring, because Area2DSW::BodyKey and Area2DSW::BodyState would need to be merged.

@madmiraal Thank you! I keep looking on my side, i will keep you up to date. To be honest, my project might be a little bit unusual, the player controls so many objects at once, collisions and other things occure like crazy everywhere, im actually pleasantly surprised, how well the engine handles it overall, and how much i can get out of it. Still have to optimise a ton though. At around 80+ Kinematic Bodies, fully packed with particles, sounds and Area2Ds etc, when the player starts moving them around like crazy, especially when dozens of objects cluster on a close space (same islands), fps goes to hell, even in 3.2.2. It might be because of the Area2Ds attached to the KBs, no idea, but i will surely try detaching the Area2Ds and reorganizing the functionalities they managed.

@madmiraal @akien-mga so, i reworked my base physics scene and removed the base Area2D, that checked a lot of stuff. Now the room gives me around 90-130 fps on RC4, still, there are 160+ Area2Ds in this room alone and 3.2.2 gives me around 20 FPS more.

I test with my own project. Is a bullet hell - twin stick shooter in a advanced development state with 3.2.2 and 3.2.3 RC4. I can have 1000 bullets on screen, a ton of characters with a large scene trees.... same fps in both versions (more or less, some randomized things don麓t allow me to measure fps between different gameplays)

  • _I use_ several tilemaps with collisions in every level scene, animated textures inside that tilemaps, Y-Sort, KinematicBody2D, CanvasLayer, Label, RichTextLabel with RichTextEffect, Area2D (with polygons and shapes), Navigation2D, Raycast2D, Sprite, AnimatedSprite, AudioStreamPlayer2D, one unique "add" canvas material and other common things .....

  • _I never use_ for performance reasons: Light2D with a mode different that "mix", Particles and any Environment. I think that i do not draw any Polygon2D but i麓m not sure now, the project is sized barely out of my control and can have any polygon in some scene made time ago. I do not use any Shader.

My project is GLES2, only GDScript. Using batch rendering, single thread for rendering and single thread for physics, nvidia rect flicker workaround -> on, pixel snap, no filter in shadows (I do not use shadows), no other filters, no hdr.

Opening the project in 3.2.2 and 3.2.3 RC4 has not made any automatic change in project.godot or other file, so i don麓t need to revert any git change (in case someone else is encouraged to try the new versions with their project to test performance changes).

I can confirm that a project with the characteristics I describe above doesn麓t have any measurable performance regression between 3.2.2 and 3.2.3 RC4. I can maintain (inside a "bullet shower" with a node count of +2000 nodes in scene) 200-400 fps in a i5-3330CPU 3.00GHZ (2015) and 100 fps in a i3 lenovo laptop. Tested in 3.2.2-stable and 3.2.3 RC4 compilation from godotengine.org. Tested in windows 7 64 bit.

I do indeed use world environment, a lot of shading and polygons2D, some of them have pretty high complexity. HDR, shadows, filters. Everything on. The Lights2D with shadows and filtering have the highest performance impact atm indeed, plus there is no batching in GLES3 yet, as far as i know, so the drawcalls can skyrocket to like 10k. Around 20k nodes per scene here.

Was this page helpful?
0 / 5 - 0 ratings