-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async task timings #6333
Async task timings #6333
Conversation
this is a rough implementation and needs further work. there's currently an issue where the first async worker to boot up doesn't enable timings if it was enabled by default in pocketmine.yml and I have no idea why - the task definitely gets scheduled so it doesn't make any sense.
we should probably add callbacks for collecting timings too, but that's a bit more complicated right now.
this allows custom threads to have timings collected via custom mechanisms, since we can't directly access another thread's timings. for RakLib, for example, we'll need an IPC command, while for workers we need an AsyncTask.
There are some unrelated changes in the PR which I made to facilitate this feature, such as |
these are all caused by the same bug phpstan/phpstan#10924
This is finished for now. However, it would be worth making some changes to RakLib to enable some basic timings to be collected from it too. This would probably involve making Currently RakLib's architecture (and the IPC system) are not flexible enough for timings integration, so they'll be skipped for this PR. This should be done as a follow-up. |
If plugin devs use this system to report their own threads' timings, we shouldn't rely on them not to just pass a random int as the thread ID.
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
TimingsHandler::printTimings()
is now deprecatedgetToggleCallbacks()
,getReloadCallbacks()
andgetCollectCallbacks()
toTimingsHandler
Behavioural changes
ThreadId
part of timer group names to namespace timer IDs (necessary since timer IDs could otherwise collide between different threads).Backwards compatibility
Should be fully backwards compatible
Tests
I tested this PR by doing the following (tick all that apply):
tests/phpunit
folder)Samples
This requires a version of the timings viewer including the following commit: pmmp/timings@13cefa6
An example report can be viewed here: https://timings.pmmp.io/?id=338211