Skip to content
Open
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
24 changes: 21 additions & 3 deletions perfkitbenchmarker/linux_benchmarks/sysbench_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@
' benchmark mode to work',
)

_SYSBENCH_OPEN_FILE_LIMIT = flags.DEFINE_integer(
'sysbench_open_file_limit',
None,
'Override the default linux open file limit (ulimit -n) for sysbench'
' execution.',
)

_SCALEUP_CLIENTS_TEST_NUM_CLIENTS = flags.DEFINE_integer(
'sysbench_scaleup_clients_test_num_clients',
1,
Expand Down Expand Up @@ -381,14 +388,24 @@ def _IsValidFlag(flag):
)


def _GetUlimitCommand() -> str:
"""Returns the ulimit command prefix if an open file limit is set."""
if _SYSBENCH_OPEN_FILE_LIMIT.value:
return f'ulimit -n {_SYSBENCH_OPEN_FILE_LIMIT.value} && '
return ''


def _GetSysbenchPrepareCommand(
db: relational_db.BaseRelationalDb, num_vms: int, vm_index: int
) -> str:
"""Returns the sysbench command used to load the database."""
# TODO(ruwa): Migrate to use sysbench.BuildLoadCommand()
ulimit_cmd = _GetUlimitCommand()
data_load_cmd_tokens = [
'cd ~/sysbench/ && nice', # run with a niceness of lower priority
'-15', # to encourage cpu time for ssh commands
# Run with a niceness of lower priority to encourage CPU time for SSH
# commands.
f'cd ~/sysbench/ && {ulimit_cmd}nice',
'-15',
'sysbench',
_GetSysbenchTestParameter(),
'--tables=%d' % FLAGS.sysbench_tables,
Expand Down Expand Up @@ -662,6 +679,7 @@ def _GetSysbenchRunCommand(
if duration <= 0:
raise ValueError('Duration must be greater than zero.')

ulimit_cmd = _GetUlimitCommand()
run_cmd_tokens = [
'nice', # run with a niceness of lower priority
'-15', # to encourage cpu time for ssh commands
Expand Down Expand Up @@ -696,7 +714,7 @@ def _GetSysbenchRunCommand(
) and not spanner_read_committed:
run_cmd_tokens.append('--trx_level=%s' % _TXN_ISOLATION_LEVEL.value)
run_cmd = ' '.join(run_cmd_tokens + _GetCommonSysbenchOptions(db) + ['run'])
run_cmd = 'cd ~/sysbench/ && ' + run_cmd
run_cmd = f'cd ~/sysbench/ && {ulimit_cmd}' + run_cmd
return run_cmd


Expand Down
15 changes: 14 additions & 1 deletion perfkitbenchmarker/linux_packages/pgbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
import socket
import statistics
import time
from absl import flags
from perfkitbenchmarker import publisher
from perfkitbenchmarker import sample
from perfkitbenchmarker import sql_engine_utils

_PGBENCH_OPEN_FILE_LIMIT = flags.DEFINE_integer(
'pgbench_open_file_limit',
None,
'Override the default linux open file limit (ulimit -n) for pgbench'
' execution.',
)

APT_PACKAGES = (
'postgresql-client-common',
'postgresql-client',
Expand Down Expand Up @@ -176,8 +184,13 @@ def RunPgBench(
jobs = min(client, 16)

start_time = datetime.datetime.now()
ulimit_cmd = (
f'ulimit -n {_PGBENCH_OPEN_FILE_LIMIT.value} && '
if _PGBENCH_OPEN_FILE_LIMIT.value
else ''
)
command = (
f'ulimit -n 10000 && pgbench {connection_string} --client={client} '
f'{ulimit_cmd}pgbench {connection_string} --client={client} '
f'--jobs={jobs} --time={seconds_per_test} --progress=1 '
'-r'
+ extended_protocol
Expand Down