Merge pull request #9662 from dborquez/fix_launchtimes_timestamp_generation

Fix launch times timestamp generation.
This commit is contained in:
Fabiano Fidêncio
2024-05-18 21:11:09 +02:00
committed by GitHub
2 changed files with 14 additions and 12 deletions

View File

@@ -149,7 +149,9 @@ function extract_kata_env() {
RUNTIME_PATH=$(sudo ${cmd} env --json | jq -r ${runtime_path}) RUNTIME_PATH=$(sudo ${cmd} env --json | jq -r ${runtime_path})
# Shimv2 path is being affected by https://github.com/kata-containers/kata-containers/issues/1151 # Shimv2 path is being affected by https://github.com/kata-containers/kata-containers/issues/1151
SHIM_PATH=$(readlink $(command -v containerd-shim-kata-v2)) SHIM_PATH=$(command -v containerd-shim-kata-v2)
[ -L ${SHIM_PATH} ] && SHIM_PATH=$(readlink ${SHIM_PATH})
SHIM_VERSION=${RUNTIME_VERSION} SHIM_VERSION=${RUNTIME_VERSION}
HYPERVISOR_PATH=$(sudo ${cmd} env --json | jq -r ${hypervisor_path}) HYPERVISOR_PATH=$(sudo ${cmd} env --json | jq -r ${hypervisor_path})

View File

@@ -63,7 +63,7 @@ declare -a to_quit_ds
# data_is_valid value 0 represent is valid # data_is_valid value 0 represent is valid
data_is_valid=0 data_is_valid=0
check_entropy_level() { function check_entropy_level() {
retries="10" retries="10"
for i in $(seq 1 "${retries}"); do for i in $(seq 1 "${retries}"); do
if [ $(cat "/proc/sys/kernel/random/entropy_avail") -ge "${entropy_level}" ]; then if [ $(cat "/proc/sys/kernel/random/entropy_avail") -ge "${entropy_level}" ]; then
@@ -77,7 +77,7 @@ check_entropy_level() {
} }
# convert a 'seconds:nanoseconds' string into nanoseconds # convert a 'seconds:nanoseconds' string into nanoseconds
sn_to_ns() { function sn_to_ns() {
# !!: Remove 0's from beginning otherwise the number will be converted to octal # !!: Remove 0's from beginning otherwise the number will be converted to octal
s=$(echo "${1%:*}" | sed 's/^0*//g') s=$(echo "${1%:*}" | sed 's/^0*//g')
ns=$(echo "${1##*:}" | sed 's/^0*//g') ns=$(echo "${1##*:}" | sed 's/^0*//g')
@@ -87,17 +87,17 @@ sn_to_ns() {
} }
# convert 'nanoseconds' (since epoch) into a 'float' seconds # convert 'nanoseconds' (since epoch) into a 'float' seconds
ns_to_s() { function ns_to_s() {
printf "%.0${CALC_SCALE}f" $(bc <<< "scale=$CALC_SCALE; $1 / 1000000000") printf "%.0${CALC_SCALE}f" $(bc <<< "scale=$CALC_SCALE; $1 / 1000000000")
} }
run_workload() { function run_workload() {
# L_CALC_SCALE is set to accounting a significant # L_CALC_SCALE is set to accounting a significant
# number of decimal digits after the decimal points # number of decimal digits after the decimal points
# for 'bc' performing math in kernel period estimation # for 'bc' performing math in kernel period estimation
L_CALC_SCALE=13 L_CALC_SCALE=13
local CONTAINER_NAME="kata_launch_times_$(( $RANDOM % 1000 + 1))" local CONTAINER_NAME="kata_launch_times_$(( $RANDOM % 1000 + 1))"
start_time=$("${DATECMD}") start_time=$(eval "${DATECMD}")
# Check entropy level of the host # Check entropy level of the host
check_entropy_level check_entropy_level
@@ -105,7 +105,7 @@ run_workload() {
# Run the image and command and capture the results into an array... # Run the image and command and capture the results into an array...
declare workload_result declare workload_result
readarray -n 0 workload_result < <(sudo -E "${CTR_EXE}" run --rm --runtime "${CTR_RUNTIME}" "${IMAGE}" "${CONTAINER_NAME}" bash -c "${DATECMD} ${DMESGCMD}") readarray -n 0 workload_result < <(sudo -E "${CTR_EXE}" run --rm --runtime "${CTR_RUNTIME}" "${IMAGE}" "${CONTAINER_NAME}" bash -c "${DATECMD} ${DMESGCMD}")
end_time=$("${DATECMD}") end_time=$(eval "${DATECMD}")
# Delay this calculation until after we have run - do not want # Delay this calculation until after we have run - do not want
# to measure it in the results # to measure it in the results
@@ -192,7 +192,7 @@ run_workload() {
# Writes a JSON with the measurements # Writes a JSON with the measurements
# results per execution # results per execution
write_individual_results() { function write_individual_results() {
for i in "${!total_result_ds[@]}"; do for i in "${!total_result_ds[@]}"; do
local json="$(cat << EOF local json="$(cat << EOF
{ {
@@ -223,7 +223,7 @@ EOF
done done
} }
init () { function init() {
TEST_ARGS="image=${IMAGE} runtime=${CTR_RUNTIME} units=seconds" TEST_ARGS="image=${IMAGE} runtime=${CTR_RUNTIME} units=seconds"
# We set the generic name here, but we save the different time results separately, # We set the generic name here, but we save the different time results separately,
@@ -233,7 +233,7 @@ init () {
# If we are scaling, note that in the name # If we are scaling, note that in the name
[ -n "$SCALING" ] && TEST_NAME="${TEST_NAME} scaling" [ -n "$SCALING" ] && TEST_NAME="${TEST_NAME} scaling"
echo "Executing test: ${TEST_NAME} ${TEST_ARGS}" info "Executing test: ${TEST_NAME} ${TEST_ARGS}"
check_cmds "${REQUIRED_CMDS[@]}" check_cmds "${REQUIRED_CMDS[@]}"
# For non-VM runtimes, we don't use the output of dmesg, and # For non-VM runtimes, we don't use the output of dmesg, and
@@ -450,7 +450,7 @@ main() {
while [ "${j}" -lt "${TIMES}" ]; do while [ "${j}" -lt "${TIMES}" ]; do
echo " run ${num_iters}" info " run ${num_iters}"
run_workload run_workload
if [ "${data_is_valid}" -eq 0 ]; then if [ "${data_is_valid}" -eq 0 ]; then
@@ -460,7 +460,7 @@ main() {
continue continue
fi fi
echo "Skipping run due to invalid result" info "Skipping run due to invalid result"
((max_reps-=1)) ((max_reps-=1))
if [ "${max_reps}" -lt 0 ]; then if [ "${max_reps}" -lt 0 ]; then