diff options
author | MS <ms@taler.net> | 2023-07-24 10:42:15 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2023-07-24 10:42:44 +0200 |
commit | 6144444b239ecf57aaf8878d294bee007654c207 (patch) | |
tree | 2d01d94b42bd2a649c36c6a57ed509f27ce2baa3 /nlnet/task5/performance/start.sh | |
parent | da000d1aa75575a194870c890b39c994271e58d2 (diff) | |
download | deployment-6144444b239ecf57aaf8878d294bee007654c207.tar.gz deployment-6144444b239ecf57aaf8878d294bee007654c207.tar.bz2 deployment-6144444b239ecf57aaf8878d294bee007654c207.zip |
NLnet task 5 delivery, draft.
Diffstat (limited to 'nlnet/task5/performance/start.sh')
-rw-r--r-- | nlnet/task5/performance/start.sh | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/nlnet/task5/performance/start.sh b/nlnet/task5/performance/start.sh new file mode 100644 index 0000000..317c52a --- /dev/null +++ b/nlnet/task5/performance/start.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# This script shows, via runnuing the benchmark, how +# the LibEuFin database connections are significantly +# shorter than the benchmark total time. + +# For this reason, it can only be that LibEuFin opens +# and closes many PostgreSQL connections, as it is required +# by milestone #3. + +set -eux + +# Converts AA:BB:CC.DDD to milliseconds. +convert_pg_time_to_ms () { + awk -F[.:] '{SECS=(60*60*$1)+(60*$2)+$3; MILLI=$4; TOTAL_MS=(SECS*1000)+MILLI; print TOTAL_MS}' +} + +createdb talercheck + +prepare_and_run () { + (taler-unified-setup.sh \ + -emwtns \ + -c /exchange/src/benchmark/benchmark-cs.conf \ + -u exchange-account-2 &> /check_ready.txt) & + + # Wait that the prep. went through. + echo -n Waiting the unified setup to complete.. + READY="NO" + for i in `seq 100` true; do + if grep "<<READY>>" /check_ready.txt; then + READY="YES" + break + fi + echo -n "."; sleep 0.5 + done + + if test $READY = "YES"; then + echo "DONE" + else + cat /check_ready.txt + echo FAIL + exit 1 + fi + + NEXUS_PID=$(cat /libeufin-nexus.pid) + SANDBOX_PID=$(cat /libeufin-sandbox.pid) + + if test -z $NEXUS_PID; then + echo Could not find Nexus PID, failing. + exit 1 + fi + + if test -z $SANDBOX_PID; then + echo Could not find Sandbox PID, failing. + exit 1 + fi + + echo Running the benchmark.. + taler-exchange-benchmark \ + -c /exchange/src/benchmark/benchmark-cs.conf.edited \ + -u exchange-account-2 \ # Which exchange account to pick from the config. + -L WARNING \ + -n1 \ # How many coins per reserve. + -r100 # How many reserves per client. +} + +/usr/bin/time -o /benchmark-wall-clock-time.txt --format=%e prepare_and_run + +# Convert the wall clock time to milliseconds, to make +# it compatible with the format as GREPped through Postgres logs. +BENCHMARK_TOT_MS=$(awk -F. '{t=($1 * 1000 + $2 * 10)} END {print t}' /benchmark-wall-clock-time.txt) + +NEXUS_LONGEST_DB_SESSION=$(grep disconnection < /var/log/postgresql/postgresql-14-main.log \ + | grep $NEXUS_PID | convert_pg_time_to_ms | sort | head -1) + +SANDBOX_LONGEST_DB_SESSION=$(grep disconnection < /var/log/postgresql/postgresql-14-main.log \ + | grep $SANDBOX_PID | convert_pg_time_to_ms | sort | head -1) + +if test $NEXUS_LONGEST_DB_SESSION -gt $BENCHMARK_TOT_MS; then + echo Nexus had a DB session longer than the benchmark itself, failing. + exit 1 +fi + +if test $SANDBOX_LONGEST_DB_SESSION -gt $BENCHMARK_TOT_MS; then + echo Sandbox had a DB session longer than the benchmark itself, failing. + exit 1 +fi + +NEXUS_TIME_FRACTION=$(echo "$BENCHMARK_TOT_MS / $NEXUS_LONGEST_DB_SESSION" | bc -lq) +SANDBOX_TIME_FRACTION=$(echo "$BENCHMARK_TOT_MS / $SANDBOX_LONGEST_DB_SESSION" | bc -lq) + +# Here: the further from 1 the better. +echo Nexus longest DB session is $NEXUS_TIME_FRACTION of the total benchmark time. +echo Sandbox longest DB session is $SANDBOX_TIME_FRACTION of the total benchmark time. + +# Now show the total space occupied by the database. +# Although that's a _total_ estimate, it'll anyhow show +# that _also_ libeufin has reasonable data usage. +echo "SELECT pg_size_pretty(pg_database_size('libeufincheck'))" | psql -d libeufincheck |