Merge branch 'luajit' into concurrency_kit

This commit is contained in:
Alexey Kopytov
2016-12-23 17:18:20 +08:00
39 changed files with 960 additions and 778 deletions

6
.gitignore vendored
View File

@ -68,3 +68,9 @@ GTAGS
/third_party/concurrency_kit/lib/
/third_party/concurrency_kit/share/
/third_party/concurrency_kit/tmp/
third_party/luajit/bin/
third_party/luajit/inc/
third_party/luajit/lib/
third_party/luajit/share/
third_party/luajit/tmp/
sysbench/lua/internal/sysbench.lua.h

View File

@ -31,6 +31,11 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
#LT_LIB_DLLOAD
AC_PROG_LIBTOOL
AC_CHECK_PROG(sb_have_xxd, xxd, yes, no)
if test x"$sb_have_xxd" = xno; then
AC_MSG_ERROR("xxd is required to build sysbench (usually comes with the vim package)")
fi
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
AC_MSG_CHECKING("C Compiler version")
@ -517,7 +522,8 @@ sysbench/tests/memory/Makefile
sysbench/tests/threads/Makefile
sysbench/tests/mutex/Makefile
sysbench/tests/db/Makefile
sysbench/scripting/Makefile
sysbench/lua/Makefile
sysbench/lua/internal/Makefile
tests/Makefile
tests/include/config.sh
])

View File

@ -106,11 +106,6 @@ target_link_libraries (sysbench sbfileio)
add_subdirectory(tests/mutex)
target_link_libraries (sysbench sbmutex)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
add_subdirectory(scripting)
target_link_libraries(sysbench sbscript lua)
add_subdirectory(tests/threads)
target_link_libraries (sysbench sbthreads)

View File

@ -1,5 +1,5 @@
# Copyright (C) 2004 MySQL AB
# Copyright (C) 2004-2014 Alexey Kopytov <akopytov@gmail.com>
# Copyright (C) 2004-2016 Alexey Kopytov <akopytov@gmail.com>
#
# 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
@ -15,7 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
SUBDIRS = drivers tests scripting .
SUBDIRS = drivers tests lua .
AM_CPPFLAGS += -DDATA_PATH=\"$(pkgdatadir)\"
bin_PROGRAMS = sysbench
@ -45,11 +47,12 @@ 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_histogram.c sb_histogram.h sb_rnd.c sb_rnd.h \
sb_thread.c sb_thread.h sb_barrier.c sb_barrier.h sb_global.h
sb_thread.c sb_thread.h sb_barrier.c sb_barrier.h sb_global.h sb_lua.c \
sb_lua.h lua/internal/sysbench.lua.h
sysbench_LDADD = tests/fileio/libsbfileio.a tests/threads/libsbthreads.a \
tests/memory/libsbmemory.a tests/cpu/libsbcpu.a \
tests/mutex/libsbmutex.a scripting/libsbscript.a \
tests/mutex/libsbmutex.a \
$(mysql_ldadd) $(drizzle_ldadd) $(attachsql_ldadd) $(pgsql_ldadd) \
$(ora_ldadd) $(LUAJIT_LIBS) $(CK_LIBS)

View File

@ -1,22 +1,17 @@
# Copyright (C) 2006 MySQL AB
# Copyright (C) 2006-2016 Alexey Kopytov <akopytov@gmail.com>
# Copyright (C) 2016 Alexey Kopytov <akopytov@gmail.com>
#
# 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
AM_CPPFLAGS += -DDATA_PATH=\"$(pkgdatadir)\"
noinst_LIBRARIES = libsbscript.a
libsbscript_a_SOURCES = sb_script.c sb_script.h script_lua.c script_lua.h
SUBDIRS = internal

View File

@ -1,21 +1,25 @@
# Copyright (C) 2008 MySQL AB
# Copyright (C) 2008 Alexey Kopytov <akopytov@gmail.com>
# Copyright (C) 2016 Alexey Kopytov <akopytov@gmail.com>
#
# 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
include_directories(lua/src ..)
add_subdirectory(lua/src)
add_library(sbscript sb_script.c sb_script.h script_lua.c script_lua.h)
BUILT_SOURCES = sysbench.lua.h
CLEARFILES = sysbench.lua.h
EXTRA_DIST = sysbench.lua
SUFFIXES = .lua .lua.h
.lua.lua.h:
xxd -i $< $@

View File

@ -0,0 +1,61 @@
-- Copyright (C) 2016 Alexey Kopytov <akopytov@gmail.com>
-- 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
-- ----------------------------------------------------------------------
-- Compatibility aliases. These may be removed in later versions
-- ----------------------------------------------------------------------
thread_id = sysbench.tid
sb_rand = sysbench.rand
sb_rand_uniq = sb_rand_uniq
sb_rnd = sysbench.rnd
sb_rand_str = sysbench.rand_str
sb_rand_uniform = sysbench.rand_uniform
sb_rand_gaussian = sysbench.rand_gaussian
sb_rand_special = sysbench.rand_special
db_connect = sysbench.db.connect
db_disconnect = sysbench.db.disconnect
db_query = sysbench.db.query
db_bulk_insert_init = sysbench.db.bulk_insert_init
db_bulk_insert_next = sysbench.db.bulk_insert_next
db_bulk_insert_done = sysbench.db.bulk_insert_done
db_prepare = sysbench.db.prepare
db_bind_param = sysbench.db.bind_param
db_bind_result = sysbench.db.bind_result
db_execute = sysbench.db.execute
db_store_results = sysbench.db.store_results
db_free_results = sysbench.db.free_results
DB_ERROR_NONE = sysbench.db.DB_ERROR_NONE
DB_ERROR_RESTART_TRANSACTION = sysbench.db.DB_ERROR_RESTART_TRANSACTION
DB_ERROR_FAILED = sysbench.db.DB_ERROR_FAILED
-- ----------------------------------------------------------------------
-- Main event loop. This is a Lua version of sysbench.c:thread_run()
-- ----------------------------------------------------------------------
function thread_run()
while sysbench.more_events() do
sysbench.event_start()
event()
sysbench.event_stop()
end
end

View File

@ -56,6 +56,12 @@
/* per-thread timers for response time stats */
sb_timer_t *timers;
/*
Mutex protecting timers.
TODO: replace with an rwlock (and implement pthread rwlocks for Windows).
*/
pthread_mutex_t timers_mutex;
/* Array of message handlers (one chain per message type) */
static sb_list_t handlers[LOG_MSG_TYPE_MAX];
@ -70,11 +76,6 @@ static char text_buf[TEXT_BUFFER_SIZE];
/* Temporary copy of timers */
static sb_timer_t *timers_copy;
/*
Mutex protecting timers.
TODO: replace with an rwlock (and implement pthread rwlocks for Windows).
*/
static pthread_mutex_t timers_mutex;
static int text_handler_init(void);
static int text_handler_process(log_msg_t *msg);
@ -139,7 +140,7 @@ int log_register(void)
log_add_handler(LOG_MSG_TYPE_TEXT, &text_handler);
log_add_handler(LOG_MSG_TYPE_OPER, &oper_handler);
return 0;
}

View File

