diff options
author | dormando <dormando@rydia.net> | 2017-12-18 23:29:47 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-12-18 23:29:47 -0800 |
commit | 97b52b18667cfce5d23234a421130c6f1b616b7a (patch) | |
tree | dea83c8acca64969b5796f24cc29736bfa0b9b7f /slabs.c | |
parent | d15f8712272f356b63ef42130175bc4a9d0729c5 (diff) | |
download | memcached-97b52b18667cfce5d23234a421130c6f1b616b7a.tar.gz |
extstore: prefill global page pool with extstore
the slab page mover algo would fill memory to evicting for a few seconds
before jumping to life and shoveling some pages into the global pool.
swore I was going to fix this post-release, but I had a moment of inspiration
after finding some code from another branch that did half the work. After a
bunch of stupid bugs it seems to work.
-o slab_automove_freeratio=0.N is now an option. This is *percentage of total
memory*, so don't set it too high.
Diffstat (limited to 'slabs.c')
-rw-r--r-- | slabs.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -62,6 +62,7 @@ static pthread_mutex_t slabs_rebalance_lock = PTHREAD_MUTEX_INITIALIZER; /* * Forward Declarations */ +static int grow_slab_list (const unsigned int id); static int do_slabs_newslab(const unsigned int id); static void *memory_allocate(size_t size); static void do_slabs_free(void *ptr, const size_t size, unsigned int id); @@ -165,6 +166,19 @@ void slabs_init(const size_t limit, const double factor, const bool prealloc, co } } +void slabs_prefill_global(void) { + void *ptr; + slabclass_t *p = &slabclass[0]; + int len = settings.slab_page_size; + + while (mem_malloced < mem_limit + && (ptr = memory_allocate(len)) != NULL) { + grow_slab_list(0); + p->slab_list[p->slabs++] = ptr; + } + mem_limit_reached = true; +} + static void slabs_preallocate (const unsigned int maxslabs) { int i; unsigned int prealloc = 0; @@ -185,7 +199,6 @@ static void slabs_preallocate (const unsigned int maxslabs) { exit(1); } } - } static int grow_slab_list (const unsigned int id) { |