From 0d4e473bdde73abe4fb6c63abbe457bb2ecf3f8c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 31 May 2020 19:29:26 +0100 Subject: [PATCH] Reduce ResourcePackChunkData chunk size to 128 KB while this is slightly less bandwidth efficient (1 in 92 datagrams not full vs 1 in 733), this is significantly less memory-hard. I made this decision looking at the memory pressures that 1MB chunks exert - especially on RakNet. Client-side, these resource pack chunks all hang around in RakNet memory until the whole thing is received, and it's a lot more costly to receive 733 datagrams than it is to receive 92, especially since it's much more likely that some of the 733 will disappear along the way. If, for example, the first couple of hundred KB split parts arrived out of 1MB, and then one of the parts got lost, all the already-received parts would hang around in memory not getting processed. With smaller chunks this is much less of a problem. I explored taking the chunk size all the way down to 1KB to reduce the bandwidth waste caused by split packets (split headers), but this made resource pack downloading unbearably slow, so it wasn't acceptable. --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index e816dc98e..23bc3801b 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -217,7 +217,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ public const SPECTATOR = 3; public const VIEW = Player::SPECTATOR; - private const RESOURCE_PACK_CHUNK_SIZE = 1048576; //1MB + private const RESOURCE_PACK_CHUNK_SIZE = 128 * 1024; //128KB /** * Validates the given username.