mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-21 14:35:45 +00:00
MEDIUM: pools: release cached objects in batches
With this patch pool_evict_last_items builds clusters of up to CONFIG_HAP_POOL_CLUSTER_SIZE entries so that accesses to the shared pools are reduced by CONFIG_HAP_POOL_CLUSTER_SIZE and the inter- thread contention is reduced by as much..
This commit is contained in:
parent
43937e920f
commit
1513c5479a
25
src/pool.c
25
src/pool.c
@ -310,8 +310,9 @@ void pool_free_nocache(struct pool_head *pool, void *ptr)
|
|||||||
static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head *ph, uint count)
|
static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head *ph, uint count)
|
||||||
{
|
{
|
||||||
struct pool_cache_item *item;
|
struct pool_cache_item *item;
|
||||||
struct pool_item *pi;
|
struct pool_item *pi, *head = NULL;
|
||||||
uint released = 0;
|
uint released = 0;
|
||||||
|
uint cluster = 0;
|
||||||
uint to_free_max;
|
uint to_free_max;
|
||||||
|
|
||||||
to_free_max = pool_releasable(pool);
|
to_free_max = pool_releasable(pool);
|
||||||
@ -320,17 +321,29 @@ static void pool_evict_last_items(struct pool_head *pool, struct pool_cache_head
|
|||||||
item = LIST_PREV(&ph->list, typeof(item), by_pool);
|
item = LIST_PREV(&ph->list, typeof(item), by_pool);
|
||||||
LIST_DELETE(&item->by_pool);
|
LIST_DELETE(&item->by_pool);
|
||||||
LIST_DELETE(&item->by_lru);
|
LIST_DELETE(&item->by_lru);
|
||||||
released++;
|
|
||||||
|
|
||||||
if (to_free_max) {
|
if (to_free_max > released || cluster) {
|
||||||
pi = (struct pool_item *)item;
|
pi = (struct pool_item *)item;
|
||||||
pi->down = NULL;
|
pi->next = NULL;
|
||||||
pool_put_to_shared_cache(pool, pi, 1);
|
pi->down = head;
|
||||||
to_free_max--;
|
head = pi;
|
||||||
|
cluster++;
|
||||||
|
if (cluster >= CONFIG_HAP_POOL_CLUSTER_SIZE) {
|
||||||
|
/* enough to make a cluster */
|
||||||
|
pool_put_to_shared_cache(pool, head, cluster);
|
||||||
|
cluster = 0;
|
||||||
|
head = NULL;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
pool_free_nocache(pool, item);
|
pool_free_nocache(pool, item);
|
||||||
|
|
||||||
|
released++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* incomplete cluster left */
|
||||||
|
if (cluster)
|
||||||
|
pool_put_to_shared_cache(pool, head, cluster);
|
||||||
|
|
||||||
ph->count -= released;
|
ph->count -= released;
|
||||||
pool_cache_count -= released;
|
pool_cache_count -= released;
|
||||||
pool_cache_bytes -= released * pool->size;
|
pool_cache_bytes -= released * pool->size;
|
||||||
|
Loading…
Reference in New Issue
Block a user