Rename --max-requests to --events, --max-time to --time.

Print warnings if old names are used, but accept them for compatibility.
This commit is contained in:
Alexey Kopytov
2017-02-01 17:20:22 +03:00
parent 8f227f64b3
commit 788fcbb30b
28 changed files with 106 additions and 76 deletions

View File

@ -105,8 +105,8 @@ The table below lists the supported common options, their descriptions and defau
*Option* | *Description* | *Default value*
----------------------|---------------|----------------
| `--num-threads` | The total number of worker threads to create | 1 |
| `--max-requests` | Limit for total number of requests. 0 means unlimited | 10000 |
| `--max-time` | Limit for total execution time in seconds. 0 (default) means unlimited | 0 |
| `--events` | Limit for total number of requests. 0 means unlimited | 10000 |
| `--time` | Limit for total execution time in seconds. 0 (default) means unlimited | 0 |
| `--rate` | Average transactions rate. The number specifies how many events (transactions) per seconds should be executed by all threads on average. 0 (default) means unlimited rate, i.e. events are executed as fast as possible | 0 |
| `--thread-stack-size` | Size of stack for each thread | 32K |
| `--report-interval` | Periodically report intermediate statistics with a specified interval in seconds. Note that statistics produced by this option is per-interval rather than cumulative. 0 disables intermediate reports | 0 |

View File

@ -2,7 +2,7 @@
-- -------------------------------------------------------------------------- --
-- Bulk insert benchmark: do multi-row INSERTs concurrently in --num-threads
-- threads with each thread inserting into its own table. The number of INSERTs
-- executed by each thread is controlled by either --max-time or --max-requests.
-- executed by each thread is controlled by either --time or --events.
-- -------------------------------------------------------------------------- --
cursize=0

View File

@ -238,6 +238,30 @@ void log_msg(log_msg_t *msg)
}
}
static const char *get_msg_prefix(log_msg_priority_t priority)
{
const char * prefix;
switch (priority) {
case LOG_FATAL:
prefix = "FATAL: ";
break;
case LOG_ALERT:
prefix = "ALERT: ";
break;
case LOG_WARNING:
prefix = "WARNING: ";
break;
case LOG_DEBUG:
prefix = "DEBUG: ";
break;
default:
prefix = "";
break;
}
return prefix;
}
/* printf-like wrapper to log text messages */
@ -268,11 +292,11 @@ void log_text(log_msg_priority_t priority, const char *fmt, ...)
*/
if (!initialized)
{
printf("%s", buf);
printf("%s%s", get_msg_prefix(priority), buf);
return;
}
msg.type = LOG_MSG_TYPE_TEXT;
msg.data = (void *)&text_msg;
text_msg.priority = priority;
@ -320,7 +344,7 @@ void log_timestamp(log_msg_priority_t priority, double seconds,
*/
if (!initialized)
{
printf("%s", buf);
printf("%s%s", get_msg_prefix(priority), buf);
return;
}
@ -420,7 +444,6 @@ int text_handler_init(void)
int text_handler_process(log_msg_t *msg)
{
char *prefix;
log_msg_text_t *text_msg = (log_msg_text_t *)msg->data;
if (text_msg->priority > sb_globals.verbosity)
@ -447,26 +470,8 @@ int text_handler_process(log_msg_t *msg)
pthread_mutex_unlock(&text_mutex);
}
switch (text_msg->priority) {
case LOG_FATAL:
prefix = "FATAL: ";
break;
case LOG_ALERT:
prefix = "ALERT: ";
break;
case LOG_WARNING:
prefix = "WARNING: ";
break;
case LOG_DEBUG:
prefix = "DEBUG: ";
break;
default:
prefix = "";
break;
}
printf("%s%s", prefix, text_msg->text);
printf("%s%s", get_msg_prefix(text_msg->priority), text_msg->text);
return 0;
}

View File

