Add tcmalloc replacement bits into LL code.

Nicky 2013-01-02 18:11:03 +01:00
parent a0851aac76
commit c3f84e8ef4
5 changed files with 36 additions and 2 deletions

View File

@ -4,6 +4,7 @@ include(Prebuilt)
# If you want to enable or disable TCMALLOC in viewer builds, this is the place.
# set ON or OFF as desired.
set (USE_TCMALLOC ON)
#set (USE_TCMALLOC OFF) # <FS:ND> tcmalloc removal
if (STANDALONE)
include(FindGooglePerfTools)
@ -59,3 +60,9 @@ if (USE_GOOGLE_PERFTOOLS)
set(GOOGLE_PERFTOOLS_LIBRARIES ${TCMALLOC_LIBRARIES} ${STACKTRACE_LIBRARIES} ${PROFILER_LIBRARIES})
else (USE_GOOGLE_PERFTOOLS)
endif (USE_GOOGLE_PERFTOOLS)
# <FS:ND> tcmalloc removal
if( NOT USE_TCMALLOC )
add_definitions( -DND_NO_TCMALLOC )
endif( NOT USE_TCMALLOC )
# </FS:ND> tcmalloc removal

View File

@ -108,7 +108,6 @@ set(llcommon_SOURCE_FILES
reflective.cpp
timing.cpp
u64.cpp
ndintrin.cpp
)
set(llcommon_HEADER_FILES
@ -266,9 +265,13 @@ set(llcommon_HEADER_FILES
timer.h
timing.h
u64.h
ndintrin.h
)
# <FS:ND> Add all nd* files. memory pool, intrinsics, ...
list(APPEND llcommon_SOURCE_FILES ndallocators.cpp ndintrin.cpp ndmemorypool.cpp )
list(APPEND llcommon_HEADER_FILES ndintrin.h ndlocks.h ndmemory.h ndmemorypool.h ndpooldefines.h )
# </FS:ND>
# <FS:CR> Add OSSL constants for OpenSim builds
if (HAS_OPENSIM_SUPPORT)
LIST(APPEND llcommon_HEADER_FILES

View File

@ -34,6 +34,11 @@
#define LL_CHECK_MEMORY
#endif
// <FS:ND> No tcmalloc
#ifdef ND_NO_TCMALLOC
#include "ndmemory.h"
#else
inline void* ll_aligned_malloc( size_t size, int align )
{
void* mem = malloc( size + (align - 1) + sizeof(void*) );
@ -130,6 +135,7 @@ inline void ll_aligned_free_32(void *p)
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
#endif // </FS:ND> No tcmalloc
#ifndef __DEBUG_PRIVATE_MEM__
#define __DEBUG_PRIVATE_MEM__ 0
@ -450,6 +456,9 @@ public:
static void freeMem(LLPrivateMemoryPool* poolp, void* addr) ;
};
// <FS:ND> No tcmalloc
#ifndef ND_NO_TCMALLOC
//-------------------------------------------------------------------------------------
#if __DEBUG_PRIVATE_MEM__
#define ALLOCATE_MEM(poolp, size) LLPrivateMemoryPoolManager::allocate((poolp), (size), __FUNCTION__, __LINE__)
@ -459,6 +468,9 @@ public:
#define FREE_MEM(poolp, addr) LLPrivateMemoryPoolManager::freeMem((poolp), (addr))
//-------------------------------------------------------------------------------------
#endif
// </FS:ND> No tcmalloc
//
//the below singleton is used to test the private memory pool.
//

View File

@ -93,6 +93,7 @@ const char MEMINFO_FILE[] = "/proc/meminfo";
extern int errno;
#endif
#include "ndmemorypool.h" // <FS:ND/> tcmalloc replacement
static const S32 CPUINFO_BUFFER_SIZE = 16383;
LLCPUInfo gSysCPU;
@ -916,6 +917,10 @@ void LLMemoryInfo::stream(std::ostream& s) const
s << value; // just use default LLSD formatting
s << std::endl;
}
// <FS:ND> tcmalloc replacement
ndMemoryPool::dumpStats( s );
// </FS:ND>
}
LLSD LLMemoryInfo::getStatsMap() const

View File

@ -241,6 +241,8 @@
// define a self-registering event API object
#include "llappviewerlistener.h"
#include "ndmemorypool.h" // <FS:ND/> tcmalloc replacement
#if (LL_LINUX || LL_SOLARIS) && LL_GTK
#include "glib.h"
#endif // (LL_LINUX || LL_SOLARIS) && LL_GTK
@ -718,6 +720,8 @@ LLAppViewer::~LLAppViewer()
bool LLAppViewer::init()
{
ndMemoryPool::startUp(); // <FS:ND/> tcmalloc replacement
//
// Start of the application
//
@ -2177,6 +2181,9 @@ bool LLAppViewer::cleanup()
llinfos << "Goodbye!" << llendflush;
// This coud leak memory that was allocated in the pool. But that's ok. We're about to die and the OS will take care of this.
// ndMemoryPool::tearDown(); // <FS:ND/> tcmalloc replacement
// return 0;
return true;
}