summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2019-07-26 01:32:26 -0700
committerdormando <dormando@rydia.net>2019-07-26 16:26:38 -0700
commitc630eeb7f4502a9d96cbec7cc9bda7ce1b1f6476 (patch)
tree3b054bd5e72b0e4da7f66455bdc01d97a9814f6b /doc
parent78eb7701e0823643d693c1a7a6fd8a0c75db74d8 (diff)
downloadmemcached-c630eeb7f4502a9d96cbec7cc9bda7ce1b1f6476.tar.gz
move mem_requested from slabs.c to items.c
mem_requested is an oddball counter: it's the total number of bytes "actually requested" from the slab's caller. It's mainly used for a stats counter, alerting the user that the slab factor may not be efficient if the gap between total_chunks * chunk_size - mem_requested is large. However, since chunked items were added it's _also_ used to help the LRU balance itself. The total number of bytes used in the class vs the total number of bytes in a sub-LRU is used to judge whether to move items between sub-LRU's. This is a layer violation; forcing slabs.c to know more about how items work, as well as EXTSTORE for calculating item sizes from headers. Further, it turns out it wasn't necessary for item allocation: if we need to evict an item we _always_ pull from COLD_LRU or force a move from HOT_LRU. So the total doesn't matter. The total does matter in the LRU maintainer background thread. However, this thread caches mem_requested to avoid hitting the slab lock too frequently. Since sizes_bytes[] within items.c is generally redundant with mem_requested, we now total sizes_bytes[] from each sub-LRU before starting a batch of LRU juggles. This simplifies the code a bit, reduces the layer violations in slabs.c slightly, and actually speeds up some hot paths as a number of branches and operations are removed completely. This also fixes an issue I was having with the restartable memory branch :) recalculating p->requested and keeping a clean API is painful and slow. NOTE: This will vary a bit compared to what mem_requested originally did, mostly for large chunked items. For items which fit inside a single slab chunk, the stat is identical. However, items constructed by chaining chunks will have a single large "nbytes" value and end up in the highest slab class. Chunked items can be capped with chunks from smaller slab classes; you will see utilization of chunks but not an increase in mem_requested for them. I'm still thinking this through but this is probably acceptable. Large chunked items should be accounted for separately, perhaps with some new counters so they can be discounted from normal calculations.
Diffstat (limited to 'doc')
-rw-r--r--doc/protocol.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/protocol.txt b/doc/protocol.txt
index 81025b3..b5587a0 100644
--- a/doc/protocol.txt
+++ b/doc/protocol.txt
@@ -900,6 +900,7 @@ number_temp Number of items presently stored in the TEMPORARY LRU.
age_hot Age of the oldest item in HOT LRU.
age_warm Age of the oldest item in WARM LRU.
age Age of the oldest item in the LRU.
+mem_requested Number of bytes requested to be stored in this LRU[*]
evicted Number of times an item had to be evicted from the LRU
before it expired.
evicted_nonzero Number of times an item which had an explicit expire
@@ -940,6 +941,12 @@ hits_to_temp Number of get_hits to each sub-LRU.
Note this will only display information about slabs which exist, so an empty
cache will return an empty set.
+* Items are stored in a slab that is the same size or larger than the
+ item. mem_requested shows the size of all items within a
+ slab. (total_chunks * chunk_size) - mem_requested shows memory
+ wasted in a slab class. If you see a lot of waste, consider tuning
+ the slab factor.
+
Item size statistics
--------------------
@@ -1038,17 +1045,10 @@ END\r\n
| free_chunks | Chunks not yet allocated to items, or freed via delete. |
| free_chunks_end | Number of free chunks at the end of the last allocated |
| | page. |
-| mem_requested | Number of bytes requested to be stored in this slab[*]. |
| active_slabs | Total number of slab classes allocated. |
| total_malloced | Total amount of memory allocated to slab pages. |
|-----------------+----------------------------------------------------------|
-* Items are stored in a slab that is the same size or larger than the
- item. mem_requested shows the size of all items within a
- slab. (total_chunks * chunk_size) - mem_requested shows memory
- wasted in a slab class. If you see a lot of waste, consider tuning
- the slab factor.
-
Connection statistics
---------------------