Collect CPU long tasks information from our real users in the navigation timing extension. A long task is a CPU task that takes more than 50 ms on the main thread in the browser.
In our synthetic tests where we use Chrome we collect CPU long tasks information: we collect number of long tasks, and the actual time spent in long tasks. We also count number of tasks before first paint and before load event end.
The metrics that we get from real users we do not collect any long tasks at all, so a first step could be to collect number of long tasks and the total time spent in long tasks. That way we would start to get a feel for how many long tasks we have for real users and see how stable that metric is, maybe we can use it for alerting. One thing to remember is that the long taks ins depending on the users hardware so it will be different depending on that device the user is using.
Long tasks will continue to happen through the user journey but at as a first implementation we can get the long tasks that happens before we beacon back navigation timing data.
To collect the metric we need to do a couple of things (you can see the full picture at https://wikitech.wikimedia.org/wiki/Performance#/media/File:WMF_Performance_Team_infrastructure_2022.png):
- Add the collection of the actual metric in the navigation timing extension https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/NavigationTiming/+/refs/heads/master - you need to pull up Mediawiki and do the changes in the extension, add tests for it and run the tests.
- Then we need to make sure that the data is stored in the schema https://gerrit.wikimedia.org/r/plugins/gitiles/schemas/event/secondary/+/refs/heads/master/jsonschema/analytics/legacy/navigationtiming/ so we need to ad the fields missing there.
- And then we need to take care of data when it arrives and send it to Graphite/Prometheus. That happens in navtiming.py: https://gerrit.wikimedia.org/r/plugins/gitiles/performance/navtiming/
- When the data has started to arrive we can make a new dashboard/graph in Grafana where we can look at the new metric.