From 9d77e030d9a0d23cebce616631677459eec1612c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Nov 2012 23:52:27 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system cleaning up build moved most includes of windows.h to llwin32headers.h to disable min/max macros, etc streamlined Time class and consolidated functionality in BlockTimer class llfasttimer is no longer included via llstring.h, so had to add it manually in several places --- indra/llcommon/llmemory.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index afaf366668..7c4ab6cf98 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -32,7 +32,6 @@ //#endif #if defined(LL_WINDOWS) -//# include # include #elif defined(LL_DARWIN) # include -- 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.cpp | 137 -------------------------------------------- 1 file changed, 137 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index c6b02df939..3fe7470d06 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -27,9 +27,7 @@ #include "linden_common.h" -//#if MEM_TRACK_MEM #include "llthread.h" -//#endif #if defined(LL_WINDOWS) # include @@ -421,141 +419,6 @@ U32 LLMemory::getWorkingSetSize() #endif -//-------------------------------------------------------------------------------------------------- -#if MEM_TRACK_MEM -#include "llframetimer.h" - -//static -LLMemTracker* LLMemTracker::sInstance = NULL ; - -LLMemTracker::LLMemTracker() -{ - mLastAllocatedMem = LLMemory::getWorkingSetSize() ; - mCapacity = 128 ; - mCurIndex = 0 ; - mCounter = 0 ; - mDrawnIndex = 0 ; - mPaused = FALSE ; - - mMutexp = new LLMutex() ; - mStringBuffer = new char*[128] ; - mStringBuffer[0] = new char[mCapacity * 128] ; - for(S32 i = 1 ; i < mCapacity ; i++) - { - mStringBuffer[i] = mStringBuffer[i-1] + 128 ; - } -} - -LLMemTracker::~LLMemTracker() -{ - delete[] mStringBuffer[0] ; - delete[] mStringBuffer; - delete mMutexp ; -} - -//static -LLMemTracker* LLMemTracker::getInstance() -{ - if(!sInstance) - { - sInstance = new LLMemTracker() ; - } - return sInstance ; -} - -//static -void LLMemTracker::release() -{ - if(sInstance) - { - delete sInstance ; - sInstance = NULL ; - } -} - -//static -void LLMemTracker::track(const char* function, const int line) -{ - static const S32 MIN_ALLOCATION = 0 ; //1KB - - if(mPaused) - { - return ; - } - - U32 allocated_mem = LLMemory::getWorkingSetSize() ; - - LLMutexLock lock(mMutexp) ; - - S32 delta_mem = allocated_mem - mLastAllocatedMem ; - mLastAllocatedMem = allocated_mem ; - - if(delta_mem <= 0) - { - return ; //occupied memory does not grow - } - - if(delta_mem < MIN_ALLOCATION) - { - return ; - } - - char* buffer = mStringBuffer[mCurIndex++] ; - F32 time = (F32)LLFrameTimer::getElapsedSeconds() ; - S32 hours = (S32)(time / (60*60)); - S32 mins = (S32)((time - hours*(60*60)) / 60); - S32 secs = (S32)((time - hours*(60*60) - mins*60)); - strcpy(buffer, function) ; - sprintf(buffer + strlen(function), " line: %d DeltaMem: %d (bytes) Time: %d:%02d:%02d", line, delta_mem, hours,mins,secs) ; - - if(mCounter < mCapacity) - { - mCounter++ ; - } - if(mCurIndex >= mCapacity) - { - mCurIndex = 0 ; - } -} - - -//static -void LLMemTracker::preDraw(BOOL pause) -{ - mMutexp->lock() ; - - mPaused = pause ; - mDrawnIndex = mCurIndex - 1; - mNumOfDrawn = 0 ; -} - -//static -void LLMemTracker::postDraw() -{ - mMutexp->unlock() ; -} - -//static -const char* LLMemTracker::getNextLine() -{ - if(mNumOfDrawn >= mCounter) - { - return NULL ; - } - mNumOfDrawn++; - - if(mDrawnIndex < 0) - { - mDrawnIndex = mCapacity - 1 ; - } - - return mStringBuffer[mDrawnIndex--] ; -} - -#endif //MEM_TRACK_MEM -//-------------------------------------------------------------------------------------------------- - - //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //minimum slot size and minimal slot size interval -- cgit v1.2.3 From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 17:11:19 -0700 Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new LL_INFOS(), LL_DEBUGS(), etc. --- indra/llcommon/llmemory.cpp | 88 ++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 3fe7470d06..a9256124f2 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -64,7 +64,7 @@ void ll_assert_aligned_func(uintptr_t ptr,U32 alignment) // Redundant, place to set breakpoints. if (ptr%alignment!=0) { - llwarns << "alignment check failed" << llendl; + LL_WARNS() << "alignment check failed" << LL_ENDL; } llassert(ptr%alignment==0); #endif @@ -109,7 +109,7 @@ void LLMemory::updateMemoryInfo() if (!GetProcessMemoryInfo(self, &counters, sizeof(counters))) { - llwarns << "GetProcessMemoryInfo failed" << llendl; + LL_WARNS() << "GetProcessMemoryInfo failed" << LL_ENDL; return ; } @@ -153,7 +153,7 @@ void* LLMemory::tryToAlloc(void* address, U32 size) { if(!VirtualFree(address, 0, MEM_RELEASE)) { - llerrs << "error happens when free some memory reservation." << llendl ; + LL_ERRS() << "error happens when free some memory reservation." << LL_ENDL ; } } return address ; @@ -171,14 +171,14 @@ void LLMemory::logMemoryInfo(BOOL update) LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ; } - llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; - llinfos << "Current allocated page size (KB): " << sAllocatedPageSizeInKB << llendl ; - llinfos << "Current availabe physical memory(KB): " << sAvailPhysicalMemInKB << llendl ; - llinfos << "Current max usable memory(KB): " << sMaxPhysicalMemInKB << llendl ; + LL_INFOS() << "Current allocated physical memory(KB): " << sAllocatedMemInKB << LL_ENDL ; + LL_INFOS() << "Current allocated page size (KB): " << sAllocatedPageSizeInKB << LL_ENDL ; + LL_INFOS() << "Current availabe physical memory(KB): " << sAvailPhysicalMemInKB << LL_ENDL ; + LL_INFOS() << "Current max usable memory(KB): " << sMaxPhysicalMemInKB << LL_ENDL ; - llinfos << "--- private pool information -- " << llendl ; - llinfos << "Total reserved (KB): " << LLPrivateMemoryPoolManager::getInstance()->mTotalReservedSize / 1024 << llendl ; - llinfos << "Total allocated (KB): " << LLPrivateMemoryPoolManager::getInstance()->mTotalAllocatedSize / 1024 << llendl ; + LL_INFOS() << "--- private pool information -- " << LL_ENDL ; + LL_INFOS() << "Total reserved (KB): " << LLPrivateMemoryPoolManager::getInstance()->mTotalReservedSize / 1024 << LL_ENDL ; + LL_INFOS() << "Total allocated (KB): " << LLPrivateMemoryPoolManager::getInstance()->mTotalAllocatedSize / 1024 << LL_ENDL ; } //return 0: everything is normal; @@ -260,7 +260,7 @@ U64 LLMemory::getCurrentRSS() if (!GetProcessMemoryInfo(self, &counters, sizeof(counters))) { - llwarns << "GetProcessMemoryInfo failed" << llendl; + LL_WARNS() << "GetProcessMemoryInfo failed" << LL_ENDL; return 0; } @@ -298,7 +298,7 @@ U32 LLMemory::getWorkingSetSize() // if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1) // { -// llwarns << "Couldn't get page size" << llendl; +// LL_WARNS() << "Couldn't get page size" << LL_ENDL; // return 0; // } else { // return page_size; @@ -317,11 +317,11 @@ U64 LLMemory::getCurrentRSS() // If we ever wanted it, the process virtual size is also available as: // virtualSize = basicInfo.virtual_size; -// llinfos << "resident size is " << residentSize << llendl; +// LL_INFOS() << "resident size is " << residentSize << LL_ENDL; } else { - llwarns << "task_info failed" << llendl; + LL_WARNS() << "task_info failed" << LL_ENDL; } return residentSize; @@ -342,7 +342,7 @@ U64 LLMemory::getCurrentRSS() if (fp == NULL) { - llwarns << "couldn't open " << statPath << llendl; + LL_WARNS() << "couldn't open " << statPath << LL_ENDL; goto bail; } @@ -355,7 +355,7 @@ U64 LLMemory::getCurrentRSS() &rss); if (ret != 1) { - llwarns << "couldn't parse contents of " << statPath << llendl; + LL_WARNS() << "couldn't parse contents of " << statPath << LL_ENDL; rss = 0; } } @@ -385,12 +385,12 @@ U64 LLMemory::getCurrentRSS() sprintf(path, "/proc/%d/psinfo", (int)getpid()); int proc_fd = -1; if((proc_fd = open(path, O_RDONLY)) == -1){ - llwarns << "LLmemory::getCurrentRSS() unable to open " << path << ". Returning 0 RSS!" << llendl; + LL_WARNS() << "LLmemory::getCurrentRSS() unable to open " << path << ". Returning 0 RSS!" << LL_ENDL; return 0; } psinfo_t proc_psinfo; if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){ - llwarns << "LLmemory::getCurrentRSS() Unable to read from " << path << ". Returning 0 RSS!" << llendl; + LL_WARNS() << "LLmemory::getCurrentRSS() Unable to read from " << path << ". Returning 0 RSS!" << LL_ENDL; close(proc_fd); return 0; } @@ -823,7 +823,7 @@ void LLPrivateMemoryPool::LLMemoryChunk::dump() total_size += blk_list[i]->getBufferSize() ; if((U32)blk_list[i]->getBuffer() < (U32)blk_list[i-1]->getBuffer() + blk_list[i-1]->getBufferSize()) { - llerrs << "buffer corrupted." << llendl ; + LL_ERRS() << "buffer corrupted." << LL_ENDL ; } } @@ -844,32 +844,32 @@ void LLPrivateMemoryPool::LLMemoryChunk::dump() } else { - llerrs << "gap happens" << llendl ; + LL_ERRS() << "gap happens" << LL_ENDL ; } } #endif #if 0 - llinfos << "---------------------------" << llendl ; - llinfos << "Chunk buffer: " << (U32)getBuffer() << " size: " << getBufferSize() << llendl ; + LL_INFOS() << "---------------------------" << LL_ENDL ; + LL_INFOS() << "Chunk buffer: " << (U32)getBuffer() << " size: " << getBufferSize() << LL_ENDL ; - llinfos << "available blocks ... " << llendl ; + LL_INFOS() << "available blocks ... " << LL_ENDL ; for(S32 i = 0 ; i < mBlockLevels ; i++) { LLMemoryBlock* blk = mAvailBlockList[i] ; while(blk) { - llinfos << "blk buffer " << (U32)blk->getBuffer() << " size: " << blk->getBufferSize() << llendl ; + LL_INFOS() << "blk buffer " << (U32)blk->getBuffer() << " size: " << blk->getBufferSize() << LL_ENDL ; blk = blk->mNext ; } } - llinfos << "free blocks ... " << llendl ; + LL_INFOS() << "free blocks ... " << LL_ENDL ; for(S32 i = 0 ; i < mPartitionLevels ; i++) { LLMemoryBlock* blk = mFreeSpaceList[i] ; while(blk) { - llinfos << "blk buffer " << (U32)blk->getBuffer() << " size: " << blk->getBufferSize() << llendl ; + LL_INFOS() << "blk buffer " << (U32)blk->getBuffer() << " size: " << blk->getBufferSize() << LL_ENDL ; blk = blk->mNext ; } } @@ -1265,7 +1265,7 @@ char* LLPrivateMemoryPool::allocate(U32 size) if(to_log) { - llwarns << "The memory pool overflows, now using heap directly!" << llendl ; + LL_WARNS() << "The memory pool overflows, now using heap directly!" << LL_ENDL ; to_log = false ; } @@ -1358,7 +1358,7 @@ void LLPrivateMemoryPool::destroyPool() if(mNumOfChunks > 0) { - llwarns << "There is some memory not freed when destroy the memory pool!" << llendl ; + LL_WARNS() << "There is some memory not freed when destroy the memory pool!" << LL_ENDL ; } mNumOfChunks = 0 ; @@ -1376,11 +1376,11 @@ bool LLPrivateMemoryPool::checkSize(U32 asked_size) { if(mReservedPoolSize + asked_size > mMaxPoolSize) { - llinfos << "Max pool size: " << mMaxPoolSize << llendl ; - llinfos << "Total reserved size: " << mReservedPoolSize + asked_size << llendl ; - llinfos << "Total_allocated Size: " << getTotalAllocatedSize() << llendl ; + LL_INFOS() << "Max pool size: " << mMaxPoolSize << LL_ENDL ; + LL_INFOS() << "Total reserved size: " << mReservedPoolSize + asked_size << LL_ENDL ; + LL_INFOS() << "Total_allocated Size: " << getTotalAllocatedSize() << LL_ENDL ; - //llerrs << "The pool is overflowing..." << llendl ; + //LL_ERRS() << "The pool is overflowing..." << LL_ENDL ; return false ; } @@ -1593,7 +1593,7 @@ void LLPrivateMemoryPool::removeFromHashTable(LLMemoryChunk* chunk) void LLPrivateMemoryPool::rehash() { - llinfos << "new hash factor: " << mHashFactor << llendl ; + LL_INFOS() << "new hash factor: " << mHashFactor << LL_ENDL ; mChunkHashList.clear() ; mChunkHashList.resize(mHashFactor) ; @@ -1673,7 +1673,7 @@ void LLPrivateMemoryPool::LLChunkHashElement::remove(LLPrivateMemoryPool::LLMemo } else { - llerrs << "This slot does not contain this chunk!" << llendl ; + LL_ERRS() << "This slot does not contain this chunk!" << LL_ENDL ; } } @@ -1705,12 +1705,12 @@ LLPrivateMemoryPoolManager::~LLPrivateMemoryPoolManager() #if __DEBUG_PRIVATE_MEM__ if(!sMemAllocationTracker.empty()) { - llwarns << "there is potential memory leaking here. The list of not freed memory blocks are from: " <first << " : " << iter->second << llendl ; + LL_INFOS() << k++ << ", " << (U32)iter->first << " : " << iter->second << LL_ENDL ; } sMemAllocationTracker.clear() ; } @@ -1906,7 +1906,7 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr } else { - llerrs << "private pool is used before initialized.!" << llendl ; + LL_ERRS() << "private pool is used before initialized.!" << LL_ENDL ; } } } @@ -1980,7 +1980,7 @@ void LLPrivateMemoryPoolTester::test(U32 min_size, U32 max_size, U32 stride, U32 //allocate space for p ; if(!(p = ::new char**[times]) || !(*p = ::new char*[times * levels])) { - llerrs << "memory initialization for p failed" << llendl ; + LL_ERRS() << "memory initialization for p failed" << LL_ENDL ; } //init @@ -2052,8 +2052,8 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times) { LLTimer timer ; - llinfos << " -**********************- " << llendl ; - llinfos << "test size: " << size << " test times: " << times << llendl ; + LL_INFOS() << " -**********************- " << LL_ENDL ; + LL_INFOS() << "test size: " << size << " test times: " << times << LL_ENDL ; timer.reset() ; char** p = new char*[times] ; @@ -2065,7 +2065,7 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times) p[i] = ALLOCATE_MEM(sPool, size) ; if(!p[i]) { - llerrs << "allocation failed" << llendl ; + LL_ERRS() << "allocation failed" << LL_ENDL ; } } //de-allocation @@ -2074,7 +2074,7 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times) FREE_MEM(sPool, p[i]) ; p[i] = NULL ; } - llinfos << "time spent using customized memory pool: " << timer.getElapsedTimeF32() << llendl ; + LL_INFOS() << "time spent using customized memory pool: " << timer.getElapsedTimeF32() << LL_ENDL ; timer.reset() ; @@ -2085,7 +2085,7 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times) p[i] = ::new char[size] ; if(!p[i]) { - llerrs << "allocation failed" << llendl ; + LL_ERRS() << "allocation failed" << LL_ENDL ; } } //de-allocation @@ -2094,7 +2094,7 @@ void LLPrivateMemoryPoolTester::testAndTime(U32 size, U32 times) ::delete[] p[i] ; p[i] = NULL ; } - llinfos << "time spent using standard allocator/de-allocator: " << timer.getElapsedTimeF32() << llendl ; + LL_INFOS() << "time spent using standard allocator/de-allocator: " << timer.getElapsedTimeF32() << LL_ENDL ; delete[] p; } -- 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.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index a9256124f2..c59b61471a 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -47,11 +47,11 @@ //static char* LLMemory::reserveMem = 0; -U32 LLMemory::sAvailPhysicalMemInKB = U32_MAX ; -U32 LLMemory::sMaxPhysicalMemInKB = 0; -U32 LLMemory::sAllocatedMemInKB = 0; -U32 LLMemory::sAllocatedPageSizeInKB = 0 ; -U32 LLMemory::sMaxHeapSizeInKB = U32_MAX ; +U32Kibibytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); +U32Kibibytes LLMemory::sMaxPhysicalMemInKB(0); +U32Kibibytes LLMemory::sAllocatedMemInKB(0); +U32Kibibytes LLMemory::sAllocatedPageSizeInKB(0); +U32Kibibytes LLMemory::sMaxHeapSizeInKB(U32_MAX); BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE; #if __DEBUG_PRIVATE_MEM__ @@ -116,7 +116,7 @@ void LLMemory::updateMemoryInfo() sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ; sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ; - U32 avail_phys, avail_virtual; + U32Kibibytes avail_phys, avail_virtual; LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB); @@ -232,19 +232,19 @@ bool LLMemory::isMemoryPoolLow() } //static -U32 LLMemory::getAvailableMemKB() +U32Kibibytes LLMemory::getAvailableMemKB() { return sAvailPhysicalMemInKB ; } //static -U32 LLMemory::getMaxMemKB() +U32Kibibytes LLMemory::getMaxMemKB() { return sMaxPhysicalMemInKB ; } //static -U32 LLMemory::getAllocatedMemKB() +U32Kibibytes LLMemory::getAllocatedMemKB() { return sAllocatedMemInKB ; } -- 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.cpp | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index c59b61471a..d46e205500 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -47,11 +47,11 @@ //static char* LLMemory::reserveMem = 0; -U32Kibibytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); -U32Kibibytes LLMemory::sMaxPhysicalMemInKB(0); -U32Kibibytes LLMemory::sAllocatedMemInKB(0); -U32Kibibytes LLMemory::sAllocatedPageSizeInKB(0); -U32Kibibytes LLMemory::sMaxHeapSizeInKB(U32_MAX); +U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); +U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0); +U32Kilobytes LLMemory::sAllocatedMemInKB(0); +U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0); +U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE; #if __DEBUG_PRIVATE_MEM__ @@ -94,9 +94,9 @@ void LLMemory::freeReserve() } //static -void LLMemory::initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure) +void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure) { - sMaxHeapSizeInKB = (U32)(max_heap_size_gb * 1024 * 1024) ; + sMaxHeapSizeInKB = max_heap_size; sEnableMemoryFailurePrevention = prevent_heap_failure ; } @@ -113,10 +113,10 @@ void LLMemory::updateMemoryInfo() return ; } - sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ; - sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ; + sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ; + sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ; - U32Kibibytes avail_phys, avail_virtual; + U32Kilobytes avail_phys, avail_virtual; LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB); @@ -126,7 +126,7 @@ void LLMemory::updateMemoryInfo() } else { - sAvailPhysicalMemInKB = 0 ; + sAvailPhysicalMemInKB = U32Kilobytes(0); } #else //not valid for other systems for now. @@ -187,8 +187,8 @@ void LLMemory::logMemoryInfo(BOOL update) //static bool LLMemory::isMemoryPoolLow() { - static const U32 LOW_MEMEOY_POOL_THRESHOLD_KB = 64 * 1024 ; //64 MB for emergency use - const static U32 MAX_SIZE_CHECKED_MEMORY_BLOCK = 64 * 1024 * 1024 ; //64 MB + static const U32Megabytes LOW_MEMORY_POOL_THRESHOLD(64); + const static U32Megabytes MAX_SIZE_CHECKED_MEMORY_BLOCK(64); static void* last_reserved_address = NULL ; if(!sEnableMemoryFailurePrevention) @@ -196,32 +196,32 @@ bool LLMemory::isMemoryPoolLow() return false ; //no memory failure prevention. } - if(sAvailPhysicalMemInKB < (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2)) //out of physical memory + if(sAvailPhysicalMemInKB < (LOW_MEMORY_POOL_THRESHOLD / 4)) //out of physical memory { return true ; } - if(sAllocatedPageSizeInKB + (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2) > sMaxHeapSizeInKB) //out of virtual address space. + if(sAllocatedPageSizeInKB + (LOW_MEMORY_POOL_THRESHOLD / 4) > sMaxHeapSizeInKB) //out of virtual address space. { return true ; } - bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMEOY_POOL_THRESHOLD_KB || - sAllocatedPageSizeInKB + LOW_MEMEOY_POOL_THRESHOLD_KB > sMaxHeapSizeInKB) ; + bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD || + sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; //check the virtual address space fragmentation if(!is_low) { if(!last_reserved_address) { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; } else { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; if(!last_reserved_address) //failed, try once more { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; } } @@ -232,19 +232,19 @@ bool LLMemory::isMemoryPoolLow() } //static -U32Kibibytes LLMemory::getAvailableMemKB() +U32Kilobytes LLMemory::getAvailableMemKB() { return sAvailPhysicalMemInKB ; } //static -U32Kibibytes LLMemory::getMaxMemKB() +U32Kilobytes LLMemory::getMaxMemKB() { return sMaxPhysicalMemInKB ; } //static -U32Kibibytes LLMemory::getAllocatedMemKB() +U32Kilobytes LLMemory::getAllocatedMemKB() { return sAllocatedMemInKB ; } -- cgit v1.2.3 From 6d9af374066421a1d8465a57795250a1614adcbb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 20 Aug 2013 12:10:05 -0700 Subject: BUILDFIX: unit assignment error --- indra/llcommon/llmemory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index d46e205500..4b21fa3bda 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -131,8 +131,8 @@ void LLMemory::updateMemoryInfo() #else //not valid for other systems for now. sAllocatedMemInKB = (U32)(LLMemory::getCurrentRSS() / 1024) ; - sMaxPhysicalMemInKB = U32_MAX ; - sAvailPhysicalMemInKB = U32_MAX ; + sMaxPhysicalMemInKB = (U32Bytes)U32_MAX ; + sAvailPhysicalMemInKB = (U32Bytes)U32_MAX ; #endif return ; -- cgit v1.2.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llcommon/llmemory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 4b21fa3bda..06334c012a 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -130,7 +130,7 @@ void LLMemory::updateMemoryInfo() } #else //not valid for other systems for now. - sAllocatedMemInKB = (U32)(LLMemory::getCurrentRSS() / 1024) ; + sAllocatedMemInKB = (U32Bytes)LLMemory::getCurrentRSS(); sMaxPhysicalMemInKB = (U32Bytes)U32_MAX ; sAvailPhysicalMemInKB = (U32Bytes)U32_MAX ; #endif -- cgit v1.2.3 From 8535b87544cc2e71896716a4cd1c3c2445ff4af0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 18:00:24 -0700 Subject: removed some unecessary template parameters from LLUnit member functions forced unit conversion code to inline unit conversion now no longer converts all the way to base and back, but tries to find equivalent units as early as possible fixed another llinfos instance scene monitor now outputs n/a for invalid samples --- indra/llcommon/llmemory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 06334c012a..cb2f853070 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -206,8 +206,8 @@ bool LLMemory::isMemoryPoolLow() return true ; } - bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD || - sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; + bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD + || sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; //check the virtual address space fragmentation if(!is_low) -- cgit v1.2.3 From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 7 Sep 2013 21:16:39 -0700 Subject: added memory usage and occlusion events to traces renamed "current" to "primary" when referring to accumulators --- indra/llcommon/llmemory.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llcommon/llmemory.cpp') diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index cb2f853070..e0b2aa87c2 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -43,12 +43,15 @@ #include "llsys.h" #include "llframetimer.h" +#include "lltrace.h" //---------------------------------------------------------------------------- //static char* LLMemory::reserveMem = 0; U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0); +static LLTrace::SampleStatHandle sAllocatedMem("allocated_mem", "active memory in use by application"); +static LLTrace::SampleStatHandle sVirtualMem("virtual_mem", "virtual memory assigned to application"); U32Kilobytes LLMemory::sAllocatedMemInKB(0); U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0); U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); @@ -114,7 +117,9 @@ void LLMemory::updateMemoryInfo() } sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ; + sample(sAllocatedMem, sAllocatedMemInKB); sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ; + sample(sVirtualMem, sAllocatedPageSizeInKB); U32Kilobytes avail_phys, avail_virtual; LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; -- cgit v1.2.3