Skip to content

Commit

Permalink
Support protocol for pgbench
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696254311
  • Loading branch information
raymond13513 authored and copybara-github committed Nov 13, 2024
1 parent 454927d commit 249f684
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions perfkitbenchmarker/linux_benchmarks/pgbench_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,25 @@
from perfkitbenchmarker import sql_engine_utils
from perfkitbenchmarker.linux_packages import pgbench

# PGProtocal
SIMPLE = 'simple'
EXTENDED = 'extended'
PREPARED = 'prepared'

flags.DEFINE_integer(
'pgbench_scale_factor',
1,
'scale factor used to fill the database',
lower_bound=1,
)

flags.DEFINE_enum(
'pgbench_protocol',
None,
[SIMPLE, EXTENDED, PREPARED],
'Protocol to use for pgbench',
)

flags.DEFINE_integer(
'pgbench_seconds_per_test',
10,
Expand Down Expand Up @@ -167,6 +180,7 @@ def UpdateBenchmarkSpecWithRunStageFlags(benchmark_spec):
benchmark_spec.seconds_to_pause = FLAGS.pgbench_seconds_to_pause_before_steps
benchmark_spec.client_counts = FLAGS.pgbench_client_counts
benchmark_spec.job_counts = FLAGS.pgbench_job_counts
benchmark_spec.pgbench_protocol = FLAGS.pgbench_protocol


def GetDbSize(relational_db, db_name):
Expand Down Expand Up @@ -358,6 +372,7 @@ def Run(benchmark_spec):
benchmark_spec.job_counts,
benchmark_spec.seconds_to_pause,
benchmark_spec.seconds_per_test,
benchmark_spec.pgbench_protocol,
common_metadata,
)
return []
Expand Down
4 changes: 4 additions & 0 deletions perfkitbenchmarker/linux_packages/pgbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def RunPgBench(
job_counts,
seconds_to_pause,
seconds_per_test,
protocol,
metadata,
file=None,
path=None,
Expand All @@ -110,6 +111,7 @@ def RunPgBench(
job_counts: Number of job
seconds_to_pause: Seconds to pause between test
seconds_per_test: Seconds per test
protocol: Protocol to use for the benchmark
metadata: Metadata of the benchmark
file: Filename of the benchmark
path: File path of the benchmar.
Expand All @@ -136,6 +138,8 @@ def RunPgBench(
metadata['pgbench_file'] = file

extended_protocol = ''
if protocol:
extended_protocol = ' --protocol=' + protocol
if relational_db.engine_type == sql_engine_utils.SPANNER_POSTGRES:
extended_protocol = ' --protocol=extended'

Expand Down

0 comments on commit 249f684

Please sign in to comment.