Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ static void logger_thread_sum_stats(struct logger_stats *ls) {
STATS_UNLOCK();
}

#define MAX_LOGGER_SLEEP 1000000
#define MIN_LOGGER_SLEEP 1000

/* Primary logger thread routine */
Expand Down Expand Up @@ -541,10 +540,10 @@ static void *logger_thread(void *arg) {

/* TODO: abstract into a function and share with lru_crawler */
if (!found_logs) {
if (to_sleep < MAX_LOGGER_SLEEP)
if (to_sleep < settings.logger_max_sleep)
to_sleep += to_sleep / 8;
if (to_sleep > MAX_LOGGER_SLEEP)
to_sleep = MAX_LOGGER_SLEEP;
if (to_sleep > settings.logger_max_sleep)
to_sleep = settings.logger_max_sleep;
} else {
to_sleep /= 2;
if (to_sleep < MIN_LOGGER_SLEEP)
Expand Down
15 changes: 15 additions & 0 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ static void settings_init(void) {
settings.crawls_persleep = 1000;
settings.logger_watcher_buf_size = LOGGER_WATCHER_BUF_SIZE;
settings.logger_buf_size = LOGGER_BUF_SIZE;
settings.logger_max_sleep = 1000000;
settings.drop_privileges = false;
settings.watch_enabled = true;
settings.read_buf_mem_limit = 0;
Expand Down Expand Up @@ -3885,6 +3886,7 @@ static void usage(void) {
" - watcher_logbuf_size: size in kilobytes of per-watcher write buffer. (default: %u)\n"
" - worker_logbuf_size: size in kilobytes of per-worker-thread buffer\n"
" read by background thread, then written to watchers. (default: %u)\n"
" - logger_max_sleep: time in miliseconds of logger maximum sleep.\n"
" - track_sizes: enable dynamic reports for 'stats sizes' command.\n"
" - no_hashexpand: disables hash table expansion (dangerous)\n"
" - modern: enables options which will be default in future.\n"
Expand Down Expand Up @@ -4553,6 +4555,7 @@ int main (int argc, char **argv) {
IDLE_TIMEOUT,
WATCHER_LOGBUF_SIZE,
WORKER_LOGBUF_SIZE,
LOGGER_MAX_SLEEP,
SLAB_SIZES,
SLAB_CHUNK_MAX,
TRACK_SIZES,
Expand Down Expand Up @@ -4606,6 +4609,7 @@ int main (int argc, char **argv) {
[IDLE_TIMEOUT] = "idle_timeout",
[WATCHER_LOGBUF_SIZE] = "watcher_logbuf_size",
[WORKER_LOGBUF_SIZE] = "worker_logbuf_size",
[LOGGER_MAX_SLEEP] = "logger_max_sleep",
[SLAB_SIZES] = "slab_sizes",
[SLAB_CHUNK_MAX] = "slab_chunk_max",
[TRACK_SIZES] = "track_sizes",
Expand Down Expand Up @@ -5181,6 +5185,17 @@ int main (int argc, char **argv) {
case SLAB_SIZES:
slab_sizes_unparsed = strdup(subopts_value);
break;
case LOGGER_MAX_SLEEP:
if (subopts_value == NULL) {
fprintf(stderr, "Missing logger_max_sleep argument\n");
return 1;
}
if (!safe_strtoul(subopts_value, &settings.logger_max_sleep)) {
fprintf(stderr, "could not parse argument to logger_max_sleep\n");
return 1;
}
settings.logger_max_sleep *= 1000; /* microseconds */
break;
case SLAB_CHUNK_MAX:
if (subopts_value == NULL) {
fprintf(stderr, "Missing slab_chunk_max argument\n");
Expand Down
1 change: 1 addition & 0 deletions memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ struct settings {
int idle_timeout; /* Number of seconds to let connections idle */
unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */
unsigned int logger_buf_size; /* size of per-thread logger buffer */
unsigned int logger_max_sleep; /* max sleep time of logger */
unsigned int read_buf_mem_limit; /* total megabytes allowable for net buffers */
bool drop_privileges; /* Whether or not to drop unnecessary process privileges */
bool watch_enabled; /* allows watch commands to be dropped */
Expand Down