achieve stable performance

This commit is contained in:
yangdsh 2019-10-29 00:07:34 +00:00 committed by Dana Van Aken
parent 9f71d1c8de
commit cf65db2231
3 changed files with 49 additions and 36 deletions

View File

@ -0,0 +1,4 @@
track_counts = on
track_functions = all
track_io_timing = on
autovacuum = off

View File

@ -3,6 +3,8 @@
"database_name" : "tpcc", "database_name" : "tpcc",
"database_disk": "", "database_disk": "",
"database_conf": "/etc/postgresql/9.6/main/postgresql.conf", "database_conf": "/etc/postgresql/9.6/main/postgresql.conf",
"base_database_conf": "configs/postgres_base.conf",
"pg_datadir": "/var/lib/postgresql/9.6/main",
"database_save_path": "~/ottertune/client/driver/dumpfiles", "database_save_path": "~/ottertune/client/driver/dumpfiles",
"username" : "dbuser", "username" : "dbuser",
"password" : "dbpassword", "password" : "dbpassword",
@ -16,5 +18,7 @@
"upload_code" : "I5I10PXK3PK27FM86YYS", "upload_code" : "I5I10PXK3PK27FM86YYS",
"lhs_knob_path" : "~/ottertune/client/driver/knobs/postgres-96.json", "lhs_knob_path" : "~/ottertune/client/driver/knobs/postgres-96.json",
"lhs_save_path" : "~/ottertune/client/driver/configs", "lhs_save_path" : "~/ottertune/client/driver/configs",
"oracle_awr_enabled": false "oracle_awr_enabled": false,
"warmup_iterations": 0,
"sleep_time": 300
} }

View File

@ -34,8 +34,6 @@ fabric_output.update({
RELOAD_INTERVAL = 10 RELOAD_INTERVAL = 10
# maximum disk usage # maximum disk usage
MAX_DISK_USAGE = 90 MAX_DISK_USAGE = 90
# Postgres datadir
PG_DATADIR = '/var/lib/postgresql/9.6/main'
# Load config # Load config
with open('driver_config.json', 'r') as _f: with open('driver_config.json', 'r') as _f:
@ -121,7 +119,7 @@ def create_controller_config():
@task @task
def restart_database(): def restart_database():
if CONF['database_type'] == 'postgres': if CONF['database_type'] == 'postgres':
cmd = 'sudo -u postgres pg_ctl -D {} -w restart'.format(PG_DATADIR) cmd = 'sudo -u postgres pg_ctl -D {} -w -t 600 restart -m fast'.format(CONF['pg_datadir'])
elif CONF['database_type'] == 'oracle': elif CONF['database_type'] == 'oracle':
cmd = 'sh oracleScripts/shutdownOracle.sh && sh oracleScripts/startupOracle.sh' cmd = 'sh oracleScripts/shutdownOracle.sh && sh oracleScripts/startupOracle.sh'
else: else:
@ -167,6 +165,10 @@ def change_conf(next_conf=None):
signal_idx = lines.index(signal) signal_idx = lines.index(signal)
lines = lines[0:signal_idx + 1] lines = lines[0:signal_idx + 1]
if CONF.__contains__('base_database_conf'):
with open(CONF['base_database_conf'], 'r') as f:
base_confs = f.readlines()
lines.extend(base_confs)
if isinstance(next_conf, str): if isinstance(next_conf, str):
with open(next_conf, 'r') as f: with open(next_conf, 'r') as f:
@ -481,8 +483,7 @@ def lhs_samples(count=10):
@task @task
def loop(): def loop(i):
# free cache # free cache
free_cache() free_cache()
@ -491,6 +492,7 @@ def loop():
# restart database # restart database
restart_database() restart_database()
time.sleep(CONF['sleep_time'])
# check disk usage # check disk usage
if check_disk_usage() > MAX_DISK_USAGE: if check_disk_usage() > MAX_DISK_USAGE:
@ -516,6 +518,7 @@ def loop():
# stop the experiment # stop the experiment
while not _ready_to_shut_down_controller(): while not _ready_to_shut_down_controller():
time.sleep(1) time.sleep(1)
signal_controller() signal_controller()
LOG.info('Start the second collection, shut down the controller') LOG.info('Start the second collection, shut down the controller')
@ -527,6 +530,7 @@ def loop():
# save result # save result
result_timestamp = save_dbms_result() result_timestamp = save_dbms_result()
if i >= CONF['warmup_iterations']:
# upload result # upload result
upload_result() upload_result()
@ -631,10 +635,11 @@ def run_loops(max_iter=1):
if RELOAD_INTERVAL > 0: if RELOAD_INTERVAL > 0:
if i % RELOAD_INTERVAL == 0: if i % RELOAD_INTERVAL == 0:
if i == 0 and dump is False: if i == 0 and dump is False:
restart_database()
restore_database() restore_database()
elif i > 0: elif i > 0:
restore_database() restore_database()
LOG.info('The %s-th Loop Starts / Total Loops %s', i + 1, max_iter) LOG.info('The %s-th Loop Starts / Total Loops %s', i + 1, max_iter)
loop() loop(i % RELOAD_INTERVAL)
LOG.info('The %s-th Loop Ends / Total Loops %s', i + 1, max_iter) LOG.info('The %s-th Loop Ends / Total Loops %s', i + 1, max_iter)