Commit 423010b5 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Addresses 1792 refs[t:1792] Further implementation of show engine status

git-svn-id: file:///svn/toku/tokudb@14742 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1dfd8acc
...@@ -49,13 +49,15 @@ static void cachetable_reader(WORKITEM); ...@@ -49,13 +49,15 @@ static void cachetable_reader(WORKITEM);
static u_int64_t cachetable_hit; static u_int64_t cachetable_hit;
static u_int64_t cachetable_miss; static u_int64_t cachetable_miss;
static u_int64_t cachetable_wait_reading; static u_int64_t cachetable_wait_reading; // how many times does get_and_pin() wait for a node to be read?
static u_int64_t cachetable_wait; static u_int64_t cachetable_wait_writing; // how many times does get_and_pin() wait for a node to be written?
#if TOKU_DO_WAIT_TIME #if TOKU_DO_WAIT_TIME
static u_int64_t cachetable_miss_time; static u_int64_t cachetable_miss_time;
static u_int64_t cachetable_wait_time; static u_int64_t cachetable_wait_time;
#endif #endif
static u_int32_t cachetable_lock_ctr = 0;
enum ctpair_state { enum ctpair_state {
CTPAIR_INVALID = 0, // invalid CTPAIR_INVALID = 0, // invalid
CTPAIR_IDLE = 1, // in memory CTPAIR_IDLE = 1, // in memory
...@@ -135,9 +137,9 @@ struct cachetable { ...@@ -135,9 +137,9 @@ struct cachetable {
PAIR head,tail; // of LRU list. head is the most recently used. tail is least recently used. PAIR head,tail; // of LRU list. head is the most recently used. tail is least recently used.
CACHEFILE cachefiles; // list of cachefiles that use this cachetable CACHEFILE cachefiles; // list of cachefiles that use this cachetable
CACHEFILE cachefiles_in_checkpoint; //list of cachefiles included in checkpoint in progress CACHEFILE cachefiles_in_checkpoint; //list of cachefiles included in checkpoint in progress
long size_current; // the sum of the sizes of the pairs in the cachetable int64_t size_current; // the sum of the sizes of the pairs in the cachetable
long size_limit; // the limit to the sum of the pair sizes int64_t size_limit; // the limit to the sum of the pair sizes
long size_writing; // the sum of the sizes of the pairs being written int64_t size_writing; // the sum of the sizes of the pairs being written
TOKULOGGER logger; TOKULOGGER logger;
toku_pthread_mutex_t *mutex; // coarse lock that protects the cachetable, the cachefiles, and the pairs toku_pthread_mutex_t *mutex; // coarse lock that protects the cachetable, the cachefiles, and the pairs
struct workqueue wq; // async work queue struct workqueue wq; // async work queue
...@@ -149,16 +151,19 @@ struct cachetable { ...@@ -149,16 +151,19 @@ struct cachetable {
toku_pthread_mutex_t openfd_mutex; // make toku_cachetable_openfd() single-threaded toku_pthread_mutex_t openfd_mutex; // make toku_cachetable_openfd() single-threaded
}; };
// Lock the cachetable // Lock the cachetable
static inline void cachetable_lock(CACHETABLE ct __attribute__((unused))) { static inline void cachetable_lock(CACHETABLE ct __attribute__((unused))) {
#if DO_CACHETABLE_LOCK #if DO_CACHETABLE_LOCK
int r = toku_pthread_mutex_lock(ct->mutex); assert(r == 0); int r = toku_pthread_mutex_lock(ct->mutex); assert(r == 0);
cachetable_lock_ctr++;
#endif #endif
} }
// Unlock the cachetable // Unlock the cachetable
static inline void cachetable_unlock(CACHETABLE ct __attribute__((unused))) { static inline void cachetable_unlock(CACHETABLE ct __attribute__((unused))) {
#if DO_CACHETABLE_LOCK #if DO_CACHETABLE_LOCK
cachetable_lock_ctr++;
int r = toku_pthread_mutex_unlock(ct->mutex); assert(r == 0); int r = toku_pthread_mutex_unlock(ct->mutex); assert(r == 0);
#endif #endif
} }
...@@ -924,7 +929,7 @@ void toku_cachetable_print_hash_histogram (void) { ...@@ -924,7 +929,7 @@ void toku_cachetable_print_hash_histogram (void) {
if (hash_histogram[i]) printf("%d:%llu ", i, hash_histogram[i]); if (hash_histogram[i]) printf("%d:%llu ", i, hash_histogram[i]);
printf("\n"); printf("\n");
printf("miss=%"PRIu64" hit=%"PRIu64" wait_reading=%"PRIu64" wait=%"PRIu64"\n", printf("miss=%"PRIu64" hit=%"PRIu64" wait_reading=%"PRIu64" wait=%"PRIu64"\n",
cachetable_miss, cachetable_hit, cachetable_wait_reading, cachetable_wait); cachetable_miss, cachetable_hit, cachetable_wait_reading, cachetable_wait_writing);
} }
static void static void
...@@ -1047,7 +1052,7 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful ...@@ -1047,7 +1052,7 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful
if (p->state == CTPAIR_READING) if (p->state == CTPAIR_READING)
cachetable_wait_reading++; cachetable_wait_reading++;
else else
cachetable_wait++; cachetable_wait_writing++;
#if TOKU_DO_WAIT_TIME #if TOKU_DO_WAIT_TIME
do_wait_time = 1; do_wait_time = 1;
gettimeofday(&t0, NULL); gettimeofday(&t0, NULL);
...@@ -1931,3 +1936,13 @@ toku_cachefile_size_in_memory(CACHEFILE cf) ...@@ -1931,3 +1936,13 @@ toku_cachefile_size_in_memory(CACHEFILE cf)
return result; return result;
} }
void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s) {
s->lock_ctr = cachetable_lock_ctr;
s->hit = cachetable_hit;
s->miss = cachetable_miss;
s->wait_reading = cachetable_wait_reading;
s->wait_writing = cachetable_wait_writing;
s->size_current = ct->size_current;
s->size_limit = ct->size_limit;
s->size_writing = ct->size_writing;
}
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef CACHETABLE_H #ifndef CACHETABLE_H
#define CACHETABLE_H #define CACHETABLE_H
...@@ -241,4 +242,18 @@ void toku_cachetable_maybe_flush_some(CACHETABLE ct); ...@@ -241,4 +242,18 @@ void toku_cachetable_maybe_flush_some(CACHETABLE ct);
u_int64_t toku_cachefile_size_in_memory(CACHEFILE cf); u_int64_t toku_cachefile_size_in_memory(CACHEFILE cf);
typedef struct cachetable_status {
u_int32_t lock_ctr;
u_int64_t hit;
u_int64_t miss;
u_int64_t wait_reading;
u_int64_t wait_writing;
int64_t size_current; // the sum of the sizes of the pairs in the cachetable
int64_t size_limit; // the limit to the sum of the pair sizes
int64_t size_writing; // the sum of the sizes of the pairs being written
} CACHETABLE_STATUS_S, *CACHETABLE_STATUS;
void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s);
#endif #endif
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#include "checkpoint.h" #include "checkpoint.h"
// footprint for debugging and status reporting only // footprint for debugging and status reporting only
static u_int64_t checkpoint_footprint = 0; static u_int32_t checkpoint_footprint = 0;
static toku_pthread_rwlock_t checkpoint_safe_lock; static toku_pthread_rwlock_t checkpoint_safe_lock;
static toku_pthread_rwlock_t multi_operation_lock; static toku_pthread_rwlock_t multi_operation_lock;
...@@ -154,7 +154,7 @@ toku_checkpoint_safe_client_unlock(void) { ...@@ -154,7 +154,7 @@ toku_checkpoint_safe_client_unlock(void) {
} }
u_int64_t u_int32_t
toku_checkpoint_get_footprint(void) { toku_checkpoint_get_footprint(void) {
return checkpoint_footprint; return checkpoint_footprint;
} }
......
...@@ -67,5 +67,5 @@ int toku_checkpoint(CACHETABLE ct, TOKULOGGER logger, char **error_string, ...@@ -67,5 +67,5 @@ int toku_checkpoint(CACHETABLE ct, TOKULOGGER logger, char **error_string,
* (If checkpoint is in progress, it may overwrite status info while it is being read.) * (If checkpoint is in progress, it may overwrite status info while it is being read.)
*****/ *****/
u_int64_t toku_checkpoint_get_footprint(void); u_int32_t toku_checkpoint_get_footprint(void);
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