commit 71c145932c8d546533a44f35268a4f5949f36905
parent ae2ea0be72f14e69c500589251161a3566c780e1
Author: Joris Vink <joris@coders.se>
Date:   Tue, 30 Oct 2018 10:36:18 +0100
grow kore_pools at a slower rate.
Before we just doubled in size the second we exhausted a pool instead
of doing a more controlled expansion.
Now we will expand at 25% of the initial elm count whenever we need to.
Will help with memory pressure in certain scenarios.
Diffstat:
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/kore/kore.h b/include/kore/kore.h
@@ -441,6 +441,7 @@ struct kore_pool {
 	size_t			slen;
 	size_t			elms;
 	size_t			inuse;
+	size_t			growth;
 	volatile int		lock;
 	char			*name;
 
diff --git a/src/pool.c b/src/pool.c
@@ -45,6 +45,7 @@ kore_pool_init(struct kore_pool *pool, const char *name,
 	pool->elms = 0;
 	pool->inuse = 0;
 	pool->elen = len;
+	pool->growth = elm * 0.25f;
 	pool->slen = pool->elen + sizeof(struct kore_pool_entry);
 
 	LIST_INIT(&(pool->regions));
@@ -79,7 +80,7 @@ kore_pool_get(struct kore_pool *pool)
 #endif
 
 	if (LIST_EMPTY(&(pool->freelist)))
-		pool_region_create(pool, pool->elms);
+		pool_region_create(pool, pool->growth);
 
 	entry = LIST_FIRST(&(pool->freelist));
 	if (entry->state != POOL_ELEMENT_FREE)