Skip to content

Stable14 runner job #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/scripts/job/aqo_instance_launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
ulimit -c unlimited

# Kill all orphan processes
pkill -U `whoami` -9 -e postgres
pkill -U `whoami` -9 -e pgbench
pkill -U `whoami` -9 -e psql

sleep 1

M=`pwd`/PGDATA
U=`whoami`

rm -rf $M || true
mkdir $M
rm -rf logfile.log || true

export LC_ALL=C
export LANGUAGE="en_US:en"
initdb -D $M --locale=C

# PG Version-specific settings
ver=$(pg_ctl -V | egrep -o "[0-9]." | head -1)
echo "PostgreSQL version: $ver"
if [ $ver -gt 13 ]
then
echo "compute_query_id = 'regress'" >> $M/postgresql.conf
fi

# Speed up the 'Join Order Benchmark' test
echo "shared_buffers = 1GB" >> $M/postgresql.conf
echo "work_mem = 128MB" >> $M/postgresql.conf
echo "fsync = off" >> $M/postgresql.conf
echo "autovacuum = 'off'" >> $M/postgresql.conf

# AQO preferences
echo "shared_preload_libraries = 'aqo, pg_stat_statements'" >> $M/postgresql.conf
echo "aqo.mode = 'disabled'" >> $M/postgresql.conf
echo "aqo.join_threshold = 0" >> $M/postgresql.conf
echo "aqo.force_collect_stat = 'off'" >> $M/postgresql.conf
echo "aqo.fs_max_items = 10000" >> $M/postgresql.conf
echo "aqo.fss_max_items = 20000" >> $M/postgresql.conf

pg_ctl -w -D $M -l logfile.log start
createdb $U
psql -c "CREATE EXTENSION aqo;"
psql -c "CREATE EXTENSION pg_stat_statements"
15 changes: 15 additions & 0 deletions .github/scripts/job/check_result.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# ##############################################################################
#
#
# ##############################################################################

# Show error delta (Negative result is a signal of possible issue)
result=$(psql -t -c "SELECT count(*) FROM aqo_cardinality_error(true) c JOIN aqo_cardinality_error(false) o USING (id) WHERE (o.error - c.error) < 0")

if [ $result -gt 0 ]; then
exit 1;
fi

exit 0;
17 changes: 17 additions & 0 deletions .github/scripts/job/dump_knowledge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# ##############################################################################
#
# Make dump of a knowledge base
#
# ##############################################################################

psql -c "CREATE TABLE aqo_data_dump AS SELECT * FROM aqo_data;"
psql -c "CREATE TABLE aqo_queries_dump AS SELECT * FROM aqo_queries;"
psql -c "CREATE TABLE aqo_query_texts_dump AS SELECT * FROM aqo_query_texts;"
psql -c "CREATE TABLE aqo_query_stat_dump AS SELECT * FROM aqo_query_stat;"

pg_dump --table='aqo*' -f knowledge_base.dump $PGDATABASE

psql -c "DROP TABLE aqo_data_dump, aqo_queries_dump, aqo_query_texts_dump, aqo_query_stat_dump"

58 changes: 58 additions & 0 deletions .github/scripts/job/job_pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# ##############################################################################
#
# Pass each JOB query over the DBMS instance. Use $1 to specify a number of
# iterations, if needed.
#
# Results:
# - explains.txt - explain of each query
# - job_onepass_aqo_stat.dat - short report on execution time
# - knowledge_base.dump - dump of the AQO knowledge base
#
# ##############################################################################

echo "The Join Order Benchmark 1Pass"
echo -e "Query Number\tITER\tQuery Name\tExecution Time, ms" > report.txt
echo -e "Clear a file with explains" > explains.txt

if [ $# -eq 0 ]
then
ITERS=1
else
ITERS=$1
fi

echo "Execute JOB with the $ITERS iterations"

filenum=1
for file in $JOB_DIR/queries/*.sql
do
# Get filename
short_file=$(basename "$file")

echo -n "EXPLAIN (ANALYZE, VERBOSE, FORMAT JSON) " > test.sql
cat $file >> test.sql

for (( i=1; i<=$ITERS; i++ ))
do
result=$(psql -f test.sql)
echo -e $result >> explains.txt
exec_time=$(echo $result | sed -n 's/.*"Execution Time": \([0-9]*\.[0-9]*\).*/\1/p')
echo -e "$filenum\t$short_file\t$i\t$exec_time" >> report.txt
echo -e "$filenum\t$i\t$short_file\t$exec_time"
done
filenum=$((filenum+1))
done

# Show total optimizer error in the test
psql -c "SELECT sum(error) AS total_error FROM aqo_cardinality_error(false)"
psql -c "SELECT sum(error) AS total_error_aqo FROM aqo_cardinality_error(true)"

# Show error delta (Negative result is a signal of possible issue)
psql -c "
SELECT id, (o.error - c.error) AS errdelta
FROM aqo_cardinality_error(true) c JOIN aqo_cardinality_error(false) o
USING (id)
"

5 changes: 5 additions & 0 deletions .github/scripts/job/load_imdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

psql -f $JOB_DIR/schema.sql
psql -vdatadir="'$JOB_DIR'" -f $JOB_DIR/copy.sql

41 changes: 41 additions & 0 deletions .github/scripts/job/set_test_conditions_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# ##############################################################################
#
# Test conditions No.1: Quick pass in 'disabled' mode with statistics and
# forced usage of a bunch of parallel workers.
#
# - Disabled mode with a stat gathering and AQO details in explain
# - Force usage of parallel workers aggressively
# - Enable pg_stat_statements statistics
#
# ##############################################################################

# AQO specific settings
psql -c "ALTER SYSTEM SET aqo.mode = 'disabled'"
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'on'"
psql -c "ALTER SYSTEM SET aqo.show_details = 'on'"
psql -c "ALTER SYSTEM SET aqo.show_hash = 'on'"

# Core settings: force parallel workers
psql -c "ALTER SYSTEM SET max_parallel_workers_per_gather = 16"
psql -c "ALTER SYSTEM SET force_parallel_mode = 'on'"
psql -c "ALTER SYSTEM SET from_collapse_limit = 20"
psql -c "ALTER SYSTEM SET join_collapse_limit = 20"
psql -c "ALTER SYSTEM SET parallel_setup_cost = 1.0"
psql -c "ALTER SYSTEM SET parallel_tuple_cost = 0.00001"
psql -c "ALTER SYSTEM SET min_parallel_table_scan_size = 0"
psql -c "ALTER SYSTEM SET min_parallel_index_scan_size = 0"

# pg_stat_statements
psql -c "ALTER SYSTEM SET pg_stat_statements.track = 'all'"
psql -c "ALTER SYSTEM SET pg_stat_statements.track_planning = 'on'"

psql -c "SELECT pg_reload_conf();"

# Enable all previously executed queries which could be disabled
psql -c "
SELECT count(*) FROM aqo_queries, LATERAL aqo_disable_class(queryid)
WHERE queryid <> 0
"

42 changes: 42 additions & 0 deletions .github/scripts/job/set_test_conditions_2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# ##############################################################################
#
# Test conditions No.2: Learn mode with forced parallel workers
#
# - Disabled mode with a stat gathering and AQO details in explain
# - Force usage of parallel workers aggressively
# - Enable pg_stat_statements statistics
#
# ##############################################################################

# AQO specific settings
psql -c "ALTER SYSTEM SET aqo.mode = 'learn'"
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'off'"
psql -c "ALTER SYSTEM SET aqo.show_details = 'on'"
psql -c "ALTER SYSTEM SET aqo.show_hash = 'on'"
psql -c "ALTER SYSTEM SET aqo.join_threshold = 0"
psql -c "ALTER SYSTEM SET aqo.wide_search = 'off'"

# Core settings: force parallel workers
psql -c "ALTER SYSTEM SET max_parallel_workers_per_gather = 16"
psql -c "ALTER SYSTEM SET force_parallel_mode = 'on'"
psql -c "ALTER SYSTEM SET from_collapse_limit = 20"
psql -c "ALTER SYSTEM SET join_collapse_limit = 20"
psql -c "ALTER SYSTEM SET parallel_setup_cost = 1.0"
psql -c "ALTER SYSTEM SET parallel_tuple_cost = 0.00001"
psql -c "ALTER SYSTEM SET min_parallel_table_scan_size = 0"
psql -c "ALTER SYSTEM SET min_parallel_index_scan_size = 0"

# pg_stat_statements
psql -c "ALTER SYSTEM SET pg_stat_statements.track = 'all'"
psql -c "ALTER SYSTEM SET pg_stat_statements.track_planning = 'on'"

psql -c "SELECT pg_reload_conf();"

# Enable all previously executed queries which could be disabled
psql -c "
SELECT count(*) FROM aqo_queries, LATERAL aqo_enable_class(queryid)
WHERE queryid <> 0
"

42 changes: 42 additions & 0 deletions .github/scripts/job/set_test_conditions_3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# ##############################################################################
#
# Test conditions No.3: Freeze ML base and forced parallel workers
#
# - Disabled mode with a stat gathering and AQO details in explain
# - Force usage of parallel workers aggressively
# - Enable pg_stat_statements statistics
#
# ##############################################################################

# AQO specific settings
psql -c "ALTER SYSTEM SET aqo.mode = 'frozen'"
psql -c "ALTER SYSTEM SET aqo.force_collect_stat = 'off'"
psql -c "ALTER SYSTEM SET aqo.show_details = 'on'"
psql -c "ALTER SYSTEM SET aqo.show_hash = 'on'"
psql -c "ALTER SYSTEM SET aqo.join_threshold = 0"
psql -c "ALTER SYSTEM SET aqo.wide_search = 'off'"

# Core settings: force parallel workers
psql -c "ALTER SYSTEM SET max_parallel_workers_per_gather = 16"
psql -c "ALTER SYSTEM SET force_parallel_mode = 'on'"
psql -c "ALTER SYSTEM SET from_collapse_limit = 20"
psql -c "ALTER SYSTEM SET join_collapse_limit = 20"
psql -c "ALTER SYSTEM SET parallel_setup_cost = 1.0"
psql -c "ALTER SYSTEM SET parallel_tuple_cost = 0.00001"
psql -c "ALTER SYSTEM SET min_parallel_table_scan_size = 0"
psql -c "ALTER SYSTEM SET min_parallel_index_scan_size = 0"

# pg_stat_statements
psql -c "ALTER SYSTEM SET pg_stat_statements.track = 'all'"
psql -c "ALTER SYSTEM SET pg_stat_statements.track_planning = 'on'"

psql -c "SELECT pg_reload_conf();"

# Enable all previously executed queries which could be disabled
psql -c "
SELECT count(*) FROM aqo_queries, LATERAL aqo_enable_class(queryid)
WHERE queryid <> 0
"

Loading