diff options
author | Ansariel <ansariel.hiller@phoenixviewer.com> | 2021-05-12 10:45:23 +0200 |
---|---|---|
committer | Ansariel <ansariel.hiller@phoenixviewer.com> | 2021-05-12 10:45:23 +0200 |
commit | 0e253cb9098cb58b2f3528860a5fd9f00ec5af96 (patch) | |
tree | e74f2c0b553478c5304789a86147176db271f4e6 | |
parent | c241c5d4b8007793cb4b5f5e54fa3883aad3dad5 (diff) |
BUG-230673: Trim asset disk cache regularly
-rw-r--r-- | indra/llfilesystem/lldiskcache.cpp | 22 | ||||
-rw-r--r-- | indra/llfilesystem/lldiskcache.h | 11 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 2 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llappviewer.h | 3 |
5 files changed, 43 insertions, 1 deletions
diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 02678864b9..68423cc4f8 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -335,3 +335,25 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) return total_file_size; } + +LLPurgeDiskCacheThread::LLPurgeDiskCacheThread() : + LLThread("PurgeDiskCacheThread", nullptr) +{ +} + +void LLPurgeDiskCacheThread::run() +{ + constexpr F64 CHECK_INTERVAL = 60; + mTimer.setTimerExpirySec(CHECK_INTERVAL); + mTimer.start(); + + do + { + if (mTimer.checkExpirationAndReset(CHECK_INTERVAL)) + { + LLDiskCache::instance().purge(); + } + + ms_sleep(100); + } while (!isQuitting()); +}
\ No newline at end of file diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index c19714434a..867a80f332 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -180,4 +180,15 @@ class LLDiskCache : bool mEnableCacheDebugInfo; }; +class LLPurgeDiskCacheThread : public LLThread +{ +public: + LLPurgeDiskCacheThread(); + +protected: + void run() override; + +private: + LLTimer mTimer; +}; #endif // _LLDISKCACHE diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index cbd33e9244..0cae9cd9cc 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1362,7 +1362,7 @@ <key>Value</key> <integer>23</integer> </map> - <key>EnableCacheDebugInfo</key> + <key>EnableDiskCacheDebugInfo</key> <map> <key>Comment</key> <string>When set, display additional cache debugging information</string> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c519e55fc3..fd094b12d7 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -655,6 +655,7 @@ LLAppViewer* LLAppViewer::sInstance = NULL; LLTextureCache* LLAppViewer::sTextureCache = NULL; LLImageDecodeThread* LLAppViewer::sImageDecodeThread = NULL; LLTextureFetch* LLAppViewer::sTextureFetch = NULL; +LLPurgeDiskCacheThread* LLAppViewer::sPurgeDiskCacheThread = NULL; std::string getRuntime() { @@ -2032,6 +2033,7 @@ bool LLAppViewer::cleanup() sTextureFetch->shutdown(); sTextureCache->shutdown(); sImageDecodeThread->shutdown(); + sPurgeDiskCacheThread->shutdown(); sTextureFetch->shutDownTextureCacheThread() ; sTextureFetch->shutDownImageDecodeThread() ; @@ -2054,6 +2056,8 @@ bool LLAppViewer::cleanup() sImageDecodeThread = NULL; delete mFastTimerLogThread; mFastTimerLogThread = NULL; + delete sPurgeDiskCacheThread; + sPurgeDiskCacheThread = NULL; if (LLFastTimerView::sAnalyzePerformance) { @@ -2174,6 +2178,7 @@ bool LLAppViewer::initThreads() sImageDecodeThread, enable_threads && true, app_metrics_qa_mode); + LLAppViewer::sPurgeDiskCacheThread = new LLPurgeDiskCacheThread(); if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) { @@ -4210,6 +4215,7 @@ bool LLAppViewer::initCache() LLDiskCache::getInstance()->purge(); } } + LLAppViewer::getPurgeDiskCacheThread()->start(); LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache")); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 5e24398caa..00d6943047 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -58,6 +58,7 @@ class LLImageDecodeThread; class LLTextureFetch; class LLWatchdogTimeout; class LLViewerJoystick; +class LLPurgeDiskCacheThread; extern LLTrace::BlockTimerStatHandle FTM_FRAME; @@ -117,6 +118,7 @@ public: static LLTextureCache* getTextureCache() { return sTextureCache; } static LLImageDecodeThread* getImageDecodeThread() { return sImageDecodeThread; } static LLTextureFetch* getTextureFetch() { return sTextureFetch; } + static LLPurgeDiskCacheThread* getPurgeDiskCacheThread() { return sPurgeDiskCacheThread; } static U32 getTextureCacheVersion() ; static U32 getObjectCacheVersion() ; @@ -284,6 +286,7 @@ private: static LLTextureCache* sTextureCache; static LLImageDecodeThread* sImageDecodeThread; static LLTextureFetch* sTextureFetch; + static LLPurgeDiskCacheThread* sPurgeDiskCacheThread; S32 mNumSessions; |