summaryrefslogtreecommitdiff
path: root/storage.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-11-28 17:56:20 -0800
committerdormando <dormando@rydia.net>2017-11-28 17:56:20 -0800
commit81c83e803d2be797f70147e7214b2382ecadb5fc (patch)
tree54a625358371781fbbc26ac8871d960b6f0b682a /storage.c
parent9716994daec8b30844c5c9bb8ee69f2dba031929 (diff)
downloadmemcached-81c83e803d2be797f70147e7214b2382ecadb5fc.tar.gz
extstore: add ext_drop_unread option + live tune
was struggling to figure out how to automatically turn this on or off, but I think it should be part of an outside process. ie; a mechanism should be able to target a specific write rate, and one of its tools for reducing the write rate should be flipping this on. there's *still* a hole where you can't trigger a compaction attempt if there's no fragmentation. I kind of want, if this feature is on, to attempt a compaction on the oldest page while dropping unread items.
Diffstat (limited to 'storage.c')
-rw-r--r--storage.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/storage.c b/storage.c
index aee0dbe..f2d4263 100644
--- a/storage.c
+++ b/storage.c
@@ -130,7 +130,7 @@ int lru_maintainer_store(void *storage, const int clsid) {
*/
static int storage_compact_check(void *storage, logger *l,
uint32_t *page_id, uint64_t *page_version,
- uint64_t *page_size, bool *drop_unread) {
+ uint64_t *page_size) {
struct extstore_stats st;
int x;
double rate;
@@ -148,10 +148,6 @@ static int storage_compact_check(void *storage, logger *l,
// the number of free pages reduces the configured frag limit
// this allows us to defrag early if pages are very empty.
rate = 1.0 - ((double)st.pages_free / st.page_count);
- // if we're nearly out of pages, drop more data ahead of eviction.
- if (st.pages_free < 2) {
- *drop_unread = true;
- }
rate *= settings.ext_max_frag;
frag_limit = st.page_size * rate;
LOGGER_LOG(l, LOG_SYSEVENTS, LOGGER_COMPACT_FRAGINFO,
@@ -348,9 +344,11 @@ static void *storage_compact_thread(void *arg) {
pthread_mutex_lock(&storage_compact_plock);
if (!compacting && storage_compact_check(storage, l,
- &page_id, &page_version, &page_size, &drop_unread)) {
+ &page_id, &page_version, &page_size)) {
page_offset = 0;
compacting = true;
+ // only allow this to flip inbetween compactions.
+ drop_unread = settings.ext_drop_unread;
LOGGER_LOG(l, LOG_SYSEVENTS, LOGGER_COMPACT_START,
NULL, page_id, page_version);
}
@@ -385,7 +383,6 @@ static void *storage_compact_thread(void *arg) {
compacting = false;
wrap.done = false;
wrap.submitted = false;
- drop_unread = false;
extstore_close_page(storage, page_id, page_version);
LOGGER_LOG(l, LOG_SYSEVENTS, LOGGER_COMPACT_END,
NULL, page_id);