Page MenuHomePhabricator

Collect performance metrics from a mobile over time
Closed, ResolvedPublic

Assigned To
Authored By
Peter
Jun 21 2018, 8:29 AM
Referenced Files
F27112748: Screen Shot 2018-11-08 at 10.22.33 AM.png
Nov 8 2018, 9:25 AM
F27112749: Screen Shot 2018-11-08 at 10.22.39 AM.png
Nov 8 2018, 9:25 AM
F27112824: 1-1.jpg
Nov 8 2018, 9:25 AM
F27112596: Screenshot 2018-11-08 at 09.41.16.png
Nov 8 2018, 9:20 AM
F27112534: Screenshot 2018-11-08 at 09.41.01.png
Nov 8 2018, 9:20 AM
F27112533: Screenshot 2018-11-08 at 09.41.07.png
Nov 8 2018, 9:20 AM
F27094608: Screenshot 2018-11-07 at 13.15.36.png
Nov 7 2018, 1:11 PM
F27094628: Screen Shot 2018-11-07 at 2.09.02 PM.png
Nov 7 2018, 1:11 PM
Subscribers

Description

Today we have a way of getting stable metrics though Moto G5, but we haven't had it running for a time. We should try to collect data for a couple of days/week and see that the metric are stable.

Event Timeline

Vvjjkkii renamed this task from Collect performance metrics from a mobile over time to kjaaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii removed Peter as the assignee of this task.
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from kjaaaaaaaa to Collect performance metrics from a mobile over time.Jul 2 2018, 9:25 AM
CommunityTechBot assigned this task to Peter.
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.
Peter triaged this task as Medium priority.Aug 20 2018, 5:54 AM

I started this again today. I got a new computer and I can use my old running Ubuntu for a couple of days. My plan is to get it up and running early next week.

When I started to prepare and tested it out with a couple of runs, the setup was broken and also there was a lot of variation between metrics and a big difference between first paint and first visual change (the same as we have seen on WPT). I've made a couple of changes + changed so the video is 60 fps (instead of 30fps) and it looks like that decreased the diff between first paint and first visual paint. But I know for sure when I have everything up and running.

Argh I need to write down the fix for this since I spent many hours to try to solve it:
I've been working on to minimize and understand the difference in firstPaint and firstVisualChange when running on Android. Since we use WebPageReplay and I want it to all "just work" I use the Docker container, and that only works on Linux. I run Ubuntu 16 in Parallels on my other laptop and to be able to do changes locally on Ubuntu, I rebuild the container ...

docker build -t XXX ..

But on my machine I couldn't build because it couldn't find any dependency for the container from archive.ubuntu.com. After some searching I found the fix. Change /etc/default/docker and enable the row:

# DOCKER_OPTS=“--dns 8.8.8.8 --dns 8.8.4.4”

I did that and I could build the container. Hooray I could build the container. But then when running, I started to get error when recording the URL with WebPageReplay (but I didn't understand that it was because of that change). Running the container and testing on desktop worked fine, running with WebPageReplay worked fine, but using WebPageReplay from my Android phone I got an error loading the URL. I made the mistake at the beginning and didn't look so much at the error.

The error I got was uri:chrome-error://chromewebdata/ so after a lot of try and error I started to search for it and I finally found that someone got that error when they had problems with certificates in Chrome on Android. I went through the changes I done through the day and rollbacked the DOCKER_OPTS change (since it was the only network change I've done), restarted Docker and it worked again!

Now I'm back on track and will try to verify the first visual change.

I got this up and running today. I need to fine-tune the start script a little but more (removing Docker data etc after each run) but I've been able to have it up and running for a couple of hours at least. At the moment we do 5 runs (the blur vertical line is when I turned on devtools.timeline):

Screenshot 2018-11-07 at 13.15.14.png (1,332×1,122 px, 172 KB)

The visual metrics isn't super stable so far, I try more runs and try to tune it the coming days.

The CPU metrics looks good (I'm using a Moto G5):

Screenshot 2018-11-07 at 13.15.36.png (1,326×948 px, 95 KB)

But WAIT! Look at the time spent scripting (this is the Obama page but it is the same for Facebook and Sweden). Its 1700 ms. Then checkout what time we have on AWS running emulate mobile:

Screen Shot 2018-11-07 at 2.09.02 PM.png (1,438×946 px, 184 KB)

290-340 ms! Much much faster than on a real phone.

I'll try to keep it running through the night to check that the phone still works and will try to get it running from my Raspberry Pi.

I had a go trying out to drive the phone from my Raspberry but got stuck on installing Chromedriver (that you need to drive chrome). Chromedriver doesn't support ARM, Docker containers needs to be built upon ARM base containers. I tried that too but then the container can't install the driver.

One of the problems was that Browsertime automatically tries to download Chromedriver, but since there's no pre-built on ARM it fails. I've added so it just skips installing on ARM and then I'll try to see if I can get a matching version to work.

I had it up and running for some time yesterday until my battery run out of power. The next I will try more runs to see if we can get more stable metrics. There was two things, checkout the spike in First Visual Change that correlates to really low time spent in JS:

Screenshot 2018-11-08 at 09.41.01.png (1,318×1,104 px, 194 KB)

Screenshot 2018-11-08 at 09.41.07.png (1,322×942 px, 150 KB)

The next time I'll make sure we store the result data, so I can get back and have look. There's also an increase in all three URLs in rendering time between 17-18 but I haven't stored the result so I don't know the cause.

Screenshot 2018-11-08 at 09.41.16.png (1,332×954 px, 133 KB)

We had the same spike on AWS but it looks differently:

Screen Shot 2018-11-08 at 10.22.33 AM.png (1,452×940 px, 160 KB)

Screen Shot 2018-11-08 at 10.22.39 AM.png (1,456×936 px, 200 KB)

And the reason:

1-1.jpg (1,124×2,000 px, 200 KB)

This is my setup: On my local machine I run Graphite/Grafana with docker-compose and then I use Ubuntu in Parallels running a simple bash script:

#!/bin/bash

RUNS=5

while true
do
        URL=https://en.m.wikipedia.org/wiki/Barack_Obama

        docker run --privileged -v /dev/bus/usb:/dev/bus/usb -e START_ADB_SERVER=true --cap-add=NET_ADMIN --shm-size=1g --rm -v "$(pwd)":/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime-autobuild:navigationScript $URL --resultDir result --chrome.android.package com.android.chrome --xvfb false --chrome.args ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDxI6I= -n $RUNS --chrome.args user-data-dir=/data/tmp/chrome --chrome.timeline true

        echo "browsertime.android.obama.SpeedIndex.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.SpeedIndex.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.obama.FirstVisualChange.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.FirstVisualChange.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.obama.cpu.categories.Scripting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Scripting.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.obama.cpu.categories.Loading.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Loading.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.obama.cpu.categories.Rendering.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Rendering.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.obama.cpu.categories.Painting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Painting.median) "`date +%s`" | nc -q0 10.0.1.9 2003


        sudo rm -fR result
        URL=https://en.m.wikipedia.org/wiki/Facebook
        docker run --privileged -v /dev/bus/usb:/dev/bus/usb -e START_ADB_SERVER=true --cap-add=NET_ADMIN --shm-size=1g --rm -v "$(pwd)":/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime-autobuild:navigationScript $URL --resultDir result --chrome.android.package com.android.chrome --xvfb false --chrome.args ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDxI6I= -n $RUNS --chrome.args user-data-dir=/data/tmp/chrome --chrome.timeline true

        echo "browsertime.android.facebook.SpeedIndex.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.SpeedIndex.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.facebook.FirstVisualChange.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.FirstVisualChange.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.facebook.cpu.categories.Scripting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Scripting.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.facebook.cpu.categories.Loading.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Loading.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.facebook.cpu.categories.Rendering.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Rendering.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.facebook.cpu.categories.Painting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Painting.median) "`date +%s`" | nc -q0 10.0.1.9 2003

        sudo rm -fR result

        URL=https://en.m.wikipedia.org/wiki/Sweden
        docker run --privileged -v /dev/bus/usb:/dev/bus/usb -e START_ADB_SERVER=true --cap-add=NET_ADMIN --shm-size=1g --rm -v "$(pwd)":/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime-autobuild:navigationScript $URL --resultDir result --chrome.android.package com.android.chrome --xvfb false --chrome.args ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDxI6I= -n $RUNS --chrome.args user-data-dir=/data/tmp/chrome --chrome.timeline true

        echo "browsertime.android.sweden.SpeedIndex.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.SpeedIndex.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.sweden.FirstVisualChange.median" $(cat result/browsertime.json | jq .statistics.visualMetrics.FirstVisualChange.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.sweden.cpu.categories.Scripting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Scripting.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.sweden.cpu.categories.Loading.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Loading.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.sweden.cpu.categories.Rendering.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Rendering.median) "`date +%s`" | nc -q0 10.0.1.9 2003
        echo "browsertime.android.sweden.cpu.categories.Painting.median" $(cat result/browsertime.json | jq .statistics.cpu.categories.Painting.median) "`date +%s`" | nc -q0 10.0.1.9 2003

        sudo rm -fR result
        sleep 120
done

Lets close this task when we have Kobiton up and running.