@ -89,13 +89,12 @@
sb_arg_t general_args[] =
{
SB_OPT("num-threads", "number of threads to use", "1", INT),
SB_OPT("max-requests", "limit for total number of requests", "10000", INT),
SB_OPT("max-time", "limit for total execution time in seconds", "0", INT),
SB_OPT("events", "limit for total number of events", "0", INT),
SB_OPT("time", "limit for total execution time in seconds", "10", INT),
SB_OPT("forced-shutdown",
"number of seconds to wait after --max-time before forcing shutdown, "
"or 'off' to disable", "off", STRING),
"number of seconds to wait after the --time limit before forcing "
"shutdown, or 'off' to disable", "off", STRING),
SB_OPT("thread-stack-size", "size of stack per thread", "64K", SIZE),
SB_OPT("tx-rate", "deprecated alias for --rate", "0", INT),
SB_OPT("rate", "average transactions rate. 0 for unlimited rate", "0", INT),
SB_OPT("report-interval", "periodically report intermediate statistics with "
"a specified interval in seconds. 0 disables intermediate reports",
@ -110,6 +109,9 @@ sb_arg_t general_args[] =
SB_OPT("help", "print help and exit", "off", BOOL),
SB_OPT("version", "print version and exit", "off", BOOL),
SB_OPT("config-file", "File containing command line options", NULL, FILE),
SB_OPT("tx-rate", "deprecated alias for --rate", "0", INT),
SB_OPT("max-requests", "deprecated alias for --events", "0", INT),
SB_OPT("max-time", "deprecated alias for --time", "0", INT),
SB_OPT_END
};
@ -693,8 +695,8 @@ bool sb_more_events(int thread_id)
}
/* Check if we have a limit on the number of events */
if (sb_globals.max_requests > 0 &&
ck_pr_faa_64(&sb_globals.nevents, 1) >= sb_globals.max_requests)
if (sb_globals.max_events > 0 &&
ck_pr_faa_64(&sb_globals.nevents, 1) >= sb_globals.max_events)
return false;
/* If we are in tx_rate mode, we take events from queue */
@ -1279,11 +1281,23 @@ static int init(void)
log_text(LOG_FATAL, "Invalid value for --num-threads: %d.\n", sb_globals.num_threads);
return 1;
}
sb_globals.max_requests = sb_get_value_int("max-requests");
sb_globals.max_time_ns = SEC2NS(sb_get_value_int("max-time"));
sb_globals.max_events = sb_get_value_int("max-requests");
if (sb_globals.max_events > 0)
log_text(LOG_WARNING, "--max-requests is deprecated, use --events instead");
else
sb_globals.max_events = sb_get_value_int("events");
if (!sb_globals.max_requests && !sb_globals.max_time_ns)
log_text(LOG_WARNING, "WARNING: Both max-requests and max-time are 0, running endless test");
int max_time = sb_get_value_int("max-time");
if (max_time > 0)
log_text(LOG_WARNING, "--max-time is deprecated, use --time instead");
else
max_time = sb_get_value_int("time");
sb_globals.max_time_ns = SEC2NS(max_time);
if (!sb_globals.max_events && !sb_globals.max_time_ns)
log_text(LOG_WARNING, "Both event and time limits are disabled, "
"running an endless test");
if (sb_globals.max_time_ns > 0)
{
@ -1335,7 +1349,7 @@ static int init(void)
sb_globals.tx_rate = sb_get_value_int("tx-rate");
if (sb_globals.tx_rate > 0)
log_text(LOG_WARNING, "--tx-rate is deprecated, use --rate");
log_text(LOG_WARNING, "--tx-rate is deprecated, use --rate instead");
else
sb_globals.tx_rate = sb_get_value_int("rate");

View File

@ -181,7 +181,7 @@ typedef struct
int argc; /* command line arguments count */
char **argv; /* command line arguments */
unsigned int tx_rate; /* target transaction rate */
uint64_t max_requests; /* maximum number of requests */
uint64_t max_events; /* maximum number of events to execute */
uint64_t max_time_ns; /* total execution time limit */
pthread_mutex_t exec_mutex CK_CC_CACHELINE; /* execution mutex */
const char *testname; /* test name or script path to execute */

View File

@ -345,8 +345,8 @@ int file_init(void)
clear_stats();
/* Use our own limit on the number of events */
max_events = sb_globals.max_requests;
sb_globals.max_requests = 0;
max_events = sb_globals.max_events;
sb_globals.max_events = 0;
return 0;
}

View File

@ -204,7 +204,7 @@ int memory_init(void)
}
/* Use our own limit on the number of events */
sb_globals.max_requests = 0;
sb_globals.max_events = 0;
return 0;
}

View File

