summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-04-25 21:10:31 (GMT)
committerQi Wang <interwq@gmail.com>2017-04-26 00:21:33 (GMT)
commitb0c2a28280d363fc85aa8b4fdbe7814ef46cb17b (patch)
treec7bddd55c6f48dd26beeb5a08ae7ce2be7c7866a
parent8584adc451f31adfc4ab8693d9189cf3a7e5d858 (diff)
downloadjemalloc-b0c2a28280d363fc85aa8b4fdbe7814ef46cb17b.zip
jemalloc-b0c2a28280d363fc85aa8b4fdbe7814ef46cb17b.tar.gz
jemalloc-b0c2a28280d363fc85aa8b4fdbe7814ef46cb17b.tar.bz2
Use try_flush first in tcache_dalloc.
Only do must_flush if try_flush didn't manage to free anything.
-rw-r--r--include/jemalloc/internal/tcache_inlines.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/jemalloc/internal/tcache_inlines.h b/include/jemalloc/internal/tcache_inlines.h
index 5e9a7a0..511fcea 100644
--- a/include/jemalloc/internal/tcache_inlines.h
+++ b/include/jemalloc/internal/tcache_inlines.h
@@ -201,8 +201,11 @@ tcache_dalloc_small(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
tbin = tcache_small_bin_get(tcache, binind);
tbin_info = &tcache_bin_info[binind];
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
- tcache_bin_flush_small(tsd, tcache, tbin, binind,
- (tbin_info->ncached_max >> 1));
+ if (tcache_bin_try_flush_small(tsd, tcache, tbin, binind,
+ (tbin_info->ncached_max >> 1)) == 0) {
+ tcache_bin_flush_small(tsd, tcache, tbin, binind,
+ (tbin_info->ncached_max >> 1));
+ }
}
assert(tbin->ncached < tbin_info->ncached_max);
tbin->ncached++;
@@ -227,8 +230,11 @@ tcache_dalloc_large(tsd_t *tsd, tcache_t *tcache, void *ptr, szind_t binind,
tbin = tcache_large_bin_get(tcache, binind);
tbin_info = &tcache_bin_info[binind];
if (unlikely(tbin->ncached == tbin_info->ncached_max)) {
- tcache_bin_flush_large(tsd, tcache, tbin, binind,
- (tbin_info->ncached_max >> 1));
+ if (tcache_bin_try_flush_large(tsd, tcache, tbin, binind,
+ (tbin_info->ncached_max >> 1)) == 0) {
+ tcache_bin_flush_large(tsd, tcache, tbin, binind,
+ (tbin_info->ncached_max >> 1));
+ }
}
assert(tbin->ncached < tbin_info->ncached_max);
tbin->ncached++;