summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--items.c25
-rw-r--r--logger.c5
-rw-r--r--logger.h3
-rw-r--r--memcached.c2
4 files changed, 24 insertions, 11 deletions
diff --git a/items.c b/items.c
index c3023d3..7f1246a 100644
--- a/items.c
+++ b/items.c
@@ -1052,7 +1052,7 @@ static int lru_maintainer_juggle(const int slabs_clsid) {
* The latter is to avoid newly started daemons from waiting too long before
* retrying a crawl.
*/
-static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata) {
+static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata, logger *l) {
int i;
static rel_time_t next_crawls[MAX_NUMBER_OF_SLAB_CLASSES];
static rel_time_t next_crawl_wait[MAX_NUMBER_OF_SLAB_CLASSES];
@@ -1078,10 +1078,6 @@ static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata) {
uint64_t low_watermark = (s->seen / 100) + 1;
rel_time_t since_run = current_time - s->end_time;
/* Don't bother if the payoff is too low. */
- if (settings.verbose > 1)
- fprintf(stderr, "maint crawler[%d]: low_watermark: %llu, possible_reclaims: %llu, since_run: %u\n",
- i, (unsigned long long)low_watermark, (unsigned long long)possible_reclaims,
- (unsigned int)since_run);
for (x = 0; x < 60; x++) {
available_reclaims += s->histo[x];
if (available_reclaims > low_watermark) {
@@ -1103,9 +1099,14 @@ static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata) {
}
next_crawls[i] = current_time + next_crawl_wait[i] + 5;
- if (settings.verbose > 1)
- fprintf(stderr, "maint crawler[%d]: next_crawl: %u, [%d] now: [%d]\n",
- i, next_crawl_wait[i], next_crawls[i], current_time);
+ LOGGER_LOG(l, LOG_SYSEVENTS, LOGGER_CRAWLER_STATUS, NULL, i, (unsigned long long)low_watermark,
+ (unsigned long long)possible_reclaims,
+ (unsigned int)since_run,
+ next_crawls[i],
+ current_time,
+ s->end_time - s->start_time,
+ s->seen,
+ s->reclaimed);
// Got our calculation, avoid running until next actual run.
s->run_complete = false;
pthread_mutex_unlock(&cdata->lock);
@@ -1134,6 +1135,11 @@ static void *lru_maintainer_thread(void *arg) {
memset(&cdata, 0, sizeof(struct crawler_expired_data));
pthread_mutex_init(&cdata.lock, NULL);
cdata.crawl_complete = true; // kick off the crawler.
+ logger *l = logger_create();
+ if (l == NULL) {
+ fprintf(stderr, "Failed to allocate logger for LRU maintainer thread\n");
+ abort();
+ }
pthread_mutex_lock(&lru_maintainer_lock);
if (settings.verbose > 2)
@@ -1167,7 +1173,7 @@ static void *lru_maintainer_thread(void *arg) {
}
/* Once per second at most */
if (settings.lru_crawler && last_crawler_check != current_time) {
- lru_maintainer_crawler_check(&cdata);
+ lru_maintainer_crawler_check(&cdata, l);
last_crawler_check = current_time;
}
}
@@ -1177,6 +1183,7 @@ static void *lru_maintainer_thread(void *arg) {
return NULL;
}
+
int stop_lru_maintainer_thread(void) {
int ret;
pthread_mutex_lock(&lru_maintainer_lock);
diff --git a/logger.c b/logger.c
index 4499276..dfb89b6 100644
--- a/logger.c
+++ b/logger.c
@@ -48,7 +48,10 @@ static const entry_details default_entries[] = {
[LOGGER_ASCII_CMD] = {LOGGER_TEXT_ENTRY, 512, LOG_RAWCMDS, "<%d %s"},
[LOGGER_EVICTION] = {LOGGER_EVICTION_ENTRY, 512, LOG_EVICTIONS, NULL},
[LOGGER_ITEM_GET] = {LOGGER_ITEM_GET_ENTRY, 512, LOG_FETCHERS, NULL},
- [LOGGER_ITEM_STORE] = {LOGGER_ITEM_STORE_ENTRY, 512, LOG_MUTATIONS, NULL}
+ [LOGGER_ITEM_STORE] = {LOGGER_ITEM_STORE_ENTRY, 512, LOG_MUTATIONS, NULL},
+ [LOGGER_CRAWLER_STATUS] = {LOGGER_TEXT_ENTRY, 512, LOG_SYSEVENTS,
+ "lru_crawler=%d low_mark=%llu possible_reclaims=%llu since_run=%u next_run=%d now=%d time_elapsed=%u examined=%llu reclaimed=%llu"
+ }
};
#define WATCHER_ALL -1
diff --git a/logger.h b/logger.h
index 6d95d40..6b6907a 100644
--- a/logger.h
+++ b/logger.h
@@ -14,7 +14,8 @@ enum log_entry_type {
LOGGER_ASCII_CMD = 0,
LOGGER_EVICTION,
LOGGER_ITEM_GET,
- LOGGER_ITEM_STORE
+ LOGGER_ITEM_STORE,
+ LOGGER_CRAWLER_STATUS,
};
enum log_entry_subtype {
diff --git a/memcached.c b/memcached.c
index 490aaea..6f2e484 100644
--- a/memcached.c
+++ b/memcached.c
@@ -3772,6 +3772,8 @@ static void process_watch_command(conn *c, token_t *tokens, const size_t ntokens
f |= LOG_FETCHERS;
} else if ((strcmp(tokens[x].value, "mutations") == 0)) {
f |= LOG_MUTATIONS;
+ } else if ((strcmp(tokens[x].value, "sysevents") == 0)) {
+ f |= LOG_SYSEVENTS;
} else {
out_string(c, "ERROR");
return;