@ -23,6 +23,10 @@
# include "config.h"
#endif
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#endif
#include "sb_global.h"
#include "sb_options.h"
#include "sb_timer.h"
@ -32,24 +36,6 @@
#define LOG_MSG_TEXT_ALLOW_DUPLICATES 1
/* Macros to log per-request execution statistics */
#define LOG_EVENT_START(msg, thread_id) \
do \
{ \
((log_msg_oper_t *)(msg).data)->thread_id = thread_id; \
((log_msg_oper_t *)(msg).data)->action = LOG_MSG_OPER_START; \
log_msg(&(msg)); \
} while (0);
#define LOG_EVENT_STOP(msg, thread_id) \
do \
{ \
((log_msg_oper_t *)(msg).data)->thread_id = thread_id; \
((log_msg_oper_t *)(msg).data)->action = LOG_MSG_OPER_STOP; \
log_msg(&(msg)); \
} while (0);
/* Message types definition */
typedef enum {
@ -123,6 +109,7 @@ typedef struct {
/* per-thread timers for response time stats */
extern sb_timer_t *timers;
extern pthread_mutex_t timers_mutex;
/* Register logger */

View File

@ -20,25 +20,26 @@
# include "config.h"
#endif
#include <stdlib.h>
#include "script_lua.h"
#include "sb_lua.h"
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "sb_script.h"
#include "db_driver.h"
#include "sb_rnd.h"
#include "sb_thread.h"
#include "ck_pr.h"
/* Auto-generated headers */
#include "lua/internal/sysbench.lua.h"
#define EVENT_FUNC "event"
#define PREPARE_FUNC "prepare"
#define CLEANUP_FUNC "cleanup"
#define HELP_FUNC "help"
#define THREAD_INIT_FUNC "thread_init"
#define THREAD_DONE_FUNC "thread_done"
#define HELP_FUNC "help"
#define THREAD_RUN_FUNC "thread_run"
/* Macros to call Lua functions */
#define CALL_ERROR(L, name) \
@ -57,7 +58,7 @@
/* Interpreter context */
typedef struct {
int thread_id; /* SysBench thread ID */
int thread_id; /* sysbench thread id */
db_conn_t *con; /* Database connection */
} sb_lua_ctxt_t;
@ -91,27 +92,24 @@ static lua_State **states;
/* Event counter */
static unsigned int nevents;
static sb_test_t sbtest;
/* Lua test operations */
static int sb_lua_init(void);
static int sb_lua_done(void);
static sb_request_t sb_lua_get_request(int thread_id);
static int sb_lua_op_execute_request(sb_request_t *, int);
static sb_event_t sb_lua_next_event(int);
static int sb_lua_op_execute_event(sb_event_t *, int);
static int sb_lua_op_thread_init(int);
static int sb_lua_op_thread_run(int);
static int sb_lua_op_thread_done(int);
static void sb_lua_op_print_stats(sb_stat_t type);
static sb_operations_t lua_ops = {
&sb_lua_init,
NULL,
NULL,
NULL,
&sb_lua_get_request,
&sb_lua_op_execute_request,
NULL,
NULL,
NULL,
&sb_lua_done
.init = sb_lua_init,
.next_event = &sb_lua_next_event,
.execute_event = sb_lua_op_execute_event,
.done = sb_lua_done
};
/* Main (global) interpreter state */
@ -158,6 +156,9 @@ static int sb_lua_rand_gaussian(lua_State *);
static int sb_lua_rand_special(lua_State *);
static int sb_lua_rnd(lua_State *);
static int sb_lua_rand_str(lua_State *);
static int sb_lua_more_events(lua_State *);
static int sb_lua_event_start(lua_State *);
static int sb_lua_event_stop(lua_State *);
/* Get a per-state interpreter context */
static sb_lua_ctxt_t *sb_lua_get_context(lua_State *);
@ -169,7 +170,7 @@ unsigned int sb_lua_table_size(lua_State *, int);
/* Load a specified Lua script */
int script_load_lua(const char *testname, sb_test_t *test)
sb_test_t *sb_load_lua(const char *testname)
{
unsigned int i;
@ -185,30 +186,34 @@ int script_load_lua(const char *testname, sb_test_t *test)
/* Test commands */
lua_getglobal(gstate, PREPARE_FUNC);
if (!lua_isnil(gstate, -1))
test->cmds.prepare = &sb_lua_cmd_prepare;
sbtest.cmds.prepare = &sb_lua_cmd_prepare;
lua_pop(gstate, 1);
lua_getglobal(gstate, CLEANUP_FUNC);
if (!lua_isnil(gstate, -1))
test->cmds.cleanup = &sb_lua_cmd_cleanup;
sbtest.cmds.cleanup = &sb_lua_cmd_cleanup;
lua_getglobal(gstate, HELP_FUNC);
if (!lua_isnil(gstate, -1) && lua_isfunction(gstate, -1))
test->cmds.help = &sb_lua_cmd_help;
sbtest.cmds.help = &sb_lua_cmd_help;
/* Test operations */
test->ops = lua_ops;
sbtest.ops = lua_ops;
lua_getglobal(gstate, THREAD_INIT_FUNC);
if (!lua_isnil(gstate, -1))
test->ops.thread_init = &sb_lua_op_thread_init;
sbtest.ops.thread_init = &sb_lua_op_thread_init;
lua_getglobal(gstate, THREAD_DONE_FUNC);
if (!lua_isnil(gstate, -1))
test->ops.thread_done = &sb_lua_op_thread_done;
sbtest.ops.thread_done = &sb_lua_op_thread_done;
lua_getglobal(gstate, THREAD_RUN_FUNC);
if (!lua_isnil(gstate, -1))
sbtest.ops.thread_run = &sb_lua_op_thread_run;
test->ops.print_stats = &sb_lua_op_print_stats;
sbtest.ops.print_stats = &sb_lua_op_print_stats;
/* Initialize per-thread interpreters */
states = (lua_State **)calloc(sb_globals.num_threads, sizeof(lua_State *));
@ -221,7 +226,7 @@ int script_load_lua(const char *testname, sb_test_t *test)
goto error;
}
return 0;
return &sbtest;
error:
@ -233,7 +238,7 @@ int script_load_lua(const char *testname, sb_test_t *test)
free(states);
}
return 1;
return NULL;
}
/* Initialize Lua script */
@ -243,9 +248,9 @@ int sb_lua_init(void)
return 0;
}
sb_request_t sb_lua_get_request(int thread_id)
sb_event_t sb_lua_next_event(int thread_id)
{
sb_request_t req;
sb_event_t req;
(void) thread_id; /* unused */
@ -261,30 +266,21 @@ sb_request_t sb_lua_get_request(int thread_id)
return req;
}
int sb_lua_op_execute_request(sb_request_t *sb_req, int thread_id)
int sb_lua_op_execute_event(sb_event_t *sb_req, int thread_id)
{
log_msg_t msg;
log_msg_oper_t op_msg;
unsigned int restart;
unsigned int restart;
lua_State *L = states[thread_id];
(void)sb_req; /* unused */
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
LOG_EVENT_START(msg, thread_id);
(void)thread_id; /* unused */
do
{
restart = 0;
lua_getglobal(L, EVENT_FUNC);
lua_pushnumber(L, thread_id);
if (lua_pcall(L, 1, 1, 0))
if (lua_pcall(L, 0, 1, 0))
{
if (lua_gettop(L) && lua_isnumber(L, -1) &&
lua_tonumber(L, -1) == SB_DB_ERROR_RESTART_TRANSACTION)
@ -303,41 +299,55 @@ int sb_lua_op_execute_request(sb_request_t *sb_req, int thread_id)
}
lua_pop(L, 1);
} while (restart);
LOG_EVENT_STOP(msg, thread_id);
return 0;
}
int sb_lua_op_thread_init(int thread_id)
{
sb_lua_ctxt_t *ctxt;
sb_lua_ctxt_t *ctxt;
lua_State * const L = states[thread_id];
ctxt = sb_lua_get_context(states[thread_id]);
ctxt = sb_lua_get_context(L);
if (ctxt->con == NULL)
sb_lua_db_connect(states[thread_id]);
sb_lua_db_connect(L);
lua_getglobal(states[thread_id], THREAD_INIT_FUNC);
lua_pushnumber(states[thread_id], (double)thread_id);
if (lua_pcall(states[thread_id], 1, 1, 0))
lua_getglobal(L, THREAD_INIT_FUNC);
if (lua_pcall(L, 0, 1, 0))
{
CALL_ERROR(states[thread_id], THREAD_INIT_FUNC);
CALL_ERROR(L, THREAD_INIT_FUNC);
return 1;
}
return 0;
}
int sb_lua_op_thread_run(int thread_id)
{
lua_State * const L = states[thread_id];
lua_getglobal(L, THREAD_RUN_FUNC);
if (lua_pcall(L, 0, 1, 0))
{
CALL_ERROR(L, THREAD_RUN_FUNC);
return 1;
}
return 0;
}
int sb_lua_op_thread_done(int thread_id)
{
lua_getglobal(states[thread_id], THREAD_DONE_FUNC);
lua_pushnumber(states[thread_id], (double)thread_id);
lua_State * const L = states[thread_id];
if (lua_pcall(states[thread_id], 1, 1, 0))
lua_getglobal(L, THREAD_DONE_FUNC);
if (lua_pcall(L, 0, 1, 0))
{
CALL_ERROR(states[thread_id], THREAD_DONE_FUNC);
CALL_ERROR(L, THREAD_DONE_FUNC);
return 1;
}
@ -367,15 +377,15 @@ int sb_lua_done(void)
lua_State *sb_lua_new_state(const char *scriptname, int thread_id)
{
lua_State *state;
lua_State *L;
sb_lua_ctxt_t *ctxt;
sb_list_item_t *pos;
option_t *opt;
char *tmp;
state = luaL_newstate();
L = luaL_newstate();
luaL_openlibs(state);
luaL_openlibs(L);
/* Export all global options */
pos = sb_options_enum_start();
@ -384,112 +394,113 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id)
switch (opt->type)
{
case SB_ARG_TYPE_FLAG:
lua_pushboolean(state, sb_opt_to_flag(opt));
lua_pushboolean(L, sb_opt_to_flag(opt));
break;
case SB_ARG_TYPE_INT:
lua_pushnumber(state, sb_opt_to_int(opt));
lua_pushnumber(L, sb_opt_to_int(opt));
break;
case SB_ARG_TYPE_FLOAT:
lua_pushnumber(state, sb_opt_to_float(opt));
lua_pushnumber(L, sb_opt_to_float(opt));
break;
case SB_ARG_TYPE_SIZE:
lua_pushnumber(state, sb_opt_to_size(opt));
lua_pushnumber(L, sb_opt_to_size(opt));
break;
case SB_ARG_TYPE_STRING:
tmp = sb_opt_to_string(opt);
lua_pushstring(state, tmp ? tmp : "");
lua_pushstring(L, tmp ? tmp : "");
break;
case SB_ARG_TYPE_LIST:
/*FIXME: should be exported as tables */
lua_pushnil(state);
lua_pushnil(L);
break;
case SB_ARG_TYPE_FILE:
/* FIXME: no need to export anything */
lua_pushnil(state);
lua_pushnil(L);
break;
default:
log_text(LOG_WARNING, "Global option '%s' will not be exported, because"
" the type is unknown", opt->name);
lua_pushnil(state);
lua_pushnil(L);
break;
}
lua_setglobal(state, opt->name);
lua_setglobal(L, opt->name);
}
/* Export functions */
lua_pushcfunction(state, sb_lua_rand);
lua_setglobal(state, "sb_rand");
lua_pushcfunction(state, sb_lua_rand_uniq);
lua_setglobal(state, "sb_rand_uniq");
#define SB_LUA_VAR(luaname, cname) \
lua_pushstring(L, luaname); \
lua_pushnumber(L, cname); \
lua_settable(L, -3)
#define SB_LUA_FUNC(luaname, cname) \
lua_pushstring(L, luaname); \
lua_pushcfunction(L, cname); \
lua_settable(L, -3)
lua_pushcfunction(state, sb_lua_rnd);
lua_setglobal(state, "sb_rnd");
/* Export variables into per-L 'sysbench' table */
lua_pushcfunction(state, sb_lua_rand_str);
lua_setglobal(state, "sb_rand_str");
lua_newtable(L);
lua_pushcfunction(state, sb_lua_rand_uniform);
lua_setglobal(state, "sb_rand_uniform");
/* sysbench.tid */
SB_LUA_VAR("tid", thread_id);
lua_pushcfunction(state, sb_lua_rand_gaussian);
lua_setglobal(state, "sb_rand_gaussian");
/* Export functions into per-L 'sysbench' table */
lua_pushcfunction(state, sb_lua_rand_special);
lua_setglobal(state, "sb_rand_special");
SB_LUA_FUNC("more_events", sb_lua_more_events);
SB_LUA_FUNC("event_start", sb_lua_event_start);
SB_LUA_FUNC("event_stop", sb_lua_event_stop);
lua_pushcfunction(state, sb_lua_db_connect);
lua_setglobal(state, "db_connect");
lua_pushcfunction(state, sb_lua_db_disconnect);
lua_setglobal(state, "db_disconnect");
SB_LUA_FUNC("rand", sb_lua_rand);
SB_LUA_FUNC("rand_uniq", sb_lua_rand_uniq);
SB_LUA_FUNC("rnd", sb_lua_rnd);
SB_LUA_FUNC("rand_str", sb_lua_rand_str);
SB_LUA_FUNC("rand_uniform", sb_lua_rand_uniform);
SB_LUA_FUNC("rand_gaussian", sb_lua_rand_gaussian);
SB_LUA_FUNC("rand_special", sb_lua_rand_special);
lua_pushcfunction(state, sb_lua_db_query);
lua_setglobal(state, "db_query");
lua_pushcfunction(state, sb_lua_db_bulk_insert_init);
lua_setglobal(state, "db_bulk_insert_init");
lua_pushcfunction(state, sb_lua_db_bulk_insert_next);
lua_setglobal(state, "db_bulk_insert_next");
lua_pushcfunction(state, sb_lua_db_bulk_insert_done);
lua_setglobal(state, "db_bulk_insert_done");
/* Export functions into per-L 'sysbench.db' table */
lua_pushcfunction(state, sb_lua_db_prepare);
lua_setglobal(state, "db_prepare");
lua_pushstring(L, "db");
lua_newtable(L);
lua_pushcfunction(state, sb_lua_db_bind_param);
lua_setglobal(state, "db_bind_param");
SB_LUA_FUNC("connect", sb_lua_db_connect);
SB_LUA_FUNC("disconnect", sb_lua_db_disconnect);
SB_LUA_FUNC("query", sb_lua_db_query);
SB_LUA_FUNC("bulk_insert_init", sb_lua_db_bulk_insert_init);
SB_LUA_FUNC("bulk_insert_next", sb_lua_db_bulk_insert_next);
SB_LUA_FUNC("bulk_insert_done", sb_lua_db_bulk_insert_done);
SB_LUA_FUNC("prepare", sb_lua_db_prepare);
SB_LUA_FUNC("bind_param", sb_lua_db_bind_param);
SB_LUA_FUNC("bind_result", sb_lua_db_bind_result);
SB_LUA_FUNC("execute", sb_lua_db_execute);
SB_LUA_FUNC("close", sb_lua_db_close);
SB_LUA_FUNC("store_results", sb_lua_db_store_results);
SB_LUA_FUNC("free_results", sb_lua_db_free_results);
lua_pushcfunction(state, sb_lua_db_bind_result);
lua_setglobal(state, "db_bind_result");
SB_LUA_VAR("DB_ERROR_NONE", SB_DB_ERROR_NONE);
SB_LUA_VAR("DB_ERROR_RESTART_TRANSACTION", SB_DB_ERROR_RESTART_TRANSACTION);
SB_LUA_VAR("DB_ERROR_FAILED", SB_DB_ERROR_FAILED);
lua_pushcfunction(state, sb_lua_db_execute);
lua_setglobal(state, "db_execute");
lua_pushcfunction(state, sb_lua_db_close);
lua_setglobal(state, "db_close");
#undef SB_LUA_VAR
#undef SB_LUA_FUNC
lua_pushcfunction(state, sb_lua_db_store_results);
lua_setglobal(state, "db_store_results");
lua_settable(L, -3); /* sysbench.db */
lua_pushcfunction(state, sb_lua_db_free_results);
lua_setglobal(state, "db_free_results");
lua_pushnumber(state, SB_DB_ERROR_NONE);
lua_setglobal(state, "DB_ERROR_NONE");
lua_pushnumber(state, SB_DB_ERROR_RESTART_TRANSACTION);
lua_setglobal(state, "DB_ERROR_RESTART_TRANSACTION");
lua_pushnumber(state, SB_DB_ERROR_FAILED);
lua_setglobal(state, "DB_ERROR_FAILED");
lua_setglobal(L, "sysbench");
luaL_newmetatable(state, "sysbench.stmt");
luaL_newmetatable(L, "sysbench.stmt");
luaL_newmetatable(L, "sysbench.rs");
luaL_newmetatable(state, "sysbench.rs");
/* Pre-load internal modules */
if (luaL_loadbuffer(L, (const char *) sysbench_lua, sysbench_lua_len,
"sysbench.lua"))
{
log_text(LOG_FATAL, "failed to load internal module sysbench.lua: %s",
lua_tostring(L, -1));
}
lua_pushstring(L, "sysbench");
lua_call(L, 1, 0);
if (luaL_loadfile(state, scriptname))
if (luaL_loadfile(L, scriptname))
{
#ifdef DATA_PATH
/* first location failed - look in DATA_PATH */
@ -502,9 +513,9 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id)
strncat(p, ".lua", sizeof(p)-strlen(p)-1);
}
if (luaL_loadfile(state, p))
if (luaL_loadfile(L, p))
{
lua_error(state);
lua_error(L);
return NULL;
}
#else
@ -512,20 +523,22 @@ lua_State *sb_lua_new_state(const char *scriptname, int thread_id)
#endif
}
if (lua_pcall(state, 0, 0, 0))
if (lua_pcall(L, 0, 0, 0))
{
lua_error(state);
lua_error(L);
return NULL;
}
/* Create new state context */
/* Create new L context */
ctxt = (sb_lua_ctxt_t *)calloc(1, sizeof(sb_lua_ctxt_t));
if (ctxt == NULL)
return NULL;
ctxt->thread_id = thread_id;
sb_lua_set_context(state, ctxt);
sb_lua_set_context(L, ctxt);
return state;
return L;
}
/* Close interpreter state */
@ -612,8 +625,7 @@ int sb_lua_db_connect(lua_State *L)
ctxt->con = db_connect(db_driver);
if (ctxt->con == NULL)
luaL_error(L, "Failed to connect to the database");
db_set_thread(ctxt->con, ctxt->thread_id);
return 0;
}
@ -1172,3 +1184,44 @@ unsigned int sb_lua_table_size(lua_State *L, int index)
return i;
}
/* Check if there are more events to execute */
int sb_lua_more_events(lua_State *L)
{
sb_event_t e;
sb_lua_ctxt_t *ctxt;
ctxt = sb_lua_get_context(L);
e = sb_next_event(&sbtest, ctxt->thread_id);
lua_pushboolean(L, e.type == SB_REQ_TYPE_SCRIPT);
return 1;
}
/* Exported wrapper for sb_event_start() */
int sb_lua_event_start(lua_State *L)
{
sb_lua_ctxt_t *ctxt;
ctxt = sb_lua_get_context(L);
sb_event_start(ctxt->thread_id);
return 0;
}
/* Exported wrapper for sb_event_stop() */
int sb_lua_event_stop(lua_State *L)
{
sb_lua_ctxt_t *ctxt;
ctxt = sb_lua_get_context(L);
sb_event_stop(ctxt->thread_id);
return 0;
}

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2006 MySQL AB
Copyright (C) 2006 Alexey Kopytov <akopytov@gmail.com>
Copyright (C) 2006-2016 Alexey Kopytov <akopytov@gmail.com>
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
@ -24,4 +24,4 @@
/* Load a specified Lua script */
int script_load_lua(const char *testname, sb_test_t *test);
sb_test_t *sb_load_lua(const char *testname);

