From 97b52b18667cfce5d23234a421130c6f1b616b7a Mon Sep 17 00:00:00 2001 From: dormando Date: Mon, 18 Dec 2017 23:29:47 -0800 Subject: 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. --- slabs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'slabs.c') diff --git a/slabs.c b/slabs.c index c9a37aa..cedb1e8 100644 --- a/slabs.c +++ b/slabs.c @@ -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) { -- cgit v1.2.1