Don't bother with global batch compression if there is only 1 recipient

this allows the session to achieve better ratios, and also reduces worker pool spam.
This commit is contained in:
Dylan K. Taylor
2023-03-04 16:34:00 +00:00
parent eb2f0ed3d0
commit f8893efb94

View File

@ -64,7 +64,7 @@ final class StandardPacketBroadcaster implements PacketBroadcaster{
$compressor = $compressors[$compressorId];
$threshold = $compressor->getCompressionThreshold();
if($threshold !== null && $packetBufferTotalLengths[$bufferId] >= $threshold){
if(count($compressorTargets) > 1 && $threshold !== null && $packetBufferTotalLengths[$bufferId] >= $threshold){
//do not prepare shared batch unless we're sure it will be compressed
$stream = new BinaryStream();
PacketBatch::encodeRaw($stream, $packetBuffers[$bufferId]);