-
-
Save squarewave/90dc84a02407216a532501ae665b8b67 to your computer and use it in GitHub Desktop.
Devtools hangs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from datetime import datetime, timedelta | |
from moztelemetry import get_pings_properties | |
from moztelemetry.dataset import Dataset | |
from scipy.stats import linregress | |
from sets import Set | |
sc.defaultParallelism | |
# In[2]: | |
bhr_pings = (Dataset.from_source("telemetry") | |
.where(docType='OTHER') | |
.where(appVersion=lambda v: v >= '57') | |
.where(appUpdateChannel="nightly") | |
.records(sc, sample=1.0)) | |
bhr_pings = bhr_pings.filter(lambda p: p.get('meta', {}).get('docType', {}) == 'bhr') | |
bhr_properties = [ | |
"meta/docType", | |
"environment/settings/e10sEnabled", | |
"environment/system/os/name", | |
"environment/system/os/version", | |
"application/architecture", | |
"application/buildId", | |
"payload/modules", | |
"payload/hangs", | |
"payload/timeSinceLastPing", | |
] | |
bhr_subset = get_pings_properties(bhr_pings, bhr_properties) | |
# In[18]: | |
def flatten_hangs(thread_hang): | |
if 'name' not in thread_hang: | |
return [] | |
hangs = thread_hang['hangs'] | |
return [ | |
{ | |
'thread_name': thread_hang['name'], | |
'hang': x | |
} | |
for x in hangs | |
] | |
def flatten_all_hangs(ping): | |
return ping['payload/hangs'] | |
def has_devtools_stack(hang): | |
return any("devtools" in s for s in hang["stack"]) | |
def count_bhr_hangs(thread_name, hangs, min_duration, max_duration): | |
count = 0 | |
for hang in hangs: | |
if (hang['thread'] == thread_name and | |
hang['duration'] >= min_duration and | |
hang['duration'] <= max_duration and | |
has_devtools_stack(hang)): | |
count += 1 | |
return count | |
def map_ping(ping): | |
hangs = flatten_all_hangs(ping) | |
subsession_length = ping['payload/timeSinceLastPing'] | |
return (ping["application/buildId"][:8], { | |
'subsession_length': subsession_length, | |
'parent_bhr_512': count_bhr_hangs('Gecko', hangs, 512, 2048), | |
'parent_bhr_2048': count_bhr_hangs('Gecko', hangs, 2048, 65538), | |
'content_bhr_512': count_bhr_hangs('Gecko_Child', hangs, 512, 2048), | |
'content_bhr_2048': count_bhr_hangs('Gecko_Child', hangs, 2048, 65538), | |
}) | |
def merge_counts(a, b): | |
return {k: a[k] + b[k] for k in a.iterkeys()} | |
def ping_is_valid(ping): | |
if type(ping["payload/timeSinceLastPing"]) != int: | |
return False | |
if not isinstance(ping["application/buildId"], basestring): | |
return False | |
if ping["application/architecture"] != "x86-64": | |
return False | |
if not ping["environment/system/os/version"].startswith("10"): | |
return False | |
if not ping["environment/settings/e10sEnabled"]: | |
return False | |
return ping["environment/system/os/name"] == "Windows_NT" | |
counts = bhr_subset.cache().filter(ping_is_valid).map(map_ping).reduceByKey(merge_counts).collectAsMap() | |
# In[28]: | |
def moving_average(a, n=3) : | |
ret = np.cumsum(a, dtype=float) | |
ret[n:] = ret[n:] - ret[:-n] | |
return ret / n | |
# In[25]: | |
import matplotlib.pyplot as plt | |
import numpy as np | |
get_ipython().magic(u'matplotlib inline') | |
data = counts | |
sorted_keys = sorted(data.iterkeys()) | |
plot_data_2048 = np.array([float(data[k]['parent_bhr_2048']) / data[k]['subsession_length'] * 3600. * 1000 for k in sorted_keys], np.float32) | |
plot_data_2048 = moving_average(plot_data_2048, 7) | |
plot_data_512 = np.array([float(data[k]['parent_bhr_512']) / data[k]['subsession_length'] * 3600. * 1000 for k in sorted_keys], np.float32) | |
plot_data_512 = moving_average(plot_data_512, 7) | |
plt.title("Devtools Hang Stats") | |
plt.xlabel("Build date") | |
plt.ylabel("Hangs per 1000 usage hours") | |
plt.xticks(range(0, len(data))) | |
max_y = np.amax(plot_data_512) | |
plt.yticks(np.arange(0., max_y, max_y / 20.)) | |
xticks = np.arange(0, len(plot_data_2048), len(plot_data_2048) / 6) | |
plt.xticks(xticks, (sorted_keys[int(i)][4:8] for i in xticks)) | |
x1,x2,y1,y2 = plt.axis() | |
plt.axis((x1,x2,0,max_y)) | |
plt.plot(range(0, len(data)), plot_data_512) | |
plt.plot(range(0, len(data)), plot_data_2048) | |
plt.legend(["2048ms > x > 512ms", "x > 2048ms"], loc="upper left") | |
# In[27]: | |
import matplotlib.pyplot as plt | |
import numpy as np | |
get_ipython().magic(u'matplotlib inline') | |
data = counts | |
sorted_keys = sorted(data.iterkeys()) | |
plot_data_2048 = np.array([float(data[k]['content_bhr_2048']) / data[k]['subsession_length'] * 3600. * 1000 for k in sorted_keys], np.float32) | |
plot_data_2048 = moving_average(plot_data_2048, 7) | |
plot_data_512 = np.array([float(data[k]['content_bhr_512']) / data[k]['subsession_length'] * 3600. * 1000 for k in sorted_keys], np.float32) | |
plot_data_512 = moving_average(plot_data_512, 7) | |
plt.title("Content devtools Hang Stats") | |
plt.xlabel("Build date") | |
plt.ylabel("Hangs per 1000 usage hours") | |
plt.xticks(range(0, len(data))) | |
max_y = np.amax(plot_data_512) | |
plt.yticks(np.arange(0., max_y, max_y / 20.)) | |
xticks = np.arange(0, len(plot_data_2048), len(plot_data_2048) / 6) | |
plt.xticks(xticks, (sorted_keys[int(i)][4:8] for i in xticks)) | |
x1,x2,y1,y2 = plt.axis() | |
plt.axis((x1,x2,0,max_y)) | |
plt.plot(range(0, len(data)), plot_data_2048) | |
plt.plot(range(0, len(data)), plot_data_512) | |
plt.legend(["2048ms > x > 512ms", "x > 2048ms"], loc="upper left") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment