for VWR-22936: design test code/plan for the object cache.

master
Xiaohong Bao 2010-09-13 12:39:14 -06:00
parent 85053e53b6
commit b5ea8b6046
6 changed files with 46 additions and 11 deletions

View File

@ -5849,6 +5849,17 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>ObjectCacheEnabled</key>
<map>
<key>Comment</key>
<string>Enable the object cache.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>OpenDebugStatAdvanced</key>
<map>
<key>Comment</key>

View File

@ -514,7 +514,8 @@ void LLGLTexMemBar::draw()
F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ;
S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
S32 v_offset = (S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
S32 total_downloaded = BYTES_TO_MEGA_BYTES(gTotalTextureBytes);
F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024);
//----------------------------------------------------------------------------
LLGLSUIDefault gls_ui;
LLColor4 text_color(1.f, 1.f, 1.f, 0.75f);
@ -525,13 +526,13 @@ void LLGLTexMemBar::draw()
LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6,
text_color, LLFontGL::LEFT, LLFontGL::TOP);
text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot: %d MB",
text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB Net Tot Tex: %.1f MB Tot Obj: %.1f MB",
total_mem,
max_total_mem,
bound_mem,
max_bound_mem,
LLImageRaw::sGlobalRawMemory >> 20, discard_bias,
cache_usage, cache_max_usage, total_downloaded);
cache_usage, cache_max_usage, total_texture_downloaded, total_object_downloaded);
//, cache_entries, cache_max_entries
LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3,

View File

@ -264,4 +264,5 @@ void send_stats();
extern std::map<S32,LLFrameTimer> gDebugTimers;
extern std::map<S32,std::string> gDebugTimerLabel;
extern U32 gTotalTextureBytes;
extern U32 gTotalObjectBytes;
#endif // LL_LLVIEWERSTATS_H

View File

@ -28,6 +28,7 @@
#include "llvocache.h"
#include "llerror.h"
#include "llregionhandle.h"
#include "llviewercontrol.h"
BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes)
{
@ -230,11 +231,11 @@ LLVOCache* LLVOCache::sInstance = NULL;
//static
LLVOCache* LLVOCache::getInstance()
{
{
if(!sInstance)
{
sInstance = new LLVOCache() ;
}
}
return sInstance ;
}
@ -259,13 +260,17 @@ LLVOCache::LLVOCache():
mReadOnly(TRUE),
mNumEntries(0)
{
mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled");
mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
}
LLVOCache::~LLVOCache()
{
writeCacheHeader();
clearCacheInMemory();
if(mEnabled)
{
writeCacheHeader();
clearCacheInMemory();
}
delete mLocalAPRFilePoolp;
}
@ -279,7 +284,7 @@ void LLVOCache::setDirNames(ELLPath location)
void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
{
if(mInitialized)
if(mInitialized || !mEnabled)
{
return ;
}
@ -406,6 +411,11 @@ BOOL LLVOCache::checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes)
void LLVOCache::readCacheHeader()
{
if(!mEnabled)
{
return ;
}
//clear stale info.
clearCacheInMemory();
@ -450,7 +460,7 @@ void LLVOCache::readCacheHeader()
void LLVOCache::writeCacheHeader()
{
if(mReadOnly)
if(mReadOnly || !mEnabled)
{
return ;
}
@ -501,6 +511,10 @@ BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry)
void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map)
{
if(!mEnabled)
{
return ;
}
llassert_always(mInitialized);
handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
@ -570,6 +584,10 @@ void LLVOCache::purgeEntries()
void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache)
{
if(!mEnabled)
{
return ;
}
llassert_always(mInitialized);
if(mReadOnly)

View File

@ -128,6 +128,7 @@ private:
BOOL checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes) ;
private:
BOOL mEnabled;
BOOL mInitialized ;
BOOL mReadOnly ;
HeaderMetaInfo mMetaInfo;
@ -142,7 +143,7 @@ private:
static LLVOCache* sInstance ;
public:
static LLVOCache* getInstance() ;
static BOOL hasInstance() ;
static BOOL hasInstance() ;
static void destroyClass() ;
};

View File

@ -121,7 +121,10 @@ void LLWorld::destroyClass()
LLViewerRegion* region_to_delete = *region_it++;
removeRegion(region_to_delete->getHost());
}
LLVOCache::getInstance()->destroyClass() ;
if(LLVOCache::hasInstance())
{
LLVOCache::getInstance()->destroyClass() ;
}
LLViewerPartSim::getInstance()->destroyClass();
}