pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.23k stars 1.51k forks source link

Async task timings #6333

Open dktapps opened 2 months ago

dktapps commented 2 months ago

Introduction

This PR adds support for asynchronously collecting timings, and for collecting timings from AsyncWorkers for AsyncTasks.

The implemented API allows custom collect callbacks to be registered, which allows plugins to include custom thread timings in timings reports. This is necessary because other threads' timings records can't be directly accessed from the main thread.

Relevant issues

Closes #6166

Changes

API changes

Behavioural changes

Backwards compatibility

Should be fully backwards compatible

Follow-up

Requires translations:

Name Value in eng.ini
N/A Compiling timings report

Tests

I tested this PR by doing the following (tick all that apply):

Samples

This requires a version of the timings viewer including the following commit: https://github.com/pmmp/timings/commit/13cefa6279ee8866dc584b9a7977a9c09cecd732

An example report can be viewed here: https://timings.pmmp.io/?id=330357

dktapps commented 2 months ago

There are some unrelated changes in the PR which I made to facilitate this feature, such as Promise::all() supporting 0 promises. These should be separated before merging.