Skip to content

Improve fireci CLI for macrobenchmark #4359

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

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ci/fireci/fireciplugins/macrobenchmark/analyze/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def mapper(quantile: float) -> str: return f'p{int(quantile * 100)}'

# Optionally save percentiles and dispersions to file
if output_dir:
output_dir.mkdir(parents=True, exist_ok=True)
percentiles.to_json(output_dir.joinpath('percentiles.json'), orient='index')
dispersions.to_json(output_dir.joinpath('dispersions.json'), orient='index')
logger.info(f'Percentiles and dispersions saved in: {output_dir}')
Expand All @@ -63,8 +64,8 @@ def calculate_statistic_diff(
):
logger.info(f'Calculating statistic diff for trace "{trace}" on device "{device}" ...')

ctl_percentiles, _ = calculate_statistic(trace, device, control)
exp_percentiles, _ = calculate_statistic(trace, device, experimental)
ctl_percentiles, _ = calculate_statistic(trace, device, control, output_dir.joinpath("ctl"))
exp_percentiles, _ = calculate_statistic(trace, device, experimental, output_dir.joinpath("exp"))

ctl_mean = ctl_percentiles.mean()
exp_mean = exp_percentiles.mean()
Expand All @@ -74,6 +75,7 @@ def calculate_statistic_diff(

# Optionally save statistics to file
if output_dir:
output_dir.mkdir(parents=True, exist_ok=True)
delta.to_json(output_dir.joinpath('delta.json'))
percentage.to_json(output_dir.joinpath('percentage.json'))
logger.info(f'Percentiles diff saved in: {output_dir}')
2 changes: 0 additions & 2 deletions ci/fireci/fireciplugins/macrobenchmark/analyze/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _process(data_points: List[DataPoint], output_dir: Path) -> None:
with progressbar(trace_device_combinations) as combinations:
for trace, device in combinations:
combination_dir = output_dir.joinpath(trace, device)
combination_dir.mkdir(parents=True, exist_ok=True)
subset = _filter_subset(data, trace, device)
calculate_statistic(trace, device, subset, combination_dir)
plot_graph(trace, device, subset, combination_dir)
Expand All @@ -88,7 +87,6 @@ def _diff(
with progressbar(trace_device_combinations) as combinations:
for trace, device in combinations:
combination_dir = output_dir.joinpath(trace, device)
combination_dir.mkdir(parents=True, exist_ok=True)

ctl_subset = _filter_subset(ctl_data, trace, device)
exp_subset = _filter_subset(exp_data, trace, device)
Expand Down
8 changes: 8 additions & 0 deletions ci/fireci/fireciplugins/macrobenchmark/analyze/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import logging
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
Expand All @@ -27,20 +28,24 @@
def plot_graph(trace: str, device: str, data: pd.DataFrame, output_dir: Path):
logger.info(f'Plotting graphs for trace "{trace}" on device "{device}" ...')

output_dir.mkdir(parents=True, exist_ok=True)

unique_run_ids = len(data['run_id'].unique())
col_wrap = int(np.ceil(np.sqrt(unique_run_ids)))

histograms = sns.displot(data=data, x='duration', kde=True, col="run_id", col_wrap=col_wrap)
histograms.set_axis_labels(x_var=f'{trace} (ms)')
histograms.set_titles(f'{device} ({{col_var}} = {{col_name}})')
histograms.savefig(output_dir.joinpath('histograms.svg'))
plt.close(histograms.fig)

distributions = sns.displot(
data=data, x='duration', kde=True, height=8,
hue='run_id', palette='muted', multiple='dodge'
)
distributions.set_axis_labels(x_var=f'{trace} (ms)').set(title=device)
distributions.savefig(output_dir.joinpath('distributions.svg'))
plt.close(distributions.fig)

logger.info(f'Graphs saved in: {output_dir}')

Expand All @@ -54,6 +59,8 @@ def plot_diff_graph(
):
logger.info(f'Plotting distribution diff graph for trace "{trace}" on device "{device}" ...')

output_dir.mkdir(parents=True, exist_ok=True)

control_run_ids = control['run_id']
experimental_run_ids = experimental['run_id']
all_data = pd.concat([control, experimental])
Expand All @@ -66,5 +73,6 @@ def plot_diff_graph(
)
distribution_diff.set_axis_labels(x_var=f'{trace} (ms)').set(title=device)
distribution_diff.savefig(output_dir.joinpath('distribution_diff.svg'))
plt.close(distribution_diff.fig)

logger.info(f'Graph saved in: {output_dir}')
2 changes: 1 addition & 1 deletion ci/fireci/fireciplugins/macrobenchmark/run/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def run(index: int, run_id: str) -> str:
args += ['--type', 'instrumentation']
args += ['--app', app_apk_path]
args += ['--test', test_apk_path]
args += ['--device', 'model=oriole,version=32,locale=en,orientation=portrait']
args += ['--device', 'model=redfin,version=30,locale=en,orientation=portrait']
args += ['--directories-to-pull', '/sdcard/Download']
args += ['--results-bucket', 'fireescape-benchmark-results']
args += ['--results-dir', run_id]
Expand Down
4 changes: 4 additions & 0 deletions ci/fireci/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ console_scripts =
strict_optional = False
[mypy-google.cloud]
ignore_missing_imports = True
[mypy-matplotlib]
ignore_missing_imports = True
[mypy-matplotlib.pyplot]
ignore_missing_imports = True
[mypy-pandas]
ignore_missing_imports = True
[mypy-pystache]
Expand Down