summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2006-01-26 08:11:23 +0000
committerjasone <jasone@FreeBSD.org>2006-01-26 08:11:23 +0000
commit6f41342041bdf21132fca3a1b0728ec216b0c123 (patch)
treef27272607cd02157bac85aa537f5773c9e01c88a /lib
parent6dc724c51c35a418fc197b2302bc3478d63d68c4 (diff)
downloadFreeBSD-src-6f41342041bdf21132fca3a1b0728ec216b0c123.zip
FreeBSD-src-6f41342041bdf21132fca3a1b0728ec216b0c123.tar.gz
Optimize arena_bin_pop() to reduce the number of separator operations.
Remove the block of code that tries to use delayed regions in LIFO order, since from a policy perspective, it conflicts with LRU caching of newly coalesced regions in arena_undelay(). There are numerous policy alternatives, and it isn't readily obvious which (if any) is superior; this change at least has the virtue of being consistent with policy.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/malloc.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 7cb4b3a..592ce19 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -2121,16 +2121,6 @@ arena_bin_pop(arena_t *arena, unsigned bin)
ret = qr_next(&tbin->regions, next.u.s.link);
assert(region_next_size_get(&ret->sep)
== ((bin + bin_shift) << opt_quantum_2pow));
- if (region_next_free_get(&ret->sep) == false) {
- /*
- * Use delayed regions in LIFO order, in order to increase
- * locality of use, and thereby (hopefully) reduce
- * fragmentation.
- */
- ret = qr_prev(&tbin->regions, next.u.s.link);
- assert(region_next_size_get(&ret->sep)
- == ((bin + bin_shift) << opt_quantum_2pow));
- }
qr_remove(ret, next.u.s.link);
#ifdef MALLOC_STATS
arena->stats.bins[bin].nregions--;
@@ -2138,9 +2128,16 @@ arena_bin_pop(arena_t *arena, unsigned bin)
if (qr_next(&tbin->regions, next.u.s.link) == &tbin->regions)
arena_mask_unset(arena, bin);
- arena_delayed_extract(arena, ret);
+ if (region_next_free_get(&ret->sep) == false) {
+ uint32_t slot;
+
+ assert(region_next_contig_get(&ret->sep));
- if (region_next_free_get(&ret->sep)) {
+ /* Extract this region from the delayed FIFO. */
+ slot = ret->next.u.s.slot;
+ assert(arena->delayed[slot] == ret);
+ arena->delayed[slot] = NULL;
+ } else {
region_t *next;
/* Non-delayed region. */
@@ -2338,7 +2335,7 @@ arena_undelay(arena_t *arena, uint32_t slot)
- (CHUNK_REG_OFFSET + offsetof(region_t, next))) {
/*
* Insert coalesced region into appropriate bin (or
- * largeRegions).
+ * large_regions).
*/
arena_lru_cache(arena, reg);
} else {
OpenPOWER on IntegriCloud