From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 01E6F46970E for ; Wed, 29 Jan 2020 04:48:23 +0300 (MSK) From: Maksim Kulis Date: Wed, 29 Jan 2020 04:48:16 +0300 Message-Id: <20200129014816.14248-1-bokuno@picodata.io> Subject: [Tarantool-patches] [PATCH] small: unite the oscillation cache of all mempools List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org The task is to unite the oscillation cache of all mempools. In the function slab_put_with_order() we check if there is any slab of the largest size except the current one, in order to avoid oscillation. https://github.com/tarantool/small/blob/master/small/slab_cache.c#L349 --- small/mempool.c | 22 ++++------------------ small/mempool.h | 6 ------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/small/mempool.c b/small/mempool.c index b20a416..54bd58d 100644 --- a/small/mempool.c +++ b/small/mempool.c @@ -126,18 +126,9 @@ mslab_free(struct mempool *pool, struct mslab *slab, void *ptr) } mslab_tree_remove(&pool->hot_slabs, slab); slab->in_hot_slabs = false; - if (pool->spare > slab) { - slab_list_del(&pool->slabs, &pool->spare->slab, - next_in_list); - slab_put_with_order(pool->cache, &pool->spare->slab); - pool->spare = slab; - } else if (pool->spare) { - slab_list_del(&pool->slabs, &slab->slab, - next_in_list); - slab_put_with_order(pool->cache, &slab->slab); - } else { - pool->spare = slab; - } + slab_list_del(&pool->slabs, &slab->slab, + next_in_list); + slab_put_with_order(pool->cache, &slab->slab); } } @@ -153,7 +144,6 @@ mempool_create_with_order(struct mempool *pool, struct slab_cache *cache, mslab_tree_new(&pool->hot_slabs); pool->first_hot_slab = NULL; rlist_create(&pool->cold_slabs); - pool->spare = NULL; pool->objsize = objsize; pool->slab_order = order; /* Total size of slab */ @@ -179,11 +169,7 @@ mempool_alloc(struct mempool *pool) { struct mslab *slab = pool->first_hot_slab; if (slab == NULL) { - if (pool->spare) { - slab = pool->spare; - pool->spare = NULL; - - } else if ((slab = (struct mslab *) + if ((slab = (struct mslab *) slab_get_with_order(pool->cache, pool->slab_order))) { mslab_create(slab, pool); diff --git a/small/mempool.h b/small/mempool.h index 15d85a4..9d0e162 100644 --- a/small/mempool.h +++ b/small/mempool.h @@ -149,12 +149,6 @@ struct mempool * tree is empty or the allocator runs out of memory. */ struct rlist cold_slabs; - /** - * A completely empty slab which is not freed only to - * avoid the overhead of slab_cache oscillation around - * a single element allocation. - */ - struct mslab *spare; /** * The size of an individual object. All objects * allocated on the pool have the same size. -- 2.17.1