15 Commits

Author SHA1 Message Date
Dylan K. Taylor
2608637210
HandlerListManager: track RegisteredListenerCache directly
This change improves the performance of calling an event with 0 handlers by about 10% with no other changes.

Since we have to access the list eventually anyway, we can cut out some unnecessary work by returning the handlers from the cache directly, instead of fetching the HandlerList for no reason.

This also improves the performance of Event::hasHandlers() by about 40%, which is pretty significant (120 ns -> 80 ns).
2023-08-01 17:37:49 +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
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
4724195791
Improved performance of event calls
This change significantly reduces the amount of work done by event handlers. Instead of traversing all of the priorities and event parent chain multiple times, we reduce event handlers down to a simple list, which doesn't require any logic to iterate over.
Previously, calling an event with lots of parents costed more than an event which directly descended from Event.
In addition, we had to do a lot of usually useless work to check all priorities, when in practice, only NORMAL will be used in almost all cases.

This change makes it more cost effective to implement the feature suggested by #5678; however, it will still require additional changes.
2023-04-05 23:02:44 +01:00
Dylan K. Taylor
10f3145af2
Merge branch 'minor-next' into major-next 2023-03-29 23:22:02 +01:00
Dylan K. Taylor
b49a9ae81d
Added timings for calling events
this gives a somewhat better overview of events, particularly if many plugins are subscribed to the same costly event (e.g. PlayerMoveEvent).

In addition, it allows us to see the frequency that events are occurring.
2023-03-28 17:26:20 +01:00
Dylan K. Taylor
aa9f8781ff
Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
083a35f970
Modernize property type declarations 2022-06-04 18:16:32 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
c0b15de504
Modernize private static property declarations 2022-05-17 21:55:16 +01:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
b7665fd906 remove unused imports 2019-10-20 21:26:22 +01:00
Dylan K. Taylor
e5b02ee5e0 make logic for fetching handler lists more consistent 2019-08-23 17:16:07 +01:00
Dylan K. Taylor
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00