pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.26k stars 1.53k forks source link

Parallelising outbound packet compression #3865

Open dktapps opened 3 years ago

dktapps commented 3 years ago

Description

The current biggest performance bottleneck in PM is compression, because zlib is slow and the server spews out more data when there are more players online. This leads to a O(nPlayers^2) scaling factor.

This means that 4x the resources are required to host 2x the number of players. Since PM uses a single core, this means that performance runs into a wall very quickly even with the best possible plugins and the fastest CPUs.

To give some real numbers, it takes twice as much processing power to handle 85 players clustered in one area as it does to handle 60, and the larger part of this problem is because of compression.

We can work around this problem to some extent by parallelising outbound packet compression. This has been possible for many years already in the form of the pocketmine.yml async-compression switch, but this setting creates a few problems of its own:

Compression per network session is entirely independent, meaning that it can be embarassingly parallel (except when compress-once, send-to-many is used, for example during packet broadcasting).

ghost commented 3 years ago

no

dktapps commented 1 year ago

Relates to #5641

This issue is much less relevant in PM4, because compression is a much lower percentage of overall load thanks to libdeflate, which is several times faster than zlib.