Avoid unnecessary CompressBatchPromise allocations for sync-prepared batches

Sync-prepared batches account for the vast majority of outbound packets. Avoiding these useless objects further reduces the overhead of zero-compressed packets, as the creation of these objects is a significant part of the overhead for these cases.

closes #6157
This commit is contained in:
Dylan K. Taylor
2023-11-17 12:35:42 +00:00
parent 519784460f
commit bc07778434
3 changed files with 52 additions and 40 deletions

View File

@ -88,9 +88,9 @@ final class StandardPacketBroadcaster implements PacketBroadcaster{
PacketBatch::encodeRaw($stream, $packetBuffers);
$batchBuffer = $stream->getBuffer();
$promise = $this->server->prepareBatch($batchBuffer, $compressor, timings: Timings::$playerNetworkSendCompressBroadcast);
$batch = $this->server->prepareBatch($batchBuffer, $compressor, timings: Timings::$playerNetworkSendCompressBroadcast);
foreach($compressorTargets as $target){
$target->queueCompressed($promise);
$target->queueCompressed($batch);
}
}else{
foreach($compressorTargets as $target){