godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

30 world3d room with 6 characterbody3d can be 1~4 fps #91094

Closed yythlj closed 6 months ago

yythlj commented 6 months ago

Tested versions

4.3.dev5

System information

window10 godot4.3.dev5 forward+

Issue description

https://github.com/godotengine/godot/issues/90998

this issue get no reply.I doubt if it is closed as you team. only 30 room and simple shape. And engine can be 1~4fps use that if this game engine never test with a multiplayer mode or multi room mode. if there is only one room, the fps can be 100 and more move and slide and the physics world must have some bug code(I use the headless mode, so there is no rendering)

Steps to reproduce

see the issue, snapshot https://github.com/godotengine/godot/issues/90998

Minimal reproduction project (MRP)

see the issue, snapshot https://github.com/godotengine/godot/issues/90998

Calinou commented 6 months ago

if this game engine never test with a multiplayer mode or multi room mode.

When you offer multiple rooms for players to use, you generally run multiple Godot processes, each hosting their own server. Hosting multiple rooms in the same process makes parallel resource usage harder (if not impossible), so it's not recommended.

Container orchestration solutions like Kubernetes can be handy for this at a large scale (though at a smaller scale, they can be overkill).

yythlj commented 6 months ago

if this game engine never test with a multiplayer mode or multi room mode.

When you offer multiple rooms for players to use, you generally run multiple Godot processes, each hosting their own server. Hosting multiple rooms in the same process makes parallel resource usage harder (if not impossible), so it's not recommended.

Container orchestration solutions like Kubernetes can be handy for this at a large scale (though at a smaller scale, they can be overkill).

Thank you for your help! The method is effective. After testing, splitting each world3d into an independent process can effectively improve the FPS. However, the memory consumption has also increased significantly.

Based on the tests, with the multi-process approach, seven rooms already used up 88% of my memory (32G). While in the single-process multi-room scenario, with 20-50 rooms, the memory usage did not see a significant increase and was maintained around 20% of (32G). Is there a compromise approach?

yythlj commented 6 months ago

The purpose of sharing different world3d processes is to ensure that the server can unify monitor the progress of different rooms. While they are completely independent world3d, so there is no need to share or compete for content. I think the best way is that Godot provides a parameter that allows me to set the interval at which different windows trigger the process and physicsprocess, and they do not need to compete for high efficiency running with each other.

yythlj commented 6 months ago

I'm still unable to resolve the second issue mentioned - when the character moves and collides with walls, with 10 rooms and 10 characters in each room for a total of 100 characters, as long as there are continuous collisions with walls, the fps will remain below 10. However, if I remove the call to move_and_slide, the fps returns to normal (only leaving the animations and attack detection etc).

I think the performance issue in 3d is definitely caused by severe bugs in the move_and_slide method.

At least collisions should be cached and not repeatedly calculated when a character moves to an area that has already been passed through before to avoid duplicate collisions.

Especially in some irregular scenes, like terrains created by the heterrain plugin, it would be more severe. Entering corners of walls alone would cause fps to drop below 10 (recovering if move_and_slide is not called).

this test with godot4.3.dev6

@Calinou

yythlj commented 6 months ago

https://github.com/Gamepro5/Custom_CharacterBody3D_Movement_System This approach seems to improve performance

Zireael07 commented 6 months ago

@yythlj Are the colliders made of cubes or are they more complex? How did you create them?

yythlj commented 6 months ago

@Zireael07 @Calinou no they just is the normal box shape and run on the headless mode.

I sincerely apologize, this was my mistake. I ran 10 rooms with 10 players each in a same process and use different world3d.

When I changed it to run each room in its own process, with 20 processes total, the FPS increased to 60. The only downside is the memory usage increased.

However, this does greatly bother me, because there are many scenes that contain static objects that never change (such as platforms, floors, etc.). But due to needing to run in multiple processes, the memory consumption is quite large. Having static objects like floors and platforms duplicated across each process does waste memory, since they never change or need to be simulated independently.

In networked multiplayer games, it is very common for the Godot server to need to run multiple identical instances of the same scene, as is the case here.

thanks

yythlj commented 6 months ago

the answer is never create multi window on the server, use different process instead

yythlj commented 6 months ago

um...memory use too much.the 20 process only start up 5 (32G windows)

if in the same process,the memory just a llite when 10 room