summaryrefslogtreecommitdiff
path: root/slabs.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-06-20 17:30:21 -0700
committerdormando <dormando@rydia.net>2017-06-23 01:12:53 -0700
commit5c43b80577a3dcdd47df9221ef42e5af22c1c641 (patch)
tree07589085149f453bf5db0d1cf11072ce98abb471 /slabs.c
parentdee6557c47e94953d230456569e9ba4974c441d1 (diff)
downloadmemcached-5c43b80577a3dcdd47df9221ef42e5af22c1c641.tar.gz
add a real slab automover algorithm
converts the python script to C, more or less.
Diffstat (limited to 'slabs.c')
-rw-r--r--slabs.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/slabs.c b/slabs.c
index f92a542..f76bd15 100644
--- a/slabs.c
+++ b/slabs.c
@@ -375,6 +375,22 @@ static void do_slabs_free(void *ptr, const size_t size, unsigned int id) {
return;
}
+/* With refactoring of the various stats code the automover won't need a
+ * custom function here.
+ */
+void fill_slab_stats_automove(slab_stats_automove *am) {
+ int n;
+ pthread_mutex_lock(&slabs_lock);
+ for (n = 0; n < MAX_NUMBER_OF_SLAB_CLASSES; n++) {
+ slabclass_t *p = &slabclass[n];
+ slab_stats_automove *cur = &am[n];
+ cur->chunks_per_page = p->perslab;
+ cur->free_chunks = p->sl_curr;
+ cur->total_pages = p->slabs;
+ }
+ pthread_mutex_unlock(&slabs_lock);
+}
+
static int nz_strcmp(int nzlength, const char *nz, const char *z) {
int zlength=strlen(z);
return (zlength == nzlength) && (strncmp(nz, z, zlength) == 0) ? 0 : -1;