mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
SERVER-18079: Use TCMalloc for WT on Windows
This commit is contained in:
parent
7e98af8de3
commit
b43f9663dd
@ -248,8 +248,8 @@ add_option( "sanitize", "enable selected sanitizers", 1, True, metavar="san1,san
|
||||
add_option( "llvm-symbolizer", "name of (or path to) the LLVM symbolizer", 1, False, default="llvm-symbolizer" )
|
||||
|
||||
# debugging/profiling help
|
||||
if is_running_os('linux'):
|
||||
defaultAllocator = 'tcmalloc'
|
||||
if is_running_os('linux') or is_running_os('windows'):
|
||||
defaultAllocator = 'tcmalloc'
|
||||
else:
|
||||
defaultAllocator = 'system'
|
||||
add_option( "allocator" , "allocator to use (tcmalloc or system)" , 1 , True,
|
||||
|
@ -147,3 +147,13 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// gperftools/windows/patch_functions.cc normally defines this function,
|
||||
// but we do not link this file since it would dynamically patch our functions.
|
||||
// We override the behavior of this function to no-patch functions, but instead
|
||||
// simply to do nothing
|
||||
// TCMalloc calls this via a static initializer
|
||||
void PatchWindowsFunctions() {
|
||||
// Intentionally left empty
|
||||
}
|
||||
#endif
|
||||
|
20
src/third_party/gperftools-2.2/SConscript
vendored
20
src/third_party/gperftools-2.2/SConscript
vendored
@ -15,10 +15,8 @@ files = [
|
||||
'src/base/elf_mem_image.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',
|
||||
@ -31,10 +29,22 @@ files = [
|
||||
'src/stacktrace.cc'
|
||||
]
|
||||
|
||||
if not debugBuild:
|
||||
files += ['src/tcmalloc.cc'],
|
||||
if env.TargetOSIs('windows'):
|
||||
files += [
|
||||
'src/windows/port.cc',
|
||||
'src/windows/system-alloc.cc',
|
||||
'src/tcmalloc.cc',
|
||||
]
|
||||
else:
|
||||
files += ['src/debugallocation.cc']
|
||||
files += [
|
||||
'src/maybe_threads.cc',
|
||||
'src/system-alloc.cc',
|
||||
]
|
||||
|
||||
if not debugBuild:
|
||||
files += ['src/tcmalloc.cc'],
|
||||
else:
|
||||
files += ['src/debugallocation.cc']
|
||||
|
||||
if has_option( 'use-cpu-profiler' ):
|
||||
files += [
|
||||
|
310
src/third_party/gperftools-2.2/src/config-10gen-windows.h
vendored
Normal file
310
src/third_party/gperftools-2.2/src/config-10gen-windows.h
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
/* A manual version of config.h fit for windows machines.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can
|
||||
* be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* Sometimes we accidentally #include this config.h instead of the one
|
||||
in .. -- this is particularly true for msys/mingw, which uses the
|
||||
unix config.h but also runs code in the windows directory.
|
||||
*/
|
||||
#ifdef __MINGW32__
|
||||
#include "../config.h"
|
||||
#define GOOGLE_PERFTOOLS_WINDOWS_CONFIG_H_
|
||||
#endif
|
||||
|
||||
#ifndef GOOGLE_PERFTOOLS_WINDOWS_CONFIG_H_
|
||||
#define GOOGLE_PERFTOOLS_WINDOWS_CONFIG_H_
|
||||
|
||||
/* define this if you are linking tcmalloc statically and overriding the
|
||||
* default allocators.
|
||||
* For instructions on how to use this mode, see
|
||||
* http://groups.google.com/group/google-perftools/browse_thread/thread/41cd3710af85e57b
|
||||
*/
|
||||
#undef WIN32_OVERRIDE_ALLOCATORS
|
||||
|
||||
/* Define to 1 if your libc has a snprintf implementation */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if compiler supports __builtin_stack_pointer */
|
||||
#undef HAVE_BUILTIN_STACK_POINTER
|
||||
|
||||
/* Define to 1 if you have the <conflict-signal.h> header file. */
|
||||
#undef HAVE_CONFLICT_SIGNAL_H
|
||||
|
||||
/* Define to 1 if you have the <cygwin/signal.h> header file. */
|
||||
#undef HAVE_CYGWIN_SIGNAL_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `cfree', and to 0 if you don't.
|
||||
*/
|
||||
#undef HAVE_DECL_CFREE
|
||||
|
||||
/* Define to 1 if you have the declaration of `memalign', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_MEMALIGN
|
||||
|
||||
/* Define to 1 if you have the declaration of `posix_memalign', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_POSIX_MEMALIGN
|
||||
|
||||
/* Define to 1 if you have the declaration of `pvalloc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_PVALLOC
|
||||
|
||||
/* Define to 1 if you have the declaration of `uname', and to 0 if you don't.
|
||||
*/
|
||||
#undef HAVE_DECL_UNAME
|
||||
|
||||
/* Define to 1 if you have the declaration of `valloc', and to 0 if you don't.
|
||||
*/
|
||||
#undef HAVE_DECL_VALLOC
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if the system has the type `Elf32_Versym'. */
|
||||
#undef HAVE_ELF32_VERSYM
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
#undef HAVE_EXECINFO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the <features.h> header file. */
|
||||
#undef HAVE_FEATURES_H
|
||||
|
||||
/* Define to 1 if you have the `geteuid' function. */
|
||||
#undef HAVE_GETEUID
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#define HAVE_GETPAGESIZE 1 /* we define it in windows/port.cc */
|
||||
|
||||
/* Define to 1 if you have the <glob.h> header file. */
|
||||
#undef HAVE_GLOB_H
|
||||
|
||||
/* Define to 1 if you have the <grp.h> header file. */
|
||||
#undef HAVE_GRP_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <libunwind.h> header file. */
|
||||
#undef HAVE_LIBUNWIND_H
|
||||
|
||||
/* Define to 1 if you have the <linux/ptrace.h> header file. */
|
||||
#undef HAVE_LINUX_PTRACE_H
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc/malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* define if the compiler implements namespaces */
|
||||
#define HAVE_NAMESPACES 1
|
||||
|
||||
/* Define to 1 if you have the <poll.h> header file. */
|
||||
#undef HAVE_POLL_H
|
||||
|
||||
/* define if libc has program_invocation_name */
|
||||
#undef HAVE_PROGRAM_INVOCATION_NAME
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
|
||||
/* Define to 1 if you have the `sbrk' function. */
|
||||
#undef HAVE_SBRK
|
||||
|
||||
/* Define to 1 if you have the <sched.h> header file. */
|
||||
#undef HAVE_SCHED_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct mallinfo'. */
|
||||
#undef HAVE_STRUCT_MALLINFO
|
||||
|
||||
/* Define to 1 if you have the <sys/cdefs.h> header file. */
|
||||
#undef HAVE_SYS_CDEFS_H
|
||||
|
||||
/* Define to 1 if you have the <sys/malloc.h> header file. */
|
||||
#undef HAVE_SYS_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/prctl.h> header file. */
|
||||
#undef HAVE_SYS_PRCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/syscall.h> header file. */
|
||||
#undef HAVE_SYS_SYSCALL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* <sys/ucontext.h> is broken on redhat 7 */
|
||||
#undef HAVE_SYS_UCONTEXT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if compiler supports __thread */
|
||||
#define HAVE_TLS 1
|
||||
|
||||
/* Define to 1 if you have the <ucontext.h> header file. */
|
||||
#undef HAVE_UCONTEXT_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <unwind.h> header file. */
|
||||
#undef HAVE_UNWIND_H
|
||||
|
||||
/* Define to 1 if you have the <valgrind.h> header file. */
|
||||
#undef HAVE_VALGRIND_H
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#undef HAVE___ATTRIBUTE__
|
||||
|
||||
/* Define to 1 if compiler supports __environ */
|
||||
#undef HAVE___ENVIRON
|
||||
|
||||
/* Define to 1 if the system has the type `__int64'. */
|
||||
#define HAVE___INT64 1
|
||||
|
||||
/* prefix where we look for installed files */
|
||||
#undef INSTALL_PREFIX
|
||||
|
||||
/* Define to 1 if int32_t is equivalent to intptr_t */
|
||||
#undef INT32_EQUALS_INTPTR
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to 'volatile' if __malloc_hook is declared volatile */
|
||||
#undef MALLOC_HOOK_MAYBE_VOLATILE
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "gperftools"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "opensource@google.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "gperftools"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "gperftools 2.2"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "gperftools"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.2"
|
||||
|
||||
/* How to access the PC from a struct ucontext */
|
||||
#undef PC_FROM_UCONTEXT
|
||||
|
||||
/* Always the empty-string on non-windows systems. On windows, should be
|
||||
"__declspec(dllexport)". This way, when we compile the dll, we export our
|
||||
functions/classes. It's safe to define this here because config.h is only
|
||||
used internally, to compile the DLL, and every DLL source file #includes
|
||||
"config.h" before anything else. */
|
||||
#ifndef PERFTOOLS_DLL_DECL
|
||||
# define PERFTOOLS_IS_A_DLL 0 /* not set if you're statically linking */
|
||||
# define PERFTOOLS_DLL_DECL /**/
|
||||
# define PERFTOOLS_DLL_DECL_FOR_UNITTESTS /**/
|
||||
#endif
|
||||
|
||||
/* printf format code for printing a size_t and ssize_t */
|
||||
#define PRIdS "Id"
|
||||
|
||||
/* printf format code for printing a size_t and ssize_t */
|
||||
#define PRIuS "Iu"
|
||||
|
||||
/* printf format code for printing a size_t and ssize_t */
|
||||
#define PRIxS "Ix"
|
||||
|
||||
/* Mark the systems where we know it's bad if pthreads runs too
|
||||
early before main (before threads are initialized, presumably). */
|
||||
#ifdef __FreeBSD__
|
||||
#define PTHREADS_CRASHES_IF_RUN_TOO_EARLY 1
|
||||
#endif
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* the namespace where STL code like vector<> is defined */
|
||||
#define STL_NAMESPACE std
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* C99 says: define this to get the PRI... macros from stdint.h */
|
||||
#ifndef __STDC_FORMAT_MACROS
|
||||
# define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Extra stuff not found in config.h.in
|
||||
|
||||
// This must be defined before the windows.h is included. We need at
|
||||
// least 0x0400 for mutex.h to have access to TryLock, and at least
|
||||
// 0x0501 for patch_functions.cc to have access to GetModuleHandleEx.
|
||||
// (This latter is an optimization we could take out if need be.)
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
||||
// We want to make sure not to ever try to #include heap-checker.h
|
||||
#define NO_HEAP_CHECK 1
|
||||
|
||||
// TODO(csilvers): include windows/port.h in every relevant source file instead?
|
||||
#include "windows/port.h"
|
||||
|
||||
#endif /* GOOGLE_PERFTOOLS_WINDOWS_CONFIG_H_ */
|
2
src/third_party/gperftools-2.2/src/config.h
vendored
2
src/third_party/gperftools-2.2/src/config.h
vendored
@ -2,6 +2,8 @@
|
||||
#include "config-10gen-linux.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include "config-10gen-macos.h"
|
||||
#elif defined(_WIN32)
|
||||
#include "config-10gen-windows.h"
|
||||
#else
|
||||
#error "In tree version of TCMalloc not supported on this platform!"
|
||||
#endif
|
||||
|
4
src/third_party/wiredtiger/SConscript
vendored
4
src/third_party/wiredtiger/SConscript
vendored
@ -3,6 +3,7 @@ import re
|
||||
import textwrap
|
||||
|
||||
Import("env debugBuild")
|
||||
Import("get_option")
|
||||
|
||||
env = env.Clone()
|
||||
env.InjectThirdPartyIncludePaths(libraries=['snappy', 'zlib'])
|
||||
@ -23,6 +24,9 @@ if env.TargetOSIs('windows'):
|
||||
env.Append(CFLAGS=[
|
||||
"/wd4090" # Ignore warning about mismatched const qualifiers
|
||||
])
|
||||
if get_option('allocator') == 'tcmalloc':
|
||||
env.InjectThirdPartyIncludePaths(libraries=['gperftools'])
|
||||
env.Append(CPPDEFINES=['HAVE_LIBTCMALLOC'])
|
||||
elif env.TargetOSIs('osx'):
|
||||
env.Append(CPPPATH=["build_darwin"])
|
||||
elif env.TargetOSIs('solaris'):
|
||||
|
Loading…
Reference in New Issue
Block a user