Bug Closed · Resolved

Is there a way to optimize performance by reducing the number of animation frames being sent?

#4740 opened by Unknown 2 years ago

Unknownreported this bug

I am currently experiencing some performance issues. When I place 10 monster models on the screen simultaneously, the server's TPS starts to drop drastically. After comparison, I can confirm that the more elements are moving on the monsters, the worse the performance.

So, my temporary solution is to reduce the number of joints on monster models and the number of moving elements on each monster to optimize the performance of scenes with multiple monsters.

I have a guess about how to optimize this issue. Firstly, the smooth frame rate exhibited by entities clearly exceeds the maximum packet frame rate supported by the Minecraft server. This surplus smooth frame rate is based on a client-side computational "interpolation algorithm," and the server's packet sending speed has not been increased from 20/s to 120/s. In other words, the model engine still sends animation update data for each model at a maximum speed of 20/s, and the rest is computed locally on the client side.

Based on this premise, is it possible for us to minimize the number of packets sent by the server per second and rely more on the client-side interpolation algorithm to fill in the missing frames? Using the concept of animation as an example, this is similar to reducing the number of keyframes while achieving the same animation effect, thereby reducing the server's burden.

[Legacy attachment omitted]

Unknowncommented

This would be a worthwhile optimization if Mojank implemented Display Entities differently. Here are some points you need to know about the current system:

  • All bones of a modeled entity are mounted on a pivot
  • Rotating a parent bone would update all the transform of its child bones
  • Changing the body rotation would update all bones' transform

With that being said, unless all your models are made with this in mind (no bone parenting, no body rotations), it's very hard for this optimization to kick, let alone for it to be worthwhile.

This also wouldn't make the server's load any less. Assuming the optimization can kick in, if the interpolation between frames isn't linear (i.e. catmullrom aka smooth keyframe,) then the server still needs to send in all ticks.

So overall, while it's technically possible, the benefits are minuscule.

Sign in to join the discussion.