mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-17 04:26:59 +00:00
MEDIUM: pools: make pool_put_to_cache() always call pool_put_to_local_cache()
Till now it used to call it only if there were not too many objects into the local cache otherwise would send the latest one directly into the shared cache. Now it always sends to the local cache and it's up to the local cache to free its oldest objects. From a cache freshness perspective it's better this way since we always evict cold objects instead of hot ones. From an API perspective it's better because it will help make the shared cache invisible to the public API.
This commit is contained in:
parent
87212036a1
commit
fa19d20ac4
@ -72,6 +72,7 @@ void pool_destroy_all();
|
||||
extern THREAD_LOCAL size_t pool_cache_bytes; /* total cache size */
|
||||
extern THREAD_LOCAL size_t pool_cache_count; /* #cache objects */
|
||||
|
||||
void pool_evict_from_local_cache(struct pool_head *pool);
|
||||
void pool_evict_from_local_caches();
|
||||
|
||||
/* returns true if the pool is considered to have too many free objects */
|
||||
@ -120,6 +121,10 @@ static inline void pool_put_to_local_cache(struct pool_head *pool, void *ptr)
|
||||
pool_cache_count++;
|
||||
pool_cache_bytes += pool->size;
|
||||
|
||||
if (unlikely(pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE * 3 / 4 &&
|
||||
ph->count >= 16 + pool_cache_count / 8))
|
||||
pool_evict_from_local_cache(pool);
|
||||
|
||||
if (unlikely(pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE))
|
||||
pool_evict_from_local_caches();
|
||||
}
|
||||
@ -286,16 +291,7 @@ static inline void *pool_get_from_cache(struct pool_head *pool)
|
||||
*/
|
||||
static inline void pool_put_to_cache(struct pool_head *pool, void *ptr)
|
||||
{
|
||||
/* put the object back into the cache only if there are not too
|
||||
* many objects yet in this pool (no more than half of the cached
|
||||
* is used or this pool uses no more than 1/8 of the cache size).
|
||||
*/
|
||||
if ((pool_cache_bytes <= CONFIG_HAP_POOL_CACHE_SIZE * 3 / 4 ||
|
||||
pool->cache[tid].count < 16 + pool_cache_count / 8)) {
|
||||
pool_put_to_local_cache(pool, ptr);
|
||||
return;
|
||||
}
|
||||
pool_put_to_shared_cache(pool, ptr);
|
||||
pool_put_to_local_cache(pool, ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,7 +196,6 @@ void pool_evict_from_local_cache(struct pool_head *pool)
|
||||
{
|
||||
struct pool_cache_head *ph = &pool->cache[tid];
|
||||
struct pool_cache_item *item;
|
||||
struct pool_head *pool;
|
||||
|
||||
while (ph->count >= 16 + pool_cache_count / 8 &&
|
||||
pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE * 3 / 4) {
|
||||
|
Loading…
Reference in New Issue
Block a user