Fixed an incorrect merge.
More compilation warnings fixed.
This commit is contained in:
12
.bzrignore
12
.bzrignore
@ -38,3 +38,15 @@ autom4te.cache
|
||||
./sysbench/tests/mutex/TAGS
|
||||
./sysbench/tests/oltp/TAGS
|
||||
./sysbench/tests/threads/TAGS
|
||||
./config/compile
|
||||
./config/depcomp
|
||||
./config/install-sh
|
||||
./config/missing
|
||||
./m4/libtool.m4
|
||||
./m4/ltoptions.m4
|
||||
./m4/ltsugar.m4
|
||||
./m4/ltversion.m4
|
||||
./m4/lt~obsolete.m4
|
||||
./sysbench/drivers/drizzle/.deps
|
||||
./sysbench/scripting/.deps
|
||||
./sysbench/scripting/lua/src/.deps
|
||||
|
||||
@ -41,16 +41,20 @@
|
||||
#define ROWS_BEFORE_COMMIT 1000
|
||||
|
||||
typedef struct {
|
||||
unsigned long read_ops;
|
||||
unsigned long write_ops;
|
||||
unsigned long other_ops;
|
||||
unsigned long transactions;
|
||||
unsigned long deadlocks;
|
||||
unsigned long read_ops;
|
||||
unsigned long write_ops;
|
||||
unsigned long other_ops;
|
||||
unsigned long transactions;
|
||||
unsigned long deadlocks;
|
||||
pthread_mutex_t stat_mutex;
|
||||
} db_thread_stat_t;
|
||||
|
||||
/* Global variables */
|
||||
db_globals_t db_globals;
|
||||
|
||||
/* Used in intermediate reports */
|
||||
unsigned long last_transactions;
|
||||
|
||||
/* Static variables */
|
||||
static sb_list_t drivers; /* list of available DB drivers */
|
||||
static db_thread_stat_t *thread_stats; /* per-thread stats */
|
||||
@ -220,6 +224,9 @@ db_driver_t *db_init(const char *name)
|
||||
if (thread_stats == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < sb_globals.num_threads; i++)
|
||||
pthread_mutex_init(&thread_stats[i].stat_mutex, NULL);
|
||||
|
||||
/* Initialize timers if in debug mode */
|
||||
if (db_globals.debug)
|
||||
{
|
||||
@ -531,7 +538,12 @@ int db_done(db_driver_t *drv)
|
||||
}
|
||||
|
||||
if (thread_stats != NULL)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < sb_globals.num_threads; i++)
|
||||
pthread_mutex_destroy(&thread_stats[i].stat_mutex);
|
||||
free(thread_stats);
|
||||
}
|
||||
|
||||
return drv->ops.done();
|
||||
}
|
||||
@ -769,9 +781,9 @@ void db_bulk_insert_done(db_conn_t *con)
|
||||
|
||||
/* Print database-specific test stats */
|
||||
|
||||
void db_print_stats(void)
|
||||
void db_print_stats(sb_stat_t type)
|
||||
{
|
||||
double total_time;
|
||||
double seconds;
|
||||
unsigned int i;
|
||||
sb_timer_t exec_timer;
|
||||
sb_timer_t fetch_timer;
|
||||
@ -785,14 +797,31 @@ void db_print_stats(void)
|
||||
read_ops = write_ops = other_ops = transactions = deadlocks = 0;
|
||||
for (i = 0; i < sb_globals.num_threads; i++)
|
||||
{
|
||||
pthread_mutex_lock(&thread_stats[i].stat_mutex);
|
||||
read_ops += thread_stats[i].read_ops;
|
||||
write_ops += thread_stats[i].write_ops;
|
||||
other_ops += thread_stats[i].other_ops;
|
||||
transactions += thread_stats[i].transactions;
|
||||
deadlocks += thread_stats[i].deadlocks;
|
||||
pthread_mutex_unlock(&thread_stats[i].stat_mutex);
|
||||
}
|
||||
|
||||
total_time = NS2SEC(sb_timer_value(&sb_globals.exec_timer));
|
||||
|
||||
if (type == SB_STAT_INTERMEDIATE)
|
||||
{
|
||||
seconds = NS2SEC(sb_timer_split(&sb_globals.exec_timer));
|
||||
|
||||
log_timestamp(LOG_NOTICE, &sb_globals.exec_timer,
|
||||
"threads: %d, tps: %4.2f",
|
||||
sb_globals.num_threads,
|
||||
(transactions - last_transactions) / seconds);
|
||||
last_transactions = transactions;
|
||||
|
||||
return;
|
||||
}
|
||||
else if (type != SB_STAT_CUMULATIVE)
|
||||
return;
|
||||
|
||||
seconds = NS2SEC(sb_timer_value(&sb_globals.exec_timer));
|
||||
|
||||
log_text(LOG_NOTICE, "OLTP test statistics:");
|
||||
log_text(LOG_NOTICE, " queries performed:");
|
||||
@ -805,14 +834,14 @@ void db_print_stats(void)
|
||||
log_text(LOG_NOTICE, " total: %d",
|
||||
read_ops + write_ops + other_ops);
|
||||
log_text(LOG_NOTICE, " transactions: %-6d"
|
||||
" (%.2f per sec.)", transactions, transactions / total_time);
|
||||
" (%.2f per sec.)", transactions, transactions / seconds);
|
||||
log_text(LOG_NOTICE, " deadlocks: %-6d"
|
||||
" (%.2f per sec.)", deadlocks, deadlocks / total_time);
|
||||
" (%.2f per sec.)", deadlocks, deadlocks / seconds);
|
||||
log_text(LOG_NOTICE, " read/write requests: %-6d"
|
||||
" (%.2f per sec.)", read_ops + write_ops,
|
||||
(read_ops + write_ops) / total_time);
|
||||
(read_ops + write_ops) / seconds);
|
||||
log_text(LOG_NOTICE, " other operations: %-6d"
|
||||
" (%.2f per sec.)", other_ops, other_ops / total_time);
|
||||
" (%.2f per sec.)", other_ops, other_ops / seconds);
|
||||
|
||||
if (db_globals.debug)
|
||||
{
|
||||
@ -878,6 +907,8 @@ void db_update_thread_stats(int id, db_query_type_t type)
|
||||
if (id < 0)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&thread_stats[id].stat_mutex);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DB_QUERY_TYPE_READ:
|
||||
@ -896,6 +927,6 @@ void db_update_thread_stats(int id, db_query_type_t type)
|
||||
default:
|
||||
log_text(LOG_WARNING, "Unknown query type: %d", type);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&thread_stats[id].stat_mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ int db_bulk_insert_next(db_conn_t *, const char *);
|
||||
void db_bulk_insert_done(db_conn_t *);
|
||||
|
||||
/* Print database-specific test stats */
|
||||
void db_print_stats(void);
|
||||
void db_print_stats(sb_stat_t type);
|
||||
|
||||
/* Associate connection with a thread (required only for statistics */
|
||||
void db_set_thread(db_conn_t *, int);
|
||||
|
||||
@ -109,8 +109,6 @@ void sb_timer_stop(sb_timer_t *t)
|
||||
|
||||
unsigned long long sb_timer_value(sb_timer_t *t)
|
||||
{
|
||||
struct timespec time_end;
|
||||
|
||||
switch (t->state) {
|
||||
case TIMER_INITIALIZED:
|
||||
log_text(LOG_WARNING, "timer was never started");
|
||||
@ -236,7 +234,6 @@ sb_timer_t merge_timers(sb_timer_t *t1, sb_timer_t *t2)
|
||||
void add_ns_to_timespec(struct timespec *dest, long long delta)
|
||||
{
|
||||
long long x;
|
||||
time_t sec;
|
||||
|
||||
x = dest->tv_nsec + delta;
|
||||
if (x > 1000000000)
|
||||
|
||||
@ -99,7 +99,7 @@ static sb_request_t sb_lua_get_request(void);
|
||||
static int sb_lua_op_execute_request(sb_request_t *, int);
|
||||
static int sb_lua_op_thread_init(int);
|
||||
static int sb_lua_op_thread_done(int);
|
||||
static void sb_lua_op_print_stats(void);
|
||||
static void sb_lua_op_print_stats(sb_stat_t type);
|
||||
|
||||
static sb_operations_t lua_ops = {
|
||||
&sb_lua_init,
|
||||
@ -334,11 +334,11 @@ int sb_lua_op_thread_done(int thread_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sb_lua_op_print_stats(void)
|
||||
void sb_lua_op_print_stats(sb_stat_t type)
|
||||
{
|
||||
/* check if db driver has been initialized */
|
||||
if (db_driver != NULL)
|
||||
db_print_stats();
|
||||
db_print_stats(type);
|
||||
}
|
||||
|
||||
int sb_lua_done(void)
|
||||
|
||||
@ -147,6 +147,8 @@ static void print_header(void);
|
||||
static void print_usage(void);
|
||||
static void print_run_mode(sb_test_t *);
|
||||
|
||||
static void *report_thread_proc(void *arg);
|
||||
|
||||
#ifdef HAVE_ALARM
|
||||
static void sigalrm_handler(int sig)
|
||||
{
|
||||
@ -403,8 +405,10 @@ static void *runner_thread(void *arg)
|
||||
sb_thread_ctxt_t *ctxt;
|
||||
sb_test_t *test;
|
||||
unsigned int thread_id;
|
||||
long long period_ns, pause_ns, jitter_ns;
|
||||
struct timespec target_tv, now_tv, wakeup_tv;
|
||||
long long pause_ns;
|
||||
long long period_ns = 0;
|
||||
long long jitter_ns = 0;
|
||||
struct timespec target_tv, now_tv;
|
||||
|
||||
ctxt = (sb_thread_ctxt_t *)arg;
|
||||
test = ctxt->test;
|
||||
|
||||
Reference in New Issue
Block a user