From ae295825efda5626f1d724e27e885d46ba20b6ef Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:15:31 -0800 Subject: [PATCH 01/96] Update oltp.lua Added new controls around range select operations (oltp_range_selects) and delete/insert operations (oltp_delete_inserts). --- sysbench/tests/db/oltp.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index c72cf69..e5f8ee6 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -18,6 +18,7 @@ end function event(thread_id) local rs local i + local idx local table_name local range_start local c_val @@ -33,6 +34,8 @@ function event(thread_id) rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) end + if oltp_range_selects then + for i=1, oltp_simple_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) @@ -53,6 +56,8 @@ function event(thread_id) rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") end + end + if not oltp_read_only then for i=1, oltp_index_updates do @@ -68,7 +73,9 @@ function event(thread_id) end end - i = sb_rand(1, oltp_table_size) + for idx=1, oltp_delete_inserts do + + idx = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) @@ -79,6 +86,8 @@ function event(thread_id) rs = db_query("INSERT INTO " .. table_name .. " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val)) + end + end -- oltp_read_only if not oltp_skip_trx then From 7ec8a14c5ee4cd13afc2cdbcaf65abfd157d2d09 Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:18:36 -0800 Subject: [PATCH 02/96] Update common.lua Add control defaults for oltp_delete_inserts and oltp_range_selects. --- sysbench/tests/db/common.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 6aabecd..6cfc62e 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -132,7 +132,14 @@ function set_vars() oltp_distinct_ranges = oltp_distinct_ranges or 1 oltp_index_updates = oltp_index_updates or 1 oltp_non_index_updates = oltp_non_index_updates or 1 + oltp_delete_inserts = oltp_delete_inserts or 1 + if (oltp_range_selets = 'off') then + oltp_range_selects = false + else + oltp_range_selects = true + end + if (oltp_auto_inc == 'off') then oltp_auto_inc = false else From 0accfd720625c80c968e49987cd30f3ae6b9da60 Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:21:41 -0800 Subject: [PATCH 03/96] Update oltp.lua --- sysbench/tests/db/oltp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index e5f8ee6..6edfc9d 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -75,7 +75,7 @@ function event(thread_id) for idx=1, oltp_delete_inserts do - idx = sb_rand(1, oltp_table_size) + i = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) From 06aa4d2d6b16a5c6fac5884681bd32d12f47ef34 Mon Sep 17 00:00:00 2001 From: VadimTK Date: Thu, 17 Mar 2016 00:28:43 -0400 Subject: [PATCH 04/96] Fix the issue when threads running < num_threads --- sysbench/sysbench.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index c008037..5a2fdae 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -474,6 +474,7 @@ static void *runner_thread(void *arg) thread_id = ctxt->id; log_text(LOG_DEBUG, "Runner thread started (%d)!", thread_id); + pthread_mutex_lock(&thread_start_mutex); if (test->ops.thread_init != NULL && test->ops.thread_init(thread_id) != 0) { sb_globals.error = 1; @@ -484,9 +485,11 @@ static void *runner_thread(void *arg) We do this to make sure all threads get to this barrier about the same time */ - pthread_mutex_lock(&thread_start_mutex); sb_globals.num_running++; pthread_mutex_unlock(&thread_start_mutex); + while(sb_globals.num_running < sb_globals.num_threads) { + sleep(1); + } do { From 26d5046cc96d6199393a75ccad4451da2f4c69b1 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 22 Mar 2016 21:09:41 +0300 Subject: [PATCH 05/96] Fixes #29: FATAL: Failed to read file! file: 24 pos: 14516224 errno = 0 (Success) Fail when test files do not exist for `sysbench --test=fileio run`, i.e. when they have not been prepared with `sysbench prepare`. --- sysbench/tests/fileio/sb_fileio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index a7a1a57..7c750d5 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -361,7 +361,7 @@ int file_prepare(void) files[i] = sb_open(file_name); if (!VALID_FILE(files[i])) { - log_errno(LOG_FATAL, "Cannot open file"); + log_errno(LOG_FATAL, "Cannot open file '%s'", file_name); return 1; } } @@ -2057,11 +2057,10 @@ static FILE_DESCRIPTOR sb_open(const char *name) return SB_INVALID_FILE; #ifndef _WIN32 - file = open(name, O_CREAT | O_RDWR | flags, - S_IRUSR | S_IWUSR); + file = open(name, O_RDWR | flags, S_IRUSR | S_IWUSR); #else - file = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, - OPEN_ALWAYS, flags, NULL); + file = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + flags, NULL); #endif #ifdef HAVE_DIRECTIO From 48bb8072318f7edf8088482511bea735582dbf73 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 23 Mar 2016 00:04:21 +0300 Subject: [PATCH 06/96] Add --with-pgsql to Travis CI builds. --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72901da..ef4372a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,14 +12,15 @@ addons: apt: packages: - libmysqlclient-dev + - libpq-dev before_install: - > case "${TRAVIS_OS_NAME:-linux}" in osx) brew update --quiet - brew install mysql + brew install mysql postgresql ;; esac -script: ./autogen.sh && ./configure && make +script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make From 24c7426e68f8c034d7b75ae69c409bd159282fcf Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 23 Mar 2016 00:09:26 +0300 Subject: [PATCH 07/96] Fix PostgreSQL driver. --- sysbench/drivers/pgsql/drv_pgsql.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sysbench/drivers/pgsql/drv_pgsql.c b/sysbench/drivers/pgsql/drv_pgsql.c index eab7755..38be62b 100644 --- a/sysbench/drivers/pgsql/drv_pgsql.c +++ b/sysbench/drivers/pgsql/drv_pgsql.c @@ -31,6 +31,7 @@ #include "sb_options.h" #include "db_driver.h" +#include "sb_rnd.h" /* Maximum length of text representation of bind parameters */ #define MAX_PARAM_LENGTH 256 From a04e9075fe30cdc7ec1d0fd8802eaa558a13e3fb Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 23 Mar 2016 07:51:03 +0300 Subject: [PATCH 08/96] Don't install PostgreSQL in Travis, as it seems to be installed by default. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef4372a..2863dc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: case "${TRAVIS_OS_NAME:-linux}" in osx) brew update --quiet - brew install mysql postgresql + brew install mysql ;; esac From 93e64fa80280b0cbee598bf17d16447222e59c03 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 23 Mar 2016 11:25:47 +0300 Subject: [PATCH 09/96] Re-create files after removing them when starting a --file-test-mode=seqwr benchmark. --- sysbench/tests/fileio/sb_fileio.c | 36 +++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index 766f42b..90e98a7 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -309,7 +309,8 @@ static unsigned long sb_getpagesize(void); static unsigned long sb_get_allocation_granularity(void); static void *sb_memalign(size_t size); static void sb_free_memaligned(void *buf); -static FILE_DESCRIPTOR sb_open(const char *name); +static FILE_DESCRIPTOR sb_open(const char *); +static FILE_DESCRIPTOR sb_create(const char *); int register_test_fileio(sb_list_t *tests) { @@ -355,8 +356,15 @@ int file_prepare(void) { snprintf(file_name, sizeof(file_name), "test_file.%d",i); /* remove test files for creation test if they exist */ - if (test_mode == MODE_WRITE) + if (test_mode == MODE_WRITE) + { unlink(file_name); + if (sb_create(file_name)) + { + log_errno(LOG_FATAL, "Cannot create file '%s'", file_name); + return 1; + } + } log_text(LOG_DEBUG, "Opening file: %s", file_name); files[i] = sb_open(file_name); @@ -2073,6 +2081,30 @@ static FILE_DESCRIPTOR sb_open(const char *name) return file; } +/* + Create a file with a given path. Signal an error if the file already + exists. Return a non-zero value on error. +*/ + +static int sb_create(const char *path) +{ + FILE_DESCRIPTOR file; + int res; + +#ifndef _WIN32 + file = open(path, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + res = !VALID_FILE(file); + close(file); +#else + file = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, + flags, NULL); + res = !VALID_FILE(file); + CloseHandle(file); +#endif + + return res; +} + /* Fill buffer with random values and write checksum */ From 7acfa8498be172b639eb6fb129cb92e384872284 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 23 Mar 2016 10:18:07 +0100 Subject: [PATCH 10/96] sb_print_value_size: use Ki, Mi, Gi, Ti Use the binary prefixes defined in IEC 80000-13. Ki, kibi = 2^10 Mi, mebi = 2^20 Gi, gibi = 2^30 Ti, tebi = 2^40 Signed-off-by: Heinrich Schuchardt --- sysbench/sb_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/sb_options.c b/sysbench/sb_options.c index bc541fc..6a18c0a 100644 --- a/sysbench/sb_options.c +++ b/sysbench/sb_options.c @@ -396,7 +396,7 @@ char *sb_print_value_size(char *buf, unsigned int buflen, double value) /* empty */ ; if (i > 0) - snprintf(buf, buflen, "%.5g%c", value, sizemods[i-1]); + snprintf(buf, buflen, "%.5g%ci", value, sizemods[i-1]); else snprintf(buf, buflen, "%.5g", value); From d373c964479f6ed24564f5c9df6a117f8f4ed33d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 23 Mar 2016 10:25:54 +0100 Subject: [PATCH 11/96] sb_fileio.c: use correct units Use the binary prefixes defined in IEC 80000-13. Ki, kibi = 2^10 Mi, mebi = 2^20 Gi, gibi = 2^30 Ti, tebi = 2^40 Use B for Byte, b for bit. Signed-off-by: Heinrich Schuchardt --- sysbench/tests/fileio/sb_fileio.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index 90e98a7..b340622 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -801,15 +801,15 @@ void file_print_mode(void) char sizestr[16]; log_text(LOG_NOTICE, "Extra file open flags: %x", file_extra_flags); - log_text(LOG_NOTICE, "%d files, %sb each", num_files, + log_text(LOG_NOTICE, "%d files, %sB each", num_files, sb_print_value_size(sizestr, sizeof(sizestr), file_size)); - log_text(LOG_NOTICE, "%sb total file size", + log_text(LOG_NOTICE, "%sB total file size", sb_print_value_size(sizestr, sizeof(sizestr), file_size * num_files)); - log_text(LOG_NOTICE, "Block size %sb", + log_text(LOG_NOTICE, "Block size %sB", sb_print_value_size(sizestr, sizeof(sizestr), file_block_size)); if (file_merged_requests > 0) - log_text(LOG_NOTICE, "Merging requests up to %sb for sequential IO.", + log_text(LOG_NOTICE, "Merging requests up to %sB for sequential IO.", sb_print_value_size(sizestr, sizeof(sizestr), file_max_request_size)); @@ -877,7 +877,7 @@ void file_print_stats(sb_stat_t type) SB_THREAD_MUTEX_UNLOCK(); log_timestamp(LOG_NOTICE, &sb_globals.exec_timer, - "reads: %4.2f MB/s writes: %4.2f MB/s fsyncs: %4.2f/s " + "reads: %4.2f MiB/s writes: %4.2f MiB/s fsyncs: %4.2f/s " "response time: %4.3fms (%u%%)", diff_read / megabyte / seconds, diff_written / megabyte / seconds, @@ -897,8 +897,8 @@ void file_print_stats(sb_stat_t type) log_text(LOG_NOTICE, "Operations performed: %d reads, %d writes, %d Other = %d Total", read_ops, write_ops, other_ops, read_ops + write_ops + other_ops); - log_text(LOG_NOTICE, "Read %sb Written %sb Total transferred %sb " - "(%sb/sec)", + log_text(LOG_NOTICE, "Read %sB Written %sB Total transferred %sB " + "(%sB/sec)", sb_print_value_size(s1, sizeof(s1), bytes_read), sb_print_value_size(s2, sizeof(s2), bytes_written), sb_print_value_size(s3, sizeof(s3), bytes_read + bytes_written), @@ -1092,7 +1092,7 @@ int create_files(void) seconds = NS2SEC(sb_timer_value(&t)); if (written > 0) - log_text(LOG_NOTICE, "%llu bytes written in %.2f seconds (%.2f MB/sec).", + log_text(LOG_NOTICE, "%llu bytes written in %.2f seconds (%.2f MiB/sec).", written, seconds, (double) (written / megabyte) / seconds); else From c9ba61dc754932275a98aae7c569b695553e0b4f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 23 Mar 2016 10:30:42 +0100 Subject: [PATCH 12/96] sb_memory.c: use correct units Use the binary prefixes defined in IEC 80000-13. Ki, kibi = 2^10 Mi, mebi = 2^20 Use B for bytes. Signed-off-by: Heinrich Schuchardt --- sysbench/tests/memory/sb_memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sysbench/tests/memory/sb_memory.c b/sysbench/tests/memory/sb_memory.c index 50f042c..ba73dff 100644 --- a/sysbench/tests/memory/sb_memory.c +++ b/sysbench/tests/memory/sb_memory.c @@ -322,9 +322,9 @@ void memory_print_mode(void) char *str; log_text(LOG_INFO, "Doing memory operations speed test"); - log_text(LOG_INFO, "Memory block size: %ldK\n", + log_text(LOG_INFO, "Memory block size: %ldKiB\n", (long)(memory_block_size / 1024)); - log_text(LOG_INFO, "Memory transfer size: %ldM\n", + log_text(LOG_INFO, "Memory transfer size: %ldMiB\n", (long)(memory_total_size / 1024 / 1024)); switch (memory_oper) { @@ -369,7 +369,7 @@ void memory_print_stats(sb_stat_t type) seconds = NS2SEC(sb_timer_split(&sb_globals.exec_timer)); log_timestamp(LOG_NOTICE, &sb_globals.exec_timer, - "%4.2f MB/sec,", + "%4.2f MiB/sec,", (double)(total_bytes - last_bytes) / megabyte / seconds); last_bytes = total_bytes; SB_THREAD_MUTEX_UNLOCK(); @@ -382,7 +382,7 @@ void memory_print_stats(sb_stat_t type) log_text(LOG_NOTICE, "Operations performed: %d (%8.2f ops/sec)\n", total_ops, total_ops / seconds); if (memory_oper != SB_MEM_OP_NONE) - log_text(LOG_NOTICE, "%4.2f MB transferred (%4.2f MB/sec)\n", + log_text(LOG_NOTICE, "%4.2f MiB transferred (%4.2f MiB/sec)\n", total_bytes / megabyte, total_bytes / megabyte / seconds); total_ops = 0; From 684c433a6edb36a4995a153da4489fbc8f005e16 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 23 Mar 2016 12:09:02 +0100 Subject: [PATCH 13/96] configure.ac: bump version number to 1.0 The version number in configure.ac should match the branch. Signed-off-by: Heinrich Schuchardt --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1712659..9b81ac1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT([sysbench],[0.9],[akopytov@gmail.com]) +AC_INIT([sysbench],[1.0],[akopytov@gmail.com]) AC_CONFIG_AUX_DIR([config]) # Setting CFLAGS here prevents AC_CANONICAL_TARGET from injecting them SAVE_CFLAGS=${CFLAGS} From 5d87570f6b40c76e3e7937e7070337692ddabba1 Mon Sep 17 00:00:00 2001 From: Vadim Tk Date: Thu, 24 Mar 2016 22:57:49 -0400 Subject: [PATCH 14/96] Fix prepare parallel for new thread initialization --- sysbench/tests/db/parallel_prepare.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sysbench/tests/db/parallel_prepare.lua b/sysbench/tests/db/parallel_prepare.lua index a28af58..f956eb7 100644 --- a/sysbench/tests/db/parallel_prepare.lua +++ b/sysbench/tests/db/parallel_prepare.lua @@ -1,12 +1,16 @@ +-- for proper initialization use --max-requests = N, where N is --num-threads +-- pathtest = string.match(test, "(.*/)") or "" dofile(pathtest .. "common.lua") function thread_init(thread_id) + set_vars() +end + +function event(thread_id) local index_name local i - set_vars() - print("thread prepare"..thread_id) if (oltp_secondary) then @@ -20,7 +24,3 @@ function thread_init(thread_id) end end - -function event(thread_id) - -end From 47c0ec5a79ee30c060f07a333b5f4e8cde6b7423 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 26 Mar 2016 21:46:41 +0300 Subject: [PATCH 15/96] Improve results formatting in the fileio test. --- sysbench/tests/fileio/sb_fileio.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index b340622..214d324 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -809,7 +809,7 @@ void file_print_mode(void) log_text(LOG_NOTICE, "Block size %sB", sb_print_value_size(sizestr, sizeof(sizestr), file_block_size)); if (file_merged_requests > 0) - log_text(LOG_NOTICE, "Merging requests up to %sB for sequential IO.", + log_text(LOG_NOTICE, "Merging requests up to %sB for sequential IO.", sb_print_value_size(sizestr, sizeof(sizestr), file_max_request_size)); @@ -854,7 +854,6 @@ void file_print_mode(void) void file_print_stats(sb_stat_t type) { double seconds; - char s1[16], s2[16], s3[16], s4[16]; unsigned long long diff_read; unsigned long long diff_written; unsigned long long diff_other_ops; @@ -878,7 +877,7 @@ void file_print_stats(sb_stat_t type) log_timestamp(LOG_NOTICE, &sb_globals.exec_timer, "reads: %4.2f MiB/s writes: %4.2f MiB/s fsyncs: %4.2f/s " - "response time: %4.3fms (%u%%)", + "latency: %4.3f ms (%uth pct.)", diff_read / megabyte / seconds, diff_written / megabyte / seconds, diff_other_ops / seconds, @@ -894,18 +893,19 @@ void file_print_stats(sb_stat_t type) case SB_STAT_CUMULATIVE: seconds = NS2SEC(sb_timer_split(&sb_globals.cumulative_timer1)); - log_text(LOG_NOTICE, - "Operations performed: %d reads, %d writes, %d Other = %d Total", - read_ops, write_ops, other_ops, read_ops + write_ops + other_ops); - log_text(LOG_NOTICE, "Read %sB Written %sB Total transferred %sB " - "(%sB/sec)", - sb_print_value_size(s1, sizeof(s1), bytes_read), - sb_print_value_size(s2, sizeof(s2), bytes_written), - sb_print_value_size(s3, sizeof(s3), bytes_read + bytes_written), - sb_print_value_size(s4, sizeof(s4), - (bytes_read + bytes_written) / seconds)); - log_text(LOG_NOTICE, "%8.2f Requests/sec executed", - (read_ops + write_ops) / seconds); + log_text(LOG_NOTICE, "\n" + "File operations:\n" + " reads/s: %4.2f\n" + " writes/s: %4.2f\n" + " fsyncs/s: %4.2f\n" + "\n" + "Throughput:\n" + " read, MiB/s: %4.2f\n" + " written, MiB/s: %4.2f", + read_ops / seconds, write_ops / seconds, other_ops / seconds, + bytes_read / megabyte / seconds, + bytes_written / megabyte / seconds); + clear_stats(); break; From db9df060509e1c9a29b525a582af0f5366486a33 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 26 Mar 2016 22:43:48 +0300 Subject: [PATCH 16/96] Add __attribute__((format...)) to printf-like function declarations. The SB_ATTRIBUTE_FORMAT() now expands to __attribute__((format...) on platforms that support it. Fixed a number of inconsistencies between format string and arguments revealed by the format attribute. --- configure.ac | 4 + m4/ax_gcc_func_attribute.m4 | 223 +++++++++++++++++++++++++++++ sysbench/db_driver.c | 18 +-- sysbench/drivers/mysql/drv_mysql.c | 10 +- sysbench/sb_global.h | 33 +++++ sysbench/sb_logger.h | 10 +- sysbench/sysbench.c | 4 +- sysbench/sysbench.h | 4 - sysbench/tests/fileio/sb_fileio.c | 7 +- 9 files changed, 288 insertions(+), 25 deletions(-) create mode 100644 m4/ax_gcc_func_attribute.m4 create mode 100644 sysbench/sb_global.h diff --git a/configure.ac b/configure.ac index 9b81ac1..6b20f9a 100644 --- a/configure.ac +++ b/configure.ac @@ -268,6 +268,10 @@ AX_TLS([], AC_MSG_ERROR([Thread-local storage is not suppored by the target platform!]) ) +# Define HAVE_FUNC_ATTRIBUTE_FORMAT if compiler supports the +# __attribute__((format...)) function attribute +AX_GCC_FUNC_ATTRIBUTE(format) + if test "$enable_largefile" = yes; then AC_SYS_LARGEFILE fi diff --git a/m4/ax_gcc_func_attribute.m4 b/m4/ax_gcc_func_attribute.m4 new file mode 100644 index 0000000..c788ca9 --- /dev/null +++ b/m4/ax_gcc_func_attribute.m4 @@ -0,0 +1,223 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's function +# attributes; many other compilers also provide function attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_func_attribute_ +# variable. +# +# The macro currently supports the following function attributes: +# +# alias +# aligned +# alloc_size +# always_inline +# artificial +# cold +# const +# constructor +# constructor_priority for constructor attribute with priority +# deprecated +# destructor +# dllexport +# dllimport +# error +# externally_visible +# flatten +# format +# format_arg +# gnu_inline +# hot +# ifunc +# leaf +# malloc +# noclone +# noinline +# nonnull +# noreturn +# nothrow +# optimize +# pure +# unused +# used +# visibility +# warning +# warn_unused_result +# weak +# weakref +# +# Unsuppored function attributes will be tested with a prototype returning +# an int and not accepting any arguments and the result of the check might +# be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 3 + +AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [alias], [ + int foo( void ) { return 0; } + int bar( void ) __attribute__(($1("foo"))); + ], + [aligned], [ + int foo( void ) __attribute__(($1(32))); + ], + [alloc_size], [ + void *foo(int a) __attribute__(($1(1))); + ], + [always_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [artificial], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [cold], [ + int foo( void ) __attribute__(($1)); + ], + [const], [ + int foo( void ) __attribute__(($1)); + ], + [constructor_priority], [ + int foo( void ) __attribute__((__constructor__(65535/2))); + ], + [constructor], [ + int foo( void ) __attribute__(($1)); + ], + [deprecated], [ + int foo( void ) __attribute__(($1(""))); + ], + [destructor], [ + int foo( void ) __attribute__(($1)); + ], + [dllexport], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [dllimport], [ + int foo( void ) __attribute__(($1)); + ], + [error], [ + int foo( void ) __attribute__(($1(""))); + ], + [externally_visible], [ + int foo( void ) __attribute__(($1)); + ], + [flatten], [ + int foo( void ) __attribute__(($1)); + ], + [format], [ + int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); + ], + [format_arg], [ + char *foo(const char *p) __attribute__(($1(1))); + ], + [gnu_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [hot], [ + int foo( void ) __attribute__(($1)); + ], + [ifunc], [ + int my_foo( void ) { return 0; } + static int (*resolve_foo(void))(void) { return my_foo; } + int foo( void ) __attribute__(($1("resolve_foo"))); + ], + [leaf], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [malloc], [ + void *foo( void ) __attribute__(($1)); + ], + [noclone], [ + int foo( void ) __attribute__(($1)); + ], + [noinline], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [nonnull], [ + int foo(char *p) __attribute__(($1(1))); + ], + [noreturn], [ + void foo( void ) __attribute__(($1)); + ], + [nothrow], [ + int foo( void ) __attribute__(($1)); + ], + [optimize], [ + __attribute__(($1(3))) int foo( void ) { return 0; } + ], + [pure], [ + int foo( void ) __attribute__(($1)); + ], + [unused], [ + int foo( void ) __attribute__(($1)); + ], + [used], [ + int foo( void ) __attribute__(($1)); + ], + [visibility], [ + int foo_def( void ) __attribute__(($1("default"))); + int foo_hid( void ) __attribute__(($1("hidden"))); + int foo_int( void ) __attribute__(($1("internal"))); + int foo_pro( void ) __attribute__(($1("protected"))); + ], + [warning], [ + int foo( void ) __attribute__(($1(""))); + ], + [warn_unused_result], [ + int foo( void ) __attribute__(($1)); + ], + [weak], [ + int foo( void ) __attribute__(($1)); + ], + [weakref], [ + static int foo( void ) { return 0; } + static int bar( void ) __attribute__(($1("foo"))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo( void ) __attribute__(($1)); + ] + )], []) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' function attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/sysbench/db_driver.c b/sysbench/db_driver.c index 8fdc438..3ec9b97 100644 --- a/sysbench/db_driver.c +++ b/sysbench/db_driver.c @@ -892,24 +892,24 @@ void db_print_stats(sb_stat_t type) log_text(LOG_NOTICE, "OLTP test statistics:"); log_text(LOG_NOTICE, " queries performed:"); - log_text(LOG_NOTICE, " read: %d", + log_text(LOG_NOTICE, " read: %lu", read_ops); - log_text(LOG_NOTICE, " write: %d", + log_text(LOG_NOTICE, " write: %lu", write_ops); - log_text(LOG_NOTICE, " other: %d", + log_text(LOG_NOTICE, " other: %lu", other_ops); - log_text(LOG_NOTICE, " total: %d", + log_text(LOG_NOTICE, " total: %lu", read_ops + write_ops + other_ops); - log_text(LOG_NOTICE, " transactions: %-6d" + log_text(LOG_NOTICE, " transactions: %-6lu" " (%.2f per sec.)", transactions, transactions / seconds); - log_text(LOG_NOTICE, " read/write requests: %-6d" + log_text(LOG_NOTICE, " read/write requests: %-6lu" " (%.2f per sec.)", read_ops + write_ops, (read_ops + write_ops) / seconds); - log_text(LOG_NOTICE, " other operations: %-6d" + log_text(LOG_NOTICE, " other operations: %-6lu" " (%.2f per sec.)", other_ops, other_ops / seconds); - log_text(LOG_NOTICE, " ignored errors: %-6d" + log_text(LOG_NOTICE, " ignored errors: %-6lu" " (%.2f per sec.)", errors, errors / seconds); - log_text(LOG_NOTICE, " reconnects: %-6d" + log_text(LOG_NOTICE, " reconnects: %-6lu" " (%.2f per sec.)", reconnects, reconnects / seconds); if (db_globals.debug) diff --git a/sysbench/drivers/mysql/drv_mysql.c b/sysbench/drivers/mysql/drv_mysql.c index 90b011e..02e0374 100644 --- a/sysbench/drivers/mysql/drv_mysql.c +++ b/sysbench/drivers/mysql/drv_mysql.c @@ -481,7 +481,8 @@ int mysql_drv_prepare(db_stmt_t *stmt, const char *query) return 1; } stmt->ptr = (void *)mystmt; - DEBUG("mysql_stmt_prepare(%p, \"%s\", %d) = %p", mystmt, query, strlen(query), stmt->ptr); + DEBUG("mysql_stmt_prepare(%p, \"%s\", %u) = %p", mystmt, query, + (unsigned int) strlen(query), stmt->ptr); if (mysql_stmt_prepare(mystmt, query, strlen(query))) { /* Check if this statement in not supported */ @@ -842,7 +843,8 @@ int mysql_drv_query(db_conn_t *sb_conn, const char *query, con = db_mysql_con->mysql; rc = (unsigned int)mysql_real_query(con, query, strlen(query)); - DEBUG("mysql_real_query(%p, \"%s\", %u) = %u", con, query, strlen(query), rc); + DEBUG("mysql_real_query(%p, \"%s\", %u) = %u", con, query, + (unsigned int) strlen(query), rc); if (rc) return check_error(sb_conn, "mysql_drv_query()", query); @@ -924,7 +926,7 @@ int mysql_drv_store_results(db_result_set_t *rs) return check_error(rs->connection, "mysql_stmt_store_result()", NULL); } rs->nrows = mysql_stmt_num_rows(rs->statement->ptr); - DEBUG("mysql_stmt_num_rows(%p) = %d", rs->statement->ptr, rs->nrows); + DEBUG("mysql_stmt_num_rows(%p) = %llu", rs->statement->ptr, rs->nrows); do { rc = (unsigned int)mysql_stmt_fetch(rs->statement->ptr); DEBUG("mysql_stmt_fetch(%p) = %d", rs->statement->ptr, rc); @@ -950,7 +952,7 @@ int mysql_drv_store_results(db_result_set_t *rs) rs->ptr = (void *)res; rs->nrows = mysql_num_rows(res); - DEBUG("mysql_num_rows(%p) = %u", res, rs->nrows); + DEBUG("mysql_num_rows(%p) = %llu", res, rs->nrows); /* just fetch result */ while((row = mysql_fetch_row(res))) diff --git a/sysbench/sb_global.h b/sysbench/sb_global.h new file mode 100644 index 0000000..edf855f --- /dev/null +++ b/sysbench/sb_global.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2016 Alexey Kopytov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* Global and portability-related macros */ + +#ifndef SB_GLOBAL_H +#define SB_GLOBAL_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT +# define SB_ATTRIBUTE_FORMAT(style, m, n) __attribute__((format(style, m, n))) +#else +# define SB_ATTRIBUTE_FORMAT(style, m, n) +#endif + +#endif /* SB_GLOBAL_H */ diff --git a/sysbench/sb_logger.h b/sysbench/sb_logger.h index eec2ac4..2d0644b 100644 --- a/sysbench/sb_logger.h +++ b/sysbench/sb_logger.h @@ -23,6 +23,7 @@ # include "config.h" #endif +#include "sb_global.h" #include "sb_options.h" #include "sb_timer.h" @@ -144,7 +145,8 @@ void log_msg(log_msg_t *); /* printf-like wrapper to log text messages */ -void log_text(log_msg_priority_t priority, const char *fmt, ...); +void log_text(log_msg_priority_t priority, const char *fmt, ...) + SB_ATTRIBUTE_FORMAT(printf, 2, 3); /* variant of log_text() which prepends log lines with a elapsed time of the @@ -152,11 +154,13 @@ void log_text(log_msg_priority_t priority, const char *fmt, ...); */ void log_timestamp(log_msg_priority_t priority, const sb_timer_t *timer, - const char *fmt, ...); + const char *fmt, ...) + SB_ATTRIBUTE_FORMAT(printf, 3, 4); /* printf-like wrapper to log system error messages */ -void log_errno(log_msg_priority_t priority, const char *fmt, ...); +void log_errno(log_msg_priority_t priority, const char *fmt, ...) + SB_ATTRIBUTE_FORMAT(printf, 2, 3); /* Uninitialize logger */ diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index e6e3d09..dc14472 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -659,7 +659,7 @@ static void *report_thread_proc(void *arg) if (current_test->ops.print_stats == NULL) { - log_text(LOG_DEBUG, "Reporting not supported by the current test, ", + log_text(LOG_DEBUG, "Reporting not supported by the current test, " "terminating the reporting thread"); return NULL; } @@ -709,7 +709,7 @@ static void *checkpoints_thread_proc(void *arg) if (current_test->ops.print_stats == NULL) { - log_text(LOG_DEBUG, "Reporting not supported by the current test, ", + log_text(LOG_DEBUG, "Reporting not supported by the current test, " "terminating the checkpoints thread"); return NULL; } diff --git a/sysbench/sysbench.h b/sysbench/sysbench.h index a26a3f0..2ba5f96 100644 --- a/sysbench/sysbench.h +++ b/sysbench/sysbench.h @@ -19,10 +19,6 @@ #ifndef SYSBENCH_H #define SYSBENCH_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #ifdef STDC_HEADERS # include # include diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index 214d324..f1a9d8f 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -751,8 +751,8 @@ int file_execute_request(sb_request_t *sb_req, int thread_id) file_validate_buffer(per_thread[thread_id].buffer, file_req->size, file_req->pos)) { log_text(LOG_FATAL, - "Validation failed on file " FD_FMT ", block offset 0x%x, exiting...", - file_req->file_id, file_req->pos); + "Validation failed on file " FD_FMT ", block offset %lld, exiting...", + file_req->file_id, (long long) file_req->pos); return 1; } @@ -2139,7 +2139,8 @@ int file_validate_buffer(unsigned char *buf, unsigned int len, size_t offset) if (checksum != *(unsigned int *)(void *)(buf + cs_offset)) { - log_text(LOG_FATAL, "Checksum mismatch in block: ", offset); + log_text(LOG_FATAL, "Checksum mismatch in block with offset: %lld", + (long long) offset); log_text(LOG_FATAL, " Calculated value: 0x%x Stored value: 0x%x", checksum, *(unsigned int *)(void *)(buf + cs_offset)); return 1; From cb9a2cdc293b1d60d551b4d3de00c69586a98544 Mon Sep 17 00:00:00 2001 From: VadimTk Date: Fri, 8 Apr 2016 17:34:50 +0000 Subject: [PATCH 17/96] Revert "Fix the issue when threads running < num_threads" This reverts commit 06aa4d2d6b16a5c6fac5884681bd32d12f47ef34. --- sysbench/sysbench.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 5a2fdae..c008037 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -474,7 +474,6 @@ static void *runner_thread(void *arg) thread_id = ctxt->id; log_text(LOG_DEBUG, "Runner thread started (%d)!", thread_id); - pthread_mutex_lock(&thread_start_mutex); if (test->ops.thread_init != NULL && test->ops.thread_init(thread_id) != 0) { sb_globals.error = 1; @@ -485,11 +484,9 @@ static void *runner_thread(void *arg) We do this to make sure all threads get to this barrier about the same time */ + pthread_mutex_lock(&thread_start_mutex); sb_globals.num_running++; pthread_mutex_unlock(&thread_start_mutex); - while(sb_globals.num_running < sb_globals.num_threads) { - sleep(1); - } do { From 4190ad29b701526c539df4ddd5c8d19b13090eb5 Mon Sep 17 00:00:00 2001 From: Vadim Tk Date: Sun, 10 Apr 2016 19:59:06 -0400 Subject: [PATCH 18/96] adjust event generation for a high volume --- sysbench/sysbench.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 0c1e5a7..3e91306 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -606,15 +606,16 @@ static void *eventgen_thread_proc(void *arg) next_ns = next_ns + intr_ns*1000; if (next_ns > curr_ns) + { pause_ns = next_ns - curr_ns; + usleep(pause_ns / 1000); + } else { - pause_ns = 1000; log_timestamp(LOG_DEBUG, &sb_globals.exec_timer, "Event generation thread is too slow"); } - usleep(pause_ns / 1000); queue_array[i].event_time = sb_timer_value(&sb_globals.exec_timer); pthread_mutex_lock(&event_queue_mutex); From 6f2ac41d16316749c3f4fa7e445c3b004add00ea Mon Sep 17 00:00:00 2001 From: Marc-T Date: Mon, 11 Apr 2016 13:42:24 +0200 Subject: [PATCH 19/96] FileIO fix - Fix sb_create function definition - Fix Windows "CreateFile" parameters --- sysbench/tests/fileio/sb_fileio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index f1a9d8f..c32e601 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -310,7 +310,7 @@ static unsigned long sb_get_allocation_granularity(void); static void *sb_memalign(size_t size); static void sb_free_memaligned(void *buf); static FILE_DESCRIPTOR sb_open(const char *); -static FILE_DESCRIPTOR sb_create(const char *); +static int sb_create(const char *); int register_test_fileio(sb_list_t *tests) { @@ -2096,8 +2096,8 @@ static int sb_create(const char *path) res = !VALID_FILE(file); close(file); #else - file = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, - flags, NULL); + file = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, + 0, NULL); res = !VALID_FILE(file); CloseHandle(file); #endif From 8c69009f1c69a49ca5bdb325befaceb5487e5636 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 19 Apr 2016 11:54:32 +1000 Subject: [PATCH 20/96] %zd for size_t printf ops --- sysbench/tests/memory/sb_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/memory/sb_memory.c b/sysbench/tests/memory/sb_memory.c index ba73dff..73abae0 100644 --- a/sysbench/tests/memory/sb_memory.c +++ b/sysbench/tests/memory/sb_memory.c @@ -415,7 +415,7 @@ void * hugetlb_alloc(size_t size) if (shmid < 0) { log_errno(LOG_FATAL, - "Failed to allocate %d bytes from HugeTLB memory.", size); + "Failed to allocate %zd bytes from HugeTLB memory.", size); return NULL; } From 9af6a88207db13ee525d5de03bce581d59473dbf Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 28 Apr 2016 09:30:51 +0300 Subject: [PATCH 21/96] Use srandom()/random() to initialize per-thread RNGs. --- sysbench/sysbench.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 3fd5973..74ff7d8 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -448,13 +448,13 @@ void print_run_mode(sb_test_t *test) if (rand_seed) { log_text(LOG_NOTICE, "Initializing random number generator from seed (%d).\n", rand_seed); - sb_srnd(rand_seed); + srandom(rand_seed); } else { log_text(LOG_NOTICE, "Initializing random number generator from current time\n"); - sb_srnd(time(NULL)); + srandom(time(NULL)); } if (sb_globals.force_shutdown) @@ -486,7 +486,7 @@ static void *worker_thread(void *arg) thread_id = ctxt->id; /* Initialize thread-local RNG state */ - sb_srnd(thread_id); + sb_srnd(random()); log_text(LOG_DEBUG, "Worker thread started (%d)!", thread_id); From 56fe38976223137099332ed91df8b8dd148b0f38 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 23 Mar 2016 11:25:47 +0300 Subject: [PATCH 22/96] Fixes #44: seqwr deleting test files Re-create files after removing them when starting a --file-test-mode=seqwr benchmark. --- sysbench/tests/fileio/sb_fileio.c | 36 +++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index 7c750d5..369c9ae 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -308,7 +308,8 @@ static unsigned long sb_getpagesize(void); static unsigned long sb_get_allocation_granularity(void); static void *sb_memalign(size_t size); static void sb_free_memaligned(void *buf); -static FILE_DESCRIPTOR sb_open(const char *name); +static FILE_DESCRIPTOR sb_open(const char *); +static FILE_DESCRIPTOR sb_create(const char *); int register_test_fileio(sb_list_t *tests) { @@ -354,8 +355,15 @@ int file_prepare(void) { snprintf(file_name, sizeof(file_name), "test_file.%d",i); /* remove test files for creation test if they exist */ - if (test_mode == MODE_WRITE) + if (test_mode == MODE_WRITE) + { unlink(file_name); + if (sb_create(file_name)) + { + log_errno(LOG_FATAL, "Cannot create file '%s'", file_name); + return 1; + } + } log_text(LOG_DEBUG, "Opening file: %s", file_name); files[i] = sb_open(file_name); @@ -2075,6 +2083,30 @@ static FILE_DESCRIPTOR sb_open(const char *name) return file; } +/* + Create a file with a given path. Signal an error if the file already + exists. Return a non-zero value on error. +*/ + +static int sb_create(const char *path) +{ + FILE_DESCRIPTOR file; + int res; + +#ifndef _WIN32 + file = open(path, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + res = !VALID_FILE(file); + close(file); +#else + file = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_NEW, + flags, NULL); + res = !VALID_FILE(file); + CloseHandle(file); +#endif + + return res; +} + /* Fill buffer with random values and write checksum */ From 29845be750b9e0f95ff288ec5660b8e34168ab07 Mon Sep 17 00:00:00 2001 From: Marc-T Date: Thu, 12 May 2016 10:03:25 +0200 Subject: [PATCH 23/96] VS2015 fix timespec and snprintf are handled natively in VS2015 --- sysbench/sb_win.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sysbench/sb_win.h b/sysbench/sb_win.h index 24618cf..b481b9b 100644 --- a/sysbench/sb_win.h +++ b/sysbench/sb_win.h @@ -20,8 +20,6 @@ #define PACKAGE_VERSION "0.5" #endif -#define snprintf(buffer, count, format,...) \ - _snprintf_s(buffer,count, _TRUNCATE,format, __VA_ARGS__) #define strcasecmp _stricmp #define strncasecmp _strnicmp #define srandom(seed) srand(seed) @@ -39,11 +37,6 @@ typedef intptr_t ssize_t; #endif #endif -struct timespec -{ - time_t tv_sec; - long long tv_nsec; -}; typedef HANDLE pthread_t; typedef CRITICAL_SECTION pthread_mutex_t; From 72e8223996df4cb160fbc3f4e4eb46f0d0a932a2 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 20 Mar 2016 15:08:30 +0300 Subject: [PATCH 24/96] Don't remake aclocal.m4 and configure after autogen.sh && configure. Call aclocal after libtoolize, as otherwise `make` will remake aclocal.m4 and configure due to aclocal.m4 being older than libtool macros installed to m4/ by libtoolize. --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index e55907c..844f2b3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -85,8 +85,8 @@ if test x$AUTOHEADER = x; then fi fi -run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal" run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize" +run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal" run $AUTOHEADER || die "Can't execute autoheader" run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake" run $AUTOCONF || die "Can't execute autoconf" From 8ac5bd67208b2297a086eef4ee8c0c41c0ed1af4 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 15 May 2016 23:51:14 +0300 Subject: [PATCH 25/96] Fix --with-mysql-libs for MySQL 5.7. Don't use the hard-coded libmysqlclient_r name for the client library, because it is obsolete in 5.7. Instead, if the client library path is specified explicitly with --with-mysql-libs, try both libmysqlclient_r and libmysqlclient in that order. --- m4/ac_check_mysqlr.m4 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/m4/ac_check_mysqlr.m4 b/m4/ac_check_mysqlr.m4 index 67715d1..fbf819a 100644 --- a/m4/ac_check_mysqlr.m4 +++ b/m4/ac_check_mysqlr.m4 @@ -1,9 +1,9 @@ dnl --------------------------------------------------------------------------- dnl Macro: AC_CHECK_MYSQLR -dnl First check for custom MySQL paths in --with-mysql-* options. -dnl If some paths are missing, check if mysql_config exists. -dnl Then check for the libraries and replace -lmysqlclient with -dnl -lmysqlclient_r, to enable threaded client library. +dnl First check if the MySQL root directory is specified with --with-mysql. +dnl Otherwise check for custom MySQL paths in --with-mysql-includes and +dnl --with-mysql-libs. If some paths are not specified explicitly, try to get +dnl them from mysql_config. dnl --------------------------------------------------------------------------- AC_DEFUN([AC_CHECK_MYSQLR],[ @@ -51,7 +51,20 @@ then ac_cv_mysql_libs=`echo ${ac_cv_mysql_libs} | sed -e 's/.libs$//' \ -e 's+.libs/$++'` AC_CACHE_CHECK([MySQL libraries], [ac_cv_mysql_libs], [ac_cv_mysql_libs=""]) - MYSQL_LIBS="-L$ac_cv_mysql_libs -lmysqlclient_r" + save_LDFLAGS="$LDFLAGS" + save_LIBS="$LIBS" + LDFLAGS="-L$ac_cv_mysql_libs" + LIBS="" + + # libmysqlclient_r has been removed in MySQL 5.7 + AC_SEARCH_LIBS([mysql_real_connect], + [mysqlclient_r mysqlclient], + [], + AC_MSG_ERROR([cannot find MySQL client libraries in $ac_cv_mysql_libs])) + + MYSQL_LIBS="$LDFLAGS $LIBS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" fi # If some path is missing, try to autodetermine with mysql_config From e34876b0781477e7469551aaf5716ddc82643600 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 20 May 2016 20:52:14 +0300 Subject: [PATCH 26/96] Calculate ranges on the client + some oltp.lua cleanups. Use "WHERE id BETWEEN 1 and 100" rather than "WHERE id BETWEEN 1 AND 1+99" in generated range SQL queries. I.e. calculate range bounds on the client, there is no reason to push it to the server. --- sysbench/tests/db/oltp.lua | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index c72cf69..db78000 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -15,11 +15,16 @@ function thread_init(thread_id) end +function get_range_str() + local start = sb_rand(1, oltp_table_size) + return string.format(" WHERE id BETWEEN %u AND %u", + start, start + oltp_range_size - 1) +end + function event(thread_id) local rs local i local table_name - local range_start local c_val local pad_val local query @@ -30,27 +35,26 @@ function event(thread_id) end for i=1, oltp_point_selects do - rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) + rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. + sb_rand(1, oltp_table_size)) end for i=1, oltp_simple_ranges do - range_start = sb_rand(1, oltp_table_size) - rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) + rs = db_query("SELECT c FROM ".. table_name .. get_range_str() end - + for i=1, oltp_sum_ranges do - range_start = sb_rand(1, oltp_table_size) - rs = db_query("SELECT SUM(K) FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) + rs = db_query("SELECT SUM(K) FROM ".. table_name .. get_range_str() end - + for i=1, oltp_order_ranges do - range_start = sb_rand(1, oltp_table_size) - rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") + rs = db_query("SELECT c FROM ".. table_name .. get_range_str() .. + " ORDER BY c") end for i=1, oltp_distinct_ranges do - range_start = sb_rand(1, oltp_table_size) - rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") + rs = db_query("SELECT DISTINCT c FROM ".. table_name .. get_range_str() .. + " ORDER BY c") end if not oltp_read_only then From d11c8f589335050e25ca60f10477bae30d64974d Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 20 May 2016 21:17:47 +0300 Subject: [PATCH 27/96] Add missing parentheses. --- sysbench/tests/db/oltp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index db78000..8dda9ff 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -40,11 +40,11 @@ function event(thread_id) end for i=1, oltp_simple_ranges do - rs = db_query("SELECT c FROM ".. table_name .. get_range_str() + rs = db_query("SELECT c FROM ".. table_name .. get_range_str()) end for i=1, oltp_sum_ranges do - rs = db_query("SELECT SUM(K) FROM ".. table_name .. get_range_str() + rs = db_query("SELECT SUM(K) FROM ".. table_name .. get_range_str()) end for i=1, oltp_order_ranges do From 41be58594d08d6c2f9bf9244fe37bcf7c67bc21d Mon Sep 17 00:00:00 2001 From: Farid Zarazvand Date: Tue, 24 May 2016 14:18:08 +0430 Subject: [PATCH 28/96] Duplicate line Removing duplicate line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f0546bc..a47128d 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ The table below lists the supported common options, their descriptions and defau | `--help` | Print help on general syntax or on a test mode specified with --test, and exit | off | | `--verbosity` | Verbosity level (0 - only critical messages, 5 - debug) | 4 | | `--percentile` | SysBench measures execution times for all processed requests to display statistical information like minimal, average and maximum execution time. For most benchmarks it is also useful to know a request execution time value matching some percentile (e.g. 95% percentile means we should drop 5% of the most long requests and choose the maximal value from the remaining ones). This option allows to specify a percentile rank of query execution times to count | 95 | -| `--validate` | Perform validation of test results where possible | off | Note that numerical values for all *size* options (like `--thread-stack-size` in this table) may be specified by appending the corresponding multiplicative suffix (K for kilobytes, M for megabytes, G for gigabytes and T for terabytes). From 343664e95098c8f3ca963eb4deba725a46f5281d Mon Sep 17 00:00:00 2001 From: Espina Date: Mon, 30 May 2016 11:52:17 -0700 Subject: [PATCH 29/96] added locking to get_request in lua scripting --- sysbench/scripting/script_lua.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index 410eda8..7955af5 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -241,15 +241,18 @@ sb_request_t sb_lua_get_request(int thread_id) (void) thread_id; /* unused */ + SB_THREAD_MUTEX_LOCK(); if (sb_globals.max_requests != 0 && nevents >= sb_globals.max_requests) { req.type = SB_REQ_TYPE_NULL; + SB_THREAD_MUTEX_UNLOCK(); return req; } req.type = SB_REQ_TYPE_SCRIPT; nevents++; - + SB_THREAD_MUTEX_UNLOCK(); + return req; } From 9244fcf14ce52fa8d95595f4d5712729229a1b97 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 31 May 2016 09:39:48 +0300 Subject: [PATCH 30/96] Don't lock thread mutex unnecessarily in script_lua.c and sb_cpu.c. script_lua.c and sb_cpu.c do not actually need to lock any mutexes when the test duration is not limited by the number of events. --- sysbench/scripting/script_lua.c | 12 ++++++++---- sysbench/tests/cpu/sb_cpu.c | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index 7955af5..a103721 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -241,12 +241,16 @@ sb_request_t sb_lua_get_request(int thread_id) (void) thread_id; /* unused */ - SB_THREAD_MUTEX_LOCK(); - if (sb_globals.max_requests != 0 && nevents >= sb_globals.max_requests) + if (sb_globals.max_requests > 0) { - req.type = SB_REQ_TYPE_NULL; + SB_THREAD_MUTEX_LOCK(); + if (nevents >= sb_globals.max_requests) + { + req.type = SB_REQ_TYPE_NULL; + SB_THREAD_MUTEX_UNLOCK(); + return req; + } SB_THREAD_MUTEX_UNLOCK(); - return req; } req.type = SB_REQ_TYPE_SCRIPT; diff --git a/sysbench/tests/cpu/sb_cpu.c b/sysbench/tests/cpu/sb_cpu.c index 970b1a4..b2e665e 100644 --- a/sysbench/tests/cpu/sb_cpu.c +++ b/sysbench/tests/cpu/sb_cpu.c @@ -70,8 +70,6 @@ static sb_test_t cpu_test = static unsigned int max_prime; /* Request counter */ static unsigned int req_performed; -/* Counter mutex */ -static pthread_mutex_t request_mutex; int register_test_cpu(sb_list_t * tests) { @@ -92,8 +90,6 @@ int cpu_init(void) req_performed = 0; - pthread_mutex_init(&request_mutex, NULL); - return 0; } @@ -104,15 +100,20 @@ sb_request_t cpu_get_request(int thread_id) (void) thread_id; /* unused */ - if (sb_globals.max_requests > 0 && req_performed >= sb_globals.max_requests) + if (sb_globals.max_requests > 0) { - req.type = SB_REQ_TYPE_NULL; - return req; + SB_THREAD_MUTEX_LOCK(); + if (req_performed >= sb_globals.max_requests) + { + req.type = SB_REQ_TYPE_NULL; + SB_THREAD_MUTEX_UNLOCK(); + return req; + } + req_performed++; + SB_THREAD_MUTEX_UNLOCK(); } + req.type = SB_REQ_TYPE_CPU; - pthread_mutex_lock(&request_mutex); - req_performed++; - pthread_mutex_unlock(&request_mutex); return req; } @@ -158,7 +159,5 @@ void cpu_print_mode(void) int cpu_done(void) { - pthread_mutex_destroy(&request_mutex); - return 0; } From 3c22365b80ae413b8614b7c904c37aac288fe7f2 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 9 Jun 2016 19:55:22 +0300 Subject: [PATCH 31/96] Fix crash introduced by commit 9244fcf. There was a regression introduced by commit regression resulting a double release of mutex in script_lua.c. --- sysbench/scripting/script_lua.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index a103721..f14c33e 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -250,13 +250,12 @@ sb_request_t sb_lua_get_request(int thread_id) SB_THREAD_MUTEX_UNLOCK(); return req; } + nevents++; SB_THREAD_MUTEX_UNLOCK(); } req.type = SB_REQ_TYPE_SCRIPT; - nevents++; - SB_THREAD_MUTEX_UNLOCK(); - + return req; } From 8753cb93be4c0b81a20b704ced91e7a422da52b1 Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Fri, 10 Jun 2016 14:33:48 -0400 Subject: [PATCH 32/96] Adding volatile modifier to tmp variable in memory test Issue explanation: ./sysbench/sysbench --test=memory --num-threads=16 \ --memory-block-size=268435456 \ --memory-total-size=137438953472 \ --memory-oper=read \ --memory-access-mode=seq \ --memory-scope=local run Without this commit the time to run the above command is 0.0004 seconds. With this commit the time is greater than 3 seconds. Essentially, without the volatile modifier, the compiler optimizes read access so that no real access happens. --- sysbench/tests/memory/sb_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/memory/sb_memory.c b/sysbench/tests/memory/sb_memory.c index eace821..334e5f8 100644 --- a/sysbench/tests/memory/sb_memory.c +++ b/sysbench/tests/memory/sb_memory.c @@ -246,7 +246,7 @@ sb_request_t memory_get_request(int thread_id) int memory_execute_request(sb_request_t *sb_req, int thread_id) { sb_mem_request_t *mem_req = &sb_req->u.mem_request; - int tmp = 0; + volatile int tmp = 0; int idx; int *buf, *end; log_msg_t msg; From 909f9ec8e70ba17af895b0103856c354c82cd9b5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 5 Jul 2016 14:17:43 +0300 Subject: [PATCH 33/96] Fixes #55: Make percentile stats optional Allow --percentile=0 as a special value to disable percentile statistics calculation to avoid the overhead in highly concurrent benchmarks. --- sysbench/sb_logger.c | 7 ++++--- sysbench/sb_percentile.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sysbench/sb_logger.c b/sysbench/sb_logger.c index 59d0af6..785d669 100644 --- a/sysbench/sb_logger.c +++ b/sysbench/sb_logger.c @@ -105,7 +105,8 @@ static log_handler_t text_handler = { static sb_arg_t oper_handler_args[] = { - {"percentile", "percentile rank of query response times to count", + {"percentile", "percentile rank of query response times to count. " + "Use the special value of 0 to disable percentile statistics.", SB_ARG_TYPE_INT, "95"}, {NULL, NULL, SB_ARG_TYPE_NULL, NULL} @@ -485,7 +486,7 @@ int oper_handler_init(void) unsigned int i, tmp; tmp = sb_get_value_int("percentile"); - if (tmp < 1 || tmp > 100) + if (tmp < 0 || tmp > 100) { log_text(LOG_FATAL, "Invalid value for percentile option: %d", tmp); @@ -641,7 +642,7 @@ int print_global_stats(void) NS2MS(get_max_time(&t))); /* Print approx. percentile value for event execution times */ - if (t.events > 0) + if (t.events > 0 && sb_globals.percentile_rank > 0) { log_text(LOG_NOTICE, " approx. %3d percentile: %10.2fms", sb_globals.percentile_rank, NS2MS(percentile_val)); diff --git a/sysbench/sb_percentile.c b/sysbench/sb_percentile.c index def2d6d..72dff63 100644 --- a/sysbench/sb_percentile.c +++ b/sysbench/sb_percentile.c @@ -32,12 +32,16 @@ # include #endif +#include "sysbench.h" #include "sb_percentile.h" #include "sb_logger.h" int sb_percentile_init(sb_percentile_t *percentile, unsigned int size, double range_min, double range_max) { + if (sb_globals.percentile_rank == 0) + return 0; + percentile->values = (unsigned long long *) calloc(size, sizeof(unsigned long long)); percentile->tmp = (unsigned long long *) @@ -65,6 +69,9 @@ void sb_percentile_update(sb_percentile_t *percentile, double value) { unsigned int n; + if (sb_globals.percentile_rank == 0) + return; + if (value < percentile->range_min) value= percentile->range_min; else if (value > percentile->range_max) @@ -84,6 +91,9 @@ double sb_percentile_calculate(sb_percentile_t *percentile, double percent) unsigned long long ncur, nmax; unsigned int i; + if (sb_globals.percentile_rank == 0) + return 0.0; + pthread_mutex_lock(&percentile->mutex); if (percentile->total == 0) @@ -111,6 +121,9 @@ double sb_percentile_calculate(sb_percentile_t *percentile, double percent) void sb_percentile_reset(sb_percentile_t *percentile) { + if (sb_globals.percentile_rank == 0) + return; + pthread_mutex_lock(&percentile->mutex); percentile->total = 0; memset(percentile->values, 0, percentile->size * sizeof(unsigned long long)); @@ -119,6 +132,9 @@ void sb_percentile_reset(sb_percentile_t *percentile) void sb_percentile_done(sb_percentile_t *percentile) { + if (sb_globals.percentile_rank == 0) + return; + pthread_mutex_destroy(&percentile->mutex); free(percentile->values); free(percentile->tmp); From 53e9072c6146a4c071b60300c9cf229a51744fdd Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 20 Jul 2016 21:48:51 +0300 Subject: [PATCH 34/96] Fix debug messages to be more specific. --- sysbench/sysbench.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 74ff7d8..4261df6 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -488,7 +488,7 @@ static void *worker_thread(void *arg) /* Initialize thread-local RNG state */ sb_srnd(random()); - log_text(LOG_DEBUG, "Worker thread started (%d)!", thread_id); + log_text(LOG_DEBUG, "Worker thread (#%d) started", thread_id); if (test->ops.thread_init != NULL && test->ops.thread_init(thread_id) != 0) { @@ -499,7 +499,7 @@ static void *worker_thread(void *arg) return NULL; } - log_text(LOG_DEBUG, "Worker thread (#%d) started!", thread_id); + log_text(LOG_DEBUG, "Worker thread (#%d) initialized", thread_id); /* Wait for other threads to initialize */ if (sb_barrier_wait(&thread_start_barrier) < 0) From a099b20f2c615c374b6ef769ea78758460077000 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 21 Jul 2016 12:27:35 +0300 Subject: [PATCH 35/96] Fixes #57: Race condition in sb_timer_value() Avoid updating the timer state in sb_timer_value() to make it safe for concurrent usage on a shared timer. --- sysbench/sb_timer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sysbench/sb_timer.c b/sysbench/sb_timer.c index 9054c28..ecca91b 100644 --- a/sysbench/sb_timer.c +++ b/sysbench/sb_timer.c @@ -130,11 +130,16 @@ void sb_timer_stop(sb_timer_t *t) } -/* get the current timer value in nanoseconds */ +/* + get the current timer value in nanoseconds without affecting is state, i.e. + is safe to be used concurrently on a shared timer. +*/ unsigned long long sb_timer_value(sb_timer_t *t) { + struct timespec ts; + switch (t->state) { case TIMER_INITIALIZED: log_text(LOG_WARNING, "timer was never started"); @@ -148,9 +153,8 @@ unsigned long long sb_timer_value(sb_timer_t *t) abort(); } - sb_timer_update(t); - - return t->elapsed; + SB_GETTIME(&ts); + return TIMESPEC_DIFF(ts, t->time_start) + t->queue_time; } From 00eb404a86b54ea99af1150a5efdecbf4d8c82b7 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 15 May 2016 23:51:14 +0300 Subject: [PATCH 36/96] Fix --with-mysql-libs for MySQL 5.7. Don't use the hard-coded libmysqlclient_r name for the client library, because it is obsolete in 5.7. Instead, if the client library path is specified explicitly with --with-mysql-libs, try both libmysqlclient_r and libmysqlclient in that order. --- m4/ac_check_mysqlr.m4 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/m4/ac_check_mysqlr.m4 b/m4/ac_check_mysqlr.m4 index 67715d1..fbf819a 100644 --- a/m4/ac_check_mysqlr.m4 +++ b/m4/ac_check_mysqlr.m4 @@ -1,9 +1,9 @@ dnl --------------------------------------------------------------------------- dnl Macro: AC_CHECK_MYSQLR -dnl First check for custom MySQL paths in --with-mysql-* options. -dnl If some paths are missing, check if mysql_config exists. -dnl Then check for the libraries and replace -lmysqlclient with -dnl -lmysqlclient_r, to enable threaded client library. +dnl First check if the MySQL root directory is specified with --with-mysql. +dnl Otherwise check for custom MySQL paths in --with-mysql-includes and +dnl --with-mysql-libs. If some paths are not specified explicitly, try to get +dnl them from mysql_config. dnl --------------------------------------------------------------------------- AC_DEFUN([AC_CHECK_MYSQLR],[ @@ -51,7 +51,20 @@ then ac_cv_mysql_libs=`echo ${ac_cv_mysql_libs} | sed -e 's/.libs$//' \ -e 's+.libs/$++'` AC_CACHE_CHECK([MySQL libraries], [ac_cv_mysql_libs], [ac_cv_mysql_libs=""]) - MYSQL_LIBS="-L$ac_cv_mysql_libs -lmysqlclient_r" + save_LDFLAGS="$LDFLAGS" + save_LIBS="$LIBS" + LDFLAGS="-L$ac_cv_mysql_libs" + LIBS="" + + # libmysqlclient_r has been removed in MySQL 5.7 + AC_SEARCH_LIBS([mysql_real_connect], + [mysqlclient_r mysqlclient], + [], + AC_MSG_ERROR([cannot find MySQL client libraries in $ac_cv_mysql_libs])) + + MYSQL_LIBS="$LDFLAGS $LIBS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" fi # If some path is missing, try to autodetermine with mysql_config From 968484d50c836140c1b4a482fb287359383882b1 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 10 Aug 2016 18:38:53 +0300 Subject: [PATCH 37/96] Initial Debian packaging based on https://github.com/percona/sysbench-packaging --- debian/changelog | 6 ++++++ debian/compat | 1 + debian/control | 27 +++++++++++++++++++++++++++ debian/copyright | 15 +++++++++++++++ debian/dirs | 1 + debian/docs | 1 + debian/install | 1 + debian/rules | 13 +++++++++++++ debian/source/format | 1 + 9 files changed, 66 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/install create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f24a9f7 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +sysbench (1.0-1) unstable; urgency=low + + * Initial release + + -- Alexey Kopytov Wed, 10 Aug 2016 18:04:53 +0300 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..96c7ae2 --- /dev/null +++ b/debian/control @@ -0,0 +1,27 @@ +Source: sysbench +Section: misc +Priority: extra +Maintainer: Alexey Kopytov +Build-Depends: debhelper, autoconf, automake, libtool, libmysqlclient-dev +Standards-Version: 3.9.5 +Homepage: https://github.com/akopytov/sysbench + +Package: sysbench +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Cross-platform and multi-threaded benchmark tool + SysBench is a modular, cross-platform and multi-threaded benchmark tool for + evaluating OS parameters that are important for a system running a database + under intensive load. + . + The idea of this benchmark suite is to quickly get an impression about system + performance without setting up complex database benchmarks or even without + installing a database at all. + . + Current features allow to test the following system parameters: + . + * file I/O performance + * scheduler performance + * memory allocation and transfer speed + * POSIX threads implementation performance + * database server performance (OLTP benchmark) diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..8d4bf50 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,15 @@ +Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat +Upstream-Name: sysbench +Upstream-Maintainer: Alexey Kopytov +Upstream-Source: https://github.com/akopytov/sysbench + +Files: * +Copyright: 2016 Alexey Kopytov +License: GPL-2 + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + . + On Debian systems, the complete text of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-2'. + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..e772481 --- /dev/null +++ b/debian/dirs @@ -0,0 +1 @@ +usr/bin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..f3f2de5 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +sysbench/tests/db/*.lua usr/lib/sysbench/tests/db diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8a36405 --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +#export DH_VERBOSE=1 + +%: + dh $@ + +override_dh_auto_configure: + dh_testdir + autoreconf -vif + dh_auto_configure + +override_dh_compress: + dh_compress -X.lua diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) From e34fd87cd8485114f82b199283eb8329242c396e Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 10 Aug 2016 19:03:25 +0300 Subject: [PATCH 38/96] Workaround for a TravisCI/Homebrew bug preventing OSX builds. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2863dc6..43aab90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,10 @@ before_install: - > case "${TRAVIS_OS_NAME:-linux}" in osx) + # Workaround for https://github.com/Homebrew/legacy-homebrew/issues/43874 + brew uninstall libtool brew update --quiet - brew install mysql + brew install libtool mysql ;; esac From 9e4a9d4cf560400514012fa4aa2853440922e79e Mon Sep 17 00:00:00 2001 From: Jeremy Cole Date: Tue, 23 Aug 2016 13:20:35 -0700 Subject: [PATCH 39/96] Create indexes after data load in parallel_prepare Creating indexes after the data has been loaded is much faster. --- sysbench/tests/db/common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 6aabecd..c0dd581 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -59,8 +59,6 @@ pad CHAR(60) DEFAULT '' NOT NULL, db_query(query) - db_query("CREATE INDEX k_" .. i .. " on sbtest" .. i .. "(k)") - print("Inserting " .. oltp_table_size .. " records into 'sbtest" .. i .. "'") if (oltp_auto_inc) then @@ -89,6 +87,8 @@ pad CHAR(60) DEFAULT '' NOT NULL, db_bulk_insert_done() + print("Creating secondary indexes on 'sbtest" .. i .. "'...") + db_query("CREATE INDEX k_" .. i .. " on sbtest" .. i .. "(k)") end From 4775856148ee9452c61049e49fb0cffb0840104b Mon Sep 17 00:00:00 2001 From: JongHyuk Lee Date: Fri, 26 Aug 2016 01:17:20 +0000 Subject: [PATCH 40/96] Fix write issue with NFS direct I/O --- sysbench/tests/fileio/sb_fileio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index c32e601..7616b03 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -1934,6 +1934,12 @@ int parse_arguments(void) for (i = 0; i < sb_globals.num_threads; i++) { per_thread[i].buffer = sb_memalign(file_max_request_size); + if (per_thread[i].buffer == NULL) + { + log_text(LOG_FATAL, "Failed to allocate a memory buffer"); + return 1; + } + memset(per_thread[i].buffer, 0, file_max_request_size); } return 0; From 7a37c6467adc7c4f67000c36c364ef43fd99be7f Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Thu, 1 Sep 2016 11:26:06 -0700 Subject: [PATCH 41/96] Added oltp-write-only control Added oltp-write-only : Specifies a test to consist of write only statements (insert, update, and deletes). --- sysbench/tests/db/common.lua | 14 ++++++++++---- sysbench/tests/db/oltp.lua | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 6cfc62e..85c240c 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -134,12 +134,12 @@ function set_vars() oltp_non_index_updates = oltp_non_index_updates or 1 oltp_delete_inserts = oltp_delete_inserts or 1 - if (oltp_range_selets = 'off') then - oltp_range_selects = false + if (oltp_range_selects == 'off') then + oltp_range_selects = false else - oltp_range_selects = true + oltp_range_selects = true end - + if (oltp_auto_inc == 'off') then oltp_auto_inc = false else @@ -152,6 +152,12 @@ function set_vars() oltp_read_only = false end + if (oltp_write_only == 'on') then + oltp_write_only = true + else + oltp_write_only = false + end + if (oltp_skip_trx == 'on') then oltp_skip_trx = true else diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index 6edfc9d..985ca0c 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -18,7 +18,6 @@ end function event(thread_id) local rs local i - local idx local table_name local range_start local c_val @@ -30,12 +29,14 @@ function event(thread_id) db_query(begin_query) end + if not oltp_write_only then + for i=1, oltp_point_selects do rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) end if oltp_range_selects then - + for i=1, oltp_simple_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) @@ -58,6 +59,8 @@ function event(thread_id) end + end + if not oltp_read_only then for i=1, oltp_index_updates do @@ -73,8 +76,8 @@ function event(thread_id) end end - for idx=1, oltp_delete_inserts do - + for i=1, oltp_delete_inserts do + i = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) From cbd1417cbae7b099f5db9b0d05f40482b943c0c9 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 3 Sep 2016 14:47:17 +0300 Subject: [PATCH 42/96] Make --oltp-read-only=on and --oltp-write-only=on mutually exclusive. --- sysbench/tests/db/common.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 78db9dc..f9c0e19 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -158,6 +158,10 @@ function set_vars() oltp_write_only = false end + if (oltp_read_only and oltp_write_only) then + error("--oltp-read-only and --oltp-write-only are mutually exclusive") + end + if (oltp_skip_trx == 'on') then oltp_skip_trx = true else From c843e4fe0f7e3bbb1ad02c65118e2aa3ef2b86fa Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 4 Sep 2016 15:30:27 +0300 Subject: [PATCH 43/96] Update .gitignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 265ff40..2b2513c 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,5 @@ GRTAGS GTAGS /config/ar-lib /sysbench/drivers/attachsql/.deps/ +/config/test-driver +*.DS_Store From 755a61b6cf40c36716835f56062395a81d52ea2e Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 4 Sep 2016 15:31:38 +0300 Subject: [PATCH 44/96] s/README/README.md/ in top-level Makefile.am. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index d92d993..aaa09f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,4 +19,4 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = doc sysbench -EXTRA_DIST = autogen.sh README README-WIN.txt ChangeLog +EXTRA_DIST = autogen.sh README.md README-WIN.txt ChangeLog From 6d5bba1fe6e97ccb7a8cd5c1f5135deefc8c9bd2 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 4 Sep 2016 20:24:07 +0300 Subject: [PATCH 45/96] Basic support for functional/regression testing. --- .gitignore | 2 ++ Makefile.am | 5 ++++- configure.ac | 1 + tests/1st.t | 1 + tests/Makefile.am | 55 +++++++++++++++++++++++++++++++++++++++++++++++ tests/README.org | 25 +++++++++++++++++++++ tests/test_run.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tests/1st.t create mode 100644 tests/Makefile.am create mode 100644 tests/README.org create mode 100755 tests/test_run.sh diff --git a/.gitignore b/.gitignore index 2b2513c..e130de4 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ GTAGS /sysbench/drivers/attachsql/.deps/ /config/test-driver *.DS_Store +/tests/*.log +/tests/*.trs diff --git a/Makefile.am b/Makefile.am index aaa09f3..3a9898b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,9 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc sysbench +SUBDIRS = doc sysbench tests EXTRA_DIST = autogen.sh README.md README-WIN.txt ChangeLog + +test: + cd tests && $(MAKE) test diff --git a/configure.ac b/configure.ac index 26e68b3..d3204bb 100644 --- a/configure.ac +++ b/configure.ac @@ -461,5 +461,6 @@ sysbench/tests/db/Makefile sysbench/scripting/Makefile sysbench/scripting/lua/Makefile sysbench/scripting/lua/src/Makefile +tests/Makefile ]) AC_OUTPUT diff --git a/tests/1st.t b/tests/1st.t new file mode 100644 index 0000000..1cb3d28 --- /dev/null +++ b/tests/1st.t @@ -0,0 +1 @@ + $ sysbench help >/dev/null 2>&1 diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..4eb5e43 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,55 @@ +# Copyright (C) 2016 Alexey Kopytov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +TESTS = test_run.sh + +test_SCRIPTS = test_run.sh + +EXTRA_DIST = $(test_SCRIPTS) \ + README.org + +testroot = $(datadir) +testdir = $(testroot)/sysbench/tests +test_dirs= . + +# Used by dist-hook and install-data-local to copy all +# test files into either dist or install directory +install_test_files: + @if test -z "$(INSTALL_TO_DIR)"; then \ + echo "Set INSTALL_TO_DIR!" && exit 1; \ + fi + @for dir in $(test_dirs); do \ + from_dir="$(srcdir)/$$dir"; \ + to_dir="$(INSTALL_TO_DIR)/$$dir"; \ + $(mkinstalldirs) "$$to_dir"; \ + for f in `(cd $$from_dir && ls *.t)`; do \ + if test -f "$$from_dir/$$f"; then \ + $(INSTALL_DATA) "$$from_dir/$$f" "$$to_dir/$$f" ; \ + fi; \ + done \ + done + +dist-hook: + $(MAKE) INSTALL_TO_DIR="$(distdir)" install_test_files + +install-data-local: + $(MAKE) INSTALL_TO_DIR="$(DESTDIR)$(testdir)" install_test_files + +uninstall-local: + rm -f -r $(DESTDIR)$(testdir) + +test: + ./test_run.sh diff --git a/tests/README.org b/tests/README.org new file mode 100644 index 0000000..4332a3e --- /dev/null +++ b/tests/README.org @@ -0,0 +1,25 @@ +* sysbench Test Suite + +sysbench uses the [[https://bitheap.org/cram/][Cram]] framework for functional and regression +testing. If your system has Python 2.7.9 or later, or Python 3.4 or +later, installing Cram is as simple as executing =pip install cram=. + +If you use an older Python version, you may need to [[https://pip.pypa.io/en/latest/installing/][install pip]] first: + +#+BEGIN_EXAMPLE +curl https://bootstrap.pypa.io/get-pip.py | python +#+END_EXAMPLE + +To run the sysbench test suite, invoke the =test_run.sh= script in the +=tests= directory like this: + +#+BEGIN_EXAMPLE +./test_run.sh [test_name]... +#+END_EXAMPLE + +Each =test_name= argument is name of a test case file. Functional and +regression tests are located in the same directory in files with the +=.t= suffix. + +If no tests are named on the =test_run.sh= command line, it will execute +all files with the =.t= suffix in the current directory. diff --git a/tests/test_run.sh b/tests/test_run.sh new file mode 100755 index 0000000..2efbce2 --- /dev/null +++ b/tests/test_run.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Copyright (C) 2016 Alexey Kopytov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +set -eu + +if [ -x "$PWD/../sysbench/sysbench" ] +then + # Invoked from a source directory? + export PATH=$PWD/../sysbench:$PATH +elif [ -x "$PWD/../bin" ] +then + # Invoked from a standalone install root directory? + export PATH=$PWD/../bin:$PATH +elif [ -x "$PWD/../../../bin/sysbench" ] +then + # Invoked from a system-wide install (e.g. /usr/local/share/sysbench/tests)? + export PATH=$PWD/../../../bin:$PATH +fi + +if ! which sysbench >/dev/null 2>&1 +then + echo "Cannot find sysbench in PATH=$PATH" + exit 1 +fi + +if [ $# -lt 1 ] +then + # Automake defines $srcdir where test datafiles are located on 'make check' + if [ -z ${srcdir+x} ] + then + testroot="." + else + testroot="$srcdir" + fi + tests="${testroot}/*.t" +else + tests="$*" +fi + +cram --shell=/bin/bash --verbose $tests From 843698a04a10897b47c727d4493f6026a36cd12c Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 4 Sep 2016 20:35:06 +0300 Subject: [PATCH 46/96] Invoke regression tests from Travis CI. --- .travis.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 43aab90..4d12f9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,14 @@ before_install: ;; esac -script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make +install: + - pip install --user cram + - > + case "${TRAVIS_OS_NAME:-linux}" in + osx) + # OS X requires this for user-local pip packages + export PATH=~/Library/Python/2.7/bin:$PATH + ;; + esac + +script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make && make test From 8fc9357cf014a7006b571785bc551d522d572e33 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 10:39:47 +0300 Subject: [PATCH 47/96] Add version.t test + some necessary test harness improvements. --- configure.ac | 1 + tests/test_run.sh | 24 ++++++++++++++---------- tests/version.t | 7 +++++++ 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 tests/version.t diff --git a/configure.ac b/configure.ac index d3204bb..7165a67 100644 --- a/configure.ac +++ b/configure.ac @@ -462,5 +462,6 @@ sysbench/scripting/Makefile sysbench/scripting/lua/Makefile sysbench/scripting/lua/src/Makefile tests/Makefile +tests/include/config.sh ]) AC_OUTPUT diff --git a/tests/test_run.sh b/tests/test_run.sh index 2efbce2..a131027 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -18,18 +18,21 @@ set -eu -if [ -x "$PWD/../sysbench/sysbench" ] +testroot=$(cd $(dirname "$0"); echo $PWD) + +# Find the sysbench binary to use +if [ -x "$testroot/../sysbench/sysbench" ] then # Invoked from a source directory? - export PATH=$PWD/../sysbench:$PATH -elif [ -x "$PWD/../bin" ] + export PATH="$testroot/../sysbench:$PATH" +elif [ -x "$testroot/../bin" ] then # Invoked from a standalone install root directory? - export PATH=$PWD/../bin:$PATH -elif [ -x "$PWD/../../../bin/sysbench" ] + export PATH="$testroot/../bin:$PATH" +elif [ -x "$testroot/../../../bin/sysbench" ] then # Invoked from a system-wide install (e.g. /usr/local/share/sysbench/tests)? - export PATH=$PWD/../../../bin:$PATH + export PATH="$testroot/../../../bin:$PATH" fi if ! which sysbench >/dev/null 2>&1 @@ -40,16 +43,17 @@ fi if [ $# -lt 1 ] then - # Automake defines $srcdir where test datafiles are located on 'make check' if [ -z ${srcdir+x} ] then - testroot="." + tests="*.t" else - testroot="$srcdir" + tests="$srcdir/*.t" fi - tests="${testroot}/*.t" else tests="$*" fi +export SBTEST_INCDIR="$PWD/include" +export SBTEST_CONFIG="$SBTEST_INCDIR/config.sh" + cram --shell=/bin/bash --verbose $tests diff --git a/tests/version.t b/tests/version.t new file mode 100644 index 0000000..8f22cd2 --- /dev/null +++ b/tests/version.t @@ -0,0 +1,7 @@ + $ . $SBTEST_CONFIG + + $ sysbench --version + sysbench [.0-9]* (re) + + $ version=$(sysbench --version | cut -d ' ' -f 2) + $ test "$version" = "$SBTEST_VERSION" From 0169adc09f2b299f45e33c0fd8f002714c1484b5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 10:45:04 +0300 Subject: [PATCH 48/96] Add tests/include/config.h.in. --- .gitignore | 1 + tests/include/config.sh.in | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/include/config.sh.in diff --git a/.gitignore b/.gitignore index e130de4..01eb86d 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ GTAGS *.DS_Store /tests/*.log /tests/*.trs +/config/config.h.in diff --git a/tests/include/config.sh.in b/tests/include/config.sh.in new file mode 100644 index 0000000..e6f2a14 --- /dev/null +++ b/tests/include/config.sh.in @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Configuration file used by the sysbench test suite. + +# Copyright (C) 2016 Alexey Kopytov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +SBTEST_VERSION=@PACKAGE_VERSION@ From ce4996c5365333c63e0ea44f836d58d8eed00498 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 14:51:05 +0300 Subject: [PATCH 49/96] Backport Travis CI support from 1.0. --- .travis.yml | 38 ++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4d12f9c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,38 @@ +language: c + +os: + - linux + - osx + +compiler: + - gcc + - clang + +addons: + apt: + packages: + - libmysqlclient-dev + - libpq-dev + +before_install: + - > + case "${TRAVIS_OS_NAME:-linux}" in + osx) + # Workaround for https://github.com/Homebrew/legacy-homebrew/issues/43874 + brew uninstall libtool + brew update --quiet + brew install libtool mysql + ;; + esac + +install: + - pip install --user cram + - > + case "${TRAVIS_OS_NAME:-linux}" in + osx) + # OS X requires this for user-local pip packages + export PATH=~/Library/Python/2.7/bin:$PATH + ;; + esac + +script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make && make test diff --git a/README.md b/README.md index a47128d..b4f162a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/akopytov/sysbench.svg?branch=1.0)](https://travis-ci.org/akopytov/sysbench) + About ===== From f366d873b3ae5f2ec66fdd4f0ba29f6dd492ae5a Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 14:53:16 +0300 Subject: [PATCH 50/96] Fix branch name in Travis CI integration. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4f162a..153ad48 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/akopytov/sysbench.svg?branch=1.0)](https://travis-ci.org/akopytov/sysbench) +[![Build Status](https://travis-ci.org/akopytov/sysbench.svg?branch=0.5)](https://travis-ci.org/akopytov/sysbench) About ===== From dbca1c60d404270e409931e1006e4e4cb55f036f Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 15:51:34 +0300 Subject: [PATCH 51/96] Add coveralls.io integration. --- .travis.yml | 10 ++++++++-- configure.ac | 29 ++++++++++++++++++----------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d12f9c..c8a9994 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: esac install: - - pip install --user cram + - pip install --user cram cpp-coveralls - > case "${TRAVIS_OS_NAME:-linux}" in osx) @@ -35,4 +35,10 @@ install: ;; esac -script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make && make test +script: + - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql + - make + - make test + +after_success: + - coveralls --gcov-options '\-lp' diff --git a/configure.ac b/configure.ac index 82d133f..d86df86 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ then CFLAGS="-ggdb3 ${CFLAGS}" DEBUG_CFLAGS="-O0" OPTIMIZE_CFLAGS="-O2" + GCOV_CFLAGS="-O0 --coverage" fi if test "$SUNCC" = "yes" then @@ -90,6 +91,7 @@ then CFLAGS="-g -mt ${IS_64} ${MEMALIGN_FLAGS} ${CFLAGS}" DEBUG_CFLAGS="-xO0" OPTIMIZE_CFLAGS="-xO2 -xlibmil -xdepend -Xa -mt -xstrconst" +# TODO: Set flags for Gcov-enabled builds, if supported by Sun Studio fi @@ -330,14 +332,6 @@ AC_ARG_WITH([debug], [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], [with_debug=$withval], [with_debug=no]) -if test "$with_debug" = "yes" -then - # Debugging. No optimization. - CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}" -else - # Optimized version. No debug - CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}" -fi AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], @@ -382,6 +376,19 @@ AC_ARG_ENABLE([go-crazy], [ac_warn_go_crazy="$enableval"], [ac_warn_go_crazy="no"]) +if test "$with_debug" = "yes" +then + # Debugging. No optimization. + CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}" +elif test "$ac_coverage" = "yes" +then + # Gcov-enabled build. No optimization. + CFLAGS="${GCOV_CFLAGS} ${CFLAGS}" +else + # Optimized version. No debug + CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}" +fi + if test "$GCC" = "yes" then if test "$ac_warn_fail" = "yes" @@ -401,7 +408,7 @@ then if test "$ac_coverage" = "yes" then - GPROF_COVERAGE="-fprofile-arcs -ftest-coverage" + GPROF_COVERAGE="--coverage" else GPROF_COVERAGE=" " fi @@ -426,7 +433,7 @@ then W_CRAZY="-Wshadow -Wconversion" fi - CC_WARNINGS="${BASE_WARNINGS} ${W_PEDANTIC} ${W_UNREACHABLE} ${GPROF_PROFILING} ${GPROF_COVERAGE} ${W_CRAZY}" + CC_WARNINGS="${BASE_WARNINGS} ${W_PEDANTIC} ${W_UNREACHABLE} ${W_CRAZY}" NO_REDUNDANT_DECLS="-Wno-redundant-decls" CPPFLAGS="${CPPFLAGS}" @@ -436,7 +443,7 @@ then CC_WARNINGS="-v -errtags=yes -errwarn=%all -erroff=E_INTEGER_OVERFLOW_DETECTED" fi -AM_CFLAGS="${CC_WARNINGS} ${AM_CFLAGS} ${PTHREAD_CFLAGS}" +AM_CFLAGS="${CC_WARNINGS} ${GPROF_PROFILING} ${GPROF_COVERAGE} ${AM_CFLAGS} ${PTHREAD_CFLAGS}" AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/sysbench" From 61ad663b65edb07b9b02c9a2777fb392c263fbe6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 15:51:34 +0300 Subject: [PATCH 52/96] Add coveralls.io integration. --- .travis.yml | 10 ++++++++-- configure.ac | 29 ++++++++++++++++++----------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4d12f9c..c8a9994 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: esac install: - - pip install --user cram + - pip install --user cram cpp-coveralls - > case "${TRAVIS_OS_NAME:-linux}" in osx) @@ -35,4 +35,10 @@ install: ;; esac -script: ./autogen.sh && ./configure --with-mysql --with-pgsql && make && make test +script: + - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql + - make + - make test + +after_success: + - coveralls --gcov-options '\-lp' diff --git a/configure.ac b/configure.ac index 7165a67..a3a31e9 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ then CFLAGS="-ggdb3 ${CFLAGS}" DEBUG_CFLAGS="-O0" OPTIMIZE_CFLAGS="-O2" + GCOV_CFLAGS="-O0 --coverage" fi if test "$SUNCC" = "yes" then @@ -90,6 +91,7 @@ then CFLAGS="-g -mt ${IS_64} ${MEMALIGN_FLAGS} ${CFLAGS}" DEBUG_CFLAGS="-xO0" OPTIMIZE_CFLAGS="-xO2 -xlibmil -xdepend -Xa -mt -xstrconst" +# TODO: Set flags for Gcov-enabled builds, if supported by Sun Studio fi @@ -323,14 +325,6 @@ AC_ARG_WITH([debug], [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], [with_debug=$withval], [with_debug=no]) -if test "$with_debug" = "yes" -then - # Debugging. No optimization. - CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}" -else - # Optimized version. No debug - CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}" -fi AC_ARG_ENABLE([profiling], [AS_HELP_STRING([--enable-profiling], @@ -375,6 +369,19 @@ AC_ARG_ENABLE([go-crazy], [ac_warn_go_crazy="$enableval"], [ac_warn_go_crazy="no"]) +if test "$with_debug" = "yes" +then + # Debugging. No optimization. + CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}" +elif test "$ac_coverage" = "yes" +then + # Gcov-enabled build. No optimization. + CFLAGS="${GCOV_CFLAGS} ${CFLAGS}" +else + # Optimized version. No debug + CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}" +fi + if test "$GCC" = "yes" then if test "$ac_warn_fail" = "yes" @@ -394,7 +401,7 @@ then if test "$ac_coverage" = "yes" then - GPROF_COVERAGE="-fprofile-arcs -ftest-coverage" + GPROF_COVERAGE="--coverage" else GPROF_COVERAGE=" " fi @@ -419,7 +426,7 @@ then W_CRAZY="-Wshadow -Wconversion" fi - CC_WARNINGS="${BASE_WARNINGS} ${W_PEDANTIC} ${W_UNREACHABLE} ${GPROF_PROFILING} ${GPROF_COVERAGE} ${W_CRAZY}" + CC_WARNINGS="${BASE_WARNINGS} ${W_PEDANTIC} ${W_UNREACHABLE} ${W_CRAZY}" NO_REDUNDANT_DECLS="-Wno-redundant-decls" CPPFLAGS="${CPPFLAGS}" @@ -429,7 +436,7 @@ then CC_WARNINGS="-v -errtags=yes -errwarn=%all -erroff=E_INTEGER_OVERFLOW_DETECTED" fi -AM_CFLAGS="${CC_WARNINGS} ${AM_CFLAGS} ${PTHREAD_CFLAGS}" +AM_CFLAGS="${CC_WARNINGS} ${GPROF_PROFILING} ${GPROF_COVERAGE} ${AM_CFLAGS} ${PTHREAD_CFLAGS}" AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/sysbench" From e4c723d2fefd16e45ba653bef7b301b92079c054 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 16:00:28 +0300 Subject: [PATCH 53/96] Ignore Gcov-generated files. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 01eb86d..1282528 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ GTAGS /tests/*.log /tests/*.trs /config/config.h.in +*.gcda +*.gcno From c1c84148f4f4ea0f9050e342bbbd7b8f365263a0 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 16:08:23 +0300 Subject: [PATCH 54/96] Add Coverage Status shield from coveralls.io. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 153ad48..0a3b897 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Coverage Status](https://coveralls.io/repos/github/akopytov/sysbench/badge.svg?branch=0.5)](https://coveralls.io/github/akopytov/sysbench?branch=0.5) [![Build Status](https://travis-ci.org/akopytov/sysbench.svg?branch=0.5)](https://travis-ci.org/akopytov/sysbench) About From ce63f867bfb3f690c9fa4bdf381a79047d418723 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 19:22:34 +0300 Subject: [PATCH 55/96] Basic command tests. --- .gitignore | 2 +- tests/cleanup.t | 3 ++ tests/commands.t | 8 ++++++ tests/help.t | 71 +++++++++++++++++++++++++++++++++++++++++++++++ tests/prepare.t | 3 ++ tests/run.t | 3 ++ tests/test_run.sh | 1 + 7 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 tests/cleanup.t create mode 100644 tests/commands.t create mode 100644 tests/help.t create mode 100644 tests/prepare.t create mode 100644 tests/run.t diff --git a/.gitignore b/.gitignore index 1282528..fddcba6 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,6 @@ GTAGS *.DS_Store /tests/*.log /tests/*.trs -/config/config.h.in *.gcda *.gcno +/tests/include/config.sh diff --git a/tests/cleanup.t b/tests/cleanup.t new file mode 100644 index 0000000..9629cbd --- /dev/null +++ b/tests/cleanup.t @@ -0,0 +1,3 @@ + $ sysbench cleanup | grep Missing + Missing required argument: --test. + [1] diff --git a/tests/commands.t b/tests/commands.t new file mode 100644 index 0000000..c7eaa4c --- /dev/null +++ b/tests/commands.t @@ -0,0 +1,8 @@ + $ commands=$(sysbench help | grep 'Commands:' | cut -d ' ' -f 2-) + $ for cmd in $commands; do + > if [ ! -r ${SBTEST_ROOTDIR}/${cmd}.t ] + > then + > echo "Cannot find test(s) for 'sysbench $cmd'!" + > exit 1 + > fi + > done diff --git a/tests/help.t b/tests/help.t new file mode 100644 index 0000000..629687f --- /dev/null +++ b/tests/help.t @@ -0,0 +1,71 @@ + $ sysbench help + sysbench 0.5: multi-threaded system evaluation benchmark + + Usage: + sysbench --test= [options]... + + Commands: prepare run cleanup help version + + 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 amount of time to wait after --max-time before forcing shutdown [off] + --thread-stack-size=SIZE size of stack per thread [64K] + --tx-rate=N target transaction rate (tps) [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. [] + --test=STRING test to run + --debug=[on|off] print more debugging info [off] + --validate=[on|off] perform validation checks where possible [off] + --help=[on|off] print help and exit + --version=[on|off] print version and exit [off] + --rand-init=[on|off] initialize random number generator [off] + --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special] + --rand-spec-iter=N number of iterations used for numbers generation [12] + --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1] + --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75] + --rand-seed=N seed for random number generator, ignored when 0 [0] + --rand-pareto-h=N parameter h for pareto distibution [0.2] + --config-file=FILENAME File containing command line options + + Log options: + --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3] + + --percentile=N percentile rank of query response times to count [95] + + General database options: + + --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) + --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] + --db-debug=[on|off] print database-specific debug information [off] + + + Compiled-in database drivers: + mysql - MySQL driver + + mysql options: + --mysql-host=[LIST,...] MySQL server host [localhost] + --mysql-port=N MySQL server port [3306] + --mysql-socket=[LIST,...] MySQL socket + --mysql-user=STRING MySQL user [sbtest] + --mysql-password=STRING MySQL password [] + --mysql-db=STRING MySQL database name [sbtest] + --mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] + --mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto] + --mysql-ssl=[on|off] use SSL connections, if available in the client library [off] + --mysql-compression=[on|off] use compression, if available in the client library [off] + --myisam-max-rows=N max-rows parameter for MyISAM tables [1000000] + --mysql-debug=[on|off] dump all client library calls [off] + --mysql-ignore-errors=[LIST,...]list of errors to ignore, or "all" [1213,1020,1205] + --mysql-dry-run=[on|off] Dry run, pretent that all MySQL client API calls are successful without executing them [off] + + Compiled-in tests: + fileio - File I/O test + cpu - CPU performance test + memory - Memory functions speed test + threads - Threads subsystem performance test + mutex - Mutex performance test + + See 'sysbench --test= help' for a list of options for each test. + diff --git a/tests/prepare.t b/tests/prepare.t new file mode 100644 index 0000000..b583012 --- /dev/null +++ b/tests/prepare.t @@ -0,0 +1,3 @@ + $ sysbench prepare | grep Missing + Missing required argument: --test. + [1] diff --git a/tests/run.t b/tests/run.t new file mode 100644 index 0000000..e706b09 --- /dev/null +++ b/tests/run.t @@ -0,0 +1,3 @@ + $ sysbench run | grep Missing + Missing required argument: --test. + [1] diff --git a/tests/test_run.sh b/tests/test_run.sh index a131027..08c3ca3 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -53,6 +53,7 @@ else tests="$*" fi +export SBTEST_ROOTDIR="$testroot" export SBTEST_INCDIR="$PWD/include" export SBTEST_CONFIG="$SBTEST_INCDIR/config.sh" From 7aa3f2d5caab4b498fedcd965d45c8407770629e Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 22:54:03 +0300 Subject: [PATCH 56/96] Test driver-specific option descriptions separately from the main help text. --- tests/help.t | 42 +++++++++++++++++++++--------------------- tests/help_drv_mysql.t | 24 ++++++++++++++++++++++++ tests/help_drv_pgsql.t | 15 +++++++++++++++ 3 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 tests/help_drv_mysql.t create mode 100644 tests/help_drv_pgsql.t diff --git a/tests/help.t b/tests/help.t index 629687f..6eabac3 100644 --- a/tests/help.t +++ b/tests/help.t @@ -1,4 +1,11 @@ - $ sysbench help +######################################################################## +Skip everything between "Compiled-in database drivers:" and +"Compiled-in tests:" as that part depends on available database +drivers and thus, build options. Driver-specific options is tested +separately. +######################################################################## + + $ sysbench help | sed '/Compiled-in database drivers:/,/Compiled-in tests:/d' sysbench 0.5: multi-threaded system evaluation benchmark Usage: @@ -41,26 +48,6 @@ --db-debug=[on|off] print database-specific debug information [off] - Compiled-in database drivers: - mysql - MySQL driver - - mysql options: - --mysql-host=[LIST,...] MySQL server host [localhost] - --mysql-port=N MySQL server port [3306] - --mysql-socket=[LIST,...] MySQL socket - --mysql-user=STRING MySQL user [sbtest] - --mysql-password=STRING MySQL password [] - --mysql-db=STRING MySQL database name [sbtest] - --mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] - --mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto] - --mysql-ssl=[on|off] use SSL connections, if available in the client library [off] - --mysql-compression=[on|off] use compression, if available in the client library [off] - --myisam-max-rows=N max-rows parameter for MyISAM tables [1000000] - --mysql-debug=[on|off] dump all client library calls [off] - --mysql-ignore-errors=[LIST,...]list of errors to ignore, or "all" [1213,1020,1205] - --mysql-dry-run=[on|off] Dry run, pretent that all MySQL client API calls are successful without executing them [off] - - Compiled-in tests: fileio - File I/O test cpu - CPU performance test memory - Memory functions speed test @@ -69,3 +56,16 @@ See 'sysbench --test= help' for a list of options for each test. + +######################################################################## +Test driver-specific options +######################################################################## + $ drivers=$(sysbench help | sed -n '/Compiled-in database drivers:/,/^$/p' | tail -n +2 | cut -d ' ' -f 3) + $ for drv in $drivers + > do + > if [ ! -r ${SBTEST_ROOTDIR}/help_drv_${drv}.t ] + > then + > echo "Cannot find test(s) for $drv driver options!" + > exit 1 + > fi + > done diff --git a/tests/help_drv_mysql.t b/tests/help_drv_mysql.t new file mode 100644 index 0000000..47ef508 --- /dev/null +++ b/tests/help_drv_mysql.t @@ -0,0 +1,24 @@ +Skip test if the MySQL driver is not available. + + $ if ! sysbench help | sed -n '/Compiled-in database drivers:/,/^$/p' | grep mysql > /dev/null 2>&1 + > then + > exit 80 + > fi + + $ sysbench help | sed -n '/mysql options:/,/^$/p' + mysql options: + --mysql-host=[LIST,...] MySQL server host [localhost] + --mysql-port=N MySQL server port [3306] + --mysql-socket=[LIST,...] MySQL socket + --mysql-user=STRING MySQL user [sbtest] + --mysql-password=STRING MySQL password [] + --mysql-db=STRING MySQL database name [sbtest] + --mysql-table-engine=STRING storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb] + --mysql-engine-trx=STRING whether storage engine used is transactional or not {yes,no,auto} [auto] + --mysql-ssl=[on|off] use SSL connections, if available in the client library [off] + --mysql-compression=[on|off] use compression, if available in the client library [off] + --myisam-max-rows=N max-rows parameter for MyISAM tables [1000000] + --mysql-debug=[on|off] dump all client library calls [off] + --mysql-ignore-errors=[LIST,...]list of errors to ignore, or "all" [1213,1020,1205] + --mysql-dry-run=[on|off] Dry run, pretent that all MySQL client API calls are successful without executing them [off] + diff --git a/tests/help_drv_pgsql.t b/tests/help_drv_pgsql.t new file mode 100644 index 0000000..b4d788c --- /dev/null +++ b/tests/help_drv_pgsql.t @@ -0,0 +1,15 @@ +Skip test if the PostgreSQL driver is not available. + + $ if ! sysbench help | sed -n '/Compiled-in database drivers:/,/^$/p' | grep pgsql > /dev/null 2>&1 + > then + > exit 80 + > fi + + $ sysbench help | sed -n '/pgsql options:/,/^$/p' + pgsql options: + --pgsql-host=STRING PostgreSQL server host [localhost] + --pgsql-port=N PostgreSQL server port [5432] + --pgsql-user=STRING PostgreSQL user [sbtest] + --pgsql-password=STRING PostgreSQL password [] + --pgsql-db=STRING PostgreSQL database name [sbtest] + From 687256377e6a637ec1a3ff895560cad91f32ad82 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 07:57:28 +0300 Subject: [PATCH 57/96] Fix typo in an error message. --- sysbench/tests/fileio/sb_fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/fileio/sb_fileio.c b/sysbench/tests/fileio/sb_fileio.c index 369c9ae..e142f60 100644 --- a/sysbench/tests/fileio/sb_fileio.c +++ b/sysbench/tests/fileio/sb_fileio.c @@ -1928,7 +1928,7 @@ int parse_arguments(void) file_rw_ratio = sb_get_value_float("file-rw-ratio"); if (file_rw_ratio < 0) { - log_text(LOG_FATAL, "Invalid value file file-rw-ratio: %f.", file_rw_ratio); + log_text(LOG_FATAL, "Invalid value for --file-rw-ratio: %f.", file_rw_ratio); return 1; } From 58e71ed23f896a84e666adfffb10e38e877cc2a6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 08:33:55 +0300 Subject: [PATCH 58/96] Basic fileio regression test. --- tests/test_fileio.t | 81 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/test_fileio.t diff --git a/tests/test_fileio.t b/tests/test_fileio.t new file mode 100644 index 0000000..72430ec --- /dev/null +++ b/tests/test_fileio.t @@ -0,0 +1,81 @@ +######################################################################## +fileio tests +######################################################################## + + $ fileio_args="--test=fileio --file-num=4 --file-total-size=32M" + + $ sysbench $fileio_args prepare + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 4 files, 8192Kb each, 32Mb total + Creating files for the test... + Extra file open flags: 0 + Creating file test_file.0 + Creating file test_file.1 + Creating file test_file.2 + Creating file test_file.3 + 33554432 bytes written in * seconds (*.* MB/sec). (glob) + + $ ls test_file.* + test_file.0 + test_file.1 + test_file.2 + test_file.3 + $ for i in $(seq 0 3) + > do + > echo -n "test_file.$i:" + > wc -c < test_file.$i + > done + test_file.0: 8388608 + test_file.1: 8388608 + test_file.2: 8388608 + test_file.3: 8388608 + + $ 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 *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Extra file open flags: 0 + 4 files, 8Mb each + 32Mb total file size + Block size 16Kb + Number of IO requests: 150 + Read/Write ratio for combined random IO test: 1.50 + Periodic FSYNC enabled, calling fsync() each 100 requests. + Calling fsync() at the end of test, Enabled. + Using synchronous I/O mode + Doing random r/w test + Initializing worker threads... + + Threads started! + + Operations performed: 90 reads, 60 writes, 8 Other = 158 Total + Read *.*Mb Written *Kb Total transferred *.*Mb (*.*Mb/sec) (glob) + *.* Requests/sec executed (glob) + + General statistics: + total time: *.*s (glob) + total number of events: 150 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): 150.0000/0.00 + execution time (avg/stddev): *.*/0.00 (glob) + + $ sysbench $fileio_args cleanup + sysbench 0.5: multi-threaded system evaluation benchmark + + Removing test files... + $ ls From 3627f7212edfaf17aafdadc9e3db5db42728ab75 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 08:42:15 +0300 Subject: [PATCH 59/96] Fix fileio test to work with wc output format on Linux. --- tests/test_fileio.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_fileio.t b/tests/test_fileio.t index 72430ec..73655fb 100644 --- a/tests/test_fileio.t +++ b/tests/test_fileio.t @@ -23,8 +23,8 @@ fileio tests test_file.3 $ for i in $(seq 0 3) > do - > echo -n "test_file.$i:" - > wc -c < test_file.$i + > echo -n "test_file.$i: " + > echo $(wc -c < test_file.$i) > done test_file.0: 8388608 test_file.1: 8388608 From e90cefada17b051bc4e10a7eb1b31b98373b97f4 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 08:54:29 +0300 Subject: [PATCH 60/96] Mask version in test_fileio.t on cleanup. --- tests/test_fileio.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fileio.t b/tests/test_fileio.t index 73655fb..b8cc164 100644 --- a/tests/test_fileio.t +++ b/tests/test_fileio.t @@ -75,7 +75,7 @@ fileio tests execution time (avg/stddev): *.*/0.00 (glob) $ sysbench $fileio_args cleanup - sysbench 0.5: multi-threaded system evaluation benchmark + sysbench *.*: multi-threaded system evaluation benchmark (glob) Removing test files... $ ls From d8956f555aeafe605e0cc4439b1c35fb3a7295eb Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 08:59:59 +0300 Subject: [PATCH 61/96] Fix test_fileio.t to pass with 1.0. --- tests/test_fileio.t | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_fileio.t b/tests/test_fileio.t index b8cc164..d11f534 100644 --- a/tests/test_fileio.t +++ b/tests/test_fileio.t @@ -14,7 +14,7 @@ fileio tests Creating file test_file.1 Creating file test_file.2 Creating file test_file.3 - 33554432 bytes written in * seconds (*.* MB/sec). (glob) + 33554432 bytes written in * seconds (*.* MiB/sec). (glob) $ ls test_file.* test_file.0 @@ -39,13 +39,13 @@ fileio tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Extra file open flags: 0 - 4 files, 8Mb each - 32Mb total file size - Block size 16Kb + 4 files, 8MiB each + 32MiB total file size + Block size 16KiB Number of IO requests: 150 Read/Write ratio for combined random IO test: 1.50 Periodic FSYNC enabled, calling fsync() each 100 requests. @@ -56,9 +56,15 @@ fileio tests Threads started! - Operations performed: 90 reads, 60 writes, 8 Other = 158 Total - Read *.*Mb Written *Kb Total transferred *.*Mb (*.*Mb/sec) (glob) - *.* Requests/sec executed (glob) + + File operations: + reads/s: *.* (glob) + writes/s: *.* (glob) + fsyncs/s: *.* (glob) + + Throughput: + read, MiB/s: *.* (glob) + written, MiB/s: *.* (glob) General statistics: total time: *.*s (glob) From 71d768af996eb751ab1a74d90dc9771dcc760ac5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 10:02:36 +0300 Subject: [PATCH 62/96] Add sb_global.h to sysbench_SOURCES. Add sb_global.h to sysbench_SOURCES. Also add 'make distcheck' to Travis CI testing to catch this kind of errors. --- .travis.yml | 1 + sysbench/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c8a9994..b0db123 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ install: script: - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql - make + - make distcheck - make test after_success: diff --git a/sysbench/Makefile.am b/sysbench/Makefile.am index eaa3761..4d565ba 100644 --- a/sysbench/Makefile.am +++ b/sysbench/Makefile.am @@ -50,7 +50,7 @@ endif sysbench_SOURCES = sysbench.c sysbench.h sb_timer.c sb_timer.h \ sb_options.c sb_options.h sb_logger.c sb_logger.h sb_list.h db_driver.h \ db_driver.c sb_percentile.c sb_percentile.h sb_rnd.c sb_rnd.h \ -sb_thread.c sb_thread.h sb_barrier.c sb_barrier.h +sb_thread.c sb_thread.h sb_barrier.c sb_barrier.h sb_global.h sysbench_LDADD = tests/fileio/libsbfileio.a tests/threads/libsbthreads.a \ tests/memory/libsbmemory.a tests/cpu/libsbcpu.a \ From 7418441572f3185d82d280406cbbbd91613dbdb6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 10:37:15 +0300 Subject: [PATCH 63/96] Move tests into a separate subdirectory. Move regression tests into a separate subdirectory. Update README in tests and covert it from org-mode to markdown. Also add 'make distcheck' to Travis CI testing. --- .travis.yml | 1 + tests/Makefile.am | 4 ++-- tests/README.md | 28 ++++++++++++++++++++++++++++ tests/README.org | 25 ------------------------- tests/{ => t}/1st.t | 0 tests/{ => t}/cleanup.t | 0 tests/{ => t}/commands.t | 2 +- tests/{ => t}/help.t | 2 +- tests/{ => t}/help_drv_mysql.t | 0 tests/{ => t}/help_drv_pgsql.t | 0 tests/{ => t}/prepare.t | 0 tests/{ => t}/run.t | 0 tests/{ => t}/test_fileio.t | 0 tests/{ => t}/version.t | 0 tests/test_run.sh | 5 +++-- 15 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 tests/README.md delete mode 100644 tests/README.org rename tests/{ => t}/1st.t (100%) rename tests/{ => t}/cleanup.t (100%) rename tests/{ => t}/commands.t (81%) rename tests/{ => t}/help.t (98%) rename tests/{ => t}/help_drv_mysql.t (100%) rename tests/{ => t}/help_drv_pgsql.t (100%) rename tests/{ => t}/prepare.t (100%) rename tests/{ => t}/run.t (100%) rename tests/{ => t}/test_fileio.t (100%) rename tests/{ => t}/version.t (100%) diff --git a/.travis.yml b/.travis.yml index c8a9994..b0db123 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ install: script: - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql - make + - make distcheck - make test after_success: diff --git a/tests/Makefile.am b/tests/Makefile.am index 4eb5e43..3279762 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,11 +19,11 @@ TESTS = test_run.sh test_SCRIPTS = test_run.sh EXTRA_DIST = $(test_SCRIPTS) \ - README.org + README.md testroot = $(datadir) testdir = $(testroot)/sysbench/tests -test_dirs= . +test_dirs= t # Used by dist-hook and install-data-local to copy all # test files into either dist or install directory diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..8ef630a --- /dev/null +++ b/tests/README.md @@ -0,0 +1,28 @@ +sysbench Test Suite +=================== + +sysbench uses the [Cram](https://bitheap.org/cram/) framework for +functional and regression testing. If your system has Python 2.7.9 or +later, or Python 3.4 or later, installing Cram is as simple as executing +`pip install cram`. + +If you use an older Python version, you may need to [install +pip](https://pip.pypa.io/en/latest/installing/) first: + +``` {.example} +curl https://bootstrap.pypa.io/get-pip.py | python +``` + +To run the sysbench test suite, invoke the `test_run.sh` script in the +`tests` directory like this: + +``` {.example} +./test_run.sh [test_name]... +``` + +Each `test_name` argument is name of a test case file. Functional and +regression tests are located in the `t` subdirectory in files with the +`.t` suffix. + +If no tests are named on the `test_run.sh` command line, it will execute +all files with the `.t` suffix in the `t` subdirectory. diff --git a/tests/README.org b/tests/README.org deleted file mode 100644 index 4332a3e..0000000 --- a/tests/README.org +++ /dev/null @@ -1,25 +0,0 @@ -* sysbench Test Suite - -sysbench uses the [[https://bitheap.org/cram/][Cram]] framework for functional and regression -testing. If your system has Python 2.7.9 or later, or Python 3.4 or -later, installing Cram is as simple as executing =pip install cram=. - -If you use an older Python version, you may need to [[https://pip.pypa.io/en/latest/installing/][install pip]] first: - -#+BEGIN_EXAMPLE -curl https://bootstrap.pypa.io/get-pip.py | python -#+END_EXAMPLE - -To run the sysbench test suite, invoke the =test_run.sh= script in the -=tests= directory like this: - -#+BEGIN_EXAMPLE -./test_run.sh [test_name]... -#+END_EXAMPLE - -Each =test_name= argument is name of a test case file. Functional and -regression tests are located in the same directory in files with the -=.t= suffix. - -If no tests are named on the =test_run.sh= command line, it will execute -all files with the =.t= suffix in the current directory. diff --git a/tests/1st.t b/tests/t/1st.t similarity index 100% rename from tests/1st.t rename to tests/t/1st.t diff --git a/tests/cleanup.t b/tests/t/cleanup.t similarity index 100% rename from tests/cleanup.t rename to tests/t/cleanup.t diff --git a/tests/commands.t b/tests/t/commands.t similarity index 81% rename from tests/commands.t rename to tests/t/commands.t index c7eaa4c..1dbc621 100644 --- a/tests/commands.t +++ b/tests/t/commands.t @@ -1,6 +1,6 @@ $ commands=$(sysbench help | grep 'Commands:' | cut -d ' ' -f 2-) $ for cmd in $commands; do - > if [ ! -r ${SBTEST_ROOTDIR}/${cmd}.t ] + > if [ ! -r ${SBTEST_SUITEDIR}/${cmd}.t ] > then > echo "Cannot find test(s) for 'sysbench $cmd'!" > exit 1 diff --git a/tests/help.t b/tests/t/help.t similarity index 98% rename from tests/help.t rename to tests/t/help.t index 6eabac3..5eec09e 100644 --- a/tests/help.t +++ b/tests/t/help.t @@ -63,7 +63,7 @@ Test driver-specific options $ drivers=$(sysbench help | sed -n '/Compiled-in database drivers:/,/^$/p' | tail -n +2 | cut -d ' ' -f 3) $ for drv in $drivers > do - > if [ ! -r ${SBTEST_ROOTDIR}/help_drv_${drv}.t ] + > if [ ! -r ${SBTEST_SUITEDIR}/help_drv_${drv}.t ] > then > echo "Cannot find test(s) for $drv driver options!" > exit 1 diff --git a/tests/help_drv_mysql.t b/tests/t/help_drv_mysql.t similarity index 100% rename from tests/help_drv_mysql.t rename to tests/t/help_drv_mysql.t diff --git a/tests/help_drv_pgsql.t b/tests/t/help_drv_pgsql.t similarity index 100% rename from tests/help_drv_pgsql.t rename to tests/t/help_drv_pgsql.t diff --git a/tests/prepare.t b/tests/t/prepare.t similarity index 100% rename from tests/prepare.t rename to tests/t/prepare.t diff --git a/tests/run.t b/tests/t/run.t similarity index 100% rename from tests/run.t rename to tests/t/run.t diff --git a/tests/test_fileio.t b/tests/t/test_fileio.t similarity index 100% rename from tests/test_fileio.t rename to tests/t/test_fileio.t diff --git a/tests/version.t b/tests/t/version.t similarity index 100% rename from tests/version.t rename to tests/t/version.t diff --git a/tests/test_run.sh b/tests/test_run.sh index 08c3ca3..85c24b1 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -45,15 +45,16 @@ if [ $# -lt 1 ] then if [ -z ${srcdir+x} ] then - tests="*.t" + tests="t/*.t" else - tests="$srcdir/*.t" + tests="$srcdir/t/*.t" fi else tests="$*" fi export SBTEST_ROOTDIR="$testroot" +export SBTEST_SUITEDIR="$testroot/t" export SBTEST_INCDIR="$PWD/include" export SBTEST_CONFIG="$SBTEST_INCDIR/config.sh" From 02aac59372b0cebf5364447c2e5f7daf4718b8ac Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 11:14:10 +0300 Subject: [PATCH 64/96] Print more info in test_run.sh to diagnose Travis failures. --- tests/test_run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_run.sh b/tests/test_run.sh index 85c24b1..c1ed01d 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -38,6 +38,12 @@ fi if ! which sysbench >/dev/null 2>&1 then echo "Cannot find sysbench in PATH=$PATH" + echo "testroot=$testroot" + echo "PWD=$PWD" + ls -l $PWD + ls -l $testroot + ls -l $testroot/.. + ls -l $testroot/../sysbench exit 1 fi From f37016879230b73d3f2c35fb566b1bf9ae0eab82 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 11:35:11 +0300 Subject: [PATCH 65/96] Look for sysbench in $PWD/../sysbench in addition to other directories. --- tests/test_run.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_run.sh b/tests/test_run.sh index c1ed01d..3d86252 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -24,15 +24,19 @@ testroot=$(cd $(dirname "$0"); echo $PWD) if [ -x "$testroot/../sysbench/sysbench" ] then # Invoked from a source directory? - export PATH="$testroot/../sysbench:$PATH" + PATH="$testroot/../sysbench:$PATH" elif [ -x "$testroot/../bin" ] then # Invoked from a standalone install root directory? - export PATH="$testroot/../bin:$PATH" + PATH="$testroot/../bin:$PATH" elif [ -x "$testroot/../../../bin/sysbench" ] then # Invoked from a system-wide install (e.g. /usr/local/share/sysbench/tests)? - export PATH="$testroot/../../../bin:$PATH" + PATH="$testroot/../../../bin:$PATH" +elif [ -x "$PWD/../sysbench/sysbench" ] +then + # Invoked from the build directory by 'make distcheck'? + PATH="$PWD/../sysbench:$PATH" fi if ! which sysbench >/dev/null 2>&1 @@ -41,6 +45,7 @@ then echo "testroot=$testroot" echo "PWD=$PWD" ls -l $PWD + ls -l $PWD/../sysbench ls -l $testroot ls -l $testroot/.. ls -l $testroot/../sysbench From e766de86a865c4790891dba4ea879bb840e39bce Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 20:09:47 +0300 Subject: [PATCH 66/96] More fileio regression tests. --- tests/t/test_fileio.t | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/tests/t/test_fileio.t b/tests/t/test_fileio.t index b8cc164..955046c 100644 --- a/tests/t/test_fileio.t +++ b/tests/t/test_fileio.t @@ -74,6 +74,132 @@ fileio tests events (avg/stddev): 150.0000/0.00 execution time (avg/stddev): *.*/0.00 (glob) + $ sysbench $fileio_args --max-requests=150 --file-test-mode=rndrd run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Extra file open flags: 0 + 4 files, 8Mb each + 32Mb total file size + Block size 16Kb + Number of IO requests: 150 + Read/Write ratio for combined random IO test: 1.50 + Periodic FSYNC enabled, calling fsync() each 100 requests. + Calling fsync() at the end of test, Enabled. + Using synchronous I/O mode + Doing random read test + Initializing worker threads... + + Threads started! + + Operations performed: 150 reads, 0 writes, 0 Other = 150 Total + Read *.*b Written 0b Total transferred *.*b (*.*b/sec) (glob) + *.* Requests/sec executed (glob) + + General statistics: + total time: *.*s (glob) + total number of events: 150 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): 150.0000/0.00 + execution time (avg/stddev): *.*/0.00 (glob) + + + $ sysbench $fileio_args --max-requests=150 --file-test-mode=seqrd run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Extra file open flags: 0 + 4 files, 8Mb each + 32Mb total file size + Block size 16Kb + Periodic FSYNC enabled, calling fsync() each 100 requests. + Calling fsync() at the end of test, Enabled. + Using synchronous I/O mode + Doing sequential read test + Initializing worker threads... + + Threads started! + + Operations performed: 150 reads, 0 writes, 0 Other = 150 Total + Read *.*b Written 0b Total transferred *.*b (*.*b/sec) (glob) + *.* Requests/sec executed (glob) + + General statistics: + total time: *.*s (glob) + total number of events: 150 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): 150.0000/0.00 + execution time (avg/stddev): *.*/0.00 (glob) + + + $ sysbench $fileio_args --max-requests=150 --file-test-mode=rndwr run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Extra file open flags: 0 + 4 files, 8Mb each + 32Mb total file size + Block size 16Kb + Number of IO requests: 150 + Read/Write ratio for combined random IO test: 1.50 + Periodic FSYNC enabled, calling fsync() each 100 requests. + Calling fsync() at the end of test, Enabled. + Using synchronous I/O mode + Doing random write test + Initializing worker threads... + + Threads started! + + Operations performed: 0 reads, 150 writes, 8 Other = 158 Total + Read 0b Written *.*b Total transferred *.*b (*.*b/sec) (glob) + *.* Requests/sec executed (glob) + + General statistics: + total time: *.*s (glob) + total number of events: 150 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): 150.0000/0.00 + execution time (avg/stddev): *.*/0.00 (glob) + + + $ sysbench $fileio_args --max-requests=150 --file-test-mode=foo run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + FATAL: Invalid IO operations mode: foo. + [1] $ sysbench $fileio_args cleanup sysbench *.*: multi-threaded system evaluation benchmark (glob) From 122c716f532025c710711e53a032cc781c815887 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 20:34:20 +0300 Subject: [PATCH 67/96] Bump the required Visual Studio version to VS2015. --- README-WIN.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-WIN.txt b/README-WIN.txt index c4a9b48..d8964f1 100644 --- a/README-WIN.txt +++ b/README-WIN.txt @@ -1,8 +1,8 @@ How to build on Windows -You need CMake (download from http://www.cmake.org/) and Visual Studio 2005 or -later (free Express edition should work ok) +You need CMake (download from http://www.cmake.org/) and Visual Studio 2015 or +later. 1.Open Visual Studio command line prompt 2.To build with MySQL support, you will need mysql.h header file and client From 66248a94e0b9f5e766472d5a172fff8ea1b1aa62 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 21:23:36 +0300 Subject: [PATCH 68/96] Adjust test_fileio.t changes to 1.0. --- tests/t/test_fileio.t | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/tests/t/test_fileio.t b/tests/t/test_fileio.t index 93da7d5..0df41ef 100644 --- a/tests/t/test_fileio.t +++ b/tests/t/test_fileio.t @@ -85,13 +85,13 @@ fileio tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Extra file open flags: 0 - 4 files, 8Mb each - 32Mb total file size - Block size 16Kb + 4 files, 8MiB each + 32MiB total file size + Block size 16KiB Number of IO requests: 150 Read/Write ratio for combined random IO test: 1.50 Periodic FSYNC enabled, calling fsync() each 100 requests. @@ -102,9 +102,15 @@ fileio tests Threads started! - Operations performed: 150 reads, 0 writes, 0 Other = 150 Total - Read *.*b Written 0b Total transferred *.*b (*.*b/sec) (glob) - *.* Requests/sec executed (glob) + + File operations: + reads/s: *.* (glob) + writes/s: 0.00 + fsyncs/s: 0.00 + + Throughput: + read, MiB/s: *.* (glob) + written, MiB/s: 0.00 General statistics: total time: *.*s (glob) @@ -126,13 +132,13 @@ fileio tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Extra file open flags: 0 - 4 files, 8Mb each - 32Mb total file size - Block size 16Kb + 4 files, 8MiB each + 32MiB total file size + Block size 16KiB Periodic FSYNC enabled, calling fsync() each 100 requests. Calling fsync() at the end of test, Enabled. Using synchronous I/O mode @@ -141,9 +147,15 @@ fileio tests Threads started! - Operations performed: 150 reads, 0 writes, 0 Other = 150 Total - Read *.*b Written 0b Total transferred *.*b (*.*b/sec) (glob) - *.* Requests/sec executed (glob) + + File operations: + reads/s: *.* (glob) + writes/s: 0.00 + fsyncs/s: 0.00 + + Throughput: + read, MiB/s: *.* (glob) + written, MiB/s: 0.00 General statistics: total time: *.*s (glob) @@ -165,13 +177,13 @@ fileio tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Extra file open flags: 0 - 4 files, 8Mb each - 32Mb total file size - Block size 16Kb + 4 files, 8MiB each + 32MiB total file size + Block size 16KiB Number of IO requests: 150 Read/Write ratio for combined random IO test: 1.50 Periodic FSYNC enabled, calling fsync() each 100 requests. @@ -182,9 +194,15 @@ fileio tests Threads started! - Operations performed: 0 reads, 150 writes, 8 Other = 158 Total - Read 0b Written *.*b Total transferred *.*b (*.*b/sec) (glob) - *.* Requests/sec executed (glob) + + File operations: + reads/s: 0.00 + writes/s: *.* (glob) + fsyncs/s: *.* (glob) + + Throughput: + read, MiB/s: 0.00 + written, MiB/s: *.* (glob) General statistics: total time: *.*s (glob) From da9300e2c0a81c3af7b90eb5cdd888c705e8a474 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 21:38:08 +0300 Subject: [PATCH 69/96] Cache PIP and Homebrew directories to speed up Travis builds. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index b0db123..f48d317 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: c +cache: + directories: + - $HOME/.cache/pip + - /usr/local os: - linux From 9328dc5e3b8d4c8774f99185adb04867c6c681cd Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Sep 2016 22:47:38 +0300 Subject: [PATCH 70/96] Remove dummy comment from sb_list.h. --- sysbench/sb_list.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sysbench/sb_list.h b/sysbench/sb_list.h index 5c2a456..2cc7368 100644 --- a/sysbench/sb_list.h +++ b/sysbench/sb_list.h @@ -22,7 +22,6 @@ typedef struct sb_list_item_t { -// char c; struct sb_list_item_t *next_p; struct sb_list_item_t *prev_p; } From 2ad038e816ba1797804e71f7a3262fa262b2c9e9 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 9 Sep 2016 17:26:43 +0300 Subject: [PATCH 71/96] Basic regression tests for MySQL and PostgreSQL drivers. Add the very basic regression tests for MySQL and PostgreSQL drivers + necessary Travis CI configuration updates. --- .travis.yml | 12 ++++++++++ tests/README.md | 24 +++++++++++++++++++ tests/include/drv_common.sh | 21 +++++++++++++++++ tests/t/drivers.t | 13 ++++++++++ tests/t/drv_mysql.t | 47 +++++++++++++++++++++++++++++++++++++ tests/t/drv_pgsql.t | 47 +++++++++++++++++++++++++++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 tests/include/drv_common.sh create mode 100644 tests/t/drivers.t create mode 100644 tests/t/drv_mysql.t create mode 100644 tests/t/drv_pgsql.t diff --git a/.travis.yml b/.travis.yml index f48d317..c83f72d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,14 @@ addons: - libmysqlclient-dev - libpq-dev +services: + - mysql + - postgresql + +env: + - SBTEST_MYSQL_ARGS="--mysql-user=root --mysql-password" + - SBTEST_PGSQL_ARGS="--pgsql-user=postgres --pgsql-password" + before_install: - > case "${TRAVIS_OS_NAME:-linux}" in @@ -39,6 +47,10 @@ install: ;; esac +before_script: + - mysql -u root -e 'CREATE DATABASE sbtest;' + - psql -U postgres -c 'CREATE DATABASE sbtest;' + script: - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql - make diff --git a/tests/README.md b/tests/README.md index 8ef630a..5c195bd 100644 --- a/tests/README.md +++ b/tests/README.md @@ -26,3 +26,27 @@ regression tests are located in the `t` subdirectory in files with the If no tests are named on the `test_run.sh` command line, it will execute all files with the `.t` suffix in the `t` subdirectory. + +Some tests require external servers (MySQL, PostgreSQL, etc.). One +should environment variables to specify connection related arguments +that sysbench can use to connect to such external server(s). The +currently recognized variables are: + +- `SBTEST_MYSQL_ARGS` -- MySQL connection options: `--mysql-host`, + `--mysql-port`, `--mysql-socket` `--mysql-user`, `--mysql-password` + and `--mysql-db`; + +- `SBTEST_PGSQL_ARGS` -- PostgreSQL connection options: `--pgsql-host`, + `--pgsql-port`, `--pgsql-user`, `--pgsql-password` and `--pgsql-db`. + +For example: +``` {.example} +export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=sbtest --mysql-password=secret --mysql-db=sbtest +export SBTEST_PGSQL_ARGS="--pgsql-host=localhost --pgsql-user=postgres --pgsql-password=secret --pgsql-db=sbtest +./test_run.sh +``` + +sysbench assumes that the server(s) are pre-configured so that the +specified database exists and the user connecting with the specified +credentials has all privileges on the database. In particular, sysbench +must have enough privileges to create/drop tables and read/write data. diff --git a/tests/include/drv_common.sh b/tests/include/drv_common.sh new file mode 100644 index 0000000..2f414bf --- /dev/null +++ b/tests/include/drv_common.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +######################################################################### +# Common code for DB driver tests +# Variables: +# DB_DRIVER_ARGS -- extra driver-specific arguments to pass to sysbench +######################################################################### + +set -eu + +cat >test.lua < do + > if [ ! -r ${SBTEST_SUITEDIR}/drv_${drv}.t ] + > then + > echo "Cannot find test(s) for the $drv driver!" + > exit 1 + > fi + > done diff --git a/tests/t/drv_mysql.t b/tests/t/drv_mysql.t new file mode 100644 index 0000000..a86a056 --- /dev/null +++ b/tests/t/drv_mysql.t @@ -0,0 +1,47 @@ +######################################################################## +MySQL driver tests +######################################################################## + + $ if [ -z "${SBTEST_MYSQL_ARGS:-}" ] + > then + > exit 80 + > fi + $ DB_DRIVER_ARGS="--db-driver=mysql $SBTEST_MYSQL_ARGS" + $ . $SBTEST_INCDIR/drv_common.sh + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + OLTP test statistics: + queries performed: + read: 10 + write: 0 + other: 0 + total: 10 + transactions: 0 (0.00 per sec.) + read/write requests: 10 (*.* per sec.) (glob) + other operations: 0 (0.00 per sec.) + ignored errors: 0 (0.00 per sec.) + reconnects: 0 (0.00 per sec.) + + General statistics: + total time: *.*s (glob) + total number of events: 10 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): *.*/*.* (glob) + execution time (avg/stddev): *.*/*.* (glob) + diff --git a/tests/t/drv_pgsql.t b/tests/t/drv_pgsql.t new file mode 100644 index 0000000..64215b5 --- /dev/null +++ b/tests/t/drv_pgsql.t @@ -0,0 +1,47 @@ +######################################################################## +PostgreSQL driver tests +######################################################################## + + $ if [ -z "${SBTEST_PGSQL_ARGS:-}" ] + > then + > exit 80 + > fi + $ DB_DRIVER_ARGS="--db-driver=pgsql $SBTEST_PGSQL_ARGS" + $ . $SBTEST_INCDIR/drv_common.sh + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + OLTP test statistics: + queries performed: + read: 10 + write: 0 + other: 0 + total: 10 + transactions: 0 (0.00 per sec.) + read/write requests: 10 (*.* per sec.) (glob) + other operations: 0 (0.00 per sec.) + ignored errors: 0 (0.00 per sec.) + reconnects: 0 (0.00 per sec.) + + General statistics: + total time: *.*s (glob) + total number of events: 10 + total time taken by event execution: *.*s (glob) + response time: + min: *.*ms (glob) + avg: *.*ms (glob) + max: *.*ms (glob) + approx. 95 percentile: *.*ms (glob) + + Threads fairness: + events (avg/stddev): *.*/*.* (glob) + execution time (avg/stddev): *.*/*.* (glob) + From aaaf21ea06b3d9ce86cfc239d4b51b56e2d05049 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 9 Sep 2016 18:05:02 +0300 Subject: [PATCH 72/96] Group both MySQL and PostgreSQL into a single item. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c83f72d..6d13c16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,8 +23,7 @@ services: - postgresql env: - - SBTEST_MYSQL_ARGS="--mysql-user=root --mysql-password" - - SBTEST_PGSQL_ARGS="--pgsql-user=postgres --pgsql-password" + - SBTEST_MYSQL_ARGS="--mysql-user=root --mysql-password" SBTEST_PGSQL_ARGS="--pgsql-user=postgres --pgsql-password" before_install: - > From b17ba51f7f4006f126e116cdcf89b7fdaa87787f Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 9 Sep 2016 18:11:01 +0300 Subject: [PATCH 73/96] Temporarily disable 'make distcheck' in Travis to diagnose build failures. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6d13c16..2679904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,6 @@ before_script: script: - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql - make - - make distcheck - make test after_success: From d853d916739d387175623795c1e144cdfc0dcf9a Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 9 Sep 2016 22:26:18 +0300 Subject: [PATCH 74/96] Travis CI configuration change to fix OS X builds. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2679904..52e8932 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,9 +22,6 @@ services: - mysql - postgresql -env: - - SBTEST_MYSQL_ARGS="--mysql-user=root --mysql-password" SBTEST_PGSQL_ARGS="--pgsql-user=postgres --pgsql-password" - before_install: - > case "${TRAVIS_OS_NAME:-linux}" in @@ -33,6 +30,8 @@ before_install: brew uninstall libtool brew update --quiet brew install libtool mysql + # OS X requires mysqld to be started explicitly + brew services start mysql ;; esac @@ -53,7 +52,8 @@ before_script: script: - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql - make - - make test + - make distcheck + - SBTEST_MYSQL_ARGS="--mysql-user=root" SBTEST_PGSQL_ARGS="--pgsql-user=postgres" make test after_success: - coveralls --gcov-options '\-lp' From 45035878065cc4eaa5ed1262fddc260e08e57e17 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 9 Sep 2016 23:21:22 +0300 Subject: [PATCH 75/96] Start and initialize PostgreSQL on OS X in Travis CI builds. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 52e8932..508cd12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,10 @@ before_install: brew uninstall libtool brew update --quiet brew install libtool mysql - # OS X requires mysqld to be started explicitly + # OS X requires servers to be started explicitly brew services start mysql + pg_ctl -D /usr/local/var/postgres start + createuser -s postgres; ;; esac From 8ac3e7e85d6701a096058c44ff221799087daccd Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 10 Sep 2016 01:42:22 +0300 Subject: [PATCH 76/96] Wait until PostgreSQL completes before initializing in Travis CI os OS X. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 508cd12..a4d17f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_install: brew install libtool mysql # OS X requires servers to be started explicitly brew services start mysql - pg_ctl -D /usr/local/var/postgres start + pg_ctl -wD /usr/local/var/postgres start createuser -s postgres; ;; esac From a00535ec551d514dee67a9b068a40b3222b182e7 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 10 Sep 2016 02:15:34 +0300 Subject: [PATCH 77/96] Adjust DB drivers tests to 1.0 output. --- tests/t/drv_mysql.t | 2 +- tests/t/drv_pgsql.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/t/drv_mysql.t b/tests/t/drv_mysql.t index a86a056..f3255fd 100644 --- a/tests/t/drv_mysql.t +++ b/tests/t/drv_mysql.t @@ -12,7 +12,7 @@ MySQL driver tests Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... diff --git a/tests/t/drv_pgsql.t b/tests/t/drv_pgsql.t index 64215b5..94c04ea 100644 --- a/tests/t/drv_pgsql.t +++ b/tests/t/drv_pgsql.t @@ -12,7 +12,7 @@ PostgreSQL driver tests Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... From 1cfcacf84fbf68d62b750c0b90792c49ded666d1 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 11 Sep 2016 14:37:35 +0300 Subject: [PATCH 78/96] Basic regression tests for cpu, memory, threads and mutex benchmarks. --- sysbench/sysbench.c | 3 --- tests/t/test_cpu.t | 49 ++++++++++++++++++++++++++++++++++++ tests/t/test_fileio.t | 2 +- tests/t/test_memory.t | 56 ++++++++++++++++++++++++++++++++++++++++++ tests/t/test_mutex.t | 49 ++++++++++++++++++++++++++++++++++++ tests/t/test_threads.t | 49 ++++++++++++++++++++++++++++++++++++ tests/t/tests.t | 13 ++++++++++ 7 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 tests/t/test_cpu.t create mode 100644 tests/t/test_memory.t create mode 100644 tests/t/test_mutex.t create mode 100644 tests/t/test_threads.t create mode 100644 tests/t/tests.t diff --git a/sysbench/sysbench.c b/sysbench/sysbench.c index 3e91306..943a499 100644 --- a/sysbench/sysbench.c +++ b/sysbench/sysbench.c @@ -1225,9 +1225,6 @@ int main(int argc, char *argv[]) } if (test->cmds.help != NULL) test->cmds.help(); - else - fprintf(stderr, "No help available for test '%s'.\n", - test->sname); } exit(0); } diff --git a/tests/t/test_cpu.t b/tests/t/test_cpu.t new file mode 100644 index 0000000..5f46a0b --- /dev/null +++ b/tests/t/test_cpu.t @@ -0,0 +1,49 @@ +######################################################################## +cpu benchmark tests +######################################################################## + $ args="--test=cpu --cpu-max-prime=1000 --max-requests=100 --num-threads=2" + $ sysbench $args help + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + cpu options: + --cpu-max-prime=N upper limit for primes generator [10000] + + $ sysbench $args prepare + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'cpu' test does not have the 'prepare' command. + [1] + $ sysbench $args run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Prime numbers limit: 1000 + + Initializing worker threads... + + Threads started! + + + General statistics: + total time: *s (glob) + total number of events: 100 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): 50.0000/* (glob) + execution time (avg/stddev): */* (glob) + + $ sysbench $args cleanup + sysbench 0.5: multi-threaded system evaluation benchmark + + 'cpu' test does not have the 'cleanup' command. + [1] diff --git a/tests/t/test_fileio.t b/tests/t/test_fileio.t index 955046c..c2a2665 100644 --- a/tests/t/test_fileio.t +++ b/tests/t/test_fileio.t @@ -1,5 +1,5 @@ ######################################################################## -fileio tests +fileio benchmark tests ######################################################################## $ fileio_args="--test=fileio --file-num=4 --file-total-size=32M" diff --git a/tests/t/test_memory.t b/tests/t/test_memory.t new file mode 100644 index 0000000..0e26b94 --- /dev/null +++ b/tests/t/test_memory.t @@ -0,0 +1,56 @@ +######################################################################## +memory benchmark tests +######################################################################## + + $ args="--test=memory --memory-block-size=4K --memory-total-size=1G --max-requests=100 --num-threads=2" + $ sysbench $args help + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + memory options: + --memory-block-size=SIZE size of memory block for test [1K] + --memory-total-size=SIZE total size of data to transfer [100G] + --memory-scope=STRING memory access scope {global,local} [global] + --memory-oper=STRING type of memory operations {read, write, none} [write] + --memory-access-mode=STRING memory access mode {seq,rnd} [seq] + + $ sysbench $args prepare + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'memory' test does not have the 'prepare' command. + [1] + $ sysbench $args run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + Operations performed: 262144 (* ops/sec) (glob) + + 1024.00 MB transferred (* MB/sec) (glob) + + + General statistics: + total time: *s (glob) + total number of events: 262144 (glob) + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + $ sysbench $args cleanup + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'memory' test does not have the 'cleanup' command. + [1] diff --git a/tests/t/test_mutex.t b/tests/t/test_mutex.t new file mode 100644 index 0000000..bf82949 --- /dev/null +++ b/tests/t/test_mutex.t @@ -0,0 +1,49 @@ +######################################################################## +mutex benchmark tests +######################################################################## + $ args="--test=mutex --max-requests=100 --num-threads=2" + $ sysbench $args help + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + mutex options: + --mutex-num=N total size of mutex array [4096] + --mutex-locks=N number of mutex locks to do per thread [50000] + --mutex-loops=N number of empty loops to do inside mutex lock [10000] + + $ sysbench $args prepare + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'mutex' test does not have the 'prepare' command. + [1] + $ sysbench $args run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + + General statistics: + total time: *s (glob) + total number of events: 2 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + $ sysbench $args cleanup + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'mutex' test does not have the 'cleanup' command. + [1] diff --git a/tests/t/test_threads.t b/tests/t/test_threads.t new file mode 100644 index 0000000..12b02db --- /dev/null +++ b/tests/t/test_threads.t @@ -0,0 +1,49 @@ +######################################################################## +threads benchmark tests +######################################################################## + + $ args="--test=threads --max-requests=100 --num-threads=2" + $ sysbench $args help + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + threads options: + --thread-yields=N number of yields to do per request [1000] + --thread-locks=N number of locks per thread [8] + + $ sysbench $args prepare + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'threads' test does not have the 'prepare' command. + [1] + $ sysbench $args run + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 2 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + + General statistics: + total time: *s (glob) + total number of events: 100 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + $ sysbench $args cleanup + sysbench *.*: multi-threaded system evaluation benchmark (glob) + + 'threads' test does not have the 'cleanup' command. + [1] diff --git a/tests/t/tests.t b/tests/t/tests.t new file mode 100644 index 0000000..bd4c65f --- /dev/null +++ b/tests/t/tests.t @@ -0,0 +1,13 @@ +######################################################################## +Make sure all built-in tests are covered +######################################################################## + + $ tests=$(sysbench help | sed -n '/Compiled-in tests:/,/^$/p' | tail -n +2 | cut -d ' ' -f 3) + $ for t in $tests + > do + > if [ ! -r ${SBTEST_SUITEDIR}/test_${t}.t ] + > then + > echo "Cannot find test(s) for 'sysbench --test=$t'!" + > exit 1 + > fi + > done From da7df5bb261715370bd008318755705a0b9d5dd9 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 11 Sep 2016 15:28:31 +0300 Subject: [PATCH 79/96] Fix the memory benchmark test to work on Linux. --- tests/t/test_memory.t | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/t/test_memory.t b/tests/t/test_memory.t index 0e26b94..4216a59 100644 --- a/tests/t/test_memory.t +++ b/tests/t/test_memory.t @@ -3,7 +3,19 @@ memory benchmark tests ######################################################################## $ args="--test=memory --memory-block-size=4K --memory-total-size=1G --max-requests=100 --num-threads=2" - $ sysbench $args help + +The --memory-hugetlb option is supported and printed by 'sysbench +help' only on Linux. + + $ if [ "$(uname -s)" = "Linux" ] + > then + > sysbench $args help | grep hugetlb + > else + > echo " --memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off]" + > fi + --memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off] + + $ sysbench $args help | grep -v hugetlb sysbench *.*: multi-threaded system evaluation benchmark (glob) memory options: @@ -40,10 +52,10 @@ memory benchmark tests total number of events: 262144 (glob) total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) From 3fcceafe6216c78cb4fa0d1bbf5a19f27c161d88 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 11 Sep 2016 15:29:48 +0300 Subject: [PATCH 80/96] Reduce --max-requests in the mutex benchmark test. Reduce --max-requests in the mutex benchmark tests, as it takes too much time on Travis CI slaves. --- tests/t/test_mutex.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/t/test_mutex.t b/tests/t/test_mutex.t index bf82949..3ca4b43 100644 --- a/tests/t/test_mutex.t +++ b/tests/t/test_mutex.t @@ -1,7 +1,7 @@ ######################################################################## mutex benchmark tests ######################################################################## - $ args="--test=mutex --max-requests=100 --num-threads=2" + $ args="--test=mutex --max-requests=10 --num-threads=2" $ sysbench $args help sysbench *.*: multi-threaded system evaluation benchmark (glob) @@ -33,10 +33,10 @@ mutex benchmark tests total number of events: 2 total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) From 7016cb67e607d6d01914d2b82f46a3bf4b6040d5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 11 Sep 2016 15:59:37 +0300 Subject: [PATCH 81/96] Adjust test_mutex.t to pass on slow machines. --- tests/t/test_mutex.t | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/t/test_mutex.t b/tests/t/test_mutex.t index 3ca4b43..1884913 100644 --- a/tests/t/test_mutex.t +++ b/tests/t/test_mutex.t @@ -33,10 +33,10 @@ mutex benchmark tests total number of events: 2 total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) From ccd9845321c9395e92e923227b158a918f38f0c3 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sun, 11 Sep 2016 16:15:07 +0300 Subject: [PATCH 82/96] Adjust tests to 1.0. --- tests/t/test_cpu.t | 4 ++-- tests/t/test_memory.t | 4 ++-- tests/t/test_mutex.t | 2 +- tests/t/test_threads.t | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/t/test_cpu.t b/tests/t/test_cpu.t index 5f46a0b..871f10c 100644 --- a/tests/t/test_cpu.t +++ b/tests/t/test_cpu.t @@ -18,7 +18,7 @@ cpu benchmark tests Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Prime numbers limit: 1000 @@ -43,7 +43,7 @@ cpu benchmark tests execution time (avg/stddev): */* (glob) $ sysbench $args cleanup - sysbench 0.5: multi-threaded system evaluation benchmark + sysbench *.*: multi-threaded system evaluation benchmark (glob) 'cpu' test does not have the 'cleanup' command. [1] diff --git a/tests/t/test_memory.t b/tests/t/test_memory.t index 4216a59..7b8e8ff 100644 --- a/tests/t/test_memory.t +++ b/tests/t/test_memory.t @@ -35,7 +35,7 @@ help' only on Linux. Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... @@ -44,7 +44,7 @@ help' only on Linux. Operations performed: 262144 (* ops/sec) (glob) - 1024.00 MB transferred (* MB/sec) (glob) + 1024.00 MiB transferred (* MiB/sec) (glob) General statistics: diff --git a/tests/t/test_mutex.t b/tests/t/test_mutex.t index 1884913..c8c58c0 100644 --- a/tests/t/test_mutex.t +++ b/tests/t/test_mutex.t @@ -20,7 +20,7 @@ mutex benchmark tests Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... diff --git a/tests/t/test_threads.t b/tests/t/test_threads.t index 12b02db..65ab9e0 100644 --- a/tests/t/test_threads.t +++ b/tests/t/test_threads.t @@ -20,7 +20,7 @@ threads benchmark tests Running the test with following options: Number of threads: 2 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... From e5e6ccb8d1f9cfdaf996ba15a6e6788c7caec6d0 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Fri, 16 Sep 2016 20:02:57 +0300 Subject: [PATCH 83/96] Fix NULL handling in PostgreSQL driver. --- sysbench/drivers/pgsql/drv_pgsql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/drivers/pgsql/drv_pgsql.c b/sysbench/drivers/pgsql/drv_pgsql.c index 38be62b..2b6b7ca 100644 --- a/sysbench/drivers/pgsql/drv_pgsql.c +++ b/sysbench/drivers/pgsql/drv_pgsql.c @@ -519,7 +519,7 @@ int pgsql_drv_execute(db_stmt_t *stmt, db_result_set_t *rs) /* Convert SysBench bind structures to PgSQL data */ for (i = 0; i < (unsigned)pgstmt->nparams; i++) { - if (stmt->bound_param[i].is_null) + if (stmt->bound_param[i].is_null && *(stmt->bound_param[i].is_null)) continue; switch (stmt->bound_param[i].type) { From f6e94a0fd66b70085e992171ce3b8c1993f3cb39 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 16 Sep 2016 16:18:27 +0300 Subject: [PATCH 84/96] Fix LOCK TABLES statements for multi-table MySQL/MyISAM benchmarks. --- sysbench/tests/db/oltp.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index 985ca0c..4b7de99 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -6,7 +6,12 @@ function thread_init(thread_id) set_vars() if (((db_driver == "mysql") or (db_driver == "attachsql")) and mysql_table_engine == "myisam") then - begin_query = "LOCK TABLES sbtest WRITE" + local i + local tables = {} + for i=1, oltp_tables_count do + tables[i] = string.format("sbtest%i WRITE", i) + end + begin_query = "LOCK TABLES " .. table.concat(tables, " ,") commit_query = "UNLOCK TABLES" else begin_query = "BEGIN" From 95885f6a9fd02df92ac29a1127b7363c81f3c311 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 16 Sep 2016 23:48:12 +0300 Subject: [PATCH 85/96] Basic tests for oltp.lua against MySQL and PostgreSQL. --- tests/include/script_oltp_common.sh | 17 +++ tests/t/script_oltp_mysql.t | 160 ++++++++++++++++++++++++++++ tests/t/script_oltp_pgsql.t | 85 +++++++++++++++ tests/test_run.sh | 1 + 4 files changed, 263 insertions(+) create mode 100644 tests/include/script_oltp_common.sh create mode 100644 tests/t/script_oltp_mysql.t create mode 100644 tests/t/script_oltp_pgsql.t diff --git a/tests/include/script_oltp_common.sh b/tests/include/script_oltp_common.sh new file mode 100644 index 0000000..aa9b715 --- /dev/null +++ b/tests/include/script_oltp_common.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +######################################################################### +# Common code for OLTP tests +# Variables: +# DB_DRIVER_ARGS -- extra driver-specific arguments to pass to sysbench +######################################################################### + +set -eu + +ARGS="--test=${SBTEST_SCRIPTDIR}/oltp.lua $DB_DRIVER_ARGS --oltp-tables-count=8" + +sysbench $ARGS prepare + +sysbench $ARGS --max-requests=100 --num-threads=1 run + +sysbench $ARGS cleanup diff --git a/tests/t/script_oltp_mysql.t b/tests/t/script_oltp_mysql.t new file mode 100644 index 0000000..d4044a4 --- /dev/null +++ b/tests/t/script_oltp_mysql.t @@ -0,0 +1,160 @@ +######################################################################## +oltp.lua + MySQL tests +######################################################################## + + $ if [ -z "${SBTEST_MYSQL_ARGS:-}" ] + > then + > exit 80 + > fi + + $ DB_DRIVER_ARGS="--db-driver=mysql --mysql-table-engine=myisam $SBTEST_MYSQL_ARGS" + $ . $SBTEST_INCDIR/script_oltp_common.sh + sysbench *: multi-threaded system evaluation benchmark (glob) + + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating secondary indexes on 'sbtest1'... + Creating table 'sbtest2'... + Inserting 10000 records into 'sbtest2' + Creating secondary indexes on 'sbtest2'... + Creating table 'sbtest3'... + Inserting 10000 records into 'sbtest3' + Creating secondary indexes on 'sbtest3'... + Creating table 'sbtest4'... + Inserting 10000 records into 'sbtest4' + Creating secondary indexes on 'sbtest4'... + Creating table 'sbtest5'... + Inserting 10000 records into 'sbtest5' + Creating secondary indexes on 'sbtest5'... + Creating table 'sbtest6'... + Inserting 10000 records into 'sbtest6' + Creating secondary indexes on 'sbtest6'... + Creating table 'sbtest7'... + Inserting 10000 records into 'sbtest7' + Creating secondary indexes on 'sbtest7'... + Creating table 'sbtest8'... + Inserting 10000 records into 'sbtest8' + Creating secondary indexes on 'sbtest8'... + sysbench *: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + OLTP test statistics: + queries performed: + read: 1400 + write: 400 + other: 200 + total: 2000 + transactions: 100 (* per sec.) (glob) + read/write requests: 1800 (* per sec.) (glob) + other operations: 200 (* per sec.) (glob) + ignored errors: 0 (* per sec.) (glob) + reconnects: 0 (* per sec.) (glob) + + General statistics: + total time: *s (glob) + total number of events: 100 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + sysbench *: multi-threaded system evaluation benchmark (glob) + + Dropping table 'sbtest1'... + Dropping table 'sbtest2'... + Dropping table 'sbtest3'... + Dropping table 'sbtest4'... + Dropping table 'sbtest5'... + Dropping table 'sbtest6'... + Dropping table 'sbtest7'... + Dropping table 'sbtest8'... + + $ DB_DRIVER_ARGS="--db-driver=mysql --mysql-table-engine=innodb $SBTEST_MYSQL_ARGS" + $ . $SBTEST_INCDIR/script_oltp_common.sh + sysbench *: multi-threaded system evaluation benchmark (glob) + + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating secondary indexes on 'sbtest1'... + Creating table 'sbtest2'... + Inserting 10000 records into 'sbtest2' + Creating secondary indexes on 'sbtest2'... + Creating table 'sbtest3'... + Inserting 10000 records into 'sbtest3' + Creating secondary indexes on 'sbtest3'... + Creating table 'sbtest4'... + Inserting 10000 records into 'sbtest4' + Creating secondary indexes on 'sbtest4'... + Creating table 'sbtest5'... + Inserting 10000 records into 'sbtest5' + Creating secondary indexes on 'sbtest5'... + Creating table 'sbtest6'... + Inserting 10000 records into 'sbtest6' + Creating secondary indexes on 'sbtest6'... + Creating table 'sbtest7'... + Inserting 10000 records into 'sbtest7' + Creating secondary indexes on 'sbtest7'... + Creating table 'sbtest8'... + Inserting 10000 records into 'sbtest8' + Creating secondary indexes on 'sbtest8'... + sysbench *: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + OLTP test statistics: + queries performed: + read: 1400 + write: 400 + other: 200 + total: 2000 + transactions: 100 (* per sec.) (glob) + read/write requests: 1800 (* per sec.) (glob) + other operations: 200 (* per sec.) (glob) + ignored errors: 0 (* per sec.) (glob) + reconnects: 0 (* per sec.) (glob) + + General statistics: + total time: *s (glob) + total number of events: 100 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + sysbench *: multi-threaded system evaluation benchmark (glob) + + Dropping table 'sbtest1'... + Dropping table 'sbtest2'... + Dropping table 'sbtest3'... + Dropping table 'sbtest4'... + Dropping table 'sbtest5'... + Dropping table 'sbtest6'... + Dropping table 'sbtest7'... + Dropping table 'sbtest8'... diff --git a/tests/t/script_oltp_pgsql.t b/tests/t/script_oltp_pgsql.t new file mode 100644 index 0000000..b78d25b --- /dev/null +++ b/tests/t/script_oltp_pgsql.t @@ -0,0 +1,85 @@ +######################################################################## +oltp.lua + PostgreSQL tests +######################################################################## + + $ if [ -z "${SBTEST_PGSQL_ARGS:-}" ] + > then + > exit 80 + > fi + + $ DB_DRIVER_ARGS="--db-driver=pgsql $SBTEST_PGSQL_ARGS" + $ . $SBTEST_INCDIR/script_oltp_common.sh + sysbench *: multi-threaded system evaluation benchmark (glob) + + Creating table 'sbtest1'... + Inserting 10000 records into 'sbtest1' + Creating secondary indexes on 'sbtest1'... + Creating table 'sbtest2'... + Inserting 10000 records into 'sbtest2' + Creating secondary indexes on 'sbtest2'... + Creating table 'sbtest3'... + Inserting 10000 records into 'sbtest3' + Creating secondary indexes on 'sbtest3'... + Creating table 'sbtest4'... + Inserting 10000 records into 'sbtest4' + Creating secondary indexes on 'sbtest4'... + Creating table 'sbtest5'... + Inserting 10000 records into 'sbtest5' + Creating secondary indexes on 'sbtest5'... + Creating table 'sbtest6'... + Inserting 10000 records into 'sbtest6' + Creating secondary indexes on 'sbtest6'... + Creating table 'sbtest7'... + Inserting 10000 records into 'sbtest7' + Creating secondary indexes on 'sbtest7'... + Creating table 'sbtest8'... + Inserting 10000 records into 'sbtest8' + Creating secondary indexes on 'sbtest8'... + sysbench *: multi-threaded system evaluation benchmark (glob) + + Running the test with following options: + Number of threads: 1 + Random number generator seed is 0 and will be ignored + + + Initializing worker threads... + + Threads started! + + OLTP test statistics: + queries performed: + read: 1400 + write: 400 + other: 200 + total: 2000 + transactions: 100 (* per sec.) (glob) + read/write requests: 1800 (* per sec.) (glob) + other operations: 200 (* per sec.) (glob) + ignored errors: 0 (* per sec.) (glob) + reconnects: 0 (* per sec.) (glob) + + General statistics: + total time: *s (glob) + total number of events: 100 + total time taken by event execution: *s (glob) + response time: + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) + + Threads fairness: + events (avg/stddev): */* (glob) + execution time (avg/stddev): */* (glob) + + sysbench *: multi-threaded system evaluation benchmark (glob) + + Dropping table 'sbtest1'... + Dropping table 'sbtest2'... + Dropping table 'sbtest3'... + Dropping table 'sbtest4'... + Dropping table 'sbtest5'... + Dropping table 'sbtest6'... + Dropping table 'sbtest7'... + Dropping table 'sbtest8'... + diff --git a/tests/test_run.sh b/tests/test_run.sh index 3d86252..8703bd9 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -65,6 +65,7 @@ else fi export SBTEST_ROOTDIR="$testroot" +export SBTEST_SCRIPTDIR="$testroot/../sysbench/tests/db" export SBTEST_SUITEDIR="$testroot/t" export SBTEST_INCDIR="$PWD/include" export SBTEST_CONFIG="$SBTEST_INCDIR/config.sh" From ee7082c3cd78dfedb3f29ff7c50a86c73ec43ed2 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Fri, 16 Sep 2016 23:55:29 +0300 Subject: [PATCH 86/96] Prevent script_oltp_*.t failures on slower machines. --- tests/t/script_oltp_mysql.t | 16 ++++++++-------- tests/t/script_oltp_pgsql.t | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/t/script_oltp_mysql.t b/tests/t/script_oltp_mysql.t index d4044a4..74f4564 100644 --- a/tests/t/script_oltp_mysql.t +++ b/tests/t/script_oltp_mysql.t @@ -63,10 +63,10 @@ oltp.lua + MySQL tests total number of events: 100 total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) @@ -139,10 +139,10 @@ oltp.lua + MySQL tests total number of events: 100 total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) diff --git a/tests/t/script_oltp_pgsql.t b/tests/t/script_oltp_pgsql.t index b78d25b..5912a7c 100644 --- a/tests/t/script_oltp_pgsql.t +++ b/tests/t/script_oltp_pgsql.t @@ -63,10 +63,10 @@ oltp.lua + PostgreSQL tests total number of events: 100 total time taken by event execution: *s (glob) response time: - min: *ms (glob) - avg: *ms (glob) - max: *ms (glob) - approx. 95 percentile: *ms (glob) + min: *ms (glob) + avg: *ms (glob) + max: *ms (glob) + approx. 95 percentile: *ms (glob) Threads fairness: events (avg/stddev): */* (glob) From d244ca42bb2eb82650b35166d37ea23833a25881 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 17 Sep 2016 07:40:29 +0300 Subject: [PATCH 87/96] Adjust script_oltp_* tests to 1.0. --- tests/t/script_oltp_mysql.t | 4 ++-- tests/t/script_oltp_pgsql.t | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/t/script_oltp_mysql.t b/tests/t/script_oltp_mysql.t index 74f4564..145f52d 100644 --- a/tests/t/script_oltp_mysql.t +++ b/tests/t/script_oltp_mysql.t @@ -39,7 +39,7 @@ oltp.lua + MySQL tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... @@ -115,7 +115,7 @@ oltp.lua + MySQL tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... diff --git a/tests/t/script_oltp_pgsql.t b/tests/t/script_oltp_pgsql.t index 5912a7c..09930db 100644 --- a/tests/t/script_oltp_pgsql.t +++ b/tests/t/script_oltp_pgsql.t @@ -39,7 +39,7 @@ oltp.lua + PostgreSQL tests Running the test with following options: Number of threads: 1 - Random number generator seed is 0 and will be ignored + Initializing random number generator from current time Initializing worker threads... From 78bd5b3819e45697a4d5104cb0513bbf4cddee39 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 22 Sep 2016 09:14:31 +1000 Subject: [PATCH 88/96] {common,bulkinsert}.lua missing from Makefile Also change the defination so that these get installed to the pkgdatadir which will help packagers. Signed-off-by: Daniel Black --- sysbench/tests/db/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysbench/tests/db/Makefile.am b/sysbench/tests/db/Makefile.am index e7647ac..3d6a7e4 100644 --- a/sysbench/tests/db/Makefile.am +++ b/sysbench/tests/db/Makefile.am @@ -15,7 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -EXTRA_DIST = delete.lua insert.lua oltp.lua \ +dist_pkgdata_DATA = common.lua delete.lua insert.lua bulk_insert.lua \ + oltp.lua \ oltp_simple.lua \ parallel_prepare.lua \ select_random_points.lua \ From 16ba86827fca12e27e2bf535e13d82e7ff36d636 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 22 Sep 2016 09:15:55 +1000 Subject: [PATCH 89/96] Load script from pkgdatadir if not local If the --test=XXX{.lua} script isn't local, load it from the pkgdatadir where some inbuilt scripts are installed. Autoappend the .lua extension if this wasn't done alrady. Here we set the LUA_PATH so that further lua 'require' directives also pull the source from the pkgdatadir. Signed-off-by: Daniel Black --- sysbench/scripting/Makefile.am | 2 +- sysbench/scripting/script_lua.c | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/sysbench/scripting/Makefile.am b/sysbench/scripting/Makefile.am index d8f1868..331e2d8 100644 --- a/sysbench/scripting/Makefile.am +++ b/sysbench/scripting/Makefile.am @@ -18,7 +18,7 @@ if USE_LUA SUBDIRS = lua . lua_sources = script_lua.c script_lua.h -AM_CPPFLAGS += -I$(srcdir)/lua/src +AM_CPPFLAGS += -I$(srcdir)/lua/src -DDATA_PATH=\"$(pkgdatadir)\" endif noinst_LIBRARIES = libsbscript.a diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index f14c33e..108dd3b 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -29,6 +29,8 @@ #include "db_driver.h" +#include + #define EVENT_FUNC "event" #define PREPARE_FUNC "prepare" #define CLEANUP_FUNC "cleanup" @@ -169,6 +171,8 @@ int script_load_lua(const char *testname, sb_test_t *test) { unsigned int i; + setenv("LUA_PATH", DATA_PATH LUA_DIRSEP "?.lua", 0); + /* Initialize global interpreter state */ gstate = sb_lua_new_state(testname, -1); if (gstate == NULL) @@ -488,8 +492,27 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id) luaL_newmetatable(state, "sysbench.stmt"); luaL_newmetatable(state, "sysbench.rs"); - - if (luaL_loadfile(state, scriptname) || lua_pcall(state, 0, 0, 0)) + + if (luaL_loadfile(state, scriptname)) + { + /* first location failed - look in DATA_PATH */ + char p[PATH_MAX + 1]; + strncpy(p, DATA_PATH LUA_DIRSEP, sizeof(p)); + strncat(p, scriptname, sizeof(p)); + if (!strrchr(scriptname, '.')) + { + /* add .lua extension if there isn't one */ + strncat(p, ".lua", sizeof(p)); + } + + if (luaL_loadfile(state, p)) + { + lua_error(state); + return NULL; + } + } + + if (lua_pcall(state, 0, 0, 0)) { lua_error(state); return NULL; From 0fefcfbc9bb4b96bb6a5186692fb9f020d7b3b9f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 22 Sep 2016 09:19:05 +1000 Subject: [PATCH 90/96] Change lua scripts to 'require common' if a testdir wasn't passed This completes what is needed to cause these scripts to pull in common from the LUA_PATH. Signed-off-by: Daniel Black --- sysbench/tests/db/delete.lua | 8 ++++++-- sysbench/tests/db/insert.lua | 8 ++++++-- sysbench/tests/db/oltp.lua | 8 ++++++-- sysbench/tests/db/oltp_simple.lua | 8 ++++++-- sysbench/tests/db/parallel_prepare.lua | 8 ++++++-- sysbench/tests/db/select.lua | 8 ++++++-- sysbench/tests/db/update_index.lua | 8 ++++++-- sysbench/tests/db/update_non_index.lua | 8 ++++++-- 8 files changed, 48 insertions(+), 16 deletions(-) diff --git a/sysbench/tests/db/delete.lua b/sysbench/tests/db/delete.lua index b4e4dc7..85c9c94 100644 --- a/sysbench/tests/db/delete.lua +++ b/sysbench/tests/db/delete.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/insert.lua b/sysbench/tests/db/insert.lua index d206609..60e9567 100644 --- a/sysbench/tests/db/insert.lua +++ b/sysbench/tests/db/insert.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index 4b7de99..0cdbe08 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/oltp_simple.lua b/sysbench/tests/db/oltp_simple.lua index 13da9b1..c55cc57 100644 --- a/sysbench/tests/db/oltp_simple.lua +++ b/sysbench/tests/db/oltp_simple.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/parallel_prepare.lua b/sysbench/tests/db/parallel_prepare.lua index f956eb7..d001310 100644 --- a/sysbench/tests/db/parallel_prepare.lua +++ b/sysbench/tests/db/parallel_prepare.lua @@ -1,8 +1,12 @@ -- for proper initialization use --max-requests = N, where N is --num-threads -- -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/select.lua b/sysbench/tests/db/select.lua index a43f7b7..b2a75f6 100644 --- a/sysbench/tests/db/select.lua +++ b/sysbench/tests/db/select.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/update_index.lua b/sysbench/tests/db/update_index.lua index e74027f..077240c 100644 --- a/sysbench/tests/db/update_index.lua +++ b/sysbench/tests/db/update_index.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() diff --git a/sysbench/tests/db/update_non_index.lua b/sysbench/tests/db/update_non_index.lua index bb17dad..1a6a502 100644 --- a/sysbench/tests/db/update_non_index.lua +++ b/sysbench/tests/db/update_non_index.lua @@ -1,6 +1,10 @@ -pathtest = string.match(test, "(.*/)") or "" +pathtest = string.match(test, "(.*/)") -dofile(pathtest .. "common.lua") +if pathtest then + dofile(pathtest .. "common.lua") +else + require("common") +end function thread_init(thread_id) set_vars() From 58007b23bc71c5fabfd98077d8527f63f570b8a0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 22 Sep 2016 09:58:06 +1000 Subject: [PATCH 91/96] add libaio-dev to travis Signed-off-by: Daniel Black --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a4d17f3..4543239 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ addons: packages: - libmysqlclient-dev - libpq-dev + - libaio-dev services: - mysql From 03ffdbd4d6b54981642ba682dab1f847fde0fa9c Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 21 Sep 2016 17:32:22 -0700 Subject: [PATCH 92/96] Some typo fixes in the docs. --- tests/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/README.md b/tests/README.md index 5c195bd..760b38e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -14,23 +14,23 @@ curl https://bootstrap.pypa.io/get-pip.py | python ``` To run the sysbench test suite, invoke the `test_run.sh` script in the -`tests` directory like this: +`tests` directory as follows: ``` {.example} ./test_run.sh [test_name]... ``` -Each `test_name` argument is name of a test case file. Functional and +Each `test_name` argument is a name of a test case file. Functional and regression tests are located in the `t` subdirectory in files with the `.t` suffix. If no tests are named on the `test_run.sh` command line, it will execute all files with the `.t` suffix in the `t` subdirectory. -Some tests require external servers (MySQL, PostgreSQL, etc.). One -should environment variables to specify connection related arguments -that sysbench can use to connect to such external server(s). The -currently recognized variables are: +Some tests require external servers (MySQL, PostgreSQL, etc). One should +use environment variables to specify connection related arguments that +sysbench can use to connect to such external server(s). The currently +recognized variables are: - `SBTEST_MYSQL_ARGS` -- MySQL connection options: `--mysql-host`, `--mysql-port`, `--mysql-socket` `--mysql-user`, `--mysql-password` @@ -41,12 +41,12 @@ currently recognized variables are: For example: ``` {.example} -export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=sbtest --mysql-password=secret --mysql-db=sbtest -export SBTEST_PGSQL_ARGS="--pgsql-host=localhost --pgsql-user=postgres --pgsql-password=secret --pgsql-db=sbtest +export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=sbtest --mysql-password=secret --mysql-db=sbtest" +export SBTEST_PGSQL_ARGS="--pgsql-host=localhost --pgsql-user=postgres --pgsql-password=secret --pgsql-db=sbtest" ./test_run.sh ``` -sysbench assumes that the server(s) are pre-configured so that the -specified database exists and the user connecting with the specified -credentials has all privileges on the database. In particular, sysbench -must have enough privileges to create/drop tables and read/write data. +sysbench assumes that server(s) are pre-configured so that the specified +database exists and the user connecting with the specified credentials +has all privileges on the database. In particular, sysbench must have +enough privileges to create/drop/read/modify tables in that database. From cd87db5a301bb0557ebe8147d90992a5d56efc5b Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 21 Sep 2016 17:32:22 -0700 Subject: [PATCH 93/96] Some typo fixes in the docs. --- tests/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/README.md b/tests/README.md index 5c195bd..760b38e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -14,23 +14,23 @@ curl https://bootstrap.pypa.io/get-pip.py | python ``` To run the sysbench test suite, invoke the `test_run.sh` script in the -`tests` directory like this: +`tests` directory as follows: ``` {.example} ./test_run.sh [test_name]... ``` -Each `test_name` argument is name of a test case file. Functional and +Each `test_name` argument is a name of a test case file. Functional and regression tests are located in the `t` subdirectory in files with the `.t` suffix. If no tests are named on the `test_run.sh` command line, it will execute all files with the `.t` suffix in the `t` subdirectory. -Some tests require external servers (MySQL, PostgreSQL, etc.). One -should environment variables to specify connection related arguments -that sysbench can use to connect to such external server(s). The -currently recognized variables are: +Some tests require external servers (MySQL, PostgreSQL, etc). One should +use environment variables to specify connection related arguments that +sysbench can use to connect to such external server(s). The currently +recognized variables are: - `SBTEST_MYSQL_ARGS` -- MySQL connection options: `--mysql-host`, `--mysql-port`, `--mysql-socket` `--mysql-user`, `--mysql-password` @@ -41,12 +41,12 @@ currently recognized variables are: For example: ``` {.example} -export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=sbtest --mysql-password=secret --mysql-db=sbtest -export SBTEST_PGSQL_ARGS="--pgsql-host=localhost --pgsql-user=postgres --pgsql-password=secret --pgsql-db=sbtest +export SBTEST_MYSQL_ARGS="--mysql-host=localhost --mysql-user=sbtest --mysql-password=secret --mysql-db=sbtest" +export SBTEST_PGSQL_ARGS="--pgsql-host=localhost --pgsql-user=postgres --pgsql-password=secret --pgsql-db=sbtest" ./test_run.sh ``` -sysbench assumes that the server(s) are pre-configured so that the -specified database exists and the user connecting with the specified -credentials has all privileges on the database. In particular, sysbench -must have enough privileges to create/drop tables and read/write data. +sysbench assumes that server(s) are pre-configured so that the specified +database exists and the user connecting with the specified credentials +has all privileges on the database. In particular, sysbench must have +enough privileges to create/drop/read/modify tables in that database. From fc37905725be7c6707c52f3ea8d509f25ef8eced Mon Sep 17 00:00:00 2001 From: Johnathan Phan Date: Mon, 26 Sep 2016 11:53:01 +0100 Subject: [PATCH 94/96] simple build instructions to include oracle client, Also minor change to look at correct folder structure of 12.1 oracle client. --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be4b8d2..900fbec 100644 --- a/README.md +++ b/README.md @@ -86,3 +86,47 @@ The table below lists the supported common options, their descriptions and defau Note that numerical values for all *size* options (like `--thread-stack-size` in this table) may be specified by appending the corresponding multiplicative suffix (K for kilobytes, M for megabytes, G for gigabytes and T for terabytes). + +-------------------------------------------------------------- +Oracle Build steps +-------------------------------------------------------------- + +Using Ubuntu 14.04 - intructions dated for 21/09/2016 (Was built on AWS in an r3.xlarge These actions were done against 0.5 checkout) + +* Setup Oracleclient - https://help.ubuntu.com/community/Oracle%20Instant%20Client +download from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. the following RPM's and upload them to the server. +oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm +oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm + +alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm +alien -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm + +* Install Cuda - http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu +wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb +sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb +sudo apt-get update +sudo apt-get install cuda +export CUDA_HOME=/usr/local/cuda-7.5 +export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 + +PATH=${CUDA_HOME}/bin:${PATH} +export PATH +echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracle-client-12.1.conf +ldconfig + +* Login and install sys bench + apt-get update + apt-get -y install automake libtool git libmysqlclient15-dev make libaio1 libaio-dev + git clone https://github.com/akopytov/sysbench.git + cd sysbench + vi configure.ac +> Replace line - ORA_CFLAGS="-I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" +> With line - ORA_CFLAGS="-I${ac_cv_use_oracle}/include -I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" +./autogen.sh +./configure --with-oracle="/usr/lib/oracle/12.1/client64" +make +Run the following commands to allow sysbench use the full number of cores. +sudo sh -c 'for x in /sys/class/net/eth0/queues/rx-*; do echo ffffffff> $x/rps_cpus; done' +sudo sh -c "echo 32768 > /proc/sys/net/core/rps_sock_flow_entries" +sudo sh -c "echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt" + diff --git a/configure.ac b/configure.ac index d86df86..618dfef 100644 --- a/configure.ac +++ b/configure.ac @@ -216,7 +216,7 @@ AM_CONDITIONAL(USE_ORACLE, test x$ac_cv_use_oracle != xno) if test x$ac_cv_use_oracle != xno; then AC_DEFINE(USE_ORACLE,1,[Define to 1 if you want to compile with Oracle support]) ORA_LIBS="-L${ac_cv_use_oracle}/lib -lclntsh" - ORA_CFLAGS="-I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" + ORA_CFLAGS="-I${ac_cv_use_oracle}/include -I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" AC_SUBST([ORA_LIBS]) AC_SUBST([ORA_CFLAGS]) fi From 5807d7772da98f3f2f279563b2b8dd325109afc0 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 26 Sep 2016 14:24:14 +0300 Subject: [PATCH 95/96] Move Oracle build steps into a separate file. Move Oracle build steps into a separate file, link to it from the main README.md. --- README-Oracle.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 51 ++++++------------------------------------------ 2 files changed, 55 insertions(+), 45 deletions(-) create mode 100644 README-Oracle.md diff --git a/README-Oracle.md b/README-Oracle.md new file mode 100644 index 0000000..25b8707 --- /dev/null +++ b/README-Oracle.md @@ -0,0 +1,49 @@ +-------------------------------------------------------------- +Oracle Build steps +-------------------------------------------------------------- + +Using Ubuntu 14.04 - intructions dated for 21/09/2016 (Was built on AWS +in an r3.xlarge These actions were done against 0.5 checkout) + +* Setup Oracle Instant Client - +https://help.ubuntu.com/community/Oracle%20Instant%20Client download +from +http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. + +The following RPM's and upload them to the server: +- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm +- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm + +``` +alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm +alien -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm +``` + +* Install Cuda - http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu + +``` +wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb +sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb +sudo apt-get update +sudo apt-get install cuda +export CUDA_HOME=/usr/local/cuda-7.5 +export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 + +PATH=${CUDA_HOME}/bin:${PATH} +export PATH +echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracle-client-12.1.conf +ldconfig +``` + +* Build sysbench +Use the following `configure` option to build with Oracle support: +``` +./configure --with-oracle="/usr/lib/oracle/12.1/client64" +``` + +Run the following commands to allow sysbench use the full number of cores: +``` +sudo sh -c 'for x in /sys/class/net/eth0/queues/rx-*; do echo ffffffff> $x/rps_cpus; done' +sudo sh -c "echo 32768 > /proc/sys/net/core/rps_sock_flow_entries" +sudo sh -c "echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt" +``` diff --git a/README.md b/README.md index 900fbec..914d761 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ To compile SysBench without MySQL support, use `--without-mysql`. In this case all database-related tests will not work, but other tests will be functional. +See [README-WIN.txt](README-WIN.txt) for instructions on Windows builds. + +See [README-Oracle.md](README-Oracle.md) for instructions on building +with Oracle client libraries. + + Usage ===== @@ -85,48 +91,3 @@ The table below lists the supported common options, their descriptions and defau | `--percentile` | SysBench measures execution times for all processed requests to display statistical information like minimal, average and maximum execution time. For most benchmarks it is also useful to know a request execution time value matching some percentile (e.g. 95% percentile means we should drop 5% of the most long requests and choose the maximal value from the remaining ones). This option allows to specify a percentile rank of query execution times to count | 95 | Note that numerical values for all *size* options (like `--thread-stack-size` in this table) may be specified by appending the corresponding multiplicative suffix (K for kilobytes, M for megabytes, G for gigabytes and T for terabytes). - - --------------------------------------------------------------- -Oracle Build steps --------------------------------------------------------------- - -Using Ubuntu 14.04 - intructions dated for 21/09/2016 (Was built on AWS in an r3.xlarge These actions were done against 0.5 checkout) - -* Setup Oracleclient - https://help.ubuntu.com/community/Oracle%20Instant%20Client -download from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. the following RPM's and upload them to the server. -oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm -oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm - -alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm -alien -i oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm - -* Install Cuda - http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu -wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb -sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb -sudo apt-get update -sudo apt-get install cuda -export CUDA_HOME=/usr/local/cuda-7.5 -export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 - -PATH=${CUDA_HOME}/bin:${PATH} -export PATH -echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracle-client-12.1.conf -ldconfig - -* Login and install sys bench - apt-get update - apt-get -y install automake libtool git libmysqlclient15-dev make libaio1 libaio-dev - git clone https://github.com/akopytov/sysbench.git - cd sysbench - vi configure.ac -> Replace line - ORA_CFLAGS="-I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" -> With line - ORA_CFLAGS="-I${ac_cv_use_oracle}/include -I${ac_cv_use_oracle}/rdbms/demo -I${ac_cv_use_oracle}/rdbms/public" -./autogen.sh -./configure --with-oracle="/usr/lib/oracle/12.1/client64" -make -Run the following commands to allow sysbench use the full number of cores. -sudo sh -c 'for x in /sys/class/net/eth0/queues/rx-*; do echo ffffffff> $x/rps_cpus; done' -sudo sh -c "echo 32768 > /proc/sys/net/core/rps_sock_flow_entries" -sudo sh -c "echo 4096 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt" - From e6fab3260481d03301f135dbfde57fa5db000aaf Mon Sep 17 00:00:00 2001 From: Martin Pluskal Date: Thu, 29 Sep 2016 10:39:47 +0200 Subject: [PATCH 96/96] Do not overflow buffer in strncat --- sysbench/scripting/script_lua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysbench/scripting/script_lua.c b/sysbench/scripting/script_lua.c index 42f5106..7b71064 100644 --- a/sysbench/scripting/script_lua.c +++ b/sysbench/scripting/script_lua.c @@ -498,11 +498,11 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id) /* first location failed - look in DATA_PATH */ char p[PATH_MAX + 1]; strncpy(p, DATA_PATH LUA_DIRSEP, sizeof(p)); - strncat(p, scriptname, sizeof(p)); + strncat(p, scriptname, sizeof(p)-strlen(p)-1); if (!strrchr(scriptname, '.')) { /* add .lua extension if there isn't one */ - strncat(p, ".lua", sizeof(p)); + strncat(p, ".lua", sizeof(p)-strlen(p)-1); } if (luaL_loadfile(state, p))