PreSpawnPacketHandler: added dedicated timer for the humongous amount of crap that has to be sent pre-spawn

This commit is contained in:
Dylan K. Taylor 2023-04-05 20:58:49 +01:00
parent b2f755720d
commit 61b0ad3e7f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 82 additions and 74 deletions

View File

@ -44,6 +44,7 @@ use pocketmine\network\mcpe\protocol\types\PlayerMovementType;
use pocketmine\network\mcpe\protocol\types\SpawnSettings; use pocketmine\network\mcpe\protocol\types\SpawnSettings;
use pocketmine\player\Player; use pocketmine\player\Player;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\timings\Timings;
use pocketmine\VersionInfo; use pocketmine\VersionInfo;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use function sprintf; use function sprintf;
@ -60,6 +61,8 @@ class PreSpawnPacketHandler extends PacketHandler{
){} ){}
public function setUp() : void{ public function setUp() : void{
Timings::$playerNetworkSendPreSpawnGameData->startTiming();
try{
$location = $this->player->getLocation(); $location = $this->player->getLocation();
$world = $location->getWorld(); $world = $location->getWorld();
@ -143,6 +146,9 @@ class PreSpawnPacketHandler extends PacketHandler{
$this->session->getLogger()->debug("Sending player list"); $this->session->getLogger()->debug("Sending player list");
$this->session->syncPlayerList($this->server->getOnlinePlayers()); $this->session->syncPlayerList($this->server->getOnlinePlayers());
}finally{
Timings::$playerNetworkSendPreSpawnGameData->stopTiming();
}
} }
public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{ public function handleRequestChunkRadius(RequestChunkRadiusPacket $packet) : bool{

View File

@ -68,6 +68,7 @@ abstract class Timings{
public static $playerNetworkSendEncrypt; public static $playerNetworkSendEncrypt;
public static TimingsHandler $playerNetworkSendInventorySync; public static TimingsHandler $playerNetworkSendInventorySync;
public static TimingsHandler $playerNetworkSendPreSpawnGameData;
/** @var TimingsHandler */ /** @var TimingsHandler */
public static $playerNetworkReceive; public static $playerNetworkReceive;
@ -187,6 +188,7 @@ abstract class Timings{
self::$playerNetworkSendCompressSessionBuffer = new TimingsHandler("Player Network Send - Compression (Session Buffer)", self::$playerNetworkSendCompress, group: self::GROUP_BREAKDOWN); self::$playerNetworkSendCompressSessionBuffer = new TimingsHandler("Player Network Send - Compression (Session Buffer)", self::$playerNetworkSendCompress, group: self::GROUP_BREAKDOWN);
self::$playerNetworkSendEncrypt = new TimingsHandler("Player Network Send - Encryption", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN); self::$playerNetworkSendEncrypt = new TimingsHandler("Player Network Send - Encryption", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
self::$playerNetworkSendInventorySync = new TimingsHandler("Player Network Send - Inventory Sync", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN); self::$playerNetworkSendInventorySync = new TimingsHandler("Player Network Send - Inventory Sync", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
self::$playerNetworkSendPreSpawnGameData = new TimingsHandler("Player Network Send - Pre-Spawn Game Data", self::$playerNetworkSend, group: self::GROUP_BREAKDOWN);
self::$playerNetworkReceive = new TimingsHandler("Player Network Receive", self::$connection); self::$playerNetworkReceive = new TimingsHandler("Player Network Receive", self::$connection);
self::$playerNetworkReceiveDecompress = new TimingsHandler("Player Network Receive - Decompression", self::$playerNetworkReceive, group: self::GROUP_BREAKDOWN); self::$playerNetworkReceiveDecompress = new TimingsHandler("Player Network Receive - Decompression", self::$playerNetworkReceive, group: self::GROUP_BREAKDOWN);