-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added middleware configs and some scripts to ease CI jobs for benchma…
…rking and improve user experience (#19) * Added scripts related to visualization, running benchmarks etc. * Improved run_all_benchmarks script and fixed some typos in this script * Added basic service client benchmark to run_all_benchmarks.sh * Added documentations for scripts and made the configs for rmw_zenoh enabled * Fixed typo in documentation * Removed the unnecessary parameter (-m) from run_all_benchmarks.sh * Modified benchmark_args in run_all_benchmarks.sh and some style fix * Added title section per plot and used dot instead of sh for running initial_script * Delete unnecessary middleware_benchmark_results.json file * Update docs/how_to_run.md for directing to how_to_install Co-authored-by: Henning Kayser <[email protected]> * Update docs/how_to_run.md for middleware-configuration related section Co-authored-by: Henning Kayser <[email protected]> --------- Co-authored-by: Henning Kayser <[email protected]>
- Loading branch information
1 parent
1bb5917
commit b554c90
Showing
7 changed files
with
210 additions
and
0 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
echo "The configurations for rmw_cyclonedds_cpp is started!" | ||
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
echo "The configurations for rmw_cyclonedds_cpp is finished!" |
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,3 @@ | ||
echo "The configurations for rmw_fastrtps_cpp is started!" | ||
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp | ||
echo "The configurations for rmw_fastrtps_cpp is finished!" |
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,6 @@ | ||
echo "The configurations for rmw_zenoh_cpp is started!" | ||
export RMW_IMPLEMENTATION=rmw_zenoh_cpp | ||
sudo sysctl -w "net.ipv4.tcp_rmem=4096 4096 4096" | ||
sudo sysctl -w "net.ipv4.tcp_wmem=4096 4096 4096" | ||
sudo sysctl -w "net.ipv4.tcp_mem=4096 4096 4096" | ||
echo "The configurations for rmw_zenoh_cpp is finished!" |
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,77 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import json | ||
import os | ||
import sys | ||
|
||
BENCHMARK_RESULTS_DIR = sys.argv[1] | ||
|
||
middleware_colors = { | ||
"rmw_zenoh_cpp": "orange", | ||
"rmw_cyclonedds_cpp": "peachpuff", | ||
"rmw_fastrtps_cpp": "tomato", | ||
} | ||
|
||
middleware_list = ["rmw_zenoh_cpp", "rmw_cyclonedds_cpp", "rmw_fastrtps_cpp"] | ||
|
||
|
||
def read_benchmark_json(file_name): | ||
benchmark_json_data = None | ||
with open(file_name) as f: | ||
benchmark_json_data = json.load(f) | ||
return benchmark_json_data | ||
|
||
|
||
def get_real_time_list_from_benchmark_json(benchmark_json_data): | ||
real_time_list = [] | ||
for benchmark_info in benchmark_json_data["benchmarks"]: | ||
if benchmark_info["run_type"] == "iteration": | ||
real_time_list.append(benchmark_info["real_time"]) | ||
return real_time_list | ||
|
||
|
||
def get_middleware_dataset_for_scenario(scenario_name): | ||
middleware_datasets = [] | ||
for middleware_name in middleware_list: | ||
file_name = os.path.join( | ||
BENCHMARK_RESULTS_DIR, scenario_name, f"{middleware_name}.json" | ||
) | ||
benchmark_json_data = read_benchmark_json(file_name) | ||
dataset = get_real_time_list_from_benchmark_json(benchmark_json_data) | ||
middleware_datasets.append( | ||
{ | ||
"name": middleware_name, | ||
"dataset": dataset, | ||
"color": middleware_colors[middleware_name], | ||
} | ||
) | ||
return middleware_datasets | ||
|
||
|
||
def plot_dataset_of_scenario(plt, scenario_name, middleware_datasets): | ||
labels = [] | ||
colors = [] | ||
datasets = [] | ||
|
||
for x in middleware_datasets: | ||
labels.append(x["name"]) | ||
colors.append(x["color"]) | ||
datasets.append(x["dataset"]) | ||
|
||
fig, ax = plt.subplots() | ||
ax.set_title(scenario_name) | ||
ax.set_ylabel("real time (ns)") | ||
ax.set_xlabel("middlewares") | ||
|
||
bplot = ax.boxplot(datasets, patch_artist=True, tick_labels=labels) | ||
|
||
# fill with colors | ||
for patch, color in zip(bplot["boxes"], colors): | ||
patch.set_facecolor(color) | ||
|
||
|
||
for scenario_name in os.listdir(BENCHMARK_RESULTS_DIR): | ||
middleware_datasets = get_middleware_dataset_for_scenario(scenario_name) | ||
plot_dataset_of_scenario(plt, scenario_name, middleware_datasets) | ||
|
||
plt.show() |
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,40 @@ | ||
# Inspired from https://unix.stackexchange.com/questions/31414/how-can-i-pass-a-command-line-argument-into-a-shell-script | ||
helpFunction() | ||
{ | ||
echo "" | ||
echo "Usage: $0 -i initial_script -d benchmark_results_directory" | ||
echo -i "\t-i initial_script to run once all benchmarks are started" | ||
echo -d "\t-d the directory the benchmark results is saved" | ||
exit 1 # Exit script after printing help | ||
} | ||
|
||
while getopts "i:m:d:" opt | ||
do | ||
case "$opt" in | ||
i ) initial_script="$OPTARG" ;; | ||
d ) benchmark_results_directory="$OPTARG" ;; | ||
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent | ||
esac | ||
done | ||
|
||
# Print helpFunction in case parameters are empty | ||
if [ -z "$initial_script" ] || [ -z "$benchmark_results_directory" ] | ||
then | ||
echo "Some or all of the parameters are empty"; | ||
helpFunction | ||
fi | ||
|
||
echo "benchmark results directory is $benchmark_results_directory" | ||
|
||
echo "Benchmarking is starting!" | ||
echo "Starting initial scripts before benchmarks run!" | ||
. "$initial_script" | ||
echo "Initial script has finished! Now starting to benchmark middleware with scenarios!" | ||
|
||
mkdir ${benchmark_results_directory}/scenario_basic_service_client -p | ||
ros2 daemon stop | ||
ros2 launch moveit_middleware_benchmark scenario_basic_service_client_benchmark.launch.py benchmark_command_args:="--benchmark_out=${benchmark_results_directory}/scenario_basic_service_client/${RMW_IMPLEMENTATION}.json --benchmark_out_format=json --benchmark_repetitions=6" | ||
|
||
mkdir ${benchmark_results_directory}/scenario_perception_pipeline -p | ||
ros2 daemon stop | ||
ros2 launch moveit_middleware_benchmark scenario_perception_pipeline_benchmark.launch.py benchmark_command_args:="--benchmark_out=${benchmark_results_directory}/scenario_perception_pipeline/${RMW_IMPLEMENTATION}.json --benchmark_out_format=json --benchmark_repetitions=6" |