PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

Implement snappy compression

Open AkmalFairuz opened this issue 3 years ago • 1 comments

Introduction

Implement snappy compression.

You can change the compression algorithm in the pocketmine.yml file (default: zlib)

network:
  #Compression algorithm. Supported algorithms: snappy, zlib
  compression-algorithm: zlib

An snappy extension is required https://github.com/kjdev/php-ext-snappy that provide snappy_compress and snappy_uncompress function.

You can use this PM php binary fork that has snappy extension https://github.com/AkmalFairuz/php-build-scripts/actions/runs/3106786925 this binary fork is only supported on Linux and MacOS, I need someone to help me to build the PM php binary with snappy extension on Windows

Relevant issues

Changes

API changes

  • Added pocketmine\network\mcpe\compression\CompressorPool
  • Added public function toNetworkCompressionAlgorithm() : int; in pocketmine\network\mcpe\compression\Compressor interface

Behavioural changes

Backwards compatibility

Follow-up

Tests

AkmalFairuz avatar Sep 22 '22 15:09 AkmalFairuz

I think we're jumping the gun on this. We're just giving users another way to break their servers without any solid motive to do so.

  • Snappy support is still experimental in the game itself.
  • There's zero evidence to suggest that this will be beneficial. No performance benchmarks have been done. This is especially important since PM uses libdeflate, which is considerably faster than zlib.
  • Snappy does not support compression levels or threshold-based zero compression.
  • The mode of operation may also change (I personally suggested per-packet compression type selection, rather than making it global).

dktapps avatar Sep 23 '22 10:09 dktapps

Adding to my previous comments, some specific words about php-ext-snappy:

  • This extension doesn't have any support for length limiting on decompressed payloads. This means that the server could be taken down with a zip bomb attack when using Snappy.
  • The extension itself isn't supported on Windows, or if it is, there's no instructions how to build it.
  • The extension uses antiquated Zend APIs that are harmful to performance.
  • It also performs useless copies of the output data, further wasting performance.

dktapps avatar Oct 10 '22 08:10 dktapps

The commits in this PR no longer contain a snappy compression implementation

jasonw4331 avatar Feb 20 '23 05:02 jasonw4331