Use try_flush first in tcache_dalloc.
Only do must_flush if try_flush didn't manage to free anything.
This commit is contained in:
parent
8584adc451
commit
b0c2a28280
@ -201,9 +201,12 @@ tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
|
|||||||
tbin = tcache_small_bin_get(tcache, binind);
|
tbin = tcache_small_bin_get(tcache, binind);
|
||||||
tbin_info = &tcache_bin_info[binind];
|
tbin_info = &tcache_bin_info[binind];
|
||||||
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
|
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
|
||||||
|
if (tcache_bin_try_flush_small(tsd, tcache, tbin, binind,
|
||||||
|
(tbin_info->ncached_max >> 1)) == 0) {
|
||||||
tcache_bin_flush_small(tsd, tcache, tbin, binind,
|
tcache_bin_flush_small(tsd, tcache, tbin, binind,
|
||||||
(tbin_info->ncached_max >> 1));
|
(tbin_info->ncached_max >> 1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assert(tbin->ncached < tbin_info->ncached_max);
|
assert(tbin->ncached < tbin_info->ncached_max);
|
||||||
tbin->ncached++;
|
tbin->ncached++;
|
||||||
*(tbin->avail - tbin->ncached) = ptr;
|
*(tbin->avail - tbin->ncached) = ptr;
|
||||||
@ -227,9 +230,12 @@ tcache_dalloc_large(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
|
|||||||
tbin = tcache_large_bin_get(tcache, binind);
|
tbin = tcache_large_bin_get(tcache, binind);
|
||||||
tbin_info = &tcache_bin_info[binind];
|
tbin_info = &tcache_bin_info[binind];
|
||||||
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
|
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
|
||||||
|
if (tcache_bin_try_flush_large(tsd, tcache, tbin, binind,
|
||||||
|
(tbin_info->ncached_max >> 1)) == 0) {
|
||||||
tcache_bin_flush_large(tsd, tcache, tbin, binind,
|
tcache_bin_flush_large(tsd, tcache, tbin, binind,
|
||||||
(tbin_info->ncached_max >> 1));
|
(tbin_info->ncached_max >> 1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assert(tbin->ncached < tbin_info->ncached_max);
|
assert(tbin->ncached < tbin_info->ncached_max);
|
||||||
tbin->ncached++;
|
tbin->ncached++;
|
||||||
*(tbin->avail - tbin->ncached) = ptr;
|
*(tbin->avail - tbin->ncached) = ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user