From 735fde8c742188d019e41faf26ff67aab6a24d25 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Sep 2012 18:52:08 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added LLThreadLocalPtr broke llmutex out into llmutex.h got primary sampling buffer under thread local storage --- indra/llcommon/llmemory.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 6a2323e7d8..4480e381e8 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -30,6 +30,11 @@ class LLMutex ; +#ifdef LL_WINDOWS +#define LL_ALIGNED(x) __declspec(align(x)) +#else +#define LL_ALIGNED(x) __attribute__ ((aligned (16))) +#endif inline void* ll_aligned_malloc( size_t size, int align ) { void* mem = malloc( size + (align - 1) + sizeof(void*) ); -- cgit v1.2.3 From 5d51175cd79b15cf036cd7e6bd646a1a0777eb7f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 20 Nov 2012 15:55:04 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixes to merge --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 3744e68956..e725bdd9fa 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -26,7 +26,7 @@ #ifndef LLMEMORY_H #define LLMEMORY_H -#include "llmemtype.h" +#include "linden_common.h" class LLMutex ; -- cgit v1.2.3 From 6e82bb7789c1e046dcfb97c6773150df110153f8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 3 Jan 2013 22:34:34 +0000 Subject: fixing linux compile errors for llcommon after LLTrace work --- indra/llcommon/llmemory.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index e725bdd9fa..7e73afe06a 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,6 +27,7 @@ #define LLMEMORY_H #include "linden_common.h" +#include "stdint.h" class LLMutex ; -- cgit v1.2.3 From b2197101c488de66ca9ecf71c229f5b80d1390fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 4 Jan 2013 13:04:09 -0800 Subject: SH-3468 WIP add memory tracking base class fix for compile error on windows ignore stdint.h even though VS2010 provides it --- indra/llcommon/llmemory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 7e73afe06a..4ead45679f 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,7 +27,9 @@ #define LLMEMORY_H #include "linden_common.h" -#include "stdint.h" +#if !LL_WINDOWS +#include +#endif class LLMutex ; -- cgit v1.2.3 From 1a888f786c274ee6eaed54272718eeef5e685dbf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 9 Jan 2013 23:05:07 -0800 Subject: SH-3468 WIP add memory tracking base class made LLTrace::MemTrackable support custom alignment LLDrawable now uses MemTrackable new and delete operators --- indra/llcommon/llmemory.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 4ead45679f..95500753e4 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -39,6 +39,20 @@ class LLMutex ; #define LL_CHECK_MEMORY #endif +#if LL_WINDOWS +#define LL_ALIGN_OF __alignof +#else +#define LL_ALIGN_OF __align_of__ +#endif + +#if LL_WINDOWS +#define LL_DEFAULT_HEAP_ALIGN 8 +#elif LL_DARWIN +#define LL_DEFAULT_HEAP_ALIGN 16 +#elif LL_LINUX +#define LL_DEFAULT_HEAP_ALIGN 8 +#endif + inline void* ll_aligned_malloc( size_t size, int align ) { void* mem = malloc( size + (align - 1) + sizeof(void*) ); -- cgit v1.2.3 From d122318bef2ff0eced7641dc24f411f792bd2935 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 8 Jul 2013 00:55:17 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console added percentage/ratio units added auto-range and auto tick calculation to stat bar to automate display stats --- indra/llcommon/llmemory.h | 45 --------------------------------------------- 1 file changed, 45 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 95500753e4..a24d97576f 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -184,51 +184,6 @@ private: static BOOL sEnableMemoryFailurePrevention; }; -//---------------------------------------------------------------------------- -#if MEM_TRACK_MEM -class LLMutex ; -class LL_COMMON_API LLMemTracker -{ -private: - LLMemTracker() ; - ~LLMemTracker() ; - -public: - static void release() ; - static LLMemTracker* getInstance() ; - - void track(const char* function, const int line) ; - void preDraw(BOOL pause) ; - void postDraw() ; - const char* getNextLine() ; - -private: - static LLMemTracker* sInstance ; - - char** mStringBuffer ; - S32 mCapacity ; - U32 mLastAllocatedMem ; - S32 mCurIndex ; - S32 mCounter; - S32 mDrawnIndex; - S32 mNumOfDrawn; - BOOL mPaused; - LLMutex* mMutexp ; -}; - -#define MEM_TRACK_RELEASE LLMemTracker::release() ; -#define MEM_TRACK LLMemTracker::getInstance()->track(__FUNCTION__, __LINE__) ; - -#else // MEM_TRACK_MEM - -#define MEM_TRACK_RELEASE -#define MEM_TRACK - -#endif // MEM_TRACK_MEM - -//---------------------------------------------------------------------------- - - // //class LLPrivateMemoryPool defines a private memory pool for an application to use, so the application does not //need to access the heap directly fro each memory allocation. Throught this, the allocation speed is faster, -- cgit v1.2.3 From 25937040de9a787c221aae7f178f43827c799028 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 16 Aug 2013 12:38:12 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms converted many values over to units system in effort to track down source of 0 ping --- indra/llcommon/llmemory.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index a24d97576f..c45c7ed213 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,6 +27,7 @@ #define LLMEMORY_H #include "linden_common.h" +#include "llunit.h" #if !LL_WINDOWS #include #endif @@ -170,17 +171,17 @@ public: static void logMemoryInfo(BOOL update = FALSE); static bool isMemoryPoolLow(); - static U32 getAvailableMemKB() ; - static U32 getMaxMemKB() ; - static U32 getAllocatedMemKB() ; + static U32Kibibytes getAvailableMemKB() ; + static U32Kibibytes getMaxMemKB() ; + static U32Kibibytes getAllocatedMemKB() ; private: static char* reserveMem; - static U32 sAvailPhysicalMemInKB ; - static U32 sMaxPhysicalMemInKB ; - static U32 sAllocatedMemInKB; - static U32 sAllocatedPageSizeInKB ; + static U32Kibibytes sAvailPhysicalMemInKB ; + static U32Kibibytes sMaxPhysicalMemInKB ; + static U32Kibibytes sAllocatedMemInKB; + static U32Kibibytes sAllocatedPageSizeInKB ; - static U32 sMaxHeapSizeInKB; + static U32Kibibytes sMaxHeapSizeInKB; static BOOL sEnableMemoryFailurePrevention; }; -- cgit v1.2.3 From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 18 Aug 2013 22:30:27 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits --- indra/llcommon/llmemory.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index c45c7ed213..23be1e5b2d 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -166,22 +166,22 @@ public: static U64 getCurrentRSS(); static U32 getWorkingSetSize(); static void* tryToAlloc(void* address, U32 size); - static void initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure); + static void initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure); static void updateMemoryInfo() ; static void logMemoryInfo(BOOL update = FALSE); static bool isMemoryPoolLow(); - static U32Kibibytes getAvailableMemKB() ; - static U32Kibibytes getMaxMemKB() ; - static U32Kibibytes getAllocatedMemKB() ; + static U32Kilobytes getAvailableMemKB() ; + static U32Kilobytes getMaxMemKB() ; + static U32Kilobytes getAllocatedMemKB() ; private: static char* reserveMem; - static U32Kibibytes sAvailPhysicalMemInKB ; - static U32Kibibytes sMaxPhysicalMemInKB ; - static U32Kibibytes sAllocatedMemInKB; - static U32Kibibytes sAllocatedPageSizeInKB ; + static U32Kilobytes sAvailPhysicalMemInKB ; + static U32Kilobytes sMaxPhysicalMemInKB ; + static U32Kilobytes sAllocatedMemInKB; + static U32Kilobytes sAllocatedPageSizeInKB ; - static U32Kibibytes sMaxHeapSizeInKB; + static U32Kilobytes sMaxHeapSizeInKB; static BOOL sEnableMemoryFailurePrevention; }; -- cgit v1.2.3 From a7aed07a5b620977fb74e4070e432eef01d11d3c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 27 Aug 2013 13:41:19 -0700 Subject: broke out llunit.h into llunittype.h and llunits.h for unit declarations changed unit declarations macros to make a lot more sense --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 23be1e5b2d..d3c5e5235d 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,7 +27,7 @@ #define LLMEMORY_H #include "linden_common.h" -#include "llunit.h" +#include "llunits.h" #if !LL_WINDOWS #include #endif -- cgit v1.2.3 From 053d97db1b283ca2548dc1f64756ddfc5166158f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 25 Sep 2013 19:12:35 -0700 Subject: better memory usage for LLTrace (tighter packing of recording arrays) removed complicated and unnecessary fast timer gapless handoff logic (it should be gapless anyway) improved MemTrackable API, better separation of shadow and footprint added memory usage stats to floater_stats.xml --- indra/llcommon/llmemory.h | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index d3c5e5235d..2330bfb8ea 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -54,7 +54,7 @@ class LLMutex ; #define LL_DEFAULT_HEAP_ALIGN 8 #endif -inline void* ll_aligned_malloc( size_t size, int align ) +inline void* ll_aligned_malloc_fallback( size_t size, int align ) { void* mem = malloc( size + (align - 1) + sizeof(void*) ); char* aligned = ((char*)mem) + sizeof(void*); @@ -64,7 +64,7 @@ inline void* ll_aligned_malloc( size_t size, int align ) return aligned; } -inline void ll_aligned_free( void* ptr ) +inline void ll_aligned_free_fallback( void* ptr ) { free( ((void**)ptr)[-1] ); } @@ -130,7 +130,7 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi #if defined(LL_WINDOWS) return _aligned_malloc(size, 32); #elif defined(LL_DARWIN) - return ll_aligned_malloc( size, 32 ); + return ll_aligned_malloc_fallback( size, 32 ); #else void *rtn; if (LL_LIKELY(0 == posix_memalign(&rtn, 32, size))) @@ -151,6 +151,49 @@ inline void ll_aligned_free_32(void *p) #endif } +// general purpose dispatch functions that are forced inline so they can compile down to a single call +LL_FORCE_INLINE void* ll_aligned_malloc(size_t alignment, size_t size) +{ + if (LL_DEFAULT_HEAP_ALIGN % alignment == 0) + { + return malloc(size); + } + else if (alignment == 16) + { + return ll_aligned_malloc_16(size); + } + else if (alignment == 32) + { + return ll_aligned_malloc_32(size); + } + else + { + return ll_aligned_malloc_fallback(size, alignment); + } +} + +LL_FORCE_INLINE void ll_aligned_free(size_t alignment, void* ptr) +{ + if (alignment == LL_DEFAULT_HEAP_ALIGN) + { + free(ptr); + } + else if (alignment == 16) + { + ll_aligned_free_16(ptr); + } + else if (alignment == 32) + { + return ll_aligned_free_32(ptr); + } + else + { + return ll_aligned_free_fallback(ptr); + } +} + + + #ifndef __DEBUG_PRIVATE_MEM__ #define __DEBUG_PRIVATE_MEM__ 0 #endif -- cgit v1.2.3 From e0a443f5a6b76fd1ab5ffaa8e7a1941d47c80f4f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Sep 2013 11:18:39 -0700 Subject: BUILDFIX: fix for mac builds also, fixed alignment of tick labels on stat bars --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 2330bfb8ea..8daea255f9 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -145,7 +145,7 @@ inline void ll_aligned_free_32(void *p) #if defined(LL_WINDOWS) _aligned_free(p); #elif defined(LL_DARWIN) - ll_aligned_free( p ); + ll_aligned_free_fallback( p ); #else free(p); // posix_memalign() is compatible with heap deallocator #endif -- cgit v1.2.3 From 1acceb3633c0f0c4fdf29b17d77d67c8a9b71986 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 14 Oct 2013 10:18:41 -0700 Subject: changed ll_aligned_(malloc|free) to take alignment size as a template argument --- indra/llcommon/llmemory.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 5ed4ea7d9e..3de59350db 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -204,37 +204,39 @@ inline void ll_aligned_free_32(void *p) } // general purpose dispatch functions that are forced inline so they can compile down to a single call -LL_FORCE_INLINE void* ll_aligned_malloc(size_t alignment, size_t size) +template +LL_FORCE_INLINE void* ll_aligned_malloc(size_t size) { - if (LL_DEFAULT_HEAP_ALIGN % alignment == 0) + if (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0) { return malloc(size); } - else if (alignment == 16) + else if (ALIGNMENT == 16) { return ll_aligned_malloc_16(size); } - else if (alignment == 32) + else if (ALIGNMENT == 32) { return ll_aligned_malloc_32(size); } else { - return ll_aligned_malloc_fallback(size, alignment); + return ll_aligned_malloc_fallback(size, ALIGNMENT); } } -LL_FORCE_INLINE void ll_aligned_free(size_t alignment, void* ptr) +template +LL_FORCE_INLINE void ll_aligned_free(void* ptr) { - if (alignment == LL_DEFAULT_HEAP_ALIGN) + if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) { free(ptr); } - else if (alignment == 16) + else if (ALIGNMENT == 16) { ll_aligned_free_16(ptr); } - else if (alignment == 32) + else if (ALIGNMENT == 32) { return ll_aligned_free_32(ptr); } -- cgit v1.2.3 From 3040b429a3b136b87ddb0ae88ccfa3a7aa71e232 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Feb 2014 11:27:16 -0800 Subject: added LL_TRACE_ENABLED to allow disabling of lltrace --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 3de59350db..1aa095e71c 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -37,7 +37,7 @@ class LLMutex ; #if LL_WINDOWS && LL_DEBUG #define LL_CHECK_MEMORY llassert(_CrtCheckMemory()); #else -#define LL_CHECK_MEMORY +#define LL_CHECK_MEMORY _CrtCheckMemory(); #endif -- cgit v1.2.3 From a8192fbf60540e42dcff5f1efb8bf8cafbfac484 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Feb 2014 13:14:40 -0800 Subject: accidentally left _CrtCheckMemory defined in non-Windows builds --- indra/llcommon/llmemory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.h') diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 1aa095e71c..db52f2b1f4 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -37,7 +37,7 @@ class LLMutex ; #if LL_WINDOWS && LL_DEBUG #define LL_CHECK_MEMORY llassert(_CrtCheckMemory()); #else -#define LL_CHECK_MEMORY _CrtCheckMemory(); +#define LL_CHECK_MEMORY #endif -- cgit v1.2.3