Commit 1ded6858 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:3988] #3988 Collect some statistics. Still need to add to header and deliver to engine status.

git-svn-id: file:///svn/toku/tokudb@36845 c7de825b-a66e-492c-adef-691d508d4ae1
parent 74e885a0
...@@ -748,6 +748,12 @@ typedef struct brt_status { ...@@ -748,6 +748,12 @@ typedef struct brt_status {
uint64_t search_root_retries; // number of searches that required the root node to be fetched more than once uint64_t search_root_retries; // number of searches that required the root node to be fetched more than once
uint64_t search_tries_gt_height; // number of searches that required more tries than the height of the tree uint64_t search_tries_gt_height; // number of searches that required more tries than the height of the tree
uint64_t search_tries_gt_heightplus3; // number of searches that required more tries than the height of the tree plus three uint64_t search_tries_gt_heightplus3; // number of searches that required more tries than the height of the tree plus three
uint64_t disk_flush_leaf; // number of leaf nodes flushed to disk, not for checkpoint
uint64_t disk_flush_nonleaf; // number of nonleaf nodes flushed to disk, not for checkpoint
uint64_t disk_flush_leaf_for_checkpoint; // number of leaf nodes flushed to disk for checkpoint
uint64_t disk_flush_nonleaf_for_checkpoint; // number of nonleaf nodes flushed to disk for checkpoint
uint64_t destroy_leaf; // number of leaf nodes destroyed
uint64_t destroy_nonleaf; // number of nonleaf nodes destroyed
uint64_t cleaner_total_nodes; // total number of nodes whose buffers are potentially flushed by cleaner thread uint64_t cleaner_total_nodes; // total number of nodes whose buffers are potentially flushed by cleaner thread
uint64_t cleaner_h1_nodes; // number of nodes of height one whose message buffers are flushed by cleaner thread uint64_t cleaner_h1_nodes; // number of nodes of height one whose message buffers are flushed by cleaner thread
uint64_t cleaner_hgt1_nodes; // number of nodes of height > 1 whose message buffers are flushed by cleaner thread uint64_t cleaner_hgt1_nodes; // number of nodes of height > 1 whose message buffers are flushed by cleaner thread
......
...@@ -671,6 +671,7 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename ...@@ -671,6 +671,7 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename
struct brt_header *h = extraargs; struct brt_header *h = extraargs;
BRTNODE brtnode = brtnode_v; BRTNODE brtnode = brtnode_v;
assert(brtnode->thisnodename.b==nodename.b); assert(brtnode->thisnodename.b==nodename.b);
int height = brtnode->height;
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]); //printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
if (write_me) { if (write_me) {
if (!h->panic) { // if the brt panicked, stop writing, otherwise try to write it. if (!h->panic) { // if the brt panicked, stop writing, otherwise try to write it.
...@@ -689,6 +690,18 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename ...@@ -689,6 +690,18 @@ void toku_brtnode_flush_callback (CACHEFILE cachefile, int fd, BLOCKNUM nodename
} }
} }
} }
if (height == 0) { // statistics incremented only when disk I/O is done, so worth the threadsafe count
if (for_checkpoint)
(void) toku_sync_fetch_and_increment_uint64(&brt_status.disk_flush_leaf_for_checkpoint);
else
(void) toku_sync_fetch_and_increment_uint64(&brt_status.disk_flush_leaf);
}
else {
if (for_checkpoint)
(void) toku_sync_fetch_and_increment_uint64(&brt_status.disk_flush_nonleaf_for_checkpoint);
else
(void) toku_sync_fetch_and_increment_uint64(&brt_status.disk_flush_nonleaf);
}
} }
//printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]); //printf("%s:%d %p->mdict[0]=%p\n", __FILE__, __LINE__, brtnode, brtnode->mdicts[0]);
*new_size = make_brtnode_pair_attr(brtnode); *new_size = make_brtnode_pair_attr(brtnode);
...@@ -1152,7 +1165,10 @@ void toku_brtnode_free (BRTNODE *nodep) { ...@@ -1152,7 +1165,10 @@ void toku_brtnode_free (BRTNODE *nodep) {
toku_mempool_destroy(mp); toku_mempool_destroy(mp);
} }
} }
toku_sync_fetch_and_increment_uint64(&brt_status.destroy_leaf);
} }
else
toku_sync_fetch_and_increment_uint64(&brt_status.destroy_nonleaf);
toku_destroy_brtnode_internals(node); toku_destroy_brtnode_internals(node);
toku_free(node); toku_free(node);
*nodep=0; *nodep=0;
......
...@@ -15,10 +15,7 @@ BOOL garbage_collection_debug = FALSE; ...@@ -15,10 +15,7 @@ BOOL garbage_collection_debug = FALSE;
static void verify_snapshot_system(TOKULOGGER logger); static void verify_snapshot_system(TOKULOGGER logger);
// accountability // accountability
static TXN_STATUS_S status = {.begin = 0, static TXN_STATUS_S status;
.commit = 0,
.abort = 0,
.close = 0};
void void
...@@ -278,6 +275,9 @@ int toku_txn_begin_with_xid ( ...@@ -278,6 +275,9 @@ int toku_txn_begin_with_xid (
*tokutxn = result; *tokutxn = result;
status.begin++; status.begin++;
status.num_open++;
if (status.num_open > status.max_open)
status.max_open = status.num_open;
if (garbage_collection_debug) { if (garbage_collection_debug) {
verify_snapshot_system(logger); verify_snapshot_system(logger);
} }
...@@ -470,6 +470,7 @@ void toku_txn_close_txn(TOKUTXN txn) { ...@@ -470,6 +470,7 @@ void toku_txn_close_txn(TOKUTXN txn) {
verify_snapshot_system(logger); verify_snapshot_system(logger);
status.close++; status.close++;
status.num_open--;
return; return;
} }
......
...@@ -64,6 +64,8 @@ typedef struct txn_status { ...@@ -64,6 +64,8 @@ typedef struct txn_status {
u_int64_t commit; // successful commits u_int64_t commit; // successful commits
u_int64_t abort; u_int64_t abort;
u_int64_t close; // should be sum of aborts and commits u_int64_t close; // should be sum of aborts and commits
u_int64_t num_open; // should be begin - close
u_int64_t max_open; // max value of num_open
} TXN_STATUS_S, *TXN_STATUS; } TXN_STATUS_S, *TXN_STATUS;
void toku_txn_get_status(TXN_STATUS s); void toku_txn_get_status(TXN_STATUS s);
......
...@@ -1455,7 +1455,13 @@ toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, ...@@ -1455,7 +1455,13 @@ toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree,
*ptree = tree; *ptree = tree;
r = 0; r = 0;
cleanup: cleanup:
if (r != 0) { if (r == 0) {
mgr->status.lt_create++;
mgr->status.lt_num++;
if (mgr->status.lt_num > mgr->status.lt_num_max)
mgr->status.lt_num_max = mgr->status.lt_num;
}
else {
if (tree != NULL) { if (tree != NULL) {
if (added_to_ltm) if (added_to_ltm)
toku_ltm_remove_lt(mgr, tree); toku_ltm_remove_lt(mgr, tree);
...@@ -1465,6 +1471,7 @@ cleanup: ...@@ -1465,6 +1471,7 @@ cleanup:
lt_remove_db(tree, db); lt_remove_db(tree, db);
toku_lt_close(tree); toku_lt_close(tree);
} }
mgr->status.lt_create_fail++;
} }
return r; return r;
} }
...@@ -1476,6 +1483,8 @@ toku_lt_close(toku_lock_tree* tree) { ...@@ -1476,6 +1483,8 @@ toku_lt_close(toku_lock_tree* tree) {
if (!tree) { if (!tree) {
r = EINVAL; goto cleanup; r = EINVAL; goto cleanup;
} }
tree->mgr->status.lt_destroy++;
tree->mgr->status.lt_num--;
toku_lock_request_tree_destroy(tree); toku_lock_request_tree_destroy(tree);
r = toku_rt_close(tree->borderwrite); r = toku_rt_close(tree->borderwrite);
if (!first_error && r != 0) if (!first_error && r != 0)
......
...@@ -128,6 +128,11 @@ typedef struct ltm_status { ...@@ -128,6 +128,11 @@ typedef struct ltm_status {
uint64_t write_lock; // number of times write lock taken successfully uint64_t write_lock; // number of times write lock taken successfully
uint64_t write_lock_fail; // number of times write lock denied uint64_t write_lock_fail; // number of times write lock denied
uint64_t out_of_write_locks; // number of times write lock denied for out_of_locks uint64_t out_of_write_locks; // number of times write lock denied for out_of_locks
uint64_t lt_create; // number of locktrees created
uint64_t lt_create_fail; // number of locktrees unable to be created
uint64_t lt_destroy; // number of locktrees destroyed
uint64_t lt_num; // number of locktrees (should be created - destroyed)
uint64_t lt_num_max; // max number of locktrees that have existed simultaneously
} LTM_STATUS_S, *LTM_STATUS; } LTM_STATUS_S, *LTM_STATUS;
......
...@@ -79,6 +79,10 @@ static u_int64_t num_multi_updates; ...@@ -79,6 +79,10 @@ static u_int64_t num_multi_updates;
static u_int64_t num_multi_updates_fail; static u_int64_t num_multi_updates_fail;
static u_int64_t num_point_queries; static u_int64_t num_point_queries;
static u_int64_t num_sequential_queries; static u_int64_t num_sequential_queries;
static u_int64_t num_db_open;
static u_int64_t num_db_close;
static u_int64_t max_db_open;
static u_int64_t num_open_dbs;
static u_int64_t directory_read_locks; /* total directory read locks taken */ static u_int64_t directory_read_locks; /* total directory read locks taken */
static u_int64_t directory_read_locks_fail; /* total directory read locks unable to be taken */ static u_int64_t directory_read_locks_fail; /* total directory read locks unable to be taken */
...@@ -2992,6 +2996,10 @@ env_note_db_opened(DB_ENV *env, DB *db) { ...@@ -2992,6 +2996,10 @@ env_note_db_opened(DB_ENV *env, DB *db) {
OMTVALUE dbv; OMTVALUE dbv;
uint32_t idx; uint32_t idx;
env->i->num_open_dbs++; env->i->num_open_dbs++;
num_open_dbs = env->i->num_open_dbs;
num_db_open++;
if (num_open_dbs > max_db_open)
max_db_open = num_open_dbs;
r = toku_omt_find_zero(env->i->open_dbs, find_db_by_db, db, &dbv, &idx); r = toku_omt_find_zero(env->i->open_dbs, find_db_by_db, db, &dbv, &idx);
assert(r==DB_NOTFOUND); //Must not already be there. assert(r==DB_NOTFOUND); //Must not already be there.
r = toku_omt_insert_at(env->i->open_dbs, db, idx); r = toku_omt_insert_at(env->i->open_dbs, db, idx);
...@@ -3007,6 +3015,8 @@ env_note_db_closed(DB_ENV *env, DB *db) { ...@@ -3007,6 +3015,8 @@ env_note_db_closed(DB_ENV *env, DB *db) {
OMTVALUE dbv; OMTVALUE dbv;
uint32_t idx; uint32_t idx;
env->i->num_open_dbs--; env->i->num_open_dbs--;
num_open_dbs = env->i->num_open_dbs;
num_db_close++;
r = toku_omt_find_zero(env->i->open_dbs, find_db_by_db, db, &dbv, &idx); r = toku_omt_find_zero(env->i->open_dbs, find_db_by_db, db, &dbv, &idx);
assert(r==0); //Must already be there. assert(r==0); //Must already be there.
assert((DB*)dbv == db); assert((DB*)dbv == db);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment