From cafe9c66c3fe600fb51a762894741fe7510ff7f0 Mon Sep 17 00:00:00 2001 From: jparisu Date: Fri, 30 Sep 2022 09:58:39 +0200 Subject: [PATCH 1/3] Memory usage performance test Signed-off-by: jparisu --- test/CMakeLists.txt | 1 + test/performance/CMakeLists.txt | 16 + .../memory_usage/run_memory_usage_test.sh | 297 ++++++++++++++++++ 3 files changed, 314 insertions(+) create mode 100644 test/performance/CMakeLists.txt create mode 100644 test/performance/memory_usage/run_memory_usage_test.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74e55f214..a323c78b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,3 +14,4 @@ add_subdirectory(unittest) add_subdirectory(dds/communication) +add_subdirectory(performance) diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt new file mode 100644 index 000000000..f6e6b0367 --- /dev/null +++ b/test/performance/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TODO uncomment +# add_subdirectory(memory_usage) diff --git a/test/performance/memory_usage/run_memory_usage_test.sh b/test/performance/memory_usage/run_memory_usage_test.sh new file mode 100644 index 000000000..3c43f450f --- /dev/null +++ b/test/performance/memory_usage/run_memory_usage_test.sh @@ -0,0 +1,297 @@ +#!/bin/bash + +############################################################ +# Script Arguments +############################################################ + +WORKSPACE_DIR=$(pwd) +FASTDDS_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/BasicConfigurationExample/BasicConfigurationExample" +BACKEND_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/HelloWorldExampleHelloWorldExample" + +RESULT_PAHT='./result' +RESULT_FILE="memory_usage.csv" +MEASURAMENT_RATE=0.2 +LIBRARIES_TO_MEASURE="libfastcdr libfastrtps libfastdds_statistics_backend stack heap anon" + +ENTITIES_LOOP_ITERATIONS=2 +ENTITIES_LOOP_ELAPSED=10 +ENTITIES_IN_LOOP=3 +STATISTIC_TOPICS="HISTORY_LATENCY_TOPIC;NETWORK_LATENCY_TOPIC;PUBLICATION_THROUGHPUT_TOPIC;SUBSCRIPTION_THROUGHPUT_TOPIC;RTPS_SENT_TOPIC;RTPS_LOST_TOPIC;HEARTBEAT_COUNT_TOPIC;ACKNACK_COUNT_TOPIC;NACKFRAG_COUNT_TOPIC;GAP_COUNT_TOPIC;DATA_COUNT_TOPIC;RESENT_DATAS_TOPIC;SAMPLE_DATAS_TOPIC;PDP_PACKETS_TOPIC;EDP_PACKETS_TOPIC;DISCOVERY_TOPIC;PHYSICAL_DATA_TOPIC" +SLEEP_RESIDUAL_TIME=2 + +PUBLICATION_RATE=10 +NUMBER_OF_TOPICS=2 + + +############################################################ +# Functions needed in script +############################################################ + +# TODO comment +get_memory_usage_from_library () { + # Get arguments + PID_=${1} + LIBRARY_NAME_=${2} + + RESULT_=0 + + # Get lines of pmap to check if they exist, if not while call fails + PMAP_RESULT_="$(pmap ${PID_} | grep ${LIBRARY_NAME_})" + + # If there are lines, analyze them + if [ ! -z "$PMAP_RESULT_" ]; + then + + # For each line, get the memory value and add it to RESULT + while read -r line; do + + LINE_=${line} + + NEW_VALUE_WITH_K_="$(echo -n "${LINE_}" | awk '{print $2}')" + + NEW_VALUE_="$(echo -n "${NEW_VALUE_WITH_K_::-1}")" + + RESULT_=$((${RESULT_}+${NEW_VALUE_})) + + done <<< "$(pmap ${PID_} | grep ${LIBRARY_NAME_})" + + fi + + # Return the final result (0 if no library in pmap) + echo -n "${RESULT_}" +} + +# TODO comment +print_memory_usage () { + # Get arguments + PID_=${1} + LIBRARY_NAMES_=${2} + RESULT_FILE_=${3} + + echo "Storing in ${RESULT_FILE_} memory usage from process ${PID_}" + + # Print time + CURRENT_TIME_="$(date +%s%3N)" + echo -n "${CURRENT_TIME_}" >> ${RESULT_FILE_} + echo -n ";" >> ${RESULT_FILE_} + + # Print library memory usage for each library + for library in ${LIBRARY_NAMES_}; + do + get_memory_usage_from_library ${PID_} ${library} >> ${RESULT_FILE_} + echo -n ";" >> ${RESULT_FILE_} + done + + # Print total + TOTAL_MEMORY_USAGE_="$(pmap ${PID_} | tail -n 1 | awk '/[0-9]/K{print $2}')" + # If there are lines, analyze them + if [ ! -z "$PMAP_RESULT_" ]; + then + echo -n "${TOTAL_MEMORY_USAGE_::-1}" >> ${RESULT_FILE_} + else + echo -n "-" >> ${RESULT_FILE_} + fi + + echo "" >> ${RESULT_FILE_} +} + + +############################################################ +# Parse arguments +############################################################ + +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + + case $key in + --workspace) + WORKSPACE_DIR="$2" + shift # past argument + shift # past value + ;; + --fastdds) + FASTDDS_EXAMPLE_EXECUTABLE="$2" + shift # past argument + shift # past value + ;; + --backend) + BACKEND_EXAMPLE_EXECUTABLE="$2" + shift # past argument + shift # past value + ;; + + --result-path) + RESULT_PAHT="$2" + shift # past argument + shift # past value + ;; + --result-file) + RESULT_FILE="$2" + shift # past argument + shift # past value + ;; + --measurament-rate) + MEASURAMENT_RATE="$2" + shift # past argument + shift # past value + ;; + --measurament-libraries) + LIBRARIES_TO_MEASURE="$2" + shift # past argument + shift # past value + ;; + + --loop-iterations) + ENTITIES_LOOP_ITERATIONS="$2" + shift # past argument + shift # past value + ;; + --loop-elapsed) + ENTITIES_LOOP_ELAPSE="$2" + shift # past argument + shift # past value + ;; + --loop-entities) + ENTITIES_IN_LOOP="$2" + shift # past argument + shift # past value + ;; + --statistics) + STATISTIC_TOPICS="$2" + shift # past argument + shift # past value + ;; + --residual-time) + SLEEP_RESIDUAL_TIME="$2" + shift # past argument + shift # past value + ;; + + --publication-rate) + PUBLICATION_RATE="$2" + shift # past argument + shift # past value + ;; + --n-topics) + NUMBER_OF_TOPICS="$2" + shift # past argument + shift # past value + ;; + + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +read -ra ARGS <<< "${EXPERIMENT_ARGS}" + +############################################################ +# Initialize values +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo "Starting execution" +echo "---------------------------------------------------------------------------" +echo + +RESULT_FILE_PATH=${RESULT_PAHT}/${RESULT_FILE} + + +############################################################ +# Prepare result path and file +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo "Initializing result file ${RESULT_FILE_PATH}" +echo "---------------------------------------------------------------------------" +echo + +mkdir -p ${RESULT_PAHT} +# Remove file if exists +rm -f ${RESULT_FILE_PATH} +# Initialize file with header. First time +echo -n "time(ms);" > ${RESULT_FILE_PATH} +# Then each of the libraries to measure +for lib in ${LIBRARIES_TO_MEASURE}; +do + echo -n "${lib};" >> ${RESULT_FILE_PATH} +done +# Finally total +echo "total(KB)" >> ${RESULT_FILE_PATH} + + +############################################################ +# Execute backend example +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo "Executing Fast DDS Statistics Backend exaple ${BACKEND_EXAMPLE_EXECUTABLE}" +echo "---------------------------------------------------------------------------" +echo + +${BACKEND_EXAMPLE_EXECUTABLE} monitor --time=1000 & +# ${BACKEND_EXAMPLE_EXECUTABLE} monitor --time=1000 > /dev/null 2>&1 & +BACKEND_EXAMPLE_PID=$! + + +############################################################ +# Start loop to calculate times and execute fastdds entities +############################################################ + +# Store memory usage measure +print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + +for i in $(seq 1 ${ENTITIES_LOOP_ITERATIONS}); +do + + echo + echo "---------------------------------------------------------------------------" + echo "Executing Fast DDS Entities for ${i} time" + echo "---------------------------------------------------------------------------" + echo + + # Excute as many entities as required + # TODO + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} publisher --interval ${PUBLICATION_RATE} --topic "TestTopic${i}" > /dev/null 2>&1 & + PUBLISHER_PID=$! + sleep ${SLEEP_RESIDUAL_TIME} + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} subscriber --topic "TestTopic${i}" > /dev/null 2>&1 & + SUBSCRIBER_PID=$! + sleep ${SLEEP_RESIDUAL_TIME} + + # Store memory usage measure + print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + + # Sleep for some time + sleep ${ENTITIES_LOOP_ELAPSED} + + # Store memory usage measure + print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + + # Kill entities + echo "Killing Fast DDS Entities" + kill ${PUBLISHER_PID} + kill ${SUBSCRIBER_PID} + + # Store memory usage measure + sleep ${SLEEP_RESIDUAL_TIME} + print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + +done + +############################################################ +# Finish execution +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo "Finishing execution" +echo "---------------------------------------------------------------------------" +echo + +# Kill backend example process +kill ${BACKEND_EXAMPLE_PID} From 34c4112e53e37af50d653e43eebca58c1e6f4b2f Mon Sep 17 00:00:00 2001 From: jparisu Date: Mon, 3 Oct 2022 14:22:26 +0200 Subject: [PATCH 2/3] Final implementation with RSS Signed-off-by: jparisu --- .../memory_usage/run_memory_usage_test.sh | 112 +++++++++++------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/test/performance/memory_usage/run_memory_usage_test.sh b/test/performance/memory_usage/run_memory_usage_test.sh index 3c43f450f..b8a8b0b2d 100644 --- a/test/performance/memory_usage/run_memory_usage_test.sh +++ b/test/performance/memory_usage/run_memory_usage_test.sh @@ -1,32 +1,41 @@ #!/bin/bash +# How to launch from a colcon workspace: +# bash ./src/fastdds_statistics_backend/test/performance/memory_usage/run_memory_usage_test.sh --fastdds ./build/fastrtps/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --backend ./build/fastdds_statistics_backend/examples/cpp/HelloWorldExample/HelloWorldExample + ############################################################ # Script Arguments ############################################################ WORKSPACE_DIR=$(pwd) FASTDDS_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/BasicConfigurationExample/BasicConfigurationExample" -BACKEND_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/HelloWorldExampleHelloWorldExample" +BACKEND_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/HelloWorldExample/HelloWorldExample" RESULT_PAHT='./result' -RESULT_FILE="memory_usage.csv" -MEASURAMENT_RATE=0.2 +RESULT_FILE="backend_memory_usage.csv" LIBRARIES_TO_MEASURE="libfastcdr libfastrtps libfastdds_statistics_backend stack heap anon" -ENTITIES_LOOP_ITERATIONS=2 -ENTITIES_LOOP_ELAPSED=10 +ENTITIES_LOOP_ITERATIONS=5 +ENTITIES_LOOP_ELAPSED=30 ENTITIES_IN_LOOP=3 STATISTIC_TOPICS="HISTORY_LATENCY_TOPIC;NETWORK_LATENCY_TOPIC;PUBLICATION_THROUGHPUT_TOPIC;SUBSCRIPTION_THROUGHPUT_TOPIC;RTPS_SENT_TOPIC;RTPS_LOST_TOPIC;HEARTBEAT_COUNT_TOPIC;ACKNACK_COUNT_TOPIC;NACKFRAG_COUNT_TOPIC;GAP_COUNT_TOPIC;DATA_COUNT_TOPIC;RESENT_DATAS_TOPIC;SAMPLE_DATAS_TOPIC;PDP_PACKETS_TOPIC;EDP_PACKETS_TOPIC;DISCOVERY_TOPIC;PHYSICAL_DATA_TOPIC" SLEEP_RESIDUAL_TIME=2 PUBLICATION_RATE=10 -NUMBER_OF_TOPICS=2 +RESET_BACKEND=" " +BUMP_BACKEND=" " +DEBUG=0 ############################################################ # Functions needed in script ############################################################ +# pmap result: +# column 1: Initial memory address +# column 2: Virtual memory +# column 3: RSS + # TODO comment get_memory_usage_from_library () { # Get arguments @@ -47,13 +56,16 @@ get_memory_usage_from_library () { LINE_=${line} - NEW_VALUE_WITH_K_="$(echo -n "${LINE_}" | awk '{print $2}')" + # Column 1 -> + NEW_VALUE_WITH_K_="$(echo -n "${LINE_}" | awk '{print $3}')" - NEW_VALUE_="$(echo -n "${NEW_VALUE_WITH_K_::-1}")" + # This is only needed without --extended to remove K + # NEW_VALUE_="$(echo -n "${NEW_VALUE_WITH_K_::-1}")" + NEW_VALUE_=${NEW_VALUE_WITH_K_} RESULT_=$((${RESULT_}+${NEW_VALUE_})) - done <<< "$(pmap ${PID_} | grep ${LIBRARY_NAME_})" + done <<< "$(pmap ${PID_} --extended | grep ${LIBRARY_NAME_})" fi @@ -83,13 +95,16 @@ print_memory_usage () { done # Print total - TOTAL_MEMORY_USAGE_="$(pmap ${PID_} | tail -n 1 | awk '/[0-9]/K{print $2}')" + # TOTAL_MEMORY_USAGE_="$(pmap ${PID_} | tail -n 1 | awk '/[0-9]/K{print $2}')" + TOTAL_MEMORY_USAGE_="$(pmap ${PID_} --extended | tail -n 1 | awk '{print $4}')" # If there are lines, analyze them if [ ! -z "$PMAP_RESULT_" ]; then - echo -n "${TOTAL_MEMORY_USAGE_::-1}" >> ${RESULT_FILE_} + # This is only needed without --extended to remove K + # echo -n "${TOTAL_MEMORY_USAGE_::-1}" >> ${RESULT_FILE_} + echo -n "${TOTAL_MEMORY_USAGE_}" >> ${RESULT_FILE_} else - echo -n "-" >> ${RESULT_FILE_} + echo -n "0" >> ${RESULT_FILE_} fi echo "" >> ${RESULT_FILE_} @@ -132,11 +147,6 @@ do shift # past argument shift # past value ;; - --measurament-rate) - MEASURAMENT_RATE="$2" - shift # past argument - shift # past value - ;; --measurament-libraries) LIBRARIES_TO_MEASURE="$2" shift # past argument @@ -149,7 +159,7 @@ do shift # past value ;; --loop-elapsed) - ENTITIES_LOOP_ELAPSE="$2" + ENTITIES_LOOP_ELAPSED="$2" shift # past argument shift # past value ;; @@ -163,21 +173,24 @@ do shift # past argument shift # past value ;; - --residual-time) - SLEEP_RESIDUAL_TIME="$2" - shift # past argument - shift # past value - ;; --publication-rate) PUBLICATION_RATE="$2" shift # past argument shift # past value ;; - --n-topics) - NUMBER_OF_TOPICS="$2" + --reset) + RESET_BACKEND=" --reset " + shift # past argument + ;; + --bump) + BUMP_BACKEND=" --bump-file __tmp_backend_test_bump_ " + shift # past argument + ;; + + --debug) + DEBUG=1 shift # past argument - shift # past value ;; *) # unknown option @@ -230,13 +243,20 @@ echo "total(KB)" >> ${RESULT_FILE_PATH} ############################################################ echo echo "---------------------------------------------------------------------------" -echo "Executing Fast DDS Statistics Backend exaple ${BACKEND_EXAMPLE_EXECUTABLE}" +echo "Executing Fast DDS Statistics Backend example ${BACKEND_EXAMPLE_EXECUTABLE}" echo "---------------------------------------------------------------------------" echo -${BACKEND_EXAMPLE_EXECUTABLE} monitor --time=1000 & -# ${BACKEND_EXAMPLE_EXECUTABLE} monitor --time=1000 > /dev/null 2>&1 & -BACKEND_EXAMPLE_PID=$! +RESET_TIME=$((${ENTITIES_LOOP_ELAPSED}+((${SLEEP_RESIDUAL_TIME}*2)*${ENTITIES_IN_LOOP})+(${SLEEP_RESIDUAL_TIME}*2))) + +if [ $DEBUG -eq 1 ]; +then + ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${BUMP_BACKEND} --time=${RESET_TIME} & + BACKEND_EXAMPLE_PID=$! +else + ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${BUMP_BACKEND} --time=${RESET_TIME} > /dev/null 2>&1 & + BACKEND_EXAMPLE_PID=$! +fi ############################################################ @@ -256,16 +276,21 @@ do echo # Excute as many entities as required + declare -a fastdds_entities_pid=() # TODO - FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} publisher --interval ${PUBLICATION_RATE} --topic "TestTopic${i}" > /dev/null 2>&1 & - PUBLISHER_PID=$! - sleep ${SLEEP_RESIDUAL_TIME} - FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} subscriber --topic "TestTopic${i}" > /dev/null 2>&1 & - SUBSCRIBER_PID=$! - sleep ${SLEEP_RESIDUAL_TIME} + for j in $(seq 1 ${ENTITIES_IN_LOOP}); + do + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} publisher --interval ${PUBLICATION_RATE} --topic "TestTopic${i}" > /dev/null 2>&1 & + fastdds_entities_pid+=($!) + sleep ${SLEEP_RESIDUAL_TIME} - # Store memory usage measure - print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} subscriber --topic "TestTopic${i}" > /dev/null 2>&1 & + fastdds_entities_pid+=($!) + sleep ${SLEEP_RESIDUAL_TIME} + + # Store memory usage measure + print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + done # Sleep for some time sleep ${ENTITIES_LOOP_ELAPSED} @@ -275,13 +300,20 @@ do # Kill entities echo "Killing Fast DDS Entities" - kill ${PUBLISHER_PID} - kill ${SUBSCRIBER_PID} + for pid_value in "${fastdds_entities_pid[@]}" + do + echo "Killing PID ${pid_value}" + kill $pid_value + done # Store memory usage measure sleep ${SLEEP_RESIDUAL_TIME} print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + # Wait for data to be removed and store measure + sleep ${SLEEP_RESIDUAL_TIME} + print_memory_usage "${BACKEND_EXAMPLE_PID}" "${LIBRARIES_TO_MEASURE}" "${RESULT_FILE_PATH}" + done ############################################################ From d7bd7bf61bbfa193a6e022cc8bf36532e84da572 Mon Sep 17 00:00:00 2001 From: jparisu Date: Thu, 27 Oct 2022 12:40:46 +0200 Subject: [PATCH 3/3] new all scrip Signed-off-by: jparisu --- test/CMakeLists.txt | 1 - test/performance/CMakeLists.txt | 16 -- test/performance/memory_usage/run_all.sh | 187 ++++++++++++++++++ .../memory_usage/run_memory_usage_test.sh | 49 +++-- 4 files changed, 221 insertions(+), 32 deletions(-) delete mode 100644 test/performance/CMakeLists.txt create mode 100644 test/performance/memory_usage/run_all.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a323c78b6..74e55f214 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,4 +14,3 @@ add_subdirectory(unittest) add_subdirectory(dds/communication) -add_subdirectory(performance) diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt deleted file mode 100644 index f6e6b0367..000000000 --- a/test/performance/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# TODO uncomment -# add_subdirectory(memory_usage) diff --git a/test/performance/memory_usage/run_all.sh b/test/performance/memory_usage/run_all.sh new file mode 100644 index 000000000..d1a0dd256 --- /dev/null +++ b/test/performance/memory_usage/run_all.sh @@ -0,0 +1,187 @@ +#!/bin/bash + +# How to launch from a colcon workspace: +# bash ./src/fastdds_statistics_backend/test/performance/memory_usage/run_memory_usage_test.sh --fastdds ./build/fastrtps/examples/cpp/dds/BasicConfigurationExample/BasicConfigurationExample --backend ./build/fastdds_statistics_backend/examples/cpp/HelloWorldExample/HelloWorldExample + +############################################################ +# Script Arguments +############################################################ + +TEST_EXECUTABLE="$(pwd)/test/performance/memory_usage/run_memory_usage_test.sh" +FASTDDS_EXAMPLE_EXECUTABLE="$(pwd)/BasicConfigurationExample/BasicConfigurationExample" +BACKEND_EXAMPLE_EXECUTABLE="$(pwd)/HelloWorldExample/HelloWorldExample" + +RESULT_PAHT='./result' + +ENTITIES_LOOP_ITERATIONS=20 +ENTITIES_LOOP_ELAPSED=60 +ENTITIES_IN_LOOP=5 +SLEEP_RESIDUAL_TIME=3 + +PUBLICATION_RATE=10 + +DEBUG=0 + +############################################################ +# Functions needed in script +############################################################ + +# TODO comment +execute_memory_usage_test () { + # Get arguments + local FILE_NAME=${1} + local RESET=${2} + local DUMP=${3} + + if [[ "${RESET}" == 1 ]]; + then + if [[ "${DUMP}" == 1 ]]; + then + echo "--- Running test with reset and dump" + /bin/bash "${TEST_EXECUTABLE}" \ + --fastdds "${FASTDDS_EXAMPLE_EXECUTABLE}" \ + --backend "${BACKEND_EXAMPLE_EXECUTABLE}" \ + --result-path "${RESULT_PAHT}" \ + --result-file "${FILE_NAME}" \ + --loop-iterations "${ENTITIES_LOOP_ITERATIONS}" \ + --loop-elapsed "${ENTITIES_LOOP_ELAPSED}" \ + --loop-entities "${ENTITIES_IN_LOOP}" \ + --publication-rate "${PUBLICATION_RATE}" \ + --reset \ + --dump + else + echo "--- Running test with reset and no dump" + /bin/bash "${TEST_EXECUTABLE}" \ + --fastdds "${FASTDDS_EXAMPLE_EXECUTABLE}" \ + --backend "${BACKEND_EXAMPLE_EXECUTABLE}" \ + --result-path "${RESULT_PAHT}" \ + --result-file "${FILE_NAME}" \ + --loop-iterations "${ENTITIES_LOOP_ITERATIONS}" \ + --loop-elapsed "${ENTITIES_LOOP_ELAPSED}" \ + --loop-entities "${ENTITIES_IN_LOOP}" \ + --publication-rate "${PUBLICATION_RATE}" \ + --reset + fi + else + if [[ "${DUMP}" == 1 ]]; + then + echo "--- Running test with no reset and dump" + /bin/bash "${TEST_EXECUTABLE}" \ + --fastdds "${FASTDDS_EXAMPLE_EXECUTABLE}" \ + --backend "${BACKEND_EXAMPLE_EXECUTABLE}" \ + --result-path "${RESULT_PAHT}" \ + --result-file "${FILE_NAME}" \ + --loop-iterations "${ENTITIES_LOOP_ITERATIONS}" \ + --loop-elapsed "${ENTITIES_LOOP_ELAPSED}" \ + --loop-entities "${ENTITIES_IN_LOOP}" \ + --publication-rate "${PUBLICATION_RATE}" \ + --dump + else + echo "--- Running test with no reset and no dump" + /bin/bash "${TEST_EXECUTABLE}" \ + --fastdds "${FASTDDS_EXAMPLE_EXECUTABLE}" \ + --backend "${BACKEND_EXAMPLE_EXECUTABLE}" \ + --result-path "${RESULT_PAHT}" \ + --result-file "${FILE_NAME}" \ + --loop-iterations "${ENTITIES_LOOP_ITERATIONS}" \ + --loop-elapsed "${ENTITIES_LOOP_ELAPSED}" \ + --loop-entities "${ENTITIES_IN_LOOP}" \ + --publication-rate "${PUBLICATION_RATE}" + fi + fi + + +} + +############################################################ +# Parse arguments +############################################################ + +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + + case $key in + --test) + TEST_EXECUTABLE="$2" + shift # past argument + shift # past value + ;; + --fastdds) + FASTDDS_EXAMPLE_EXECUTABLE="$2" + shift # past argument + shift # past value + ;; + --backend) + BACKEND_EXAMPLE_EXECUTABLE="$2" + shift # past argument + shift # past value + ;; + + --result-path) + RESULT_PAHT="$2" + shift # past argument + shift # past value + ;; + + --loop-iterations) + ENTITIES_LOOP_ITERATIONS="$2" + shift # past argument + shift # past value + ;; + --loop-elapsed) + ENTITIES_LOOP_ELAPSED="$2" + shift # past argument + shift # past value + ;; + --loop-entities) + ENTITIES_IN_LOOP="$2" + shift # past argument + shift # past value + ;; + + --publication-rate) + PUBLICATION_RATE="$2" + shift # past argument + shift # past value + ;; + + --debug) + DEBUG=1 + shift # past argument + ;; + + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +read -ra ARGS <<< "${EXPERIMENT_ARGS}" + + +############################################################ +# Prepare result path +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo " Starting execution " +echo "---------------------------------------------------------------------------" +echo + +execute_memory_usage_test "backend_memory_usage.csv" "0" "0" +execute_memory_usage_test "backend_memory_usage_reset.csv" "1" "0" +execute_memory_usage_test "backend_memory_usage_dump.csv" "0" "1" +execute_memory_usage_test "backend_memory_usage_reset_dump.csv" "1" "1" + +############################################################ +# Finish execution +############################################################ +echo +echo "---------------------------------------------------------------------------" +echo "Finishing execution" +echo "---------------------------------------------------------------------------" +echo diff --git a/test/performance/memory_usage/run_memory_usage_test.sh b/test/performance/memory_usage/run_memory_usage_test.sh index b8a8b0b2d..0e20e8187 100644 --- a/test/performance/memory_usage/run_memory_usage_test.sh +++ b/test/performance/memory_usage/run_memory_usage_test.sh @@ -7,9 +7,8 @@ # Script Arguments ############################################################ -WORKSPACE_DIR=$(pwd) -FASTDDS_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/BasicConfigurationExample/BasicConfigurationExample" -BACKEND_EXAMPLE_EXECUTABLE="${WORKSPACE_DIR}/HelloWorldExample/HelloWorldExample" +FASTDDS_EXAMPLE_EXECUTABLE="$(pwd)/BasicConfigurationExample/BasicConfigurationExample" +BACKEND_EXAMPLE_EXECUTABLE="$(pwd)/HelloWorldExample/HelloWorldExample" RESULT_PAHT='./result' RESULT_FILE="backend_memory_usage.csv" @@ -23,7 +22,7 @@ SLEEP_RESIDUAL_TIME=2 PUBLICATION_RATE=10 RESET_BACKEND=" " -BUMP_BACKEND=" " +DUMP_BACKEND=" " DEBUG=0 @@ -121,75 +120,95 @@ do key="$1" case $key in - --workspace) - WORKSPACE_DIR="$2" - shift # past argument - shift # past value - ;; --fastdds) FASTDDS_EXAMPLE_EXECUTABLE="$2" + echo "Using fastdds executable: ${FASTDDS_EXAMPLE_EXECUTABLE}" shift # past argument shift # past value ;; --backend) BACKEND_EXAMPLE_EXECUTABLE="$2" + echo "Using backend executable: ${BACKEND_EXAMPLE_EXECUTABLE}" + shift # past argument shift # past value ;; --result-path) RESULT_PAHT="$2" + echo "Using result directory: ${RESULT_PAHT}" + shift # past argument shift # past value ;; --result-file) RESULT_FILE="$2" + echo "Using result file: ${RESULT_FILE}" + shift # past argument shift # past value ;; --measurament-libraries) LIBRARIES_TO_MEASURE="$2" + echo "Using libraries to measure: ${LIBRARIES_TO_MEASURE}" + shift # past argument shift # past value ;; --loop-iterations) ENTITIES_LOOP_ITERATIONS="$2" + echo "Using loop iterations: ${ENTITIES_LOOP_ITERATIONS}" + shift # past argument shift # past value ;; --loop-elapsed) ENTITIES_LOOP_ELAPSED="$2" + echo "Using loop elapsed time: ${ENTITIES_LOOP_ELAPSED}" + shift # past argument shift # past value ;; --loop-entities) ENTITIES_IN_LOOP="$2" + echo "Using n entities in loop: ${ENTITIES_IN_LOOP}" + shift # past argument shift # past value ;; --statistics) STATISTIC_TOPICS="$2" + echo "Using statistic topics: ${STATISTIC_TOPICS}" + shift # past argument shift # past value ;; --publication-rate) PUBLICATION_RATE="$2" + echo "Using publication rate: ${PUBLICATION_RATE}" + shift # past argument shift # past value ;; --reset) RESET_BACKEND=" --reset " + echo "Using reset option" + shift # past argument ;; - --bump) - BUMP_BACKEND=" --bump-file __tmp_backend_test_bump_ " + --dump) + DUMP_BACKEND=" --dump-file __tmp_backend_test_dump_ " + echo "Using dump option" + shift # past argument ;; --debug) DEBUG=1 + echo "Using debug option" + shift # past argument ;; @@ -251,10 +270,10 @@ RESET_TIME=$((${ENTITIES_LOOP_ELAPSED}+((${SLEEP_RESIDUAL_TIME}*2)*${ENTITIES_IN if [ $DEBUG -eq 1 ]; then - ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${BUMP_BACKEND} --time=${RESET_TIME} & + ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${DUMP_BACKEND} --time=${RESET_TIME} & BACKEND_EXAMPLE_PID=$! else - ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${BUMP_BACKEND} --time=${RESET_TIME} > /dev/null 2>&1 & + ${BACKEND_EXAMPLE_EXECUTABLE} monitor ${RESET_BACKEND} ${DUMP_BACKEND} --time=${RESET_TIME} > /dev/null & BACKEND_EXAMPLE_PID=$! fi @@ -280,11 +299,11 @@ do # TODO for j in $(seq 1 ${ENTITIES_IN_LOOP}); do - FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} publisher --interval ${PUBLICATION_RATE} --topic "TestTopic${i}" > /dev/null 2>&1 & + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} publisher --interval ${PUBLICATION_RATE} --topic "TestTopic${i}" > /dev/null & fastdds_entities_pid+=($!) sleep ${SLEEP_RESIDUAL_TIME} - FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} subscriber --topic "TestTopic${i}" > /dev/null 2>&1 & + FASTDDS_STATISTICS="${STATISTIC_TOPICS}" ${FASTDDS_EXAMPLE_EXECUTABLE} subscriber --topic "TestTopic${i}" > /dev/null & fastdds_entities_pid+=($!) sleep ${SLEEP_RESIDUAL_TIME}