from IPython.core.interactiveshell import InteractiveShell
from IPython.display import display, Markdown, SVG, HTML
import pandas as pd
import altair as alt
import re
import pickle
from utils import seconds_to_ms, ms_to_seconds
from benchmark_result import get_benchmark_results,get_time_n_tasks_source, get_no_delay_source, BenchmarkType, SchedulerType, get_broad_cast_source, get_echo_many_arguments_source
from benchmarks.utils import echo
from benchmarks.overhead_latency import echo_many_arguments
InteractiveShell.ast_node_interactivity = "all"
#benchmark_results = get_benchmark_results()
from benchmark_result import BenchmarkResult, Result
with open('saved_results.pkl', 'rb') as saved_results:
benchmark_results = pickle.load(saved_results)
The first benchmark comes from benchmarking the runtime of sending n tasks to m engines. Where the each task is just the echo function.
??echo
source = get_time_n_tasks_source(benchmark_results)
for delay, result_for_delay in source.items():
display(Markdown(f'### With a delay of {ms_to_seconds(delay)}s. :'))
for core_num, results in sorted(result_for_delay.items(), key=lambda key: key[0]):
display(Markdown(f'#### {core_num} cores:'))
alt.Chart(
pd.DataFrame(results['direct_view'])
).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
y='Duration in ms',
color='Number of engines:N',
tooltip='Duration in ms'
).properties(
title=f'DirectView',
width=800
).interactive().display(renderer='svg')
alt.Chart(
pd.DataFrame(results['load_balanced'])
).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
y='Duration in ms',
color='Number of engines:N',
tooltip='Duration in ms'
).properties(
title=f'Load Balanced',
width=800
).interactive().display(renderer='svg')
no_delay_source = get_no_delay_source(benchmark_results)
display(Markdown(f'### With no delay and 100 engines:'))
data = pd.DataFrame(no_delay_source[BenchmarkType.TIME_N_TASKS_NO_DELAY]['direct_view'])
alt.Chart(data).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
color='Number of cores:N',
y='Duration in ms',
tooltip='Duration in ms',
).properties(title=f'Ran with no delay on 100 engines Direct View', width=800).interactive().display(renderer='svg')
data = pd.DataFrame(no_delay_source[BenchmarkType.TIME_N_TASKS_NO_DELAY]['load_balanced'])
alt.Chart(data).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
color='Number of cores:N',
y='Duration in ms',
tooltip='Duration in ms',
).properties(title=f'Ran with no delay on 100 engines Load Balanced', width=800).interactive().display(renderer='svg')
display(Markdown(f'### With no delay and non-blocking map on 100 engines:'))
data = pd.DataFrame(no_delay_source[BenchmarkType.TIME_N_TASKS_NO_DELAY_NON_BLOCKING]['direct_view'])
alt.Chart(data).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
color='Number of cores:N',
y='Duration in ms',
tooltip='Duration in ms',
).properties(title=f'Ran with no delay on 100 engines Direct View', width=800).interactive().display(renderer='svg')
data = pd.DataFrame(no_delay_source[BenchmarkType.TIME_N_TASKS_NO_DELAY_NON_BLOCKING]['load_balanced'])
alt.Chart(data).mark_line(point=True).encode(
alt.X(
'Number of tasks',
scale=alt.Scale(type='log')
),
color='Number of cores:N',
y='Duration in ms',
tooltip='Duration in ms',
).properties(title=f'Ran with no delay on 100 engines Load Balanced', width=800).interactive().display(renderer='svg')
The second benchmark comes from benchmarking the runtime of sending and array of n bytes to m engines.
from benchmarks.throughput import NumpyArrayBroadcast
NumpyArrayBroadcast.time_broadcast??
source = get_broad_cast_source(benchmark_results)
for core_num, results in sorted(source.items(), key=lambda key: key[0]):
data = pd.DataFrame(results)
alt.Chart(data).mark_line(point=True).encode(
alt.X(
'Number of bytes',
scale=alt.Scale(type='log')
),
y='Duration in ms',
color='Number of engines:N',
tooltip='Duration in ms',
).properties(title=f'Broadcast benchmark running on {core_num} cores with Direct View', width=800).interactive().display(renderer='svg')
??echo_many_arguments
source = get_echo_many_arguments_source(benchmark_results)
display(Markdown(f'### With non-blocking map on {source["number_of_engines"]} engines:'))
display(Markdown(f'#### {core_num} cores:'))
alt.Chart(
pd.DataFrame(source['direct_view'])
).mark_line(point=True).encode(
alt.X(
'Number of arguments',
scale=alt.Scale(type='log')
),
y='Duration in ms',
color='Number of cores:N',
tooltip='Duration in ms'
).properties(
title=f'DirectView',
width=800
).interactive().display(renderer='svg')
alt.Chart(
pd.DataFrame(source['load_balanced'])
).mark_line(point=True).encode(
alt.X(
'Number of arguments',
scale=alt.Scale(type='log')
),
y='Duration in ms',
color='Number of cores:N',
tooltip='Duration in ms'
).properties(
title=f'Load Balanced',
width=800
).interactive().display(renderer='svg')