@ -10,7 +10,7 @@
set -eu
SB_ARGS="--verbosity=1 --max-requests=1 --num-threads=1 $DB_DRIVER_ARGS $CRAMTMP/api_sql.lua"
SB_ARGS="--verbosity=1 --events=1 --num-threads=1 $DB_DRIVER_ARGS $CRAMTMP/api_sql.lua"
cat >$CRAMTMP/api_sql.lua <<EOF
function thread_init()
drv = sysbench.sql.driver()

View File

@ -15,7 +15,7 @@ end
EOF
sysbench test.lua \
--max-requests=10 \
--events=10 \
--num-threads=2 \
$DB_DRIVER_ARGS \
run

View File

@ -23,7 +23,7 @@ do
db_show_table sbtest${i} || true # Error on non-existing table
done
sysbench $ARGS --max-requests=100 --verbosity=3 run
sysbench $ARGS --events=100 --verbosity=3 run
sysbench $ARGS cleanup

View File

@ -31,7 +31,7 @@ db_show_table sbtest9 || true # Error on non-existing table
sysbench $ARGS prewarm || true # MySQL only
sysbench $ARGS --max-requests=100 --num-threads=2 run
sysbench $ARGS --events=100 --num-threads=2 run
sysbench $ARGS cleanup

View File

@ -27,7 +27,7 @@ do
db_show_table sbtest${i} || true # Error on non-existing table
done
sysbench $ARGS --max-requests=100 --num-threads=1 run
sysbench $ARGS --events=100 --num-threads=1 run
sysbench $ARGS cleanup

View File

@ -2,7 +2,7 @@
Basic Lua API tests
########################################################################
$ SB_ARGS="--verbosity=0 --max-requests=2 --num-threads=1 --db-driver=mysql $SBTEST_MYSQL_ARGS $CRAMTMP/api_basic.lua"
$ SB_ARGS="--verbosity=0 --events=2 --num-threads=1 --db-driver=mysql $SBTEST_MYSQL_ARGS $CRAMTMP/api_basic.lua"
$ cat >$CRAMTMP/api_basic.lua <<EOF
> function init(thread_id)
@ -67,7 +67,7 @@ Basic Lua API tests
> end
> EOF
$ sysbench $SB_ARGS --max-requests=1 run |
$ sysbench $SB_ARGS --events=1 run |
> sed -e "s/$SBTEST_VERSION_STRING/VERSION_STRING/" \
> -e "s/$SBTEST_VERSION/VERSION/"
VERSION
@ -78,7 +78,7 @@ Basic Lua API tests
> print(string.format("sysbench.cmdline.script_path = %s", sysbench.cmdline.script_path))
> end
> EOF
$ sysbench $SB_ARGS --max-requests=1 run
$ sysbench $SB_ARGS --events=1 run
sysbench.cmdline.script_path = */api_basic.lua (glob)
########################################################################

View File

@ -42,10 +42,12 @@ Legacy basic Lua API tests
$ sysbench $SB_ARGS prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
tid:(nil) prepare()
$ sysbench $SB_ARGS run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
tid:0 thread_init()
tid:0 event()
tid:0 event()
@ -53,10 +55,12 @@ Legacy basic Lua API tests
$ sysbench $SB_ARGS cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
tid:(nil) cleanup()
$ sysbench $SB_ARGS help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
tid:0 help()
$ cat >$CRAMTMP/api_legacy_basic.lua <<EOF
@ -66,4 +70,5 @@ Legacy basic Lua API tests
> EOF
$ sysbench $SB_ARGS prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
*/api_legacy_basic.lua (glob)

View File

@ -18,6 +18,7 @@ Legacy PRNG Lua API tests
$ sysbench $SB_ARGS --test=$CRAMTMP/api_legacy_rand.lua run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
sb_rand\(0, 9\) = [0-9]{1} (re)
sb_rand_uniq\(0, 4294967295\) = [0-9]{1,10} (re)
sb_rnd\(\) = [0-9]+ (re)
@ -41,6 +42,6 @@ issue #96: sb_rand_uniq(1, oltp_table_size) generate duplicate value
> EOF
$ sysbench $SB_ARGS --max-requests=100000 --test=$CRAMTMP/api_rand_uniq.lua run |
> sort -n | uniq | wc -l | sed -e 's/ //g'
> grep -v WARNING | sort -n | uniq | wc -l | sed -e 's/ //g'
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
100000

View File

