From d0ec2daa028cbe94f196b474a00c4525f0b891ae Mon Sep 17 00:00:00 2001 From: Barry Perlman <barry@tokutek.com> Date: Tue, 16 Apr 2013 23:58:03 -0400 Subject: [PATCH] Addresses #1792 refs[t:1792] Added ydb-layer operation counters to engine status git-svn-id: file:///svn/toku/tokudb@14812 c7de825b-a66e-492c-adef-691d508d4ae1 --- buildheader/db.h_4_1 | 8 +++++++- buildheader/db.h_4_3 | 8 +++++++- buildheader/db.h_4_4 | 8 +++++++- buildheader/db.h_4_5 | 8 +++++++- buildheader/db.h_4_6 | 8 +++++++- buildheader/make_db_h.c | 8 +++++++- buildheader/tdb.h | 8 +++++++- include/db.h | 8 +++++++- src/ydb.c | 45 +++++++++++++++++++++++++++++++++++++++-- 9 files changed, 99 insertions(+), 10 deletions(-) diff --git a/buildheader/db.h_4_1 b/buildheader/db.h_4_1 index 5e1f2a508ec..93bc56d3d23 100644 --- a/buildheader/db.h_4_1 +++ b/buildheader/db.h_4_1 @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_3 b/buildheader/db.h_4_3 index e203530a8b4..e0b369f3b89 100644 --- a/buildheader/db.h_4_3 +++ b/buildheader/db.h_4_3 @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_4 b/buildheader/db.h_4_4 index 6e22faa8d33..bac404cc9fe 100644 --- a/buildheader/db.h_4_4 +++ b/buildheader/db.h_4_4 @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_5 b/buildheader/db.h_4_5 index 0232f4d2e9f..47898a92676 100644 --- a/buildheader/db.h_4_5 +++ b/buildheader/db.h_4_5 @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/db.h_4_6 b/buildheader/db.h_4_6 index 761e23e9e15..4c9c1df56de 100644 --- a/buildheader/db.h_4_6 +++ b/buildheader/db.h_4_6 @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/buildheader/make_db_h.c b/buildheader/make_db_h.c index 59099446afd..73dba5f8d1c 100644 --- a/buildheader/make_db_h.c +++ b/buildheader/make_db_h.c @@ -364,7 +364,13 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un printf(" int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ \n"); printf(" u_int32_t range_locks_max; /* max total number of range locks */ \n"); printf(" u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ \n"); - printf(" u_int32_t range_locks_curr; /* total range locks currently in use */ \n"); + printf(" u_int32_t range_locks_curr; /* total range locks currently in use */ \n"); + printf(" u_int64_t inserts; /* ydb row insert operations */ \n"); + printf(" u_int64_t deletes; /* ydb row delete operations */ \n"); + printf(" u_int64_t commits; /* ydb txn commit operations */ \n"); + printf(" u_int64_t aborts; /* ydb txn abort operations */ \n"); + printf(" u_int64_t point_queries; /* ydb point queries */ \n"); + printf(" u_int64_t sequential_queries; /* ydb sequential queries */ \n"); // printf(" struct timeval checkpoint_tbegin; /* time of last checkpoint begin */ \n"); // printf(" struct timeval checkpoint_tend; /* time of last checkpoint end */ \n"); diff --git a/buildheader/tdb.h b/buildheader/tdb.h index abd82a94ec7..97c76d6f6f8 100644 --- a/buildheader/tdb.h +++ b/buildheader/tdb.h @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/include/db.h b/include/db.h index abd82a94ec7..97c76d6f6f8 100644 --- a/include/db.h +++ b/include/db.h @@ -60,7 +60,13 @@ typedef struct __toku_engine_status { int64_t cachetable_size_writing; /* the sum of the sizes of the nodes being written */ u_int32_t range_locks_max; /* max total number of range locks */ u_int32_t range_locks_max_per_db; /* max range locks per dictionary */ - u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int32_t range_locks_curr; /* total range locks currently in use */ + u_int64_t inserts; /* ydb row insert operations */ + u_int64_t deletes; /* ydb row delete operations */ + u_int64_t commits; /* ydb txn commit operations */ + u_int64_t aborts; /* ydb txn abort operations */ + u_int64_t point_queries; /* ydb point queries */ + u_int64_t sequential_queries; /* ydb sequential queries */ } ENGINE_STATUS; typedef enum { DB_BTREE=1, diff --git a/src/ydb.c b/src/ydb.c index 68e9bc4c2d4..490a749d617 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -42,6 +42,18 @@ const char *toku_copyright_string = "Copyright (c) 2007-2009 Tokutek Inc. All r int toku_close_trace_file (void) { return 0; } #endif + +// Accountability: operation counters available for debugging and for "show engine status" +static u_int64_t num_inserts; +static u_int64_t num_deletes; +static u_int64_t num_commits; +static u_int64_t num_aborts; +static u_int64_t num_point_queries; +static u_int64_t num_sequential_queries; + + + + /** The default maximum number of persistent locks in a lock tree */ const u_int32_t __toku_env_default_max_locks = 1000; @@ -983,6 +995,14 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat) { r = toku_ltm_get_max_locks_per_db(ltm, &(engstat->range_locks_max_per_db)); assert(r==0); r = toku_ltm_get_curr_locks(ltm, &(engstat->range_locks_curr)); assert(r==0); } + { + engstat->inserts = num_inserts; + engstat->deletes = num_deletes; + engstat->commits = num_commits; + engstat->aborts = num_aborts; + engstat->point_queries = num_point_queries; + engstat->sequential_queries = num_sequential_queries; + } } return r; } @@ -1170,6 +1190,7 @@ static int toku_txn_commit(DB_TXN * txn, u_int32_t flags) { toku_free(db_txn_struct_i(txn)); #endif toku_free(txn); + num_commits++; // accountability if (flags!=0) return EINVAL; return r ? r : (r2 ? r2 : r_child_first); } @@ -1209,6 +1230,7 @@ static int toku_txn_abort(DB_TXN * txn) { toku_free(db_txn_struct_i(txn)); #endif toku_free(txn); + num_aborts++; // accountability return r ? r : (r2 ? r2 : r_child_first); } @@ -1844,7 +1866,7 @@ static int toku_c_getf_first(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - + num_point_queries++; // accountability QUERY_CONTEXT_S context; //Describes the context of this query. query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_first will call c_getf_first_callback(..., context) (if query is successful) @@ -1898,7 +1920,7 @@ static int toku_c_getf_last(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); - + num_point_queries++; // accountability QUERY_CONTEXT_S context; //Describes the context of this query. query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_last will call c_getf_last_callback(..., context) (if query is successful) @@ -1957,6 +1979,7 @@ toku_c_getf_next(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { else if (toku_c_uninitialized(c)) r = toku_c_getf_first(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful) r = toku_brt_cursor_next(dbc_struct_i(c)->c, c_getf_next_callback, &context); @@ -2011,6 +2034,7 @@ toku_c_getf_next_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex if (toku_c_uninitialized(c)) r = toku_c_getf_first(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_next will call c_getf_next_callback(..., context) (if query is successful) r = toku_brt_cursor_next_nodup(dbc_struct_i(c)->c, c_getf_next_callback, &context); @@ -2028,6 +2052,7 @@ toku_c_getf_next_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr if (toku_c_uninitialized(c)) return EINVAL; QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_next_dup will call c_getf_next_dup_callback(..., context) (if query is successful) int r = toku_brt_cursor_next_dup(dbc_struct_i(c)->c, c_getf_next_dup_callback, &context); @@ -2083,6 +2108,7 @@ toku_c_getf_prev(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra) { else if (toku_c_uninitialized(c)) r = toku_c_getf_last(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful) r = toku_brt_cursor_prev(dbc_struct_i(c)->c, c_getf_prev_callback, &context); @@ -2137,6 +2163,7 @@ toku_c_getf_prev_nodup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *ex if (toku_c_uninitialized(c)) r = toku_c_getf_last(c, flag, f, extra); else { QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_prev will call c_getf_prev_callback(..., context) (if query is successful) r = toku_brt_cursor_prev_nodup(dbc_struct_i(c)->c, c_getf_prev_callback, &context); @@ -2154,6 +2181,7 @@ toku_c_getf_prev_dup(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extr if (toku_c_uninitialized(c)) return EINVAL; QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_prev_dup will call c_getf_prev_dup_callback(..., context) (if query is successful) int r = toku_brt_cursor_prev_dup(dbc_struct_i(c)->c, c_getf_prev_dup_callback, &context); @@ -2206,6 +2234,7 @@ toku_c_getf_current(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, void *extra HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful) int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT, c_getf_current_callback, &context); @@ -2241,6 +2270,7 @@ toku_c_getf_current_binding(DBC *c, u_int32_t flag, YDB_CALLBACK_FUNCTION f, voi HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_S context; //Describes the context of this query. + num_sequential_queries++; // accountability query_context_init(&context, c, flag, f, extra); //toku_brt_cursor_current will call c_getf_current_callback(..., context) (if query is successful) int r = toku_brt_cursor_current(dbc_struct_i(c)->c, DB_CURRENT_BINDING, c_getf_current_callback, &context); @@ -2256,6 +2286,7 @@ toku_c_getf_set(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, void HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, NULL, f, extra); //toku_brt_cursor_set will call c_getf_set_callback(..., context) (if query is successful) int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, NULL, c_getf_set_callback, &context); @@ -2313,6 +2344,7 @@ toku_c_getf_set_range(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUNCTION f, HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, NULL, f, extra); //toku_brt_cursor_set_range will call c_getf_set_range_callback(..., context) (if query is successful) int r = toku_brt_cursor_set_range(dbc_struct_i(c)->c, key, c_getf_set_range_callback, &context); @@ -2371,6 +2403,7 @@ toku_c_getf_set_range_reverse(DBC *c, u_int32_t flag, DBT *key, YDB_CALLBACK_FUN HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, NULL, f, extra); //toku_brt_cursor_set_range_reverse will call c_getf_set_range_reverse_callback(..., context) (if query is successful) int r = toku_brt_cursor_set_range_reverse(dbc_struct_i(c)->c, key, c_getf_set_range_reverse_callback, &context); @@ -2429,6 +2462,7 @@ toku_c_getf_get_both(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLBACK_FU HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, val, f, extra); //toku_brt_cursor_get_both will call c_getf_get_both_callback(..., context) (if query is successful) int r = toku_brt_cursor_set(dbc_struct_i(c)->c, key, val, c_getf_get_both_callback, &context); @@ -2481,6 +2515,7 @@ toku_c_getf_get_both_range(DBC *c, u_int32_t flag, DBT *key, DBT *val, YDB_CALLB if (c_db_is_nodup(c)) r = toku_c_getf_get_both(c, flag, key, val, f, extra); else { QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, val, f, extra); //toku_brt_cursor_get_both_range will call c_getf_get_both_range_callback(..., context) (if query is successful) r = toku_brt_cursor_get_both_range(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_callback, &context); @@ -2541,6 +2576,7 @@ toku_c_getf_get_both_range_reverse(DBC *c, u_int32_t flag, DBT *key, DBT *val, Y if (c_db_is_nodup(c)) r = toku_c_getf_get_both(c, flag, key, val, f, extra); else { QUERY_CONTEXT_WITH_INPUT_S context; //Describes the context of this query. + num_point_queries++; // accountability query_context_with_input_init(&context, c, flag, key, val, f, extra); //toku_brt_cursor_get_both_range_reverse will call c_getf_get_both_range_reverse_callback(..., context) (if query is successful) r = toku_brt_cursor_get_both_range_reverse(dbc_struct_i(c)->c, key, val, c_getf_get_both_range_reverse_callback, &context); @@ -2630,6 +2666,7 @@ toku_c_getf_heaviside(DBC *c, u_int32_t flag, int r; HANDLE_PANICKED_DB(c->dbp); HANDLE_CURSOR_ILLEGAL_WORKING_PARENT_TXN(c); + num_point_queries++; // accountability HEAVI_WRAPPER_S wrapper; heavi_wrapper_init(&wrapper, h, extra_h, direction); QUERY_CONTEXT_HEAVISIDE_S context; //Describes the context of this query. @@ -2872,6 +2909,7 @@ static int toku_db_del(DB *db, DB_TXN *txn, DBT *key, u_int32_t flags) { HANDLE_PANICKED_DB(db); HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); + num_deletes++; // accountability u_int32_t unchecked_flags = flags; //DB_DELETE_ANY means delete regardless of whether it exists in the db. BOOL error_if_missing = (BOOL)(!(flags&DB_DELETE_ANY)); @@ -2978,6 +3016,7 @@ static int toku_db_delboth(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) { HANDLE_PANICKED_DB(db); HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); + num_deletes++; // accountability u_int32_t unchecked_flags = flags; //DB_DELETE_ANY means delete regardless of whether it exists in the db. BOOL error_if_missing = (BOOL)(!(flags&DB_DELETE_ANY)); @@ -3397,6 +3436,8 @@ toku_db_put(DB *db, DB_TXN *txn, DBT *key, DBT *val, u_int32_t flags) { HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN(db, txn); int r; + num_inserts++; + u_int32_t lock_flags = get_prelocked_flags(flags, txn); flags &= ~lock_flags; BOOL do_locking = (BOOL)(db->i->lt && !(lock_flags&DB_PRELOCKED_WRITE)); -- 2.30.9