Commit bffc3219 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3836 add cachetable eviction counter to engine status refs[t:3836]

git-svn-id: file:///svn/toku/tokudb@33558 c7de825b-a66e-492c-adef-691d508d4ae1
parent f52e7b1f
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -491,6 +491,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ ...@@ -491,6 +491,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf(" u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ \n"); printf(" u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ \n");
printf(" u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ \n"); printf(" u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ \n");
printf(" u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ \n"); printf(" u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ \n");
printf(" u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */ \n");
printf(" u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ \n"); printf(" u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ \n");
printf(" u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ \n"); printf(" u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ \n");
printf(" u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ \n"); printf(" u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ \n");
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status { ...@@ -99,6 +99,7 @@ typedef struct __toku_engine_status {
u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */ u_int64_t cachetable_wait_reading; /* how many times get_and_pin waits for a node to be read */
u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */ u_int64_t cachetable_wait_writing; /* how many times get_and_pin waits for a node to be written */
u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/ u_int64_t cachetable_wait_checkpoint; /* how many times get_and_pin waits for a node to be written for a checkpoint*/
u_int64_t cachetable_evictions; /* how many cache table blocks are evicted */
u_int64_t puts; /* how many times has a newly created node been put into the cachetable */ u_int64_t puts; /* how many times has a newly created node been put into the cachetable */
u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */ u_int64_t prefetches; /* how many times has a block been prefetched into the cachetable */
u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */ u_int64_t maybe_get_and_pins; /* how many times has maybe_get_and_pin(_clean) been called */
......
...@@ -51,7 +51,7 @@ static u_int64_t cachetable_lock_released = 0; ...@@ -51,7 +51,7 @@ static u_int64_t cachetable_lock_released = 0;
static u_int64_t local_checkpoint; // number of times a local checkpoint was taken for a commit (2440) static u_int64_t local_checkpoint; // number of times a local checkpoint was taken for a commit (2440)
static u_int64_t local_checkpoint_files; // number of files subject to local checkpoint taken for a commit (2440) static u_int64_t local_checkpoint_files; // number of files subject to local checkpoint taken for a commit (2440)
static u_int64_t local_checkpoint_during_checkpoint; // number of times a local checkpoint happened during normal checkpoint (2440) static u_int64_t local_checkpoint_during_checkpoint; // number of times a local checkpoint happened during normal checkpoint (2440)
static u_int64_t cachetable_evictions;
enum ctpair_state { enum ctpair_state {
...@@ -1069,6 +1069,7 @@ static void cachetable_maybe_remove_and_free_pair (CACHETABLE ct, PAIR p) { ...@@ -1069,6 +1069,7 @@ static void cachetable_maybe_remove_and_free_pair (CACHETABLE ct, PAIR p) {
long size = p->size; long size = p->size;
rwlock_prefer_read_lock(&cachefile->fdlock, ct->mutex); rwlock_prefer_read_lock(&cachefile->fdlock, ct->mutex);
cachetable_evictions++;
cachetable_unlock(ct); cachetable_unlock(ct);
flush_callback(cachefile, cachefile->fd, key, value, write_extraargs, size, FALSE, FALSE, TRUE); flush_callback(cachefile, cachefile->fd, key, value, write_extraargs, size, FALSE, FALSE, TRUE);
...@@ -1964,7 +1965,6 @@ int toku_cachetable_get_and_pin_nonblocking ( ...@@ -1964,7 +1965,6 @@ int toku_cachetable_get_and_pin_nonblocking (
case CTPAIR_READING: case CTPAIR_READING:
case CTPAIR_WRITING: case CTPAIR_WRITING:
wait_on_io: wait_on_io:
cachetable_miss++;
run_unlockers(unlockers); // The contract says the unlockers are run with the ct lock being held. run_unlockers(unlockers); // The contract says the unlockers are run with the ct lock being held.
if (ct->ydb_unlock_callback) ct->ydb_unlock_callback(); if (ct->ydb_unlock_callback) ct->ydb_unlock_callback();
// Now wait for the I/O to occur. // Now wait for the I/O to occur.
...@@ -1980,13 +1980,15 @@ int toku_cachetable_get_and_pin_nonblocking ( ...@@ -1980,13 +1980,15 @@ int toku_cachetable_get_and_pin_nonblocking (
assert(p==0); assert(p==0);
// Not found // Not found
cachetable_miss++;
p = cachetable_insert_at(ct, cf, key, zero_value, CTPAIR_READING, fullhash, zero_size, flush_callback, pe_callback, write_extraargs, CACHETABLE_CLEAN); p = cachetable_insert_at(ct, cf, key, zero_value, CTPAIR_READING, fullhash, zero_size, flush_callback, pe_callback, write_extraargs, CACHETABLE_CLEAN);
assert(p); assert(p);
rwlock_write_lock(&p->rwlock, ct->mutex); rwlock_write_lock(&p->rwlock, ct->mutex);
run_unlockers(unlockers); // we hold the ct mutex. run_unlockers(unlockers); // we hold the ct mutex.
if (ct->ydb_unlock_callback) ct->ydb_unlock_callback(); if (ct->ydb_unlock_callback) ct->ydb_unlock_callback();
u_int64_t t0 = get_tnow();
int r = cachetable_fetch_pair(ct, cf, p, fetch_callback, read_extraargs); int r = cachetable_fetch_pair(ct, cf, p, fetch_callback, read_extraargs);
cachetable_miss++;
cachetable_misstime += get_tnow() - t0;
cachetable_unlock(ct); cachetable_unlock(ct);
if (ct->ydb_lock_callback) ct->ydb_lock_callback(); if (ct->ydb_lock_callback) ct->ydb_lock_callback();
if (r!=0) return r; if (r!=0) return r;
...@@ -2319,13 +2321,6 @@ toku_cachetable_close (CACHETABLE *ctp) { ...@@ -2319,13 +2321,6 @@ toku_cachetable_close (CACHETABLE *ctp) {
return 0; return 0;
} }
void toku_cachetable_get_miss_times(CACHETABLE UU(ct), uint64_t *misscount, uint64_t *misstime) {
if (misscount)
*misscount = cachetable_miss;
if (misstime)
*misstime = cachetable_misstime;
}
int toku_cachetable_unpin_and_remove (CACHEFILE cachefile, CACHEKEY key) { int toku_cachetable_unpin_and_remove (CACHEFILE cachefile, CACHEKEY key) {
int r = ENOENT; int r = ENOENT;
// Removing something already present is OK. // Removing something already present is OK.
...@@ -2955,6 +2950,7 @@ void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s) { ...@@ -2955,6 +2950,7 @@ void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s) {
s->local_checkpoint = local_checkpoint; s->local_checkpoint = local_checkpoint;
s->local_checkpoint_files = local_checkpoint_files; s->local_checkpoint_files = local_checkpoint_files;
s->local_checkpoint_during_checkpoint = local_checkpoint_during_checkpoint; s->local_checkpoint_during_checkpoint = local_checkpoint_during_checkpoint;
s->evictions = cachetable_evictions;
} }
char * char *
......
...@@ -66,9 +66,6 @@ void toku_cachetable_minicron_shutdown(CACHETABLE ct); ...@@ -66,9 +66,6 @@ void toku_cachetable_minicron_shutdown(CACHETABLE ct);
// Effects: All of the memory objects are flushed to disk, and the cachetable is destroyed. // Effects: All of the memory objects are flushed to disk, and the cachetable is destroyed.
int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */ int toku_cachetable_close (CACHETABLE*); /* Flushes everything to disk, and destroys the cachetable. */
// Get the number of cachetable misses (in misscount) and the accumulated time waiting for reads (in misstime, units of microseconds)
void toku_cachetable_get_miss_times(CACHETABLE ct, uint64_t *misscount, uint64_t *misstime);
// Open a file and bind the file to a new cachefile object. (For use by test programs only.) // Open a file and bind the file to a new cachefile object. (For use by test programs only.)
int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname_in_env*/, int flags, mode_t mode); int toku_cachetable_openf (CACHEFILE *,CACHETABLE, const char */*fname_in_env*/, int flags, mode_t mode);
...@@ -414,6 +411,7 @@ typedef struct cachetable_status { ...@@ -414,6 +411,7 @@ typedef struct cachetable_status {
uint64_t local_checkpoint; // number of times a local checkpoint was taken for a commit (2440) uint64_t local_checkpoint; // number of times a local checkpoint was taken for a commit (2440)
uint64_t local_checkpoint_files; // number of files subject to local checkpoint taken for a commit (2440) uint64_t local_checkpoint_files; // number of files subject to local checkpoint taken for a commit (2440)
uint64_t local_checkpoint_during_checkpoint; // number of times a local checkpoint happened during normal checkpoint (2440) uint64_t local_checkpoint_during_checkpoint; // number of times a local checkpoint happened during normal checkpoint (2440)
u_int64_t evictions;
} CACHETABLE_STATUS_S, *CACHETABLE_STATUS; } CACHETABLE_STATUS_S, *CACHETABLE_STATUS;
void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s); void toku_cachetable_get_status(CACHETABLE ct, CACHETABLE_STATUS s);
......
...@@ -1880,6 +1880,7 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat, char * env_panic_st ...@@ -1880,6 +1880,7 @@ env_get_engine_status(DB_ENV * env, ENGINE_STATUS * engstat, char * env_panic_st
engstat->local_checkpoint = ctstat.local_checkpoint; engstat->local_checkpoint = ctstat.local_checkpoint;
engstat->local_checkpoint_files = ctstat.local_checkpoint_files; engstat->local_checkpoint_files = ctstat.local_checkpoint_files;
engstat->local_checkpoint_during_checkpoint = ctstat.local_checkpoint_during_checkpoint; engstat->local_checkpoint_during_checkpoint = ctstat.local_checkpoint_during_checkpoint;
engstat->cachetable_evictions = ctstat.evictions;
} }
{ {
toku_ltm* ltm = env->i->ltm; toku_ltm* ltm = env->i->ltm;
...@@ -2089,6 +2090,7 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) { ...@@ -2089,6 +2090,7 @@ env_get_engine_status_text(DB_ENV * env, char * buff, int bufsiz) {
n += snprintf(buff + n, bufsiz - n, "cachetable_waittime %"PRIu64"\n", engstat.cachetable_waittime); n += snprintf(buff + n, bufsiz - n, "cachetable_waittime %"PRIu64"\n", engstat.cachetable_waittime);
n += snprintf(buff + n, bufsiz - n, "cachetable_wait_reading %"PRIu64"\n", engstat.cachetable_wait_reading); n += snprintf(buff + n, bufsiz - n, "cachetable_wait_reading %"PRIu64"\n", engstat.cachetable_wait_reading);
n += snprintf(buff + n, bufsiz - n, "cachetable_wait_writing %"PRIu64"\n", engstat.cachetable_wait_writing); n += snprintf(buff + n, bufsiz - n, "cachetable_wait_writing %"PRIu64"\n", engstat.cachetable_wait_writing);
n += snprintf(buff + n, bufsiz - n, "cachetable_evictions %"PRIu64"\n", engstat.cachetable_evictions);
n += snprintf(buff + n, bufsiz - n, "puts %"PRIu64"\n", engstat.puts); n += snprintf(buff + n, bufsiz - n, "puts %"PRIu64"\n", engstat.puts);
n += snprintf(buff + n, bufsiz - n, "prefetches %"PRIu64"\n", engstat.prefetches); n += snprintf(buff + n, bufsiz - n, "prefetches %"PRIu64"\n", engstat.prefetches);
n += snprintf(buff + n, bufsiz - n, "maybe_get_and_pins %"PRIu64"\n", engstat.maybe_get_and_pins); n += snprintf(buff + n, bufsiz - n, "maybe_get_and_pins %"PRIu64"\n", engstat.maybe_get_and_pins);
......
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