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__))) {
printf(" UINT64, // interpret as uint64_t \n");
printf(" CHARSTR, // interpret as char * \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("typedef struct __toku_engine_status_row {\n");
......@@ -637,6 +639,8 @@ int main (int argc, char *const argv[] __attribute__((__unused__))) {
printf(" union { \n");
printf(" uint64_t num; \n");
printf(" const char * str; \n");
printf(" struct partitioned_counter *parcount;\n");
printf(" struct max_partitioned_counter *maxcount;\n");
printf(" } value; \n");
printf("} * TOKU_ENGINE_STATUS_ROW, TOKU_ENGINE_STATUS_ROW_S; \n");
......
......@@ -953,9 +953,9 @@ typedef enum {
FT_PARTIAL_EVICTIONS_NONLEAF, // number of nonleaf 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_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_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_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
......@@ -969,7 +969,7 @@ typedef enum {
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_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_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
......
This diff is collapsed.
......@@ -253,16 +253,14 @@ static inline struct local_counter *get_thread_local_counter(uint64_t pc_key, Gr
}
}
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.
static struct local_counter *get_or_alloc_thread_local_counter(PARTITIONED_COUNTER pc)
{
// 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
// trying to access the same local counter at the same time.
uint64_t pc_key = pc->pc_key;
struct local_counter *lc = get_thread_local_counter(pc_key, &thread_local_array);
if (lc==NULL) {
struct local_counter *lc = get_thread_local_counter(pc->pc_key, &thread_local_array);
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.
pc_lock();
......@@ -287,6 +285,14 @@ void increment_partitioned_counter(PARTITIONED_COUNTER pc, uint64_t amount)
pc->ll_counter_head.insert(&lc->ll_in_counter, lc);
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;
}
......@@ -327,4 +333,3 @@ void partitioned_counters_destroy(void)
destroy_counters();
pc_unlock();
}
......@@ -41,6 +41,7 @@ const char *toku_copyright_string = "Copyright (c) 2007-2012 Tokutek Inc. All r
#include "ydb_write.h"
#include "ydb_txn.h"
#include "ft/txn_manager.h"
#include "ft/partitioned_counter.h"
// 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
......@@ -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);
}
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:
n += snprintf(buff + n, bufsiz - n, "UNKNOWN STATUS TYPE: %d\n", mystat[row].type);
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