godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

multi world3d performance optimize #10297

Open yythlj opened 1 month ago

yythlj commented 1 month ago

Describe the project you are working on

net match game multi player multi room a godot server program ctrol sync to every room.

Describe the problem or limitation you are having in your project

In the single-process multiple world3d situation, Godot's running efficiency is significantly lower than opening multiple separate processes for different world3d, even if there is not much resource contention and operation between them.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It's a pity that Godot cannot optimize frame rate drops under multiple world3d situations. I think this could help Godot become an even better game engine.

As a server program, I optimized everything to make room memory leaks 0 (meaning the server program can continuously switch between new rooms without needing to start another process).

However, Godot's computation seems quite weak under multiple world3d situations. My program can ensure there is no code that requires cross-world3d protection and locking. But the frame rate cannot reach 30 once the number of rooms reaches about 15 (it can stably maintain 30 frames with 5 rooms).

If Godot can optimize this aspect to maintain the same efficiency as running in multi-process mode under multiple world3d situations,

It would mean that subsequent similar Godot networked games can manage rooms within a single process rather than the awkward way of needing third party software for process management. (This brings a more complex architecture and is prone to crashes)

Finally, thank you for reading. I repeatedly propose this suggestion only to help Godot become an even better game engine. If test program support is needed, I can provide a mini server project.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

single process multi world3d perfermance to 80% as multi processes will be great

If this enhancement will not be used often, can it be worked around with a few lines of script?

every net game need a feature like this

Is there a reason why this should be core and not an add-on in the asset library?

yes, that must change the core

yythlj commented 1 month ago

I suspect the main root cause lies in group-related operations. This is the only method that looks like it crosses world3d. I will try to test this.

AThousandShips commented 1 month ago

How many objects do you have in each room? How is the performance if you have all the objects in one world?

Calinou commented 1 month ago

If test program support is needed, I can provide a mini server project.

Yes, we need a minimal reproduction project to be able to do anything about this.

yythlj commented 1 month ago

GD4_TPS_Server_mini.zip @Calinou @AThousandShips

this is a mini proj very simple only five character on a level scene random move

and in 50 room, it is 30 fps in 100 rom, it is 4 fps

but if use different processes there is a high fps

yythlj commented 1 month ago

change this on main_local to test

const room_max = 100