DoubleDeez / MDFramework

A multiplayer C# game framework for Godot 3.4 Mono.
https://discord.gg/UH49eHK
MIT License
76 stars 13 forks source link

Performance Pass #52

Open DoubleDeez opened 4 years ago

DoubleDeez commented 4 years ago

There are quite a few features in the framework that do a lot of memory allocations, looping, and other processing. It would be a good idea to get metrics on the runtimes of the various features to make sure the framework's performance is in a good state and don't break down in larger games.

Once a workflow for this has been established it should be applied to any other features we add in the future.

Beider commented 4 years ago

The MDReplicator could be optimized for Interval members.

Currently the replicator loops through every node and every member of that node each frame. However now that we moved to frame groups we could in theory keep the interval update nodes separate from OnChange nodes So it would go like

In theory if you had say 100 OnChange members and 300 interval members (divided into 6 frame groups, so 50 in each), currently you are checking 400 members a frame. With this change we would be checking 100 OnChange members + 50 members for the current frame group. So only 150 members a frame

It's not a massive amount of compares we do per member though, so in most cases you probably won't even notice it. But if your interval member count grows large you may notice something.

A rough count from the replicator shows that we are doing the following per member 4 bool compares 2 enum compares 1 HashSet lookup