From edfe674f96e1dcb2865e66176ef0ca8bc578e8e4 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 11:24:33 -0700 Subject: [PATCH 1/8] metrics: Move remaining scripts from wip Move the remaining network metrics scripts from the wip directory in preparation for porting them. Signed-off-by: Brett T. Warden --- metrics/network/{wip => }/network-metrics-cpu-consumption.sh | 0 metrics/network/{wip => }/network-metrics-iperf3.sh | 0 metrics/network/{wip => }/network-metrics-memory-pss-1g.sh | 0 metrics/network/{wip => }/network-metrics-memory-pss.sh | 0 metrics/network/{wip => }/network-metrics-memory-rss-1g.sh | 0 metrics/network/{wip => }/network-metrics-nuttcp.sh | 0 metrics/network/{wip => }/network-metrics.sh | 0 metrics/network/{wip => }/network-nginx-ab-benchmark.sh | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename metrics/network/{wip => }/network-metrics-cpu-consumption.sh (100%) rename metrics/network/{wip => }/network-metrics-iperf3.sh (100%) rename metrics/network/{wip => }/network-metrics-memory-pss-1g.sh (100%) rename metrics/network/{wip => }/network-metrics-memory-pss.sh (100%) rename metrics/network/{wip => }/network-metrics-memory-rss-1g.sh (100%) rename metrics/network/{wip => }/network-metrics-nuttcp.sh (100%) rename metrics/network/{wip => }/network-metrics.sh (100%) rename metrics/network/{wip => }/network-nginx-ab-benchmark.sh (100%) diff --git a/metrics/network/wip/network-metrics-cpu-consumption.sh b/metrics/network/network-metrics-cpu-consumption.sh similarity index 100% rename from metrics/network/wip/network-metrics-cpu-consumption.sh rename to metrics/network/network-metrics-cpu-consumption.sh diff --git a/metrics/network/wip/network-metrics-iperf3.sh b/metrics/network/network-metrics-iperf3.sh similarity index 100% rename from metrics/network/wip/network-metrics-iperf3.sh rename to metrics/network/network-metrics-iperf3.sh diff --git a/metrics/network/wip/network-metrics-memory-pss-1g.sh b/metrics/network/network-metrics-memory-pss-1g.sh similarity index 100% rename from metrics/network/wip/network-metrics-memory-pss-1g.sh rename to metrics/network/network-metrics-memory-pss-1g.sh diff --git a/metrics/network/wip/network-metrics-memory-pss.sh b/metrics/network/network-metrics-memory-pss.sh similarity index 100% rename from metrics/network/wip/network-metrics-memory-pss.sh rename to metrics/network/network-metrics-memory-pss.sh diff --git a/metrics/network/wip/network-metrics-memory-rss-1g.sh b/metrics/network/network-metrics-memory-rss-1g.sh similarity index 100% rename from metrics/network/wip/network-metrics-memory-rss-1g.sh rename to metrics/network/network-metrics-memory-rss-1g.sh diff --git a/metrics/network/wip/network-metrics-nuttcp.sh b/metrics/network/network-metrics-nuttcp.sh similarity index 100% rename from metrics/network/wip/network-metrics-nuttcp.sh rename to metrics/network/network-metrics-nuttcp.sh diff --git a/metrics/network/wip/network-metrics.sh b/metrics/network/network-metrics.sh similarity index 100% rename from metrics/network/wip/network-metrics.sh rename to metrics/network/network-metrics.sh diff --git a/metrics/network/wip/network-nginx-ab-benchmark.sh b/metrics/network/network-nginx-ab-benchmark.sh similarity index 100% rename from metrics/network/wip/network-nginx-ab-benchmark.sh rename to metrics/network/network-nginx-ab-benchmark.sh From 115b1de1b34cda8443ce2d340cb4e36af5b7dd8b Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 12:01:13 -0700 Subject: [PATCH 2/8] metrics: add reporting to network-metrics.sh Implement results reporting to network-metrics.sh by calling save_results(). Also reworking data gathering to eliminate multiple subshells. Signed-off-by: Brett T. Warden --- metrics/network/network-metrics.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/metrics/network/network-metrics.sh b/metrics/network/network-metrics.sh index 17f5f0291..80918775d 100755 --- a/metrics/network/network-metrics.sh +++ b/metrics/network/network-metrics.sh @@ -49,10 +49,29 @@ function bidirectional_bandwidth_server_client { client_command="iperf -c ${server_address} -d -t ${time}" start_client "$extra_args" "$client_name" "$image" "$client_command" > "$result" - local total_bidirectional_server_bandwidth=$(cat $result | tail -1 | awk '{print $(NF-1), $NF}') - local total_bidirectional_client_bandwidth=$(cat $result | tail -n 2 | head -1 | awk '{print $(NF-1), $NF}') - echo "Bi-directional network bandwidth is (client to server) : $total_bidirectional_client_bandwidth" - echo "Bi-directional network bandwidth is (server to server) : $total_bidirectional_server_bandwidth" + local server_result=$(tail -1 $result) + read -a server_results <<< ${server_result%$'\r'} + local client_result=$(tail -n 2 $result | head -1) + read -a client_results <<< ${client_result%$'\r'} + + local total_bidirectional_server_bandwidth=${server_results[-2]} + local total_bidirectional_server_bandwidth_units=${server_results[-1]} + local total_bidirectional_client_bandwidth=${client_results[-2]} + local total_bidirectional_client_bandwidth_units=${client_results[-1]} + echo "Bi-directional network bandwidth is (client to server) :" \ + "$total_bidirectional_client_bandwidth" \ + "$total_bidirectional_client_bandwidth_units" + echo "Bi-directional network bandwidth is (server to client) :" \ + "$total_bidirectional_server_bandwidth" \ + "$total_bidirectional_server_bandwidth_units" + + save_results "network metrics" "client to server" \ + "$total_bidirectional_client_bandwidth" \ + "$total_bidirectional_client_bandwidth_units" + save_results "network metrics" "server to client" \ + "$total_bidirectional_server_bandwidth" \ + "$total_bidirectional_server_bandwidth_units" + clean_environment "$server_name" } From 05a189ef18b6a1020e9cd1532cf110036e793995 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 12:18:05 -0700 Subject: [PATCH 3/8] metrics: add reporting to network cpu consumption Add reporting via send_results() to network-metrics-cpu-consumption.sh. Optimize results gathering. Signed-off-by: Brett T. Warden --- metrics/network/network-metrics-cpu-consumption.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metrics/network/network-metrics-cpu-consumption.sh b/metrics/network/network-metrics-cpu-consumption.sh index 61a0f19e9..9c8ff607c 100755 --- a/metrics/network/network-metrics-cpu-consumption.sh +++ b/metrics/network/network-metrics-cpu-consumption.sh @@ -64,11 +64,13 @@ function cpu_consumption { echo >&2 "WARNING: sleeping for $middle_time seconds in order to have server and client stable" sleep ${middle_time} qemu_pids=$(pidof ${QEMU_PATH}) - ps --no-headers -o %cpu -p "$qemu_pids" > "$result" - sed -i 's/ //g' "$result" - local total_cpu_consumption=$(awk '{ total += $1 } END { print total/NR }' "$result") + local total_cpu_consumption=$(ps --no-headers -o %cpu \ + -p $(pidof ${QEMU_PATH}) | awk '{ total+= $1 } END { print total/NR }') echo "The cpu % consumption is : $total_cpu_consumption" + save_results "network metrics cpu consumption" "" \ + "$total_cpu_consumption" "%" + clean_environment "$server_name" $DOCKER_EXE rm -f ${client_name} > /dev/null } From 2c7bb599cc195d2f17452c988fa0b0a2aa85c122 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 14:34:46 -0700 Subject: [PATCH 4/8] metrics: enable reporting for iperf3 test Enable reporting via save_results() for network-metrics-iperf3.sh. Also rework parsing of results log files to reduce subshells. Signed-off-by: Brett T. Warden --- metrics/network/network-metrics-iperf3.sh | 54 +++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/metrics/network/network-metrics-iperf3.sh b/metrics/network/network-metrics-iperf3.sh index f1d56a5cb..864a62a06 100755 --- a/metrics/network/network-metrics-iperf3.sh +++ b/metrics/network/network-metrics-iperf3.sh @@ -36,6 +36,9 @@ extra_args="-ti --rm" set -e +## Test name for reporting purposes +test_name="network metrics iperf3" + # This script will perform all the measurements using a local setup using iperf3 # Test single direction TCP bandwith @@ -47,8 +50,16 @@ function iperf3_bandwidth { local client_command="mount -t ramfs -o size=20M ramfs /tmp && iperf3 -c ${server_address} -t ${time}" start_client "$extra_args" "$client_name" "$image" "$client_command" > "$result" - local total_bandwidth=$(cat $result | tail -n 3 | head -1 | awk '{print $(NF-2), $(NF-1)}') - echo "Network bandwidth is : $total_bandwidth" + local result_line=$(grep -m1 -E '\breceiver\b' $result) + local -a results + read -a results <<< $result_line + local total_bandwidth=${results[6]} + local total_bandwidth_units=${results[7]} + echo "Network bandwidth is : $total_bandwidth $total_bandwidth_units" + + save_results "${test_name}" "network bandwidth" \ + "$total_bandwidth" "$total_bandwidth_units" + clean_environment "$server_name" } @@ -61,8 +72,16 @@ function iperf3_jitter { local client_command="mount -t ramfs -o size=20M ramfs /tmp && iperf3 -c ${server_address} -u -t ${time}" start_client "$extra_args" "$client_name" "$image" "$client_command" > "$result" - local total_jitter=$(cat $result | tail -n 4 | head -1 | awk '{print $(NF-4), $(NF-3)}') - echo "Network jitter is : $total_jitter" + local result_line=$(grep -m1 -A1 -E '\bJitter\b' $result | tail -1) + local -a results + read -a results <<< $result_line + local total_jitter=${results[8]} + local total_jitter_units=${results[9]} + echo "Network jitter is : $total_jitter $total_jitter_units" + + save_results "${test_name}" "network jitter" \ + "$total_jitter" "$total_jitter_units" + clean_environment "$server_name" } @@ -75,10 +94,29 @@ function iperf3_bidirectional_bandwidth_client_server { local client_command="mount -t ramfs -o size=20M ramfs /tmp && iperf3 -c ${server_address} -d -t ${time}" start_client "$extra_args" "$client_name" "$image" "$client_command" > "$result" - local total_bidirectional_client_bandwidth=$(cat $result | tail -n 3 | head -1 | awk '{print $(NF-2), $(NF-1)}') - local total_bidirectional_server_bandwidth=$(cat $result | tail -n 4 | head -1 | awk '{print $(NF-3), $(NF-2)}') - echo "Network bidirectional bandwidth (client to server) is : $total_bidirectional_client_bandwidth" - echo "Network bidirectional bandwidth (server to client) is : $total_bidirectional_server_bandwidth" + local client_result=$(grep -m1 -E '\breceiver\b' $result) + local server_result=$(grep -m1 -E '\bsender\b' $result) + local -a client_results + read -a client_results <<< ${client_result} + read -a server_results <<< ${server_result} + local total_bidirectional_client_bandwidth=${client_results[6]} + local total_bidirectional_client_bandwidth_units=${client_results[7]} + local total_bidirectional_server_bandwidth=${server_results[6]} + local total_bidirectional_server_bandwidth_units=${server_results[7]} + echo "Network bidirectional bandwidth (client to server) is :" \ + "$total_bidirectional_client_bandwidth" \ + "$total_bidirectional_client_bandwidth_units" + echo "Network bidirectional bandwidth (server to client) is :" \ + "$total_bidirectional_server_bandwidth" \ + "$total_bidirectional_server_bandwidth_units" + + save_results "${test_name}" "network bidir bw client to server" \ + "$total_bidirectional_client_bandwidth" \ + "$total_bidirectional_client_bandwidth_units" + save_results "${test_name}" "network bidir bw server to client" \ + "$total_bidirectional_server_bandwidth" \ + "$total_bidirectional_server_bandwidth_units" + clean_environment "$server_name" } From c6baf9f74bacd544789903cd67bf9e24fbffe856 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 15:27:29 -0700 Subject: [PATCH 5/8] metrics: add reporting for nuttcp test Add results reporting for network-metrics-nuttcp.sh via save_results(). Rework data extraction from results files to reduce subshells. Signed-off-by: Brett T. Warden --- metrics/network/network-metrics-nuttcp.sh | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/metrics/network/network-metrics-nuttcp.sh b/metrics/network/network-metrics-nuttcp.sh index d2d137776..282062a7d 100755 --- a/metrics/network/network-metrics-nuttcp.sh +++ b/metrics/network/network-metrics-nuttcp.sh @@ -30,6 +30,9 @@ set -e # Test single docker->docker udp bandwidth +## Test name for reporting purposes +test_name="network metrics nuttcp" + function udp_bandwidth { # Currently default nuttcp has a bug # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745051 @@ -52,10 +55,26 @@ function udp_bandwidth { $DOCKER_EXE exec ${server_name} sh -c "${server_command}" start_client "$extra_args" "$client_name" "$image" "$client_command" > "$result" - local total_bandwidth=$(cat "$result" | tail -1 | cut -d'=' -f2 | awk '{print $(NF-11), $(NF-10)}') - local total_loss=$(cat "$result" | tail -1 | awk '{print $(NF-1), $(NF)}') - echo "UDP bandwidth is (${bl} buffer size) : $total_bandwidth" - echo "UDP % of packet loss is (${bl} buffer size) : $total_loss" +# 6, 7, 16, "%" + + local result_line=$(tail -1 ${result}) + local -a results + read -a results <<< ${result_line%$'\r'} + local total_bandwidth=${results[6]} + local total_bandwidth_units=${results[7]} + local total_loss=${results[16]} + local total_loss_units="%" + echo "UDP bandwidth is (${bl} buffer size) :" \ + "$total_bandwidth $total_bandwidth_units" + echo "UDP % of packet loss is (${bl} buffer size) :" \ + "${total_loss}${total_loss_units}" + + local subtest_name="UDP ${bl}b buffer" + save_results "${test_name}" "${subtest_name} bandwidth" \ + "$total_bandwidth" "$total_bandwidth_units" + save_results "${test_name}" "${subtest_name} packet loss" \ + "$total_loss" "$total_loss_units" + clean_environment "$server_name" } From d2b08e37cf1d73dd35d32d672910c09e5c4a032d Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 15:59:27 -0700 Subject: [PATCH 6/8] metrics: add reporting to nginx test Add results reporting to network-nginx-ab-benchmark.sh via save_results(). Rework results gathering to use fewer subshells. Signed-off-by: Brett T. Warden --- metrics/network/network-nginx-ab-benchmark.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/metrics/network/network-nginx-ab-benchmark.sh b/metrics/network/network-nginx-ab-benchmark.sh index ed4956361..0d425d1a0 100755 --- a/metrics/network/network-nginx-ab-benchmark.sh +++ b/metrics/network/network-nginx-ab-benchmark.sh @@ -69,10 +69,16 @@ function nginx_ab_networking { sleep "$sleep_secs" ab -n ${requests} -c ${concurrency} http://${url}/ > "$total_requests" - result=$(cat "$total_requests" | grep "Requests per second" | cut -d ':' -f2 | sed 's/ //g' | cut -d '[' -f1) + cp -p $total_requests result.test + + local result=$(grep "^Requests per second" $total_requests) + [[ $result =~ :[[:blank:]]*([[:digit:]]+(\.[[:digit:]]*)?) ]] && rps=${BASH_REMATCH[1]} $DOCKER_EXE rm -f ${container_name} > /dev/null rm -f "$total_requests" } nginx_ab_networking -echo "The total of requests per second is : $result" +echo "The total of requests per second is : $rps" +save_results "network nginx ab benchmark" \ + "requests=${requests} concurrency=${concurrency}" \ + "$rps" "requests/s" From f67f4759dbe1c214c541daaacecd1c95967f70f3 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 16:21:39 -0700 Subject: [PATCH 7/8] metrics: Add reporting to network memory tests Add results reporting via save_results() for: network-metrics-memory-pss-1g.sh network-metrics-memory-pss.sh network-metrics-memory-rss-1g.sh Remove unnecessary tail from output parsing. Unify smem command generation. Add --no-header to smem command line to prevent header line from being counted in average denominator. This was typically causing reported results to be 1/2 of correct value. All 3 scripts now report into a single results file (network-metrics-memory.csv), using parameters field for differentiation. Signed-off-by: Brett T. Warden --- metrics/network/network-metrics-memory-pss-1g.sh | 7 +++++-- metrics/network/network-metrics-memory-pss.sh | 6 +++++- metrics/network/network-metrics-memory-rss-1g.sh | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/metrics/network/network-metrics-memory-pss-1g.sh b/metrics/network/network-metrics-memory-pss-1g.sh index 4022cef94..f198bbb2d 100755 --- a/metrics/network/network-metrics-memory-pss-1g.sh +++ b/metrics/network/network-metrics-memory-pss-1g.sh @@ -65,11 +65,14 @@ function pss_memory { echo >&2 "WARNING: sleeping for $middle_time seconds in order to sample the PSS" sleep ${middle_time} - local memory_command="smem -c pss" - ${memory_command} -P ${QEMU_PATH} | tail -n 2 > "$result" + local memory_command="smem --no-header -c pss" + ${memory_command} -P ${QEMU_PATH} > "$result" + local memory=$(awk '{ total += $1 } END { print total/NR }' "$result") echo "The PSS memory is : $memory Kb" + save_results "network metrics memory" "pss 1g" "$memory" "kb" + echo >&2 "WARNING: This test is being affected by https://github.com/01org/cc-oci-runtime/issues/795" clean_environment "$server_name" $DOCKER_EXE rm -f ${client_name} > /dev/null diff --git a/metrics/network/network-metrics-memory-pss.sh b/metrics/network/network-metrics-memory-pss.sh index d675951d8..8abbad7fe 100755 --- a/metrics/network/network-metrics-memory-pss.sh +++ b/metrics/network/network-metrics-memory-pss.sh @@ -63,10 +63,14 @@ function pss_memory { # Measurement after client and server are more stable echo >&2 "WARNING: sleeping for $middle_time seconds in order to have server and client stable" sleep ${middle_time} - smem -c "pss" -P ${QEMU_PATH} | tail -n 2 > "$result" + local memory_command="smem --no-header -c pss" + ${memory_command} -P ${QEMU_PATH} > "$result" + local total_pss_memory=$(awk '{ total += $1 } END { print total/NR }' "$result") echo "The PSS memory is : $total_pss_memory Kb" + save_results "network metrics memory" "pss" "$total_pss_memory" "kb" + clean_environment "$server_name" $DOCKER_EXE rm -f ${client_name} > /dev/null } diff --git a/metrics/network/network-metrics-memory-rss-1g.sh b/metrics/network/network-metrics-memory-rss-1g.sh index b39c72731..e8ea31cb8 100755 --- a/metrics/network/network-metrics-memory-rss-1g.sh +++ b/metrics/network/network-metrics-memory-rss-1g.sh @@ -65,10 +65,13 @@ function rss_memory { echo >&2 "WARNING: sleeping for $middle_time seconds in order to sample the RSS" sleep ${middle_time} - local memory_command="smem -c rss" - ${memory_command} -P ${QEMU_PATH} | tail -n 2 > "$result" + local memory_command="smem --no-header -c rss" + ${memory_command} -P ${QEMU_PATH} > "$result" + local memory=$(awk '{ total += $1 } END { print total/NR }' "$result") echo "The RSS memory is : $memory Kb" + + save_results "network metrics memory" "rss 1g" "$memory" "kb" echo >&2 "WARNING: This test is being affected by https://github.com/01org/cc-oci-runtime/issues/795" clean_environment "$server_name" From b49d7e9b711b209616a7e56a4e9170595f14f307 Mon Sep 17 00:00:00 2001 From: "Brett T. Warden" Date: Mon, 14 Aug 2017 16:38:31 -0700 Subject: [PATCH 8/8] metrics: Add network metrics to run_all_metrics Add the now-ported network metrics tests to the run_all_metrics.sh script. Fixes #149. Signed-off-by: Brett T. Warden --- metrics/run_all_metrics.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metrics/run_all_metrics.sh b/metrics/run_all_metrics.sh index 5062b5cf6..34158af61 100755 --- a/metrics/run_all_metrics.sh +++ b/metrics/run_all_metrics.sh @@ -33,3 +33,11 @@ bash ${SCRIPT_PATH}/time/docker_workload_time.sh true busybox $RUNTIME 100 # Run the network metrics bash ${SCRIPT_PATH}/network/network-latency.sh +bash ${SCRIPT_PATH}/network/network-metrics-cpu-consumption.sh +bash ${SCRIPT_PATH}/network/network-metrics-iperf3.sh +bash ${SCRIPT_PATH}/network/network-metrics-memory-pss-1g.sh +bash ${SCRIPT_PATH}/network/network-metrics-memory-pss.sh +bash ${SCRIPT_PATH}/network/network-metrics-memory-rss-1g.sh +bash ${SCRIPT_PATH}/network/network-metrics-nuttcp.sh +bash ${SCRIPT_PATH}/network/network-metrics.sh +bash ${SCRIPT_PATH}/network/network-nginx-ab-benchmark.sh