-
Notifications
You must be signed in to change notification settings - Fork 4
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
Hook the benchmark runner and benchmark visualizations into GitHub #30
Draft
petervdonovan
wants to merge
15
commits into
main
Choose a base branch
from
automated-full-benchmark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+177
−17
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
355fabe
Make automated benchmarks easier.
petervdonovan d0916fd
Produce image URI.
petervdonovan 7821ae2
Add matplotlib dependency.
petervdonovan 725e881
Do not produce image URI.
petervdonovan 849d482
Allow multiple source paths.
petervdonovan b852700
Make legend more precise in graph.
petervdonovan 600f68b
Update make-graphics.py.
petervdonovan e1b7b27
Make legend more readable.
petervdonovan f0e10de
Respect the timeout parameter.
petervdonovan 04273d2
Include stack trace in timeout error message.
petervdonovan 76aeaec
Repair subprocess I/O.
petervdonovan 6a6d73e
Disable stacktrace by default.
petervdonovan c210de2
Re-apply suppression of empty lines.
petervdonovan fee71c1
Roll back unnecessary change.
petervdonovan 6a6447d
Repair collect_results.csv.
petervdonovan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from typing import Iterable, List, Tuple | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import matplotlib | ||
import numpy as np | ||
import argparse | ||
|
||
DEFAULT_YLIM = 1000 | ||
|
||
FONT = {"family": "serif", "size": 18} | ||
LARGE_FONT = 28 | ||
|
||
STYLES = [ | ||
("o", "yellow", "orange"), | ||
("*", "brown", "brown"), | ||
("x", "teal", "teal"), | ||
("+", "pink", "red"), | ||
("*", "magenta", "magenta"), | ||
("v", "blue", "purple"), | ||
(".", "orange", "orange"), | ||
("x", "cyan", "green"), | ||
] | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("src_paths", nargs="+") | ||
parser.add_argument("out_path") | ||
parser.add_argument("--uri", dest="uri", action="store_true") | ||
args = parser.parse_args() | ||
df = load_df(args.src_paths) | ||
render(df, args.out_path) | ||
|
||
|
||
def load_df(src_paths: List[str]) -> pd.DataFrame: | ||
dataframes = [] | ||
for src_path in src_paths: | ||
dataframes.append(pd.read_csv(src_path)) | ||
dataframes[-1]["src_path"] = [src_path] * len(dataframes[-1].index) | ||
df = pd.concat(dataframes) | ||
df["runtime_version"] = [ | ||
f"{target.replace('lf-', '').upper()} {scheduler}{src_path.split('.')[0].split('-')[-1]}" | ||
for src_path, scheduler, target in zip( | ||
df.src_path, | ||
( | ||
[ scheduler + " " for scheduler in df.scheduler ] | ||
if "scheduler" in df.columns else [""] * len(df.index) | ||
), | ||
df.target | ||
) | ||
] | ||
return df | ||
|
||
|
||
def compute_legend(runtime_versions: Iterable[str]) -> List[Tuple[str, str, str, str]]: | ||
assert len(STYLES) >= len(runtime_versions) | ||
return [(a, *b) for a, b in zip(runtime_versions, STYLES)] | ||
|
||
|
||
def render(df: pd.DataFrame, out_path: str): | ||
matplotlib.rc("font", **FONT) | ||
fig, axes = plt.subplots(6, 4) | ||
fig.set_size_inches(30, 45) | ||
axes = axes.ravel() | ||
x = sorted(list(df.threads.unique())) | ||
df_numbers = df[np.isfinite(df.mean_time_ms)] | ||
for ax, benchmark in zip(axes, sorted(list(df.benchmark.unique()))): | ||
df_benchmark = df_numbers[df_numbers.benchmark == benchmark] | ||
top = 1.3 * df_benchmark[np.isfinite(df_benchmark.mean_time_ms)].mean_time_ms.max() | ||
if pd.isna(top): | ||
top = DEFAULT_YLIM | ||
for version, marker, linecolor, markercolor in compute_legend( | ||
df.runtime_version.unique() | ||
): | ||
df_benchmark_scheduler = df_benchmark[ | ||
df_benchmark.runtime_version == version | ||
] | ||
ax.set_title(benchmark) | ||
ax.set_xticks(x) | ||
ax.set_ylim(bottom=0, top=top) | ||
(line,) = ax.plot( | ||
x, | ||
[ | ||
df_benchmark_scheduler[ | ||
df_benchmark_scheduler.threads == threads | ||
].mean_time_ms.mean() | ||
for threads in x | ||
], | ||
marker=marker, | ||
ms=12, | ||
linewidth=2, | ||
c=linecolor, | ||
markeredgecolor=markercolor, | ||
) | ||
line.set_label(version) | ||
ax.legend() | ||
ax = fig.add_subplot(111, frameon=False) | ||
ax.xaxis.label.set_fontsize(LARGE_FONT) | ||
ax.yaxis.label.set_fontsize(LARGE_FONT) | ||
ax.title.set_fontsize(LARGE_FONT) | ||
ax.set_facecolor("white") | ||
plt.rc("font", size=LARGE_FONT) | ||
plt.tick_params(labelcolor="none", top=False, bottom=False, left=False, right=False) | ||
plt.title("Comparison of Scheduler Versions\n") | ||
plt.xlabel("Number of Threads") | ||
plt.ylabel("Mean Time (milliseconds)\n") | ||
fig.patch.set_facecolor("white") | ||
fig.savefig(out_path, transparent=False) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
hydra-core>=1.2.0 | ||
cogapp | ||
matplotlib | ||
pandas |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide some context on why you changes this and what exactly it does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to read the output of the process in a non-blocking way so that we could capture the stack trace of the running process before killing it. By default, the stack trace is captured because the user may not have eu-stack, but I wanted this feature so that ideally, it might be possible to debug a deadlock in CI without having to manually run the executable hundreds of times.