summaryrefslogtreecommitdiff
path: root/items.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-02-22 19:32:50 -0800
committerdormando <dormando@rydia.net>2017-03-19 18:32:33 -0700
commitae84d771811394a9f6f2ff12022707f69bdc311f (patch)
treec84a692064c2604be72c097072afd4f6d53f4762 /items.h
parent2f9f51d48af688b1283a235de9d918963666e166 (diff)
downloadmemcached-ae84d771811394a9f6f2ff12022707f69bdc311f.tar.gz
refactor chunk chaining for memory efficiency1.4.36
Memory chunk chains would simply stitch multiple chunks of the highest slab class together. If your item was 17k and the chunk limit is 16k, the item would use 32k of space instead of a bit over 17k. This refactor simplifies the slab allocation path and pulls the allocation of chunks into the upload process. A "large" item gets a small chunk assigned as an object header, rather than attempting to inline a slab chunk into a parent chunk. It then gets chunks individually allocated and added into the chain while the object uploads. This solves a lot of issues: 1) When assembling new, potentially very large items, we don't have to sit and spin evicting objects all at once. If there are 20 16k chunks in the tail and we allocate a 1 meg item, the new item will evict one of those chunks inbetween each read, rather than trying to guess how many loops to run before giving up. Very large objects take time to read from the socket anyway. 2) Simplifies code around the initial chunk. Originally embedding data into the top chunk and embedding data at the same time required a good amount of fiddling. (Though this might flip back to embedding the initial chunk if I can clean it up a bit more). 3) Pulling chunks individually means the slabber code can be flatened to not think about chunks aside from freeing them, which culled a lot of code and removed branches from a hot path. 4) The size of the final chunk is naturally set to the remaining about of bytes that need to be stored, which means chunks from another slab class can be pulled to "cap off" a large item, reducing memory overhead.
Diffstat (limited to 'items.h')
-rw-r--r--items.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/items.h b/items.h
index fd1d485..6683bf7 100644
--- a/items.h
+++ b/items.h
@@ -10,6 +10,7 @@ uint64_t get_cas_id(void);
/*@null@*/
item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, const rel_time_t exptime, const int nbytes);
+item_chunk *do_item_alloc_chunk(item_chunk *ch, const size_t bytes_remain);
void item_free(item *it);
bool item_size_ok(const size_t nkey, const int flags, const int nbytes);