272 Commits

Author SHA1 Message Date
Dylan K. Taylor
bc07778434
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
2023-11-17 12:35:42 +00:00
Dylan K. Taylor
b41960dfec
Merge branch 'stable' into minor-next 2023-10-26 12:55:47 +01:00
Dylan K. Taylor
53a740433f
Changes for 1.20.40 2023-10-26 12:32:59 +01:00
Dylan K. Taylor
ae564e445d
Start migrating EnumTrait enums to PHP 8.1 native enums 2023-09-07 17:20:52 +01:00
Dylan K. Taylor
31d8cc1cb5
Generate and use constants for pocketmine.yml constant names
a couple of usages of properties that no longer exist couldn't be migrated.
in addition, this revealed a couple of dead properties in the default file.

this is not an ideal solution (I'd much rather model the configs using classes and map them) but in the absence of a good and reliable library to do that, this is the next best thing.
2023-08-25 13:23:38 +01:00
Dylan K. Taylor
0b86fafafb
Hot path optimisation for DataPacketSendEvent 2023-08-01 17:41:53 +01:00
Dylan K. Taylor
442d65143d
Merge branch 'minor-next' into hot-events-optimisation 2023-08-01 17:01:52 +01:00
Dylan K. Taylor
914dd90b3d
Use first-class closures in more places 2023-07-19 13:56:48 +01:00
Dylan K. Taylor
537721fe7d
Replace Closure::fromCallable() usages with first-class callables
PHP 8.1 <3
2023-07-19 13:34:42 +01:00
Dylan K. Taylor
b7210755a7
1.20.10 2023-07-12 13:39:39 +01:00
Dylan K. Taylor
edafe9d21f
Entity: Rename and document isImmobile() and friends
while I could implement server-side ability to disable entity movement, I don't think that's particularly useful. However, the intended function of this (disabling client sided AI) is useful, so it makes more sense to rename it to match its functionality, rather than changing its functionality to match the name.

closes #3130
2023-05-26 14:01:21 +01:00
Dylan K. Taylor
ee9ce8a4f4
Merge branch 'minor-next' into major-next 2023-05-17 15:45:03 +01:00
Dylan K. Taylor
9499e2e595
always the CS... 2023-05-16 14:22:03 +01:00
Dylan K. Taylor
a4fea1444a
Remove validateCallableSignature() calls from network hot paths
we rely on phpstan for validation of this internally, and plugins shouldn't be calling these methods anyway.
this significantly reduces the overhead of CompressBatchPromise.
2023-05-16 14:21:32 +01:00
Dylan K. Taylor
8e6c1762d7
Merge branch 'minor-next' into major-next 2023-05-06 18:27:06 +01:00
Dylan K. Taylor
aac4f6c0e1
Fixed all game modes allowing flight
moral of the story: do not trust that mojang things do what they say they do - the spectator ability layer always applies, regardless of whether the player is actually in spectator mode or not ...
2023-05-06 18:18:05 +01:00
Dylan K. Taylor
926f68d8c5
Move SkinAdapter under TypeConverter, remove SkinAdapterSingleton
this is legacy cruft from PM3, which didn't have TypeConverter or SingletonTrait.
2023-05-06 17:53:24 +01:00
Dylan K. Taylor
e0a6ec0c24
Start deglobalizing TypeConverter
there's a bunch of places we can't reach with this right now:

- particles
- sounds
- tile NBT
- entity metadata
- crafting data cache
- chunk encoding
- world block update encoding

this is a work in progress, but ultimately we want to get rid of these singletons entirely.
2023-05-06 17:47:09 +01:00
Dylan K. Taylor
5c7f4570b4
Merge branch 'minor-next' into major-next 2023-05-06 17:20:37 +01:00
Dylan K. Taylor
4caa2c7690
NetworkSession: send FLYING flag on spectator ability layer
fixes #5722

I'm not very clear why this works. PM doesn't use real spectator mode yet (we're still using the faux spectator mode PM has had for years, because I haven't yet assessed how real spectator mode will affect stuff like block interactions), so this ability layer shouldn't have any effect.

thank you @Alemiz112
2023-05-06 15:54:23 +01:00
Dylan K. Taylor
0dca85af44
Merge branch 'minor-next' into major-next 2023-04-26 23:28:27 +01:00
Dylan K. Taylor
0d21e591d1
Support sign editing UI in 1.19.80, with APIs to allow plugins to use it
this doesn't support editing the rear side of a sign, since the 1.12 format doesn't allow us to represent the rear text, and it would necessitate API breaks to support anyway.

However, we can quite trivially support APIs for the sign GUI, which plugins can use to enable editing signs. PocketMine-MP doesn't currently permit this, since it's currently an experimental feature in 1.20, but plugins can simply use Player->openSignEditor() to mimic it.

This is, however, a byproduct of the fact that APIs needed to be added in order to facilitate the use of OpenSignPacket in 1.19.80.
2023-04-26 22:55:05 +01:00
Dylan K. Taylor
c878bd8289
Merge remote-tracking branch 'origin/minor-next' into major-next 2023-04-20 00:18:19 +01:00
Dylan K. Taylor
0629d11e13
Avoid unnecessary events work in handleDataPacket if the events have no registered handlers
this particular optimisation became possible thanks to changes in 4.19.

I observed that the allocation of Event objects and calling ->call() was costing us a significant percentage of the time taken in PlayerAuthInputPacket handlers. This change produces a measurable 2 microsecond reduction in overhead for PlayerAuthInputPacket handling when players are not moving (10.7 -> 8.7 microseconds). On a server with 200 players, this translates into a 1% reduction in CPU load for PlayerAuthInputPacket alone. It will also benefit other packets, but not to the extent that PlayerAuthInputPacket benefits.
2023-04-16 20:51:55 +01:00
Dylan K. Taylor
a0dadc6e37
Merge branch 'minor-next' into major-next 2023-04-10 14:38:23 +01:00
Dylan K. Taylor
017fcde6aa
always the CS... 2023-04-10 13:56:53 +01:00
Dylan K. Taylor
24374297e7
NetworkSession: extract rate limiting functionality into its own unit, and apply a separate rate limit to game packets 2023-04-10 13:53:22 +01:00
Dylan K. Taylor
3b11191043
Merge remote-tracking branch 'origin/minor-next' into major-next 2023-03-22 22:49:22 +00:00
Dylan K. Taylor
f978c1e9a0
Merge remote-tracking branch 'origin/stable' into minor-next 2023-03-22 22:45:41 +00:00
Dylan K. Taylor
b11457d605
Fixed uncaught exception when retrieving a packet from the pool 2023-03-22 22:24:25 +00:00
Dylan K. Taylor
a4d34be6df
Merge branch 'minor-next' into major-next 2023-03-20 23:42:40 +00:00
Dylan K. Taylor
e7771d76f2
Cover buffered inventory sync in timings 2023-03-20 23:29:02 +00:00
Dylan K. Taylor
23ea721164
Reduce packets-per-batch limit to 100
this should be well in excess of requirements with the ItemStackRequest system in use.
2023-03-20 22:15:02 +00:00
Dylan K. Taylor
7cdab75b05
Merge branch 'minor-next' into major-next 2023-03-20 22:12:54 +00:00
Dylan K. Taylor
2bf7941aec
Merge branch 'item-stack-request-pm5' into major-next 2023-03-20 22:07:09 +00:00
Dylan K. Taylor
8408da8534
Merge branch 'item-stack-request' into minor-next 2023-03-20 22:05:50 +00:00
Dylan K. Taylor
453ad997e9
Merge branch 'item-stack-request' into item-stack-request-pm5 2023-03-20 22:05:12 +00:00
Dylan K. Taylor
ca6d51498f
Buffer slot and content syncing until the end of the tick
we may receive multiple requests in one tick (e.g. crafting in a batch)
2023-03-20 19:16:00 +00:00
Dylan K. Taylor
f696a5881b
Merge remote-tracking branch 'origin/stable' into minor-next 2023-03-19 16:23:09 +00:00
Dylan K. Taylor
9a969e21c7
ÂNetworkSession: ensure onResolve handler for CompressBatchPromise is covered by network send timings 2023-03-18 22:49:52 +00:00
Dylan K. Taylor
195bc3b623
NetworkSession: prevent dev client asserts from missing ability flags 2023-03-18 21:53:17 +00:00
Dylan K. Taylor
cf0e7b4213
Merge branch 'minor-next' into major-next 2023-03-16 15:04:27 +00:00
Dylan K. Taylor
ef45180b80
Rename DataPacketPreReceiveEvent -> DataPacketDecodeEvent
thank you @IvanCraft623 for the suggestion
2023-03-16 13:40:37 +00:00
Dylan K. Taylor
ec2b53f61a
Remove unnecessary PacketBatch instantiations 2023-03-16 13:35:12 +00:00
Dylan K. Taylor
abd4ef01eb
Merge branch 'minor-next' into major-next 2023-03-15 23:02:41 +00:00
Dylan K. Taylor
941fd03998
Remove useless code 2023-03-15 22:58:10 +00:00
Armen Deroian
183d1f4038
Implement DataPacketPreReceiveEvent (#5559)
closes #5554

This is called just before the packet is decoded, allowing the event to be used to drop packets from clients without wasting CPU time decoding them. This can be particularly useful for mitigating denial-of-service attacks.
2023-03-15 22:47:19 +00:00
Dylan K. Taylor
cc8660629b
First look at shared EntityEventBroadcaster,
this improves performance in PvP servers and other areas where lots of players or entities exist in one space.

fixes #5622
2023-03-15 18:22:56 +00:00
Dylan K. Taylor
dace20ad1f
Merge branch 'item-stack-request' into item-stack-request-pm5 2023-03-14 22:34:47 +00:00
Dylan K. Taylor
14f141fab2
NetworkSession: Stop counting DataPacketReceiveEvent in handler timings
we want it to be included in receive timings, but not handler timings. Handler timings should reflect the time spent in the actual session PacketHandler, not in the event.
2023-03-14 19:00:15 +00:00