Rework the perffarm client configuration.
authorTomas Vondra <tv@fuzzy.cz>
Wed, 10 Aug 2016 22:46:26 +0000 (00:46 +0200)
committerTomas Vondra <tomas@2ndquadrant.com>
Mon, 27 Feb 2017 00:23:42 +0000 (01:23 +0100)
Instead of configuration hardcoded into the perffrarm-client.py
script, move it into a separate settings.py file, and allow
override using settings_local.py (not required).

Also somewhat improve the benchmark configurations by allowing
specifying number of runs, durations etc. in the configuration
file (instead of using default parameter values).

client/.gitignore [new file with mode: 0644]
client/benchmarks/pgbench.py
client/perffarm-client.py
client/settings.py [new file with mode: 0644]

diff --git a/client/.gitignore b/client/.gitignore
new file mode 100644 (file)
index 0000000..fd2351e
--- /dev/null
@@ -0,0 +1 @@
+settings_local.py
index da9506497c639a4ba246c42867e416bb62bf21a6..eaa84024c76fbb5ceaf300546addc210fb73e52e 100644 (file)
@@ -14,15 +14,19 @@ class PgBench(object):
        # TODO allow running custom scripts, not just the default read-write/read-only tests
        # TODO allow running 'prepared' mode
 
-       def __init__(self, bin_path, dbname):
+       def __init__(self, bin_path, dbname, runs = 3, duration = 60):
                '''
                bin_path   - path to PostgreSQL binaries (dropdb, createdb, psql commands)
                dbname     - name of the database to use
+               runs       - number of runs (for each client count)
+               duration   - duration of each execution
                '''
 
                self._bin = bin_path
                self._dbname = dbname
                self._results = {}
+               self._duration = duration
+               self._runs = runs
 
 
        @staticmethod
@@ -185,7 +189,7 @@ class PgBench(object):
                return r
 
 
-       def run_tests(self, duration=10, runs=3):
+       def run_tests(self):
                'execute the whole benchmark, including initialization, warmup and benchmark runs'
 
                # derive configuration for the CPU count / RAM size
@@ -196,20 +200,22 @@ class PgBench(object):
                        # init for the dataset scale and warmup
                        self._init(config['scale'])
 
-                       warmup = self._run(duration, cpu_count(), cpu_count())
+                       warmup = self._run(self._duration, cpu_count(), cpu_count())
                        results = []
 
-                       for run in range(runs):
+                       for run in range(self._runs):
+
+                               log("pgbench : run=%d" % (run,))
 
                                for clients in config['clients']:
 
                                        # read-only
-                                       r = self._run(duration, clients, clients, True)
+                                       r = self._run(self._duration, clients, clients, True)
                                        r.update({'run' : run})
                                        results.append(r)
 
                                        # read-write
-                                       r = self._run(duration, clients, clients, False)
+                                       r = self._run(self._duration, clients, clients, False)
                                        r.update({'run' : run})
                                        results.append(r)
 
index 0d97677dbe9f9e3f6fbe51ac67b508fcb1277261..1d75a10bf8feb9276ef7fcc68c3cd1d2efc422cb 100755 (executable)
@@ -14,28 +14,7 @@ from utils.git import GitRepository
 from utils.cluster import PgCluster
 from utils import logging
 
-GIT_URL = 'git@github.com:postgres/postgres.git'
-REPOSITORY_PATH = '/home/user/tmp/git-postgres'
-BUILD_PATH = '/home/user/tmp/bin-postgres'
-BIN_PATH = os.path.join(BUILD_PATH, 'bin')
-DATADIR_PATH = '/home/user/tmp/data-postgres'
-
-POSTGRES_CONFIG = {'shared_buffers' : '1GB',
-                                  'work_mem' : '64MB',
-                                  'maintenance_work_mem' : '128MB',
-                                  'min_wal_size' : '2GB',
-                                  'max_wal_size' : '4GB',
-                                  'log_line_prefix' : '%n %t ',
-                                  'log_checkpoints' : 'on',
-                                  'log_autovacuum_min_duration' : '0',
-                                  'log_temp_files' : '32',
-                                  'checkpoint_timeout' : '15min',
-                                  'checkpoint_completion_target' : '0.9'}
-
-DATABASE_NAME = 'perf'
-
-OUTPUT_DIR = '/home/user/perf-output'
-
+from settings import *
 
 if __name__ == '__main__':
 
@@ -69,6 +48,7 @@ if __name__ == '__main__':
 
                runner.register_config('pgbench-basic', 'pgbench', dbname = DATABASE_NAME,
                                                                bin_path = ('%s/bin' % (BUILD_PATH,)),
-                                                               postgres_config = POSTGRES_CONFIG)
+                                                               postgres_config = POSTGRES_CONFIG,
+                                                               **PGBENCH_CONFIG)
 
                runner.run()
diff --git a/client/settings.py b/client/settings.py
new file mode 100644 (file)
index 0000000..4895f74
--- /dev/null
@@ -0,0 +1,42 @@
+import os
+import sys
+
+# global configuration
+GIT_URL = 'git@github.com:postgres/postgres.git'
+REPOSITORY_PATH = '/home/user/tmp/git-postgres'
+BUILD_PATH = '/home/user/tmp/bin-postgres'
+BIN_PATH = os.path.join(BUILD_PATH, 'bin')
+DATADIR_PATH = '/home/user/tmp/data-postgres'
+
+POSTGRES_CONFIG = {'shared_buffers' : '1GB',
+                                  'work_mem' : '64MB',
+                                  'maintenance_work_mem' : '128MB',
+                                  'min_wal_size' : '2GB',
+                                  'max_wal_size' : '4GB',
+                                  'log_line_prefix' : '%n %t ',
+                                  'log_checkpoints' : 'on',
+                                  'log_autovacuum_min_duration' : '0',
+                                  'log_temp_files' : '32',
+                                  'checkpoint_timeout' : '15min',
+                                  'checkpoint_completion_target' : '0.9'}
+
+DATABASE_NAME = 'perf'
+
+OUTPUT_DIR = '/home/user/tmp/perf-output'
+
+# configuration for PgBench
+#
+# runs     - number of repetitions (including test for all client counts)
+# duration - duration (in seconds) of a single benchmark (per client count)
+#
+PGBENCH_CONFIG = {
+       'runs' : 3,
+       'duration' : 60         # duration of per-client-count benchmark
+}
+
+# ignore missing file with local config
+try:
+       from settings_local import *
+except:
+       print >> sys.stderr, "ERROR: local configuration (settings_local.py) not found"
+       sys.exit(1)