diff options
author | dormando <dormando@rydia.net> | 2017-12-08 16:52:40 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-12-08 16:52:40 -0800 |
commit | 08ea194cd6b4d58c768b7b899f06dc304710d821 (patch) | |
tree | 4713d4de08da026e94fc8c4d50c8b3d3b21c7365 /storage.c | |
parent | 48b07bd3200a92a82b7500b10f14843204502060 (diff) | |
download | memcached-08ea194cd6b4d58c768b7b899f06dc304710d821.tar.gz |
extstore: fix size tracking and adjust drop_unread
was early evicting from HOT/WARM LRU's for item headers because the
*original* item size was being tracked, then compared to the actual byte
totals for the class.
also adjusts drop_unread so it drops items which are currently in the COLD_LRU
this is expected to be used with very low compacat_under values; ie 2-5
depending on page count and write load. If you can't defrag-compact,
drop-compact.
but this is still subtly wrong, since drop_compact is now an option.
Diffstat (limited to 'storage.c')
-rw-r--r-- | storage.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -135,7 +135,9 @@ static int storage_compact_check(void *storage, logger *l, double rate; uint64_t frag_limit; uint64_t low_version = ULLONG_MAX; + uint64_t lowest_version = ULLONG_MAX; unsigned int low_page = 0; + unsigned int lowest_page = 0; extstore_get_stats(storage, &st); if (st.pages_used == 0) return 0; @@ -159,6 +161,10 @@ static int storage_compact_check(void *storage, logger *l, if (st.page_data[x].version == 0 || st.page_data[x].bucket == PAGE_BUCKET_LOWTTL) continue; + if (st.page_data[x].version < lowest_version) { + lowest_page = x; + lowest_version = st.page_data[x].version; + } if (st.page_data[x].bytes_used < frag_limit) { if (st.page_data[x].version < low_version) { low_page = x; @@ -174,6 +180,11 @@ 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) { + // 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; } return 0; @@ -226,7 +237,8 @@ static void storage_compact_readback(void *storage, logger *l, if (hdr->page_id == page_id && hdr->page_version == page_version) { // Item header is still completely valid. extstore_delete(storage, page_id, page_version, 1, ntotal); - if (drop_unread && (hdr_it->it_flags & ITEM_FETCHED) == 0) { + // drop inactive items. + if (drop_unread && GET_LRU(hdr_it->slabs_clsid) == COLD_LRU) { do_write = false; skipped++; } else { |