summaryrefslogtreecommitdiff
path: root/storage.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-11-16 18:51:44 -0800
committerdormando <dormando@rydia.net>2017-11-28 14:18:05 -0800
commit46a297cb0b6bad956793c25cc04ee208fc75a843 (patch)
tree585aeee59c1ad4a7cba82e2a44826329cdfb611d /storage.c
parentfa37474c2a98ce4f23a4c3e059d432f798b878b6 (diff)
downloadmemcached-46a297cb0b6bad956793c25cc04ee208fc75a843.tar.gz
extstore: crawler fix and ext_low_ttl option
LRU crawler was not marking reclaimed expired items as removed from the storage engine. This could cause fragmentation to persist much longer than it should, but would not cause any problems once compaction started. Adds "ext_low_ttl" option. Items with a remaining expiration age below this value are grouped into special pages. If you have a mixed TTL workload this would help prevent low TTL items from causing excess fragmentation/compaction. Pages with low ttl items are excluded from compaction.
Diffstat (limited to 'storage.c')
-rw-r--r--storage.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/storage.c b/storage.c
index cf2f7fb..aee0dbe 100644
--- a/storage.c
+++ b/storage.c
@@ -10,6 +10,7 @@
#define PAGE_BUCKET_DEFAULT 0
#define PAGE_BUCKET_COMPACT 1
#define PAGE_BUCKET_CHUNKED 2
+#define PAGE_BUCKET_LOWTTL 3
int lru_maintainer_store(void *storage, const int clsid) {
//int i;
@@ -25,7 +26,7 @@ int lru_maintainer_store(void *storage, const int clsid) {
chunks_free = slabs_available_chunks(clsid, &mem_limit_reached,
NULL, &chunks_perslab);
// if we are low on chunks and no spare, push out early.
- if (chunks_free < (chunks_perslab / 2) && mem_limit_reached)
+ if (chunks_free < chunks_perslab && mem_limit_reached)
item_age = 0;
it_info.it = NULL;
@@ -57,6 +58,10 @@ int lru_maintainer_store(void *storage, const int clsid) {
if (hdr_it != NULL) {
int bucket = (it->it_flags & ITEM_CHUNKED) ?
PAGE_BUCKET_CHUNKED : PAGE_BUCKET_DEFAULT;
+ // Compres soon to expire items into similar pages.
+ if (it->exptime - current_time < settings.ext_low_ttl) {
+ bucket = PAGE_BUCKET_LOWTTL;
+ }
hdr_it->it_flags |= ITEM_HDR;
io.len = orig_ntotal;
io.mode = OBJ_IO_WRITE;
@@ -156,7 +161,8 @@ static int storage_compact_check(void *storage, logger *l,
// find oldest page by version that violates the constraint
for (x = 0; x < st.page_count; x++) {
- if (st.page_data[x].version == 0)
+ if (st.page_data[x].version == 0 ||
+ st.page_data[x].bucket == PAGE_BUCKET_LOWTTL)
continue;
if (st.page_data[x].bytes_used < frag_limit) {
if (st.page_data[x].version < low_version) {