View File

@ -1,39 +0,0 @@
/* Copyright (C) 2006 MySQL AB
Copyright (C) 2006 Alexey Kopytov <akopytov@gmail.com>
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "sb_script.h"
#include "script_lua.h"
static sb_test_t test;
/* Initialize interpreter with a given script name */
sb_test_t *script_load(const char *testname)
{
test.sname = strdup(testname);
if (!script_load_lua(testname, &test))
return &test;
return NULL;
}

View File

@ -1,32 +0,0 @@
/* Copyright (C) 2006 MySQL AB
Copyright (C) 2006 Alexey Kopytov <akopytov@gmail.com>
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
*/
#ifndef SB_SCRIPT_H
#define SB_SCRIPT_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "sysbench.h"
/* Initialize interpreter with a given script name */
sb_test_t *script_load(const char *testname);
#endif /* SB_SCRIPT_H */

View File

@ -68,7 +68,7 @@
#include "sysbench.h"
#include "sb_options.h"
#include "scripting/sb_script.h"
#include "sb_lua.h"
#include "db_driver.h"
#include "sb_rnd.h"
#include "sb_thread.h"
@ -227,44 +227,6 @@ static void sigalrm_forced_shutdown_handler(int sig)
}
#endif
/* Main request provider function */
static sb_request_t get_request(sb_test_t *test, int thread_id)
{
sb_request_t r;
(void)thread_id; /* unused */
if (test->ops.get_request != NULL)
r = test->ops.get_request(thread_id);
else
{
log_text(LOG_ALERT, "Unsupported mode! Creating NULL request.");
r.type = SB_REQ_TYPE_NULL;
}
return r;
}
/* Main request execution function */
static int execute_request(sb_test_t *test, sb_request_t *r,int thread_id)
{
unsigned int rc;
if (test->ops.execute_request != NULL)
rc = test->ops.execute_request(r, thread_id);
else
{
log_text(LOG_FATAL, "Unknown request. Aborting");
rc = 1;
}
return rc;
}
static int register_tests(void)
{
@ -474,19 +436,139 @@ void print_run_mode(sb_test_t *test)
test->ops.print_mode();
}
/*
Get the next event, or return an 'empty' event with type = SB_REQ_TYPE_NULL,
if there are no more events to execute.
*/
/* Main worker test thread */
sb_event_t sb_next_event(sb_test_t *test, int thread_id)
{
sb_event_t event;
sb_list_item_t *pos;
event_queue_elem_t *elem;
unsigned long long queue_start_time = 0;
event.type = SB_REQ_TYPE_NULL;
if (sb_globals.error)
return event;
/* Check if we have a time limit */
if (sb_globals.max_time != 0 &&
sb_timer_value(&sb_globals.exec_timer) >= SEC2NS(sb_globals.max_time))
{
log_text(LOG_INFO, "Time limit exceeded, exiting...");
return event;
}
/* If we are in tx_rate mode, we take events from queue */
if (sb_globals.tx_rate > 0)
{
if (queue_is_full)
{
log_text(LOG_FATAL, "Event queue is full.");
return event;
}
pthread_mutex_lock(&event_queue_mutex);
while(!sb_globals.event_queue_length)
pthread_cond_wait(&event_queue_cv, &event_queue_mutex);
SB_LIST_ONCE(pos, &event_queue)
{
elem = SB_LIST_ENTRY(pos, event_queue_elem_t, listitem);
queue_start_time = elem->event_time;;
SB_LIST_DELETE(pos);
sb_globals.event_queue_length--;
}
sb_globals.concurrency++;
pthread_mutex_unlock(&event_queue_mutex);
timers[thread_id].queue_time = sb_timer_value(&sb_globals.exec_timer) -
queue_start_time;
}
event = test->ops.next_event(thread_id);
return event;
}
void sb_event_start(int thread_id)
{
sb_timer_t *timer = &timers[thread_id];
if (sb_globals.n_checkpoints > 0)
pthread_mutex_lock(&timers_mutex);
sb_timer_start(timer);
if (sb_globals.n_checkpoints > 0)
pthread_mutex_unlock(&timers_mutex);
}
void sb_event_stop(int thread_id)
{
sb_timer_t *timer = &timers[thread_id];
long long value;
if (sb_globals.n_checkpoints > 0)
pthread_mutex_lock(&timers_mutex);
sb_timer_stop(timer);
value = sb_timer_value(timer);
if (sb_globals.n_checkpoints > 0)
pthread_mutex_unlock(&timers_mutex);
if (sb_globals.percentile > 0)
sb_histogram_update(&global_histogram, NS2MS(value));
}
/* Main event loop -- the default thread_run implementation */
static void thread_run(sb_test_t *test, int thread_id)
{
sb_event_t event;
int rc;
while ((event = sb_next_event(test, thread_id)).type != SB_REQ_TYPE_NULL)
{
sb_event_start(thread_id);
rc = test->ops.execute_event(&event, thread_id);
sb_event_stop(thread_id);
if (sb_globals.tx_rate > 0)
{
pthread_mutex_lock(&event_queue_mutex);
sb_globals.concurrency--;
pthread_mutex_unlock(&event_queue_mutex);
}
if (rc != 0)
break;
}
}
/* Main worker thread */
static void *worker_thread(void *arg)
{
sb_request_t request;
sb_thread_ctxt_t *ctxt;
sb_test_t *test;
unsigned int thread_id;
unsigned long long queue_start_time = 0;
sb_list_item_t *pos;
event_queue_elem_t *event;
unsigned int thread_id;
ctxt = (sb_thread_ctxt_t *)arg;
test = ctxt->test;
@ -512,65 +594,16 @@ static void *worker_thread(void *arg)
if (sb_barrier_wait(&thread_start_barrier) < 0)
return NULL;
do
if (test->ops.thread_run != NULL)
{
/* If we are in tx_rate mode, we take events from queue */
if (sb_globals.tx_rate > 0)
{
if (queue_is_full)
{
log_text(LOG_FATAL, "Event queue is full.");
break;
}
pthread_mutex_lock(&event_queue_mutex);
while(!sb_globals.event_queue_length)
pthread_cond_wait(&event_queue_cv, &event_queue_mutex);
SB_LIST_ONCE(pos, &event_queue)
{
event = SB_LIST_ENTRY(pos, event_queue_elem_t, listitem);
queue_start_time = event->event_time;;
SB_LIST_DELETE(pos);
sb_globals.event_queue_length--;
}
sb_globals.concurrency++;
pthread_mutex_unlock(&event_queue_mutex);
timers[thread_id].queue_time = sb_timer_value(&sb_globals.exec_timer) -
queue_start_time;
}
request = get_request(test, thread_id);
/* check if we shall execute it */
if (request.type != SB_REQ_TYPE_NULL)
{
if (execute_request(test, &request, thread_id))
break; /* break if error returned (terminates only one thread) */
}
if (sb_globals.tx_rate > 0)
{
pthread_mutex_lock(&event_queue_mutex);
sb_globals.concurrency--;
pthread_mutex_unlock(&event_queue_mutex);
}
/* Check if we have a time limit */
if (sb_globals.max_time != 0 &&
sb_timer_value(&sb_globals.exec_timer) >= SEC2NS(sb_globals.max_time))
{
log_text(LOG_INFO, "Time limit exceeded, exiting...");
break;
}
} while ((request.type != SB_REQ_TYPE_NULL) && (!sb_globals.error) );
/* Use benchmark-provided thread_run implementation */
test->ops.thread_run(thread_id);
}
else
{
/* Use default thread_run implementation */
thread_run(test, thread_id);
}
if (test->ops.thread_done != NULL)
test->ops.thread_done(thread_id);
@ -1212,7 +1245,7 @@ int main(int argc, char *argv[])
/* Check if the testname is a script filename */
if (test == NULL)
test = script_load(testname);
test = sb_load_lua(testname);
}
/* 'help' command */

