MDFramework icon indicating copy to clipboard operation
MDFramework copied to clipboard

Performance Pass

Open DoubleDeez opened this issue 5 years ago • 1 comments

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.

DoubleDeez avatar Jul 06 '20 04:07 DoubleDeez

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

  • First loop through all nodes and remove any that don't exist any more, including removing members from frame groups
  • During this loop also go through OnChange members
  • Finally go through all members in the current frame group.

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

Beider avatar Jul 16 '20 16:07 Beider