Commit 78362ced authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

closes #5464 merge partitioned counters as ft-ops.cc status variables to main

git-svn-id: file:///svn/toku/tokudb@47804 c7de825b-a66e-492c-adef-691d508d4ae1
parent 921abd7d
...@@ -627,7 +627,9 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) { ...@@ -627,7 +627,9 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf(" UINT64, // interpret as uint64_t \n"); printf(" UINT64, // interpret as uint64_t \n");
printf(" CHARSTR, // interpret as char * \n"); printf(" CHARSTR, // interpret as char * \n");
printf(" UNIXTIME, // interpret as time_t \n"); printf(" UNIXTIME, // interpret as time_t \n");
printf(" TOKUTIME // interpret as tokutime_t \n"); printf(" TOKUTIME, // interpret as tokutime_t \n");
printf(" PARCOUNT, // interpret as PARTITIONED_COUNTER\n");
printf(" MAXCOUNT // interpret as MAX_PARTITIONED_COUNTER\n");
printf("} toku_engine_status_display_type; \n"); printf("} toku_engine_status_display_type; \n");
printf("typedef struct __toku_engine_status_row {\n"); printf("typedef struct __toku_engine_status_row {\n");
...@@ -637,6 +639,8 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) { ...@@ -637,6 +639,8 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf(" union { \n"); printf(" union { \n");
printf(" uint64_t num; \n"); printf(" uint64_t num; \n");
printf(" const char * str; \n"); printf(" const char * str; \n");
printf(" struct partitioned_counter *parcount;\n");
printf(" struct max_partitioned_counter *maxcount;\n");
printf(" } value; \n"); printf(" } value; \n");
printf("} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S; \n"); printf("} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S; \n");
......
...@@ -953,9 +953,9 @@ typedef enum { ...@@ -953,9 +953,9 @@ typedef enum {
FT_PARTIAL_EVICTIONS_NONLEAF, // number of nonleaf node partial evictions FT_PARTIAL_EVICTIONS_NONLEAF, // number of nonleaf node partial evictions
FT_PARTIAL_EVICTIONS_LEAF, // number of leaf node partial evictions FT_PARTIAL_EVICTIONS_LEAF, // number of leaf node partial evictions
FT_MSN_DISCARDS, // how many messages were ignored by leaf because of msn FT_MSN_DISCARDS, // how many messages were ignored by leaf because of msn
FT_MAX_WORKDONE, // max workdone value of any buffer //FT_MAX_WORKDONE, // max workdone value of any buffer
FT_TOTAL_RETRIES, // total number of search retries due to TRY_AGAIN FT_TOTAL_RETRIES, // total number of search retries due to TRY_AGAIN
FT_MAX_SEARCH_EXCESS_RETRIES, // max number of excess search retries (retries - treeheight) due to TRY_AGAIN //FT_MAX_SEARCH_EXCESS_RETRIES, // max number of excess search retries (retries - treeheight) due to TRY_AGAIN
FT_SEARCH_TRIES_GT_HEIGHT, // number of searches that required more tries than the height of the tree FT_SEARCH_TRIES_GT_HEIGHT, // number of searches that required more tries than the height of the tree
FT_SEARCH_TRIES_GT_HEIGHTPLUS3, // number of searches that required more tries than the height of the tree plus three FT_SEARCH_TRIES_GT_HEIGHTPLUS3, // number of searches that required more tries than the height of the tree plus three
FT_DISK_FLUSH_LEAF, // number of leaf nodes flushed to disk, not for checkpoint FT_DISK_FLUSH_LEAF, // number of leaf nodes flushed to disk, not for checkpoint
...@@ -969,7 +969,7 @@ typedef enum { ...@@ -969,7 +969,7 @@ typedef enum {
FT_MSG_BYTES_IN, // how many bytes of messages injected at root (for all trees) FT_MSG_BYTES_IN, // how many bytes of messages injected at root (for all trees)
FT_MSG_BYTES_OUT, // how many bytes of messages flushed from h1 nodes to leaves FT_MSG_BYTES_OUT, // how many bytes of messages flushed from h1 nodes to leaves
FT_MSG_BYTES_CURR, // how many bytes of messages currently in trees (estimate) FT_MSG_BYTES_CURR, // how many bytes of messages currently in trees (estimate)
FT_MSG_BYTES_MAX, // how many bytes of messages currently in trees (estimate) //FT_MSG_BYTES_MAX, // how many bytes of messages currently in trees (estimate)
FT_MSG_NUM, // how many messages injected at root FT_MSG_NUM, // how many messages injected at root
FT_MSG_NUM_BROADCAST, // how many broadcast messages injected at root FT_MSG_NUM_BROADCAST, // how many broadcast messages injected at root
FT_NUM_BASEMENTS_DECOMPRESSED_NORMAL, // how many basement nodes were decompressed because they were the target of a query FT_NUM_BASEMENTS_DECOMPRESSED_NORMAL, // how many basement nodes were decompressed because they were the target of a query
......
This diff is collapsed.
...@@ -253,18 +253,16 @@ static inline struct local_counter *get_thread_local_counter(uint64_t pc_key, Gr ...@@ -253,18 +253,16 @@ static inline struct local_counter *get_thread_local_counter(uint64_t pc_key, Gr
} }
} }
void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount) static struct local_counter *get_or_alloc_thread_local_counter(PARTITIONED_COUNTER pc)
// Effect: Increment the counter by amount.
// Requires: No overflows. This is a 64-bit unsigned counter.
{ {
// Only this thread is allowed to modify thread_local_array, except for setting tla->array[pc_key] to NULL // Only this thread is allowed to modify thread_local_array, except for setting tla->array[pc_key] to NULL
// when a counter is destroyed (and in that case there should be no race because no other thread should be // when a counter is destroyed (and in that case there should be no race because no other thread should be
// trying to access the same local counter at the same time. // trying to access the same local counter at the same time.
uint64_t pc_key = pc->pc_key; uint64_t pc_key = pc->pc_key;
struct local_counter *lc = get_thread_local_counter(pc_key, &thread_local_array); struct local_counter *lc = get_thread_local_counter(pc->pc_key, &thread_local_array);
if (lc==NULL) { if (__builtin_expect(!!(lc == NULL), 0)) {
XMALLOC(lc); // Might as well do the malloc without holding the pc lock. But most of the rest of this work needs the lock. XMALLOC(lc); // Might as well do the malloc without holding the pc lock. But most of the rest of this work needs the lock.
pc_lock(); pc_lock();
// Set things up so that this thread terminates, the thread-local parts of the counter will be destroyed and merged into their respective counters. // Set things up so that this thread terminates, the thread-local parts of the counter will be destroyed and merged into their respective counters.
if (!thread_local_array_inited) { if (!thread_local_array_inited) {
...@@ -274,9 +272,9 @@ void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount) ...@@ -274,9 +272,9 @@ void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount)
all_thread_local_arrays.insert(&thread_local_ll_elt, &thread_local_array); all_thread_local_arrays.insert(&thread_local_ll_elt, &thread_local_array);
} }
lc->sum = 0; lc->sum = 0;
HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&lc->sum, sizeof(lc->sum)); // the counter increment is kind of racy. HELGRIND_VALGRIND_HG_DISABLE_CHECKING(&lc->sum, sizeof(lc->sum)); // the counter increment is kind of racy.
lc->owner_pc = pc; lc->owner_pc = pc;
lc->thread_local_array = &thread_local_array; lc->thread_local_array = &thread_local_array;
// Grow the array if needed, filling in NULLs // Grow the array if needed, filling in NULLs
...@@ -285,8 +283,16 @@ void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount) ...@@ -285,8 +283,16 @@ void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount)
} }
thread_local_array.store_unchecked(pc_key, lc); thread_local_array.store_unchecked(pc_key, lc);
pc->ll_counter_head.insert(&lc->ll_in_counter, lc); pc->ll_counter_head.insert(&lc->ll_in_counter, lc);
pc_unlock(); pc_unlock();
} }
return lc;
}
void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount)
// Effect: Increment the counter by amount.
// Requires: No overflows. This is a 64-bit unsigned counter.
{
struct local_counter *lc = get_or_alloc_thread_local_counter(pc);
lc->sum += amount; lc->sum += amount;
} }
...@@ -322,9 +328,8 @@ void partitioned_counters_destroy(void) ...@@ -322,9 +328,8 @@ void partitioned_counters_destroy(void)
while (all_thread_local_arrays.pop(&a_ll)) { while (all_thread_local_arrays.pop(&a_ll)) {
a_ll->get_container()->deinit(); a_ll->get_container()->deinit();
} }
pk_delete(thread_destructor_key); pk_delete(thread_destructor_key);
destroy_counters(); destroy_counters();
pc_unlock(); pc_unlock();
} }
...@@ -41,6 +41,7 @@ const char *toku_copyright_string = "Copyright (c) 2007-2012 Tokutek Inc. All r ...@@ -41,6 +41,7 @@ const char *toku_copyright_string = "Copyright (c) 2007-2012 Tokutek Inc. All r
#include "ydb_write.h" #include "ydb_write.h"
#include "ydb_txn.h" #include "ydb_txn.h"
#include "ft/txn_manager.h" #include "ft/txn_manager.h"
#include "ft/partitioned_counter.h"
// Include ydb_lib.cc here so that its constructor/destructor gets put into // Include ydb_lib.cc here so that its constructor/destructor gets put into
// ydb.o, to make sure they don't get erased at link time (when linking to // ydb.o, to make sure they don't get erased at link time (when linking to
...@@ -2083,6 +2084,18 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { ...@@ -2083,6 +2084,18 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) {
n += snprintf(buff + n, bufsiz - n, "%.6f\n", t); n += snprintf(buff + n, bufsiz - n, "%.6f\n", t);
} }
break; break;
case PARCOUNT:
{
uint64_t v = read_partitioned_counter(mystat[row].value.parcount);
n += snprintf(buff + n, bufsiz - n, "%" PRIu64 "\n", v);
}
#if 0
case MAXCOUNT:
{
uint64_t v = read_max_partitioned_counter(mystat[row].value.maxcount);
n += snprintf(buff + n, bufsiz - n, "%" PRIu64 "\n", v);
}
#endif
default: default:
n += snprintf(buff + n, bufsiz - n, "UNKNOWN STATUS TYPE: %d\n", mystat[row].type); n += snprintf(buff + n, bufsiz - n, "UNKNOWN STATUS TYPE: %d\n", mystat[row].type);
break; break;
......
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