View File

@ -23,6 +23,7 @@
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <stdbool.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@ -73,7 +74,7 @@ typedef enum
SB_REQ_TYPE_THREADS,
SB_REQ_TYPE_MUTEX,
SB_REQ_TYPE_SCRIPT
} sb_request_type_t;
} sb_event_type_t;
/* Request structure definition */
@ -92,7 +93,7 @@ typedef struct
sb_threads_request_t threads_request;
sb_mutex_request_t mutex_request;
} u;
} sb_request_t;
} sb_event_t;
typedef enum
{
@ -113,9 +114,10 @@ typedef int sb_cmd_cleanup(void);
typedef int sb_op_init(void);
typedef int sb_op_prepare(void);
typedef int sb_op_thread_init(int);
typedef int sb_op_thread_run(int);
typedef void sb_op_print_mode(void);
typedef sb_request_t sb_op_get_request(int);
typedef int sb_op_execute_request(sb_request_t *, int);
typedef sb_event_t sb_op_next_event(int);
typedef int sb_op_execute_event(sb_event_t *, int);
typedef void sb_op_print_stats(sb_stat_t);
typedef int sb_op_thread_done(int);
typedef int sb_op_cleanup(void);
@ -141,9 +143,10 @@ typedef struct
sb_op_thread_init *thread_init; /* thread initialization
(called when each thread starts) */
sb_op_print_mode *print_mode; /* print mode function */
sb_op_get_request *get_request; /* request generation function */
sb_op_execute_request *execute_request; /* request execution function */
sb_op_next_event *next_event; /* event generation function */
sb_op_execute_event *execute_event; /* event execution function */
sb_op_print_stats *print_stats; /* stats generation function */
sb_op_thread_run *thread_run; /* main thread loop */
sb_op_thread_done *thread_done; /* thread finalize function */
sb_op_cleanup *cleanup; /* called after exit from thread,
but before timers stop */
@ -210,6 +213,10 @@ typedef struct
extern sb_globals_t sb_globals;
extern pthread_mutex_t event_queue_mutex;
sb_event_t sb_next_event(sb_test_t *test, int thread_id);
void sb_event_start(int thread_id);
void sb_event_stop(int thread_id);
/* Random number generators */
int sb_rand(int, int);
int sb_rand_uniform(int, int);

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2004 MySQL AB
Copyright (C) 2004-2015 Alexey Kopytov <akopytov@gmail.com>
Copyright (C) 2004-2016 Alexey Kopytov <akopytov@gmail.com>
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
@ -39,31 +39,22 @@ static sb_arg_t cpu_args[] =
/* CPU test operations */
static int cpu_init(void);
static void cpu_print_mode(void);
static sb_request_t cpu_get_request(int thread_id);
static int cpu_execute_request(sb_request_t *, int);
static sb_event_t cpu_next_event(int thread_id);
static int cpu_execute_event(sb_event_t *, int);
static int cpu_done(void);
static sb_test_t cpu_test =
{
"cpu",
"CPU performance test",
{
cpu_init,
NULL,
NULL,
cpu_print_mode,
cpu_get_request,
cpu_execute_request,
NULL,
NULL,
NULL,
cpu_done
.sname = "cpu",
.lname = "CPU performance test",
.ops = {
.init = cpu_init,
.print_mode = cpu_print_mode,
.next_event = cpu_next_event,
.execute_event = cpu_execute_event,
.done = cpu_done
},
{
NULL,NULL,NULL,NULL
},
cpu_args,
{NULL, NULL}
.args = cpu_args
};
/* Upper limit for primes */
@ -94,9 +85,9 @@ int cpu_init(void)
}
sb_request_t cpu_get_request(int thread_id)
sb_event_t cpu_next_event(int thread_id)
{
sb_request_t req;
sb_event_t req;
(void) thread_id; /* unused */
@ -118,25 +109,19 @@ sb_request_t cpu_get_request(int thread_id)
return req;
}
int cpu_execute_request(sb_request_t *r, int thread_id)
int cpu_execute_event(sb_event_t *r, int thread_id)
{
unsigned long long c;
unsigned long long l;
double t;
unsigned long long n=0;
log_msg_t msg;
log_msg_oper_t op_msg;
(void)thread_id; /* unused */
(void)r; /* unused */
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
/* So far we're using very simple test prime number tests in 64bit */
LOG_EVENT_START(msg, thread_id);
for(c=3; c < max_prime; c++)
for(c=3; c < max_prime; c++)
{
t = sqrt((double)c);
for(l = 2; l <= t; l++)
@ -146,8 +131,6 @@ int cpu_execute_request(sb_request_t *r, int thread_id)
n++;
}
LOG_EVENT_STOP(msg, thread_id);
return 0;
}

View File

@ -35,7 +35,7 @@ PRIMARY KEY (id)
end --for
end
function event(thread_id)
function event()
local i
if (cursize == 0) then

View File

@ -17,6 +17,12 @@ function create_insert(table_id)
index_name = "PRIMARY KEY"
end
if (pgsql_variant == 'redshift') then
auto_inc_type = "INTEGER IDENTITY(1,1)"
else
auto_inc_type = "SERIAL"
end
i = table_id
print("Creating table 'sbtest" .. i .. "'...")
@ -36,7 +42,7 @@ pad CHAR(60) DEFAULT '' NOT NULL,
elseif (db_driver == "pgsql") then
query = [[
CREATE TABLE sbtest]] .. i .. [[ (
id SERIAL NOT NULL,
id ]] .. auto_inc_type .. [[ NOT NULL,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
@ -176,4 +182,9 @@ function set_vars()
oltp_create_secondary = true
end
if (pgsql_variant == 'redshift') then
oltp_create_secondary = false
oltp_delete_inserts = 0
end
end

View File

@ -6,11 +6,11 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local table_name
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. sb_rand(1, oltp_table_size))

View File

@ -10,7 +10,7 @@ function thread_init(thread_id)
set_vars()
end
function event(thread_id)
function event()
local table_name
local i
local c_val

View File

@ -6,7 +6,7 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
if (((db_driver == "mysql") or (db_driver == "attachsql")) and mysql_table_engine == "myisam") then
@ -30,7 +30,7 @@ function get_range_str()
start, start + oltp_range_size - 1)
end
function event(thread_id)
function event()
local rs
local i
local table_name

View File

@ -6,12 +6,12 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local table_name
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)

View File

@ -8,11 +8,11 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local index_name
local i
print("thread prepare"..thread_id)

View File

@ -6,11 +6,11 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local table_name
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
rs = db_query("SELECT pad FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))

View File

@ -4,100 +4,20 @@
-- For details about key_cache_segments please refer to:
-- http://kb.askmonty.org/v/segmented-key-cache
--
function prepare()
local query
local i
set_vars()
-- Override oltp_tables_count, this test only supports a single table
oltp_tables_count = 1
db_connect()
pathtest = string.match(test, "(.*/)")
print("Creating table 'sbtest'...")
if ((db_driver == "mysql") or (db_driver == "attachsql")) then
query = [[
CREATE TABLE sbtest (
id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
elseif (db_driver == "oracle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL,
k INTEGER,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60 DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "pgsql") then
query = [[
CREATE TABLE sbtest (
id ]] .. ((oltp_auto_inc and "SERIAL") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "drizzle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
else
print("Unknown database driver: " .. db_driver)
return 1
end
db_query(query)
if (db_driver == "oracle") then
db_query("CREATE SEQUENCE sbtest_seq")
db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest
FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
end
db_query("CREATE INDEX k on sbtest(k)")
print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
if (oltp_auto_inc) then
db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
else
db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
end
for i = 1,oltp_table_size do
if (oltp_auto_inc) then
db_bulk_insert_next("("..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
else
db_bulk_insert_next("("..i..", "..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
end
end
db_bulk_insert_done()
return 0
if pathtest then
dofile(pathtest .. "common.lua")
else
require("common")
end
function cleanup()
print("Dropping table 'sbtest'...")
db_query("DROP TABLE sbtest")
end
function thread_init(thread_id)
set_vars()
function thread_init()
set_vars_points()
points = ""
for i = 1,random_points do
@ -109,7 +29,7 @@ function thread_init(thread_id)
stmt = db_prepare([[
SELECT id, k, c, pad
FROM sbtest
FROM sbtest1
WHERE k IN (]] .. points .. [[)
]])
@ -121,7 +41,7 @@ function thread_init(thread_id)
db_bind_param(stmt, params)
end
function event(thread_id)
function event()
local rs
-- To prevent overlapping of our range queries we need to partition the whole table
@ -135,13 +55,7 @@ function event(thread_id)
db_free_results(rs)
end
function set_vars()
oltp_table_size = oltp_table_size or 10000
random_points = random_points or 10
if (oltp_auto_inc == 'off') then
oltp_auto_inc = false
else
oltp_auto_inc = true
end
function set_vars_points()
set_vars()
random_points = random_points or 10
end

View File

@ -4,100 +4,20 @@
-- For details about key_cache_segments please refer to:
-- http://kb.askmonty.org/v/segmented-key-cache
--
function prepare()
local query
local i
set_vars()
pathtest = string.match(test, "(.*/)")
db_connect()
print("Creating table 'sbtest'...")
if ((db_driver == "mysql") or (db_driver == "attachsql")) then
query = [[
CREATE TABLE sbtest (
id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
elseif (db_driver == "oracle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL,
k INTEGER,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60 DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "pgsql") then
query = [[
CREATE TABLE sbtest (
id ]] .. ((oltp_auto_inc and "SERIAL") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "drizzle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
else
print("Unknown database driver: " .. db_driver)
return 1
end
db_query(query)
if (db_driver == "oracle") then
db_query("CREATE SEQUENCE sbtest_seq")
db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest
FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
end
db_query("CREATE INDEX k on sbtest(k)")
print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
if (oltp_auto_inc) then
db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
else
db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
end
for i = 1,oltp_table_size do
if (oltp_auto_inc) then
db_bulk_insert_next("("..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
else
db_bulk_insert_next("("..i..", "..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
end
end
db_bulk_insert_done()
return 0
if pathtest then
dofile(pathtest .. "common.lua")
else
require("common")
end
function cleanup()
print("Dropping table 'sbtest'...")
db_query("DROP TABLE sbtest")
end
-- Override oltp_tables_count, this test only supports a single table
oltp_tables_count = 1
function thread_init(thread_id)
set_vars()
function thread_init()
set_vars_ranges()
ranges = ""
for i = 1,number_of_ranges do
@ -109,7 +29,7 @@ function thread_init(thread_id)
stmt = db_prepare([[
SELECT count(k)
FROM sbtest
FROM sbtest1
WHERE ]] .. ranges .. [[
]])
@ -122,7 +42,7 @@ function thread_init(thread_id)
end
function event(thread_id)
function event()
local rs
-- To prevent overlapping of our range queries we need to partition the whole table
@ -137,14 +57,8 @@ function event(thread_id)
db_free_results(rs)
end
function set_vars()
oltp_table_size = oltp_table_size or 10000
function set_vars_ranges()
set_vars()
number_of_ranges = number_of_ranges or 10
delta = random_ranges_delta or 5
if (oltp_auto_inc == 'off') then
oltp_auto_inc = false
else
oltp_auto_inc = true
end
end

View File

@ -6,11 +6,11 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local table_name
table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
rs = db_query("UPDATE ".. table_name .." SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size))

View File

@ -6,11 +6,11 @@ else
require("common")
end
function thread_init(thread_id)
function thread_init()
set_vars()
end
function event(thread_id)
function event()
local table_name
local c_val
local query

View File

@ -234,8 +234,8 @@ static int file_cmd_cleanup(void);
static int file_init(void);
static void file_print_mode(void);
static int file_prepare(void);
static sb_request_t file_get_request(int thread_id);
static int file_execute_request(sb_request_t *, int);
static sb_event_t file_next_event(int thread_id);
static int file_execute_event(sb_event_t *, int);
#ifdef HAVE_LIBAIO
static int file_thread_done(int);
#endif
@ -244,32 +244,27 @@ static void file_print_stats(sb_stat_t);
static sb_test_t fileio_test =
{
"fileio",
"File I/O test",
{
file_init,
file_prepare,
NULL,
file_print_mode,
file_get_request,
file_execute_request,
file_print_stats,
.sname = "fileio",
.lname = "File I/O test",
.ops = {
.init = file_init,
.prepare = file_prepare,
.print_mode = file_print_mode,
.next_event = file_next_event,
.execute_event = file_execute_event,
.print_stats = file_print_stats,
#ifdef HAVE_LIBAIO
file_thread_done,
.thread_done = file_thread_done,
#else
NULL,
.thread_done = NULL,
#endif
NULL,
file_done
.done = file_done
},
{
NULL,
file_cmd_prepare,
NULL,
file_cmd_cleanup
.cmds = {
.prepare = file_cmd_prepare,
.cleanup = file_cmd_cleanup
},
fileio_args,
{0,0}
.args = fileio_args
};
@ -278,8 +273,8 @@ static int remove_files(void);
static int parse_arguments(void);
static void clear_stats(void);
static void init_vars(void);
static sb_request_t file_get_seq_request(void);
static sb_request_t file_get_rnd_request(int thread_id);
static sb_event_t file_get_seq_request(void);
static sb_event_t file_get_rnd_request(int thread_id);
static void check_seq_req(sb_file_request_t *, sb_file_request_t *);
static const char *get_io_mode_str(file_io_mode_t mode);
static const char *get_test_mode_str(file_test_mode_t mode);
@ -410,7 +405,7 @@ int file_done(void)
return 0;
}
sb_request_t file_get_request(int thread_id)
sb_event_t file_next_event(int thread_id)
{
if (test_mode == MODE_WRITE || test_mode == MODE_REWRITE ||
test_mode == MODE_READ)
@ -424,9 +419,9 @@ sb_request_t file_get_request(int thread_id)
/* Get sequential read or write request */
sb_request_t file_get_seq_request(void)
sb_event_t file_get_seq_request(void)
{
sb_request_t sb_req;
sb_event_t sb_req;
sb_file_request_t *file_req = &sb_req.u.file_request;
sb_req.type = SB_REQ_TYPE_FILE;
@ -529,9 +524,9 @@ sb_request_t file_get_seq_request(void)
/* Request generatior for random tests */
sb_request_t file_get_rnd_request(int thread_id)
sb_event_t file_get_rnd_request(int thread_id)
{
sb_request_t sb_req;
sb_event_t sb_req;
sb_file_request_t *file_req = &sb_req.u.file_request;
unsigned long long tmppos;
int real_mode = test_mode;
@ -640,12 +635,10 @@ retry:
}
int file_execute_request(sb_request_t *sb_req, int thread_id)
int file_execute_event(sb_event_t *sb_req, int thread_id)
{
FILE_DESCRIPTOR fd;
sb_file_request_t *file_req = &sb_req->u.file_request;
log_msg_t msg;
log_msg_oper_t op_msg;
if (sb_globals.debug)
{
@ -670,9 +663,6 @@ int file_execute_request(sb_request_t *sb_req, int thread_id)
return 1;
}
fd = files[file_req->file_id];
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
switch (file_req->operation) {
case FILE_OP_TYPE_NULL:
@ -684,7 +674,6 @@ int file_execute_request(sb_request_t *sb_req, int thread_id)
if (sb_globals.validate)
file_fill_buffer(per_thread[thread_id].buffer, file_req->size, file_req->pos);
LOG_EVENT_START(msg, thread_id);
if(file_pwrite(file_req->file_id, per_thread[thread_id].buffer,
file_req->size, file_req->pos, thread_id)
!= (ssize_t)file_req->size)
@ -708,8 +697,6 @@ int file_execute_request(sb_request_t *sb_req, int thread_id)
SB_THREAD_MUTEX_UNLOCK();
}
LOG_EVENT_STOP(msg, thread_id);
/* In async mode stats will me updated on AIO requests completion */
if (file_io_mode != FILE_IO_MODE_ASYNC)
{
@ -721,7 +708,6 @@ int file_execute_request(sb_request_t *sb_req, int thread_id)
break;
case FILE_OP_TYPE_READ:
LOG_EVENT_START(msg, thread_id);
if(file_pread(file_req->file_id, per_thread[thread_id].buffer,
file_req->size, file_req->pos, thread_id)
!= (ssize_t)file_req->size)
@ -730,7 +716,6 @@ int file_execute_request(sb_request_t *sb_req, int thread_id)
fd, (long long)file_req->pos);
return 1;
}
LOG_EVENT_STOP(msg, thread_id);
/* Validate block if run with validation enabled */
if (sb_globals.validate &&

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2004 MySQL AB
Copyright (C) 2004-2015 Alexey Kopytov <akopytov@gmail.com>
Copyright (C) 2004-2016 Alexey Kopytov <akopytov@gmail.com>
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
@ -57,34 +57,22 @@ static sb_arg_t memory_args[] =
/* Memory test operations */
static int memory_init(void);
static void memory_print_mode(void);
static sb_request_t memory_get_request(int);
static int memory_execute_request(sb_request_t *, int);
static sb_event_t memory_next_event(int);
static int memory_execute_event(sb_event_t *, int);
static void memory_print_stats(sb_stat_t type);
static sb_test_t memory_test =
{
"memory",
"Memory functions speed test",
{
memory_init,
NULL,
NULL,
memory_print_mode,
memory_get_request,
memory_execute_request,
memory_print_stats,
NULL,
NULL,
NULL
.sname = "memory",
.lname = "Memory functions speed test",
.ops = {
.init = memory_init,
.print_mode = memory_print_mode,
.next_event = memory_next_event,
.execute_event = memory_execute_event,
.print_stats = memory_print_stats
},
{
NULL,
NULL,
NULL,
NULL
},
memory_args,
{NULL, NULL}
.args = memory_args
};
/* Test arguments */
@ -218,9 +206,9 @@ int memory_init(void)
}
sb_request_t memory_get_request(int thread_id)
sb_event_t memory_next_event(int thread_id)
{
sb_request_t req;
sb_event_t req;
sb_mem_request_t *mem_req = &req.u.mem_request;
(void) thread_id; /* unused */
@ -244,20 +232,14 @@ sb_request_t memory_get_request(int thread_id)
return req;
}
int memory_execute_request(sb_request_t *sb_req, int thread_id)
int memory_execute_event(sb_event_t *sb_req, int thread_id)
{
sb_mem_request_t *mem_req = &sb_req->u.mem_request;
volatile int tmp = 0;
int idx;
int *buf, *end;
log_msg_t msg;
log_msg_oper_t op_msg;
long i;
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
if (mem_req->scope == SB_MEM_SCOPE_GLOBAL)
buf = buffer;
else
@ -266,7 +248,6 @@ int memory_execute_request(sb_request_t *sb_req, int thread_id)
if (memory_access_rnd)
{
LOG_EVENT_START(msg, thread_id);
switch (mem_req->type) {
case SB_MEM_OP_WRITE:
for (i = 0; i < memory_block_size; i++)
@ -290,7 +271,6 @@ int memory_execute_request(sb_request_t *sb_req, int thread_id)
}
else
{
LOG_EVENT_START(msg, thread_id);
switch (mem_req->type) {
case SB_MEM_OP_NONE:
for (; buf < end; buf++)
@ -310,8 +290,6 @@ int memory_execute_request(sb_request_t *sb_req, int thread_id)
return 1;
}
}
LOG_EVENT_STOP(msg, thread_id);
return 0;
}

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2004 MySQL AB
Copyright (C) 2004-2008 Alexey Kopytov <akopytov@gmail.com>
Copyright (C) 2004-2016 Alexey Kopytov <akopytov@gmail.com>
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
@ -51,34 +51,22 @@ static sb_arg_t mutex_args[] =
/* Mutex test operations */
static int mutex_init(void);
static void mutex_print_mode(void);
static sb_request_t mutex_get_request(int);
static int mutex_execute_request(sb_request_t *, int);
static sb_event_t mutex_next_event(int);
static int mutex_execute_event(sb_event_t *, int);
static int mutex_done(void);
static sb_test_t mutex_test =
{
"mutex",
"Mutex performance test",
{
mutex_init,
NULL,
NULL,
mutex_print_mode,
mutex_get_request,
mutex_execute_request,
NULL,
NULL,
NULL,
mutex_done
.sname = "mutex",
.lname = "Mutex performance test",
.ops = {
.init = mutex_init,
.print_mode = mutex_print_mode,
.next_event = mutex_next_event,
.execute_event = mutex_execute_event,
.done = mutex_done
},
{
NULL,
NULL,
NULL,
NULL
},
mutex_args,
{NULL, NULL}
.args = mutex_args
};
@ -130,9 +118,9 @@ int mutex_done(void)
}
sb_request_t mutex_get_request(int thread_id)
sb_event_t mutex_next_event(int thread_id)
{
sb_request_t sb_req;
sb_event_t sb_req;
sb_mutex_request_t *mutex_req = &sb_req.u.mutex_request;
(void) thread_id; /* unused */
@ -145,20 +133,15 @@ sb_request_t mutex_get_request(int thread_id)
}
int mutex_execute_request(sb_request_t *sb_req, int thread_id)
int mutex_execute_event(sb_event_t *sb_req, int thread_id)
{
unsigned int i;
unsigned int c=0;
unsigned int current_lock;
sb_mutex_request_t *mutex_req = &sb_req->u.mutex_request;
log_msg_t msg;
log_msg_oper_t op_msg;
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
(void) thread_id; /* unused */
LOG_EVENT_START(msg, thread_id);
do
{
current_lock = rand() % mutex_num;
@ -170,7 +153,6 @@ int mutex_execute_request(sb_request_t *sb_req, int thread_id)
mutex_req->nlocks--;
}
while (mutex_req->nlocks > 0);
LOG_EVENT_STOP(msg, thread_id);
/* Perform only one request per thread */
return 1;

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2004 MySQL AB
Copyright (C) 2004-2015 Alexey Kopytov <akopytov@gmail.com>
Copyright (C) 2004-2016 Alexey Kopytov <akopytov@gmail.com>
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
@ -54,34 +54,23 @@ static sb_arg_t threads_args[] =
static int threads_init(void);
static int threads_prepare(void);
static void threads_print_mode(void);
static sb_request_t threads_get_request(int);
static int threads_execute_request(sb_request_t *, int);
static sb_event_t threads_next_event(int);
static int threads_execute_event(sb_event_t *, int);
static int threads_cleanup(void);
static sb_test_t threads_test =
{
"threads",
"Threads subsystem performance test",
{
threads_init,
threads_prepare,
NULL,
threads_print_mode,
threads_get_request,
threads_execute_request,
NULL,
NULL,
NULL,
threads_cleanup,
.sname = "threads",
.lname = "Threads subsystem performance test",
.ops = {
.init = threads_init,
.prepare = threads_prepare,
.print_mode = threads_print_mode,
.next_event = threads_next_event,
.execute_event = threads_execute_event,
.cleanup = threads_cleanup
},
{
NULL,
NULL,
NULL,
NULL
},
threads_args,
{NULL, NULL}
.args = threads_args
};
static unsigned int thread_yields;
@ -139,9 +128,9 @@ int threads_cleanup(void)
}
sb_request_t threads_get_request(int thread_id)
sb_event_t threads_next_event(int thread_id)
{
sb_request_t sb_req;
sb_event_t sb_req;
sb_threads_request_t *threads_req = &sb_req.u.threads_request;
(void) thread_id; /* unused */
@ -163,25 +152,19 @@ sb_request_t threads_get_request(int thread_id)
}
int threads_execute_request(sb_request_t *sb_req, int thread_id)
int threads_execute_event(sb_event_t *sb_req, int thread_id)
{
unsigned int i;
sb_threads_request_t *threads_req = &sb_req->u.threads_request;
log_msg_t msg;
log_msg_oper_t op_msg;
/* Prepare log message */
msg.type = LOG_MSG_TYPE_OPER;
msg.data = &op_msg;
LOG_EVENT_START(msg, thread_id);
(void) thread_id; /* unused */
for(i = 0; i < thread_yields; i++)
{
pthread_mutex_lock(&test_mutexes[threads_req->lock_num]);
YIELD();
pthread_mutex_unlock(&test_mutexes[threads_req->lock_num]);
}
LOG_EVENT_STOP(msg, thread_id);
return 0;
}

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
################################################################################
# Common code for select_random_* tests
#
# Expects the following variables and callback functions to be defined by the
# caller:
#
# DB_DRIVER_ARGS -- extra driver-specific arguments to pass to sysbench
#
# db_show_table() -- called with a single argument to dump a specified table
# schema
################################################################################
set -eu
for test in select_random_points select_random_ranges
do
ARGS="--test=${SBTEST_SCRIPTDIR}/${test}.lua $DB_DRIVER_ARGS --oltp-tables-count=8"
sysbench $ARGS prepare
db_show_table sbtest1
for i in $(seq 2 8)
do
db_show_table sbtest${i} || true # Error on non-existing table
done
sysbench $ARGS --max-requests=100 --num-threads=1 run
sysbench $ARGS cleanup
for i in $(seq 1 8)
do
db_show_table sbtest${i} || true # Error on non-existing table
done
ARGS="--test=${SBTEST_SCRIPTDIR}/select_random_points.lua $DB_DRIVER_ARGS --oltp-tables-count=8"
done

View File

@ -18,5 +18,5 @@ Make sure all available DB drivers are covered
Dropping table 'sbtest1'...
(FATAL: invalid database driver name: 'nonexisting'|FATAL: No DB drivers available) (re)
FATAL: failed to execute function `cleanup': */common.lua:122: DB initialization failed (glob)
FATAL: failed to execute function `cleanup': */common.lua:*: DB initialization failed (glob)
[1]

View File

@ -175,7 +175,7 @@ oltp.lua + MySQL tests
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist
sysbench *.* * (glob)
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
@ -188,7 +188,7 @@ oltp.lua + MySQL tests
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
sysbench *.* * (glob)
sysbench * (glob)
Dropping table 'sbtest1'...
@ -356,7 +356,7 @@ oltp.lua + MySQL tests
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist
sysbench *.* * (glob)
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
@ -369,6 +369,6 @@ oltp.lua + MySQL tests
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
sysbench *.* * (glob)
sysbench * (glob)
Dropping table 'sbtest1'...

View File

@ -184,7 +184,7 @@ oltp.lua + PostgreSQL tests
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".
sysbench *.* * (glob)
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
@ -198,6 +198,6 @@ oltp.lua + PostgreSQL tests
Indexes:
"sbtest1_pkey" PRIMARY KEY, btree (id)
sysbench *.* * (glob)
sysbench * (glob)
Dropping table 'sbtest1'...

View File

@ -0,0 +1,155 @@
########################################################################
select_random_*.lua + MySQL tests
########################################################################
$ if [ -z "${SBTEST_MYSQL_ARGS:-}" ]
> then
> exit 80
> fi
$ function db_show_table() {
> mysql -uroot sbtest -Nse "SHOW CREATE TABLE $1\G"
> }
$ DB_DRIVER_ARGS="--db-driver=mysql $SBTEST_MYSQL_ARGS"
$ . $SBTEST_INCDIR/script_select_random_common.sh
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
*************************** 1. row ***************************
sbtest1
CREATE TABLE `sbtest1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest2' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest3' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest5' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist
sysbench * (glob)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 0 (0.00 per sec.)
read/write requests: 100 (* 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: 100
total time taken by event execution: *s (glob)
response time:
min:* (glob)
avg:* (glob)
max:* (glob)
approx.* (glob)
Threads fairness:
events (avg/stddev):* (glob)
execution time (avg/stddev):* (glob)
sysbench * (glob)
Dropping table 'sbtest1'...
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest1' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest2' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest3' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest5' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
*************************** 1. row ***************************
sbtest1
CREATE TABLE `sbtest1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`k` int(10) unsigned NOT NULL DEFAULT '0',
`c` char(120)* NOT NULL DEFAULT '', (glob)
`pad` char(60)* NOT NULL DEFAULT '', (glob)
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=* MAX_ROWS=1000000 (glob)
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest2' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest3' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest5' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist
sysbench * (glob)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 0 (0.00 per sec.)
read/write requests: 100 (* 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: 100
total time taken by event execution: *s (glob)
response time:
min:* (glob)
avg:* (glob)
max:* (glob)
approx.* (glob)
Threads fairness:
events (avg/stddev):* (glob)
execution time (avg/stddev):* (glob)
sysbench * (glob)
Dropping table 'sbtest1'...
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest1' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest2' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest3' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest4' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest5' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest6' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest7' doesn't exist
ERROR 1146 (42S02) at line 1: Table 'sbtest.sbtest8' doesn't exist

View File

@ -0,0 +1,157 @@
########################################################################
select_random_*.lua + PostgreSQL tests
########################################################################
$ if [ -z "${SBTEST_PGSQL_ARGS:-}" ]
> then
> exit 80
> fi
$ function db_show_table() {
> psql -c "\d+ $1" sbtest
> }
$ DB_DRIVER_ARGS="--db-driver=pgsql $SBTEST_PGSQL_ARGS"
$ . $SBTEST_INCDIR/script_select_random_common.sh
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
Table "public.sbtest1"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest1_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest1_pkey" PRIMARY KEY, btree (id)
"k_1" btree (k)
Did not find any relation named "sbtest2".
Did not find any relation named "sbtest3".
Did not find any relation named "sbtest4".
Did not find any relation named "sbtest5".
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".
sysbench * (glob)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 0 (0.00 per sec.)
read/write requests: 100 (* 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: 100
total time taken by event execution: *s (glob)
response time:
min:* (glob)
avg:* (glob)
max:* (glob)
approx.* (glob)
Threads fairness:
events (avg/stddev):* (glob)
execution time (avg/stddev):* (glob)
sysbench * (glob)
Dropping table 'sbtest1'...
Did not find any relation named "sbtest1".
Did not find any relation named "sbtest2".
Did not find any relation named "sbtest3".
Did not find any relation named "sbtest4".
Did not find any relation named "sbtest5".
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".
sysbench * (glob)
Creating table 'sbtest1'...
Inserting 10000 records into 'sbtest1'
Creating secondary indexes on 'sbtest1'...
Table "public.sbtest1"
Column | Type | Modifiers | Storage | Stats target | Description
--------+----------------+------------------------------------------------------+----------+--------------+-------------
id | integer | not null default nextval('sbtest1_id_seq'::regclass) | plain | |
k | integer | not null default 0 | plain | |
c | character(120) | not null default ''::bpchar | extended | |
pad | character(60) | not null default ''::bpchar | extended | |
Indexes:
"sbtest1_pkey" PRIMARY KEY, btree (id)
"k_1" btree (k)
Did not find any relation named "sbtest2".
Did not find any relation named "sbtest3".
Did not find any relation named "sbtest4".
Did not find any relation named "sbtest5".
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".
sysbench * (glob)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
OLTP test statistics:
queries performed:
read: 100
write: 0
other: 0
total: 100
transactions: 0 (0.00 per sec.)
read/write requests: 100 (* 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: 100
total time taken by event execution: *s (glob)
response time:
min:* (glob)
avg:* (glob)
max:* (glob)
approx.* (glob)
Threads fairness:
events (avg/stddev):* (glob)
execution time (avg/stddev):* (glob)
sysbench * (glob)
Dropping table 'sbtest1'...
Did not find any relation named "sbtest1".
Did not find any relation named "sbtest2".
Did not find any relation named "sbtest3".
Did not find any relation named "sbtest4".
Did not find any relation named "sbtest5".
Did not find any relation named "sbtest6".
Did not find any relation named "sbtest7".
Did not find any relation named "sbtest8".

View File

@ -68,7 +68,7 @@ fileio benchmark tests
General statistics:
total time: *.*s (glob)
total number of events: 150
total number of events: 158
total time taken by event execution: *.*s (glob)
response time:
min: *.*ms (glob)
@ -77,7 +77,7 @@ fileio benchmark tests
approx. 95th percentile: *.*ms (glob)
Threads fairness:
events (avg/stddev): 150.0000/0.00
events (avg/stddev): 158.0000/0.00
execution time (avg/stddev): *.*/0.00 (glob)
$ sysbench $fileio_args --max-requests=150 --file-test-mode=rndrd run
@ -206,7 +206,7 @@ fileio benchmark tests
General statistics:
total time: *.*s (glob)
total number of events: 150
total number of events: 158
total time taken by event execution: *.*s (glob)
response time:
min: *.*ms (glob)
@ -215,7 +215,7 @@ fileio benchmark tests
approx. 95th percentile: *.*ms (glob)
Threads fairness:
events (avg/stddev): 150.0000/0.00
events (avg/stddev): 158.0000/0.00
execution time (avg/stddev): *.*/0.00 (glob)