Streamline tcache-related malloc/free fast paths.

tcache_get() is inlined, so do the config_tcache check inside
tcache_get() and simplify its callers.

Make arena_malloc() an inline function, since it is part of the malloc()
fast path.

Remove conditional logic that cause build issues if --disable-tcache was
specified.
This commit is contained in:
Jason Evans
2012-02-13 12:29:49 -08:00
parent 4162627757
commit 962463d9b5
4 changed files with 34 additions and 57 deletions

View File

@@ -1455,35 +1455,6 @@ arena_malloc_large(arena_t *arena, size_t size, bool zero)
return (ret);
}
void *
arena_malloc(size_t size, bool zero)
{
assert(size != 0);
assert(QUANTUM_CEILING(size) <= arena_maxclass);
if (size <= small_maxclass) {
tcache_t *tcache;
if (config_tcache && (tcache = tcache_get()) != NULL)
return (tcache_alloc_small(tcache, size, zero));
else
return (arena_malloc_small(choose_arena(), size, zero));
} else {
if (config_tcache && size <= tcache_maxclass) {
tcache_t *tcache;
if ((tcache = tcache_get()) != NULL)
return (tcache_alloc_large(tcache, size, zero));
else {
return (arena_malloc_large(choose_arena(),
size, zero));
}
} else
return (arena_malloc_large(choose_arena(), size, zero));
}
}
/* Only handles large allocations that require more than page alignment. */
void *
arena_palloc(arena_t *arena, size_t size, size_t alloc_size, size_t alignment,

View File

@@ -1,6 +1,6 @@
#define JEMALLOC_TCACHE_C_
#include "jemalloc/internal/jemalloc_internal.h"
#ifdef JEMALLOC_TCACHE
/******************************************************************************/
/* Data. */
@@ -436,5 +436,3 @@ tcache_boot(void)
return (false);
}
/******************************************************************************/
#endif /* JEMALLOC_TCACHE */