summaryrefslogtreecommitdiff
path: root/storage.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-12-15 15:06:24 -0800
committerdormando <dormando@rydia.net>2017-12-15 15:06:24 -0800
commitb6f7b55eea7dba509292c8d88ede43e1dd592259 (patch)
treeb83c1227aaed30aa44a8ed48fed4d4e51264db69 /storage.c
parenta78d168f6d82c8b6e073dc8c89b80e988eafe657 (diff)
downloadmemcached-b6f7b55eea7dba509292c8d88ede43e1dd592259.tar.gz
extstore: tuning drop_unread semantics
there's now an optional ext_drop_under setting which defaults to the same as compact_under, which should be fine. now, if drop_unread is enabled, it only kicks in if there are no pages matching the compaction threshold. This allows you to set a lower compaction frag rate, then start rescuing only non-COLD items if storage is too full. You can also compact up to a point, then allow a buffer of pages to be used before dropping unread. previously enabling drop_unread would always drop_unread even when compacting normally. This limited utility of the feature.
Diffstat (limited to 'storage.c')
-rw-r--r--storage.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/storage.c b/storage.c
index 2f378bf..648ef35 100644
--- a/storage.c
+++ b/storage.c
@@ -131,7 +131,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) {
+ uint64_t *page_size, bool *drop_unread) {
struct extstore_stats st;
int x;
double rate;
@@ -147,6 +147,7 @@ static int storage_compact_check(void *storage, logger *l,
// lets pick a target "wasted" value and slew.
if (st.pages_free > settings.ext_compact_under)
return 0;
+ *drop_unread = false;
// the number of free pages reduces the configured frag limit
// this allows us to defrag early if pages are very empty.
@@ -182,11 +183,13 @@ static int storage_compact_check(void *storage, logger *l,
*page_id = low_page;
*page_version = low_version;
return 1;
- } else if (lowest_version != ULLONG_MAX && settings.ext_drop_unread) {
+ } else if (lowest_version != ULLONG_MAX && settings.ext_drop_unread
+ && st.pages_free <= settings.ext_drop_under) {
// nothing matched the frag rate barrier, so pick the absolute oldest
// version if we're configured to drop items.
*page_id = lowest_page;
*page_version = lowest_version;
+ *drop_unread = true;
return 1;
}
@@ -358,11 +361,9 @@ 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)) {
+ &page_id, &page_version, &page_size, &drop_unread)) {
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);
}