From a6a2c8a80af57b99e08da36c4e64b0a0b868636f Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Tue, 16 Sep 2008 02:08:45 -0500 Subject: Applied VWR-3878: Purging cache textures causes viewer to pause for many seconds, with heavy disk activity. --- ChangeLog.txt | 7 ++++ linden/indra/newview/lltexturecache.cpp | 65 ++++++++++++++++++++++++++++++--- linden/indra/newview/lltexturecache.h | 5 +++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..da78f78 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,7 @@ +2008-09-16 Nicholaz Beresford + + * linden/indra/newview/lltexturecache.cpp: + VWR-3878: Purging cache textures causes viewer to pause for many + seconds, with heavy disk activity. + * linden/indra/newview/lltexturecache.h: + Ditto. diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 22cb6c1..0fbb3d9 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -881,6 +881,8 @@ LLTextureCache::LLTextureCache(bool threaded) LLTextureCache::~LLTextureCache() { + purgeTextureFilesTimeSliced(TRUE); // force-flush all pending file deletes + apr_pool_destroy(mFileAPRPool); } @@ -1187,7 +1189,7 @@ void LLTextureCache::purgeTextures(bool validate) return; } - LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Reading Entries..." << LL_ENDL; + LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Reading " << num_entries << " Entries from " << mTexturesDirEntriesFileName << LL_ENDL; std::map entry_idx_map; S64 total_size = 0; @@ -1216,7 +1218,7 @@ void LLTextureCache::purgeTextures(bool validate) LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Validating: " << validate_idx << LL_ENDL; } - S64 min_cache_size = (sCacheMaxTexturesSize * 9) / 10; + S64 min_cache_size = sCacheMaxTexturesSize / 100 * 95; S32 purge_count = 0; S32 next_idx = 0; for (S32 idx=0; idx max_time_per_pass) + { + break; + } + } + + if (!mFilesToDelete.empty()) + { + llinfos << "TEXTURE CACHE: "<< howmany << " files deleted (" + << mFilesToDelete.size() << " files left for next pass)" + << llendl; + } + + mTimeLastFileDelete.reset(); +} + + + ////////////////////////////////////////////////////////////////////////////// // call lockWorkers() first! @@ -1462,6 +1511,10 @@ LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 prio purgeTextures(false); mDoPurge = FALSE; } + + purgeTextureFilesTimeSliced(); // purge textures from cache in a non-hiccup-way + + if (datasize >= TEXTURE_CACHE_ENTRY_SIZE) { LLMutexLock lock(&mWorkersMutex); diff --git a/linden/indra/newview/lltexturecache.h b/linden/indra/newview/lltexturecache.h index f083dd0..e15a88b 100644 --- a/linden/indra/newview/lltexturecache.h +++ b/linden/indra/newview/lltexturecache.h @@ -119,6 +119,7 @@ private: void readHeaderCache(apr_pool_t* poolp = NULL); void purgeAllTextures(bool purge_directories); void purgeTextures(bool validate); + void purgeTextureFilesTimeSliced(BOOL force_all = FALSE); S32 getHeaderCacheEntry(const LLUUID& id, bool touch, S32* imagesize = NULL); bool removeHeaderCacheEntry(const LLUUID& id); void lockHeaders() { mHeaderMutex.lock(); } @@ -140,6 +141,10 @@ private: typedef std::vector, bool> > responder_list_t; responder_list_t mCompletedList; + + typedef std::list filename_list_t; + filename_list_t mFilesToDelete; + LLTimer mTimeLastFileDelete; BOOL mReadOnly; -- cgit v1.1 From d98f0844bd9d3dc6740d45960a65dd4e8f11e9ec Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Tue, 16 Sep 2008 12:20:16 -0500 Subject: Skip "N files scheduled for deletion" message when nothing scheduled. --- ChangeLog.txt | 5 +++++ linden/indra/newview/lltexturecache.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index da78f78..4b154b2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +2008-09-16 Jacek Antonelli + + * linden/indra/newview/lltexturecache.cpp (purgeTextureFilesTimeSliced): + Skip "N files scheduled for deletion" message when nothing scheduled. + 2008-09-16 Nicholaz Beresford * linden/indra/newview/lltexturecache.cpp: diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 0fbb3d9..ac956e2 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -1315,7 +1315,10 @@ void LLTextureCache::purgeTextureFilesTimeSliced(BOOL force_all) LLTimer timer; S32 howmany = 0; - llinfos << "TEXTURE CACHE: " << mFilesToDelete.size() << " files scheduled for deletion" << llendl; + if (mFilesToDelete.size() > 0) + { + llinfos << "TEXTURE CACHE: " << mFilesToDelete.size() << " files scheduled for deletion" << llendl; + } for (LLTextureCache::filename_list_t::iterator iter = mFilesToDelete.begin(); iter!=mFilesToDelete.end(); ) { -- cgit v1.1