forked from mongodb/mongo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-4683 Support the imported tcmalloc, ystem tcmalloc or the defa…
…ult system allocator library. Pass --allocator=tcmalloc (default on Linux) or --allocator=system (default elsewhere) to control which allocator is used, and --use-system-tcmalloc to use the system- installed tcmalloc instead of the one in the mongo source tree if you use --allocator=tcmalloc.
- Loading branch information
Andy Schwerin
committed
Aug 10, 2012
1 parent
b49bac3
commit eee3fe4
Showing
6 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- mode: python -*- | ||
|
||
Import("env") | ||
|
||
files = [ | ||
'src/base/dynamic_annotations.c', | ||
'src/base/spinlock_internal.cc', | ||
'src/base/logging.cc', | ||
'src/base/atomicops-internals-x86.cc', | ||
'src/base/sysinfo.cc', | ||
'src/base/spinlock.cc', | ||
'src/tcmalloc.cc', | ||
'src/malloc_hook.cc', | ||
'src/span.cc', | ||
'src/maybe_threads.cc', | ||
'src/internal_logging.cc', | ||
'src/symbolize.cc', | ||
'src/system-alloc.cc', | ||
'src/memfs_malloc.cc', | ||
'src/central_freelist.cc', | ||
'src/thread_cache.cc', | ||
'src/page_heap.cc', | ||
'src/common.cc', | ||
'src/static_vars.cc', | ||
'src/stack_trace_table.cc', | ||
'src/malloc_extension.cc', | ||
'src/sampler.cc', | ||
'src/stacktrace.cc' | ||
] | ||
|
||
__malloc_hook_fragment = ''' | ||
#include <malloc.h> | ||
void* (* volatile __malloc_hook)(size_t, const void*) = 0; | ||
''' | ||
|
||
def __checkMallocHookVolatile(check_context): | ||
check_context.Message("Checking if __malloc_hook is declared volatile... ") | ||
is_malloc_hook_volatile = check_context.TryCompile(__malloc_hook_fragment, '.cc') | ||
check_context.Result(is_malloc_hook_volatile) | ||
check_context.env.Append(CPPDEFINES=dict( | ||
MALLOC_HOOK_MAYBE_VOLATILE=(is_malloc_hook_volatile and "volatile" or ""))) | ||
|
||
conf = Configure(env.Clone(), custom_tests=dict(CheckMallocHookVolatile=__checkMallocHookVolatile)) | ||
conf.CheckMallocHookVolatile() | ||
env = conf.Finish() | ||
|
||
|
||
env.Append( CPPDEFINES=["NO_TCMALLOC_SAMPLES","NO_TCMALLOC_SAMPLES","NO_HEAP_CHECK"] ) | ||
env.Prepend( CPPPATH=["src/"] ) | ||
|
||
def removeIfPresent(lst, item): | ||
try: | ||
lst.remove(item) | ||
except ValueError: | ||
pass | ||
|
||
for to_remove in ['-Werror', "-Wsign-compare","-Wall"]: | ||
removeIfPresent(env['CCFLAGS'], to_remove) | ||
|
||
env.StaticLibrary('tcmalloc_minimal', files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file intentionally blank. shim_allocator.cpp is part of the third_party/shim_allocator | ||
// library, used to manage memory allocator selection (tcmalloc, libc, etc.). |