@ -41,6 +41,7 @@ Legacy SQL Lua API tests
$ sysbench $SB_ARGS run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
DB_ERROR_NONE = [0-9] (re)
DB_ERROR_RESTART_TRANSACTION = [0-9] (re)
DB_ERROR_FAILED = [0-9] (re)
@ -177,6 +178,7 @@ Legacy SQL Lua API tests
) ENGINE=MyISAM AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest9' doesn't exist
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
sysbench *.* * (glob)
Running the test with following options:
@ -363,6 +365,7 @@ Legacy SQL Lua API tests
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest9' doesn't exist
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --max-requests is deprecated, use --events instead
sysbench *.* * (glob)
Running the test with following options:

View File

@ -2,7 +2,7 @@
PRNG Lua API tests
########################################################################
$ SB_ARGS="--verbosity=0 --max-requests=1 --num-threads=1"
$ SB_ARGS="--verbosity=0 --events=1 --num-threads=1"
$ cat >$CRAMTMP/api_rand.lua <<EOF
> function event()
@ -39,6 +39,6 @@ issue #96: sb_rand_uniq(1, oltp_table_size) generate duplicate value
> end
> EOF
$ sysbench $SB_ARGS --max-requests=100000 $CRAMTMP/api_rand_uniq.lua run |
$ sysbench $SB_ARGS --events=100000 $CRAMTMP/api_rand_uniq.lua run |
> sort -n | uniq | wc -l | sed -e 's/ //g'
100000

View File

@ -3,7 +3,7 @@ Tests for custom report hooks
########################################################################
# Trigger one intermediate and one cumulative report
$ SB_ARGS="api_reports.lua --max-time=3 --report-interval=2 --verbosity=1"
$ SB_ARGS="api_reports.lua --time=3 --report-interval=2 --verbosity=1"
########################################################################
# Default human-readable format via a custom hook

View File

@ -51,12 +51,12 @@
> print('event function')
> end
> EOF
$ sysbench --max-requests=1 $CRAMTMP/cmdline.lua
$ sysbench --events=1 $CRAMTMP/cmdline.lua
sysbench * (glob)
script body
$ sysbench --max-requests=1 $CRAMTMP/cmdline.lua run
$ sysbench --events=1 $CRAMTMP/cmdline.lua run
sysbench * (glob)
script body

View File

@ -13,11 +13,10 @@ separately.
General options:
--num-threads=N number of threads to use [1]
--max-requests=N limit for total number of requests [10000]
--max-time=N limit for total execution time in seconds [0]
--forced-shutdown=STRING number of seconds to wait after --max-time before forcing shutdown, or 'off' to disable [off]
--events=N limit for total number of events [0]
--time=N limit for total execution time in seconds [10]
--forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off]
--thread-stack-size=SIZE size of stack per thread [64K]
--tx-rate=N deprecated alias for --rate [0]
--rate=N average transactions rate. 0 for unlimited rate [0]
--report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
--report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
@ -26,6 +25,9 @@ separately.
--help[=on|off] print help and exit [off]
--version[=on|off] print version and exit [off]
--config-file=FILENAME File containing command line options
--tx-rate=N deprecated alias for --rate [0]
--max-requests=N deprecated alias for --events [0]
--max-time=N deprecated alias for --time [0]
Pseudo-Random Numbers Generator options:
--rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]

View File

@ -15,7 +15,7 @@
> end
> end
> EOF
$ sysbench --histogram $CRAMTMP/histogram.lua --max-requests=2 --num-threads=2 run
$ sysbench --histogram $CRAMTMP/histogram.lua --events=2 --num-threads=2 run
sysbench * (glob)
Running the test with following options:

View File

@ -7,7 +7,7 @@
> exit 80
> fi
$ sysbench ${SBTEST_SCRIPTDIR}/oltp_read_write.lua --db-driver=mysql --mysql-dry-run --max-time=3 --max-requests=0 --report-checkpoints=1,2 run | egrep '(Checkpoint report|SQL statistics)'
$ sysbench ${SBTEST_SCRIPTDIR}/oltp_read_write.lua --db-driver=mysql --mysql-dry-run --time=3 --events=0 --report-checkpoints=1,2 run | egrep '(Checkpoint report|SQL statistics)'
[ 1s] Checkpoint report:
SQL statistics:
[ 2s] Checkpoint report:
@ -16,5 +16,5 @@
# Run a test that does not support checkpoint reports
$ sysbench cpu --report-checkpoints=1 --max-time=2 run | grep 'Checkpoint report'
$ sysbench cpu --report-checkpoints=1 --time=2 run | grep 'Checkpoint report'
[ 1s] Checkpoint report:

View File

@ -7,10 +7,10 @@
> exit 80
> fi
$ sysbench ${SBTEST_SCRIPTDIR}/oltp_read_write.lua --db-driver=mysql --mysql-dry-run --max-time=3 --max-requests=0 --report-interval=1 run | grep '\[ 2s\]'
$ sysbench ${SBTEST_SCRIPTDIR}/oltp_read_write.lua --db-driver=mysql --mysql-dry-run --time=3 --events=0 --report-interval=1 run | grep '\[ 2s\]'
[ 2s] threads: 1 tps: * qps: * (r/w/o: */*/*) latency (ms,95%): *.* errors/s: 0.00 reconnects/s: 0.00 (glob)
# Run a test that does not support intermediate reports
$ sysbench cpu --report-interval=1 --max-time=2 run | grep '\[ 1s\]'
$ sysbench cpu --report-interval=1 --time=2 run | grep '\[ 1s\]'
[ 1s] threads: 1 events/s: * latency (ms,95%): * (glob)

View File

@ -1,7 +1,7 @@
########################################################################
cpu benchmark tests
########################################################################
$ args="cpu --cpu-max-prime=1000 --max-requests=100 --num-threads=2"
$ args="cpu --cpu-max-prime=1000 --events=100 --num-threads=2"
$ sysbench $args help
sysbench *.* * (glob)

View File

@ -34,7 +34,7 @@ fileio benchmark tests
$ sysbench $fileio_args run | grep FATAL
FATAL: Missing required argument: --file-test-mode
$ sysbench $fileio_args --max-requests=150 --file-test-mode=rndrw run
$ sysbench $fileio_args --events=150 --file-test-mode=rndrw run
sysbench *.* * (glob)
Running the test with following options:
@ -81,7 +81,7 @@ fileio benchmark tests
events (avg/stddev): 158.0000/0.00
execution time (avg/stddev): *.*/0.00 (glob)
$ sysbench $fileio_args --max-requests=150 --file-test-mode=rndrd run
$ sysbench $fileio_args --events=150 --file-test-mode=rndrd run
sysbench *.* * (glob)
Running the test with following options:
@ -129,7 +129,7 @@ fileio benchmark tests
execution time (avg/stddev): *.*/0.00 (glob)
$ sysbench $fileio_args --max-requests=150 --file-test-mode=seqrd run
$ sysbench $fileio_args --events=150 --file-test-mode=seqrd run
sysbench *.* * (glob)
Running the test with following options:
@ -175,7 +175,7 @@ fileio benchmark tests
execution time (avg/stddev): *.*/0.00 (glob)
$ sysbench $fileio_args --max-requests=150 --file-test-mode=rndwr run
$ sysbench $fileio_args --events=150 --file-test-mode=rndwr run
sysbench *.* * (glob)
Running the test with following options:
@ -223,7 +223,7 @@ fileio benchmark tests
execution time (avg/stddev): *.*/0.00 (glob)
$ sysbench $fileio_args --max-requests=150 --file-test-mode=foo run
$ sysbench $fileio_args --events=150 --file-test-mode=foo run
sysbench *.* * (glob)
FATAL: Invalid IO operations mode: foo.

View File

@ -2,7 +2,7 @@
memory benchmark tests
########################################################################
$ args="memory --memory-block-size=4K --memory-total-size=1G --max-requests=100 --num-threads=2"
$ args="memory --memory-block-size=4K --memory-total-size=1G --events=100 --num-threads=2"
The --memory-hugetlb option is supported and printed by 'sysbench
help' only on Linux.

View File

@ -1,7 +1,7 @@
########################################################################
mutex benchmark tests
########################################################################
$ args="mutex --max-requests=10 --num-threads=2"
$ args="mutex --events=10 --num-threads=2"
$ sysbench $args help
sysbench *.* * (glob)

View File

@ -2,7 +2,7 @@
threads benchmark tests
########################################################################
$ args="threads --max-requests=100 --num-threads=2"
$ args="threads --events=100 --num-threads=2"
$ sysbench $args help
sysbench *.* * (glob)