diff options
author | Jason Evans <jasone@canonware.com> | 2015-05-19 17:42:31 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2015-05-22 10:47:42 -0700 |
commit | a1c77dc2db66bbb690917f05c63e00c3ef7dd838 (patch) | |
tree | aef4dfef02022dc4c85fa03a13c52ba1f31df529 | |
parent | b0f414093571d358979e9591d0249b57ab23e292 (diff) | |
download | jemalloc-a1c77dc2db66bbb690917f05c63e00c3ef7dd838.tar.gz |
Fix performance regression in arena_palloc().
Pass large allocation requests to arena_malloc() when possible. This
regression was introduced by 155bfa7da18cab0d21d87aa2dce4554166836f5d
(Normalize size classes.).
Bug: 21326736
(cherry picked from commit 2bb0b03fd3c2e72d21505db1f813362c6204d18f)
Change-Id: I305acf080a91f1448e3fc4a602712d4f240ef367
-rw-r--r-- | src/arena.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/arena.c b/src/arena.c index d0619b5..0ee46d3 100644 --- a/src/arena.c +++ b/src/arena.c @@ -2177,9 +2177,20 @@ arena_palloc(tsd_t *tsd, arena_t *arena, size_t usize, size_t alignment, void *ret; if (usize <= SMALL_MAXCLASS && (alignment < PAGE || (alignment == PAGE - && (usize & PAGE_MASK) == 0))) + && (usize & PAGE_MASK) == 0))) { + /* Small; alignment doesn't require special run placement. */ ret = arena_malloc(tsd, arena, usize, zero, tcache); - else { + } else if (usize <= arena_maxclass && alignment <= PAGE) { + /* + * Large; alignment doesn't require special run placement. + * However, the cached pointer may be at a random offset from + * the base of the run, so do some bit manipulation to retrieve + * the base. + */ + ret = arena_malloc(tsd, arena, usize, zero, tcache); + if (config_cache_oblivious) + ret = (void *)((uintptr_t)ret & ~PAGE_MASK); + } else { if (likely(usize <= arena_maxclass)) { ret = arena_palloc_large(tsd, arena, usize, alignment, zero); |