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:
Increased packet sending latency (the async pool is only polled every 50ms)
Delays in packet sending caused by plugins (plugins can hog the async worker pool with tasks which do not use the CPU, delaying compression)
Packets being sent in the wrong order (this problem has been fixed on PM4)
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).
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.
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).