mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Added separate timings for broadcast and session buffer compression
This commit is contained in:
parent
f8893efb94
commit
a523189149
@ -1381,9 +1381,10 @@ class Server{
|
||||
*
|
||||
* @param bool|null $sync Compression on the main thread (true) or workers (false). Default is automatic (null).
|
||||
*/
|
||||
public function prepareBatch(PacketBatch $stream, Compressor $compressor, ?bool $sync = null) : CompressBatchPromise{
|
||||
public function prepareBatch(PacketBatch $stream, Compressor $compressor, ?bool $sync = null, ?TimingsHandler $timings = null) : CompressBatchPromise{
|
||||
$timings ??= Timings::$playerNetworkSendCompress;
|
||||
try{
|
||||
Timings::$playerNetworkSendCompress->startTiming();
|
||||
$timings->startTiming();
|
||||
|
||||
$buffer = $stream->getBuffer();
|
||||
|
||||
@ -1402,7 +1403,7 @@ class Server{
|
||||
|
||||
return $promise;
|
||||
}finally{
|
||||
Timings::$playerNetworkSendCompress->stopTiming();
|
||||
$timings->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ class NetworkSession{
|
||||
PacketBatch::encodeRaw($stream, $this->sendBuffer);
|
||||
|
||||
if($this->enableCompression){
|
||||
$promise = $this->server->prepareBatch(new PacketBatch($stream->getBuffer()), $this->compressor, $syncMode);
|
||||
$promise = $this->server->prepareBatch(new PacketBatch($stream->getBuffer()), $this->compressor, $syncMode, Timings::$playerNetworkSendCompressSessionBuffer);
|
||||
}else{
|
||||
$promise = new CompressBatchPromise();
|
||||
$promise->resolve($stream->getBuffer());
|
||||
|
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\utils\BinaryStream;
|
||||
use function spl_object_id;
|
||||
use function strlen;
|
||||
@ -70,7 +71,7 @@ final class StandardPacketBroadcaster implements PacketBroadcaster{
|
||||
PacketBatch::encodeRaw($stream, $packetBuffers[$bufferId]);
|
||||
$batchBuffer = $stream->getBuffer();
|
||||
|
||||
$promise = $this->server->prepareBatch(new PacketBatch($batchBuffer), $compressor);
|
||||
$promise = $this->server->prepareBatch(new PacketBatch($batchBuffer), $compressor, timings: Timings::$playerNetworkSendCompressBroadcast);
|
||||
foreach($compressorTargets as $target){
|
||||
$target->queueCompressed($promise);
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ abstract class Timings{
|
||||
public static $playerNetworkSend;
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkSendCompress;
|
||||
|
||||
public static TimingsHandler $playerNetworkSendCompressBroadcast;
|
||||
public static TimingsHandler $playerNetworkSendCompressSessionBuffer;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $playerNetworkSendEncrypt;
|
||||
/** @var TimingsHandler */
|
||||
@ -153,6 +157,8 @@ abstract class Timings{
|
||||
|
||||
self::$playerNetworkSend = new TimingsHandler("Player Network Send");
|
||||
self::$playerNetworkSendCompress = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Compression", self::$playerNetworkSend);
|
||||
self::$playerNetworkSendCompressBroadcast = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Compression (Broadcast)", self::$playerNetworkSendCompress);
|
||||
self::$playerNetworkSendCompressSessionBuffer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Compression (Session Buffer)", self::$playerNetworkSendCompress);
|
||||
self::$playerNetworkSendEncrypt = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Encryption", self::$playerNetworkSend);
|
||||
|
||||
self::$playerNetworkReceive = new TimingsHandler("Player Network Receive");
|
||||
|
Loading…
x
Reference in New Issue
Block a user