chrome-input-latency
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
| # coding: utf-8 | |
| # --- | |
| # title: "Chrome Input Latency" | |
| # authors: | |
| # - bsmedberg | |
| # created_at: 2017-04-13 | |
| # --- | |
| # In[1]: | |
| import ujson as json | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| import numpy as np | |
| import plotly.plotly as py | |
| from plotly.graph_objs import * | |
| from moztelemetry import get_pings_properties, get_one_ping_per_client | |
| from moztelemetry.dataset import Dataset | |
| from moztelemetry.histogram import Histogram | |
| from operator import add | |
| from datetime import date, timedelta | |
| get_ipython().magic(u'matplotlib inline') | |
| # In[2]: | |
| sc.defaultParallelism | |
| # In[7]: | |
| def ping_filter(p): | |
| if p.get("environment/system/os/name", None) != "Windows_NT": | |
| return False | |
| if p.get("payload/info/subsessionLength", 0) <= 0: | |
| return False | |
| if p.get("environment/settings/e10sEnabled", False) != True: | |
| return False | |
| addons = p.get("environment/addons/activeAddons", {}) or {} | |
| for a in addons.itervalues(): | |
| if a.get("isSystem", False) != True: | |
| return False | |
| return True | |
| def print_histogram(histogram, processtype, hours): | |
| print "{} process:".format(processtype) | |
| stotal = 0 | |
| for cutoff, count in histogram.buckets.sort_index(ascending=False).iteritems(): | |
| if cutoff < 150: | |
| break | |
| stotal = stotal + count | |
| print " {:5}ms: {:0.3f} hours".format(cutoff, float(hours) / stotal) | |
| def input_latency_mtbf(startdate, days=7, channel="nightly"): | |
| sdstring = startdate.strftime("%Y%m%d") | |
| edstring = (startdate + timedelta(days=days)).strftime("%Y%m%d") | |
| pings = Dataset.from_source("telemetry") .where(docType='main') .where(submissionDate=lambda d: sdstring <= d <= edstring) .where(appUpdateChannel=channel) .records(sc) | |
| data = get_pings_properties(pings, [ | |
| "environment/system/os/name", | |
| "environment/settings/e10sEnabled", | |
| "environment/addons/activeAddons", | |
| "payload/histograms/INPUT_EVENT_RESPONSE_MS", | |
| "payload/info/subsessionLength"], with_processes=True) \ | |
| .filter(ping_filter).cache() | |
| total_session_length_hours = data .map(lambda p: p["payload/info/subsessionLength"]) .reduce(add) / 60 / 60 | |
| print "Input jank MTBF for {} channel, {} for {} days:".format(channel, startdate.strftime("%Y-%m-%d"), days) | |
| print "Usage hours total: {}".format(total_session_length_hours) | |
| aggregated_input_latency_chrome = data .map(lambda p: p.get("payload/histograms/INPUT_EVENT_RESPONSE_MS_parent", None)) .filter(lambda v: v is not None) .reduce(add) | |
| chrome_histogram = Histogram("INPUT_EVENT_RESPONSE_MS", aggregated_input_latency_chrome) | |
| print_histogram(chrome_histogram, "chrome", total_session_length_hours) | |
| aggregated_input_latency_content = data .map(lambda p: p.get("payload/histograms/INPUT_EVENT_RESPONSE_MS_children", None)) .filter(lambda v: v is not None) .reduce(add) | |
| content_histogram = Histogram("INPUT_EVENT_RESPONSE_MS", aggregated_input_latency_content) | |
| print_histogram(content_histogram, "content", total_session_length_hours) | |
| # Caculate mean time between failure (MTBF) of "hangs at least as long as X ms". Cut off at 150ms because for now that's not a failure case. | |
| # In[8]: | |
| input_latency_mtbf(date(2017, 4, 2), channel="nightly") | |
| # In[9]: | |
| input_latency_mtbf(date(2017, 4, 2), channel="beta") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment