From 9d259a03d7a87b4267fffc5a2c075ef00086e6db Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Thu, 4 May 2023 17:58:03 -0400 Subject: [PATCH] Various cache code tweaks --- indra/cmake/00-Common.cmake | 4 ++++ indra/cmake/LLPhysicsExtensions.cmake | 2 -- indra/llfilesystem/lldiskcache.cpp | 20 ++++---------------- indra/llfilesystem/lldiskcache.h | 2 ++ indra/llfilesystem/llfilesystem.cpp | 11 ++++++++--- indra/newview/lltexturecache.cpp | 23 +++++++++++++---------- indra/newview/viewer_manifest.py | 2 +- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 41a684d8430..f7a2f2273c8 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -279,3 +279,7 @@ option(ENABLE_TIMING "Enable all fast timers" ON) if(ENABLE_TIMING) add_compile_definitions(AL_ENABLE_ALL_TIMERS=1) endif() + +if(HAVOK OR HAVOK_TPV) + add_compile_definitions(LL_HAVOK=1) +endif() diff --git a/indra/cmake/LLPhysicsExtensions.cmake b/indra/cmake/LLPhysicsExtensions.cmake index 8d18d84840a..a2c860720b0 100644 --- a/indra/cmake/LLPhysicsExtensions.cmake +++ b/indra/cmake/LLPhysicsExtensions.cmake @@ -26,7 +26,6 @@ if (HAVOK) set(LLPHYSICSEXTENSIONS_SRC_DIR ${LIBS_PREBUILT_DIR}/llphysicsextensions/src) target_link_libraries( llphysicsextensions_impl INTERFACE llphysicsextensions) target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions) - target_compile_definitions( llphysicsextensions_impl INTERFACE LL_HAVOK=1) elseif (HAVOK_TPV) use_prebuilt_binary(llphysicsextensions_tpv) if(WINDOWS) @@ -35,7 +34,6 @@ elseif (HAVOK_TPV) target_link_libraries( llphysicsextensions_impl INTERFACE ${ARCH_PREBUILT_DIRS}/libllphysicsextensions_tpv.a) endif() target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions) - target_compile_definitions( llphysicsextensions_impl INTERFACE LL_HAVOK=1) else (HAVOK) if (NOT USE_LL_STUBS) use_prebuilt_binary( ndPhysicsStub ) diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 5095c1d01c5..e6fe96cffe0 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -62,7 +62,9 @@ void LLDiskCache::createCache() { LLFile::mkdir(fmt::format("{}{}{}", sCacheDir, gDirUtilp->getDirDelimiter(), prefixchar)); } +#if 0 prepopulateCacheWithStatic(); +#endif } // WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must @@ -118,7 +120,6 @@ void LLDiskCache::purge() { for (auto& entry : boost::make_iterator_range(dir_iter, {})) { - ec.clear(); if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed()) { if (entry.path().string().rfind(sCacheFilenameExt) != std::string::npos) @@ -156,9 +157,6 @@ void LLDiskCache::purge() { file_removed.reserve(file_info.size()); } - int keep{0}; - int del{0}; - int skip{0}; uintmax_t file_size_total = 0; for (const file_info_t& entry : file_info) { @@ -170,24 +168,17 @@ void LLDiskCache::purge() file_removed.push_back(should_remove); } - std::string action = ""; if (should_remove) { - - action = "DELETE:"; auto uuid_as_string = LLUUID(gDirUtilp->getBaseFileName(entry.second.second.string(), true)); // LL_INFOS() << "checking UUID=" <<uuid_as_string<< LL_ENDL; if (uuid_as_string.notNull() && mSkipList.find(uuid_as_string) != mSkipList.end()) { // this is one of our protected items so no purging - action = "STATIC:"; - skip++; updateFileAccessTime(entry.second.second); // force these to the front of the list next time so that purge size works } else { - del++; // Extra accounting to track the retention of static assets - boost::filesystem::remove(entry.second.second, ec); if (ec.failed()) { @@ -196,10 +187,6 @@ void LLDiskCache::purge() } } } - else - { - keep++; - } } if (mEnableCacheDebugInfo) @@ -228,7 +215,6 @@ void LLDiskCache::purge() LL_INFOS() << "Total dir size after purge is " << dirFileSize(sCacheDir) << LL_ENDL; LL_INFOS() << "Cache purge took " << execute_time << " ms to execute for " << file_info.size() << " files" << LL_ENDL; - LL_INFOS() << "Deleted: " << del << " Skipped: " << skip << " Kept: " << keep << LL_ENDL; } } @@ -343,6 +329,7 @@ const std::string LLDiskCache::getCacheInfo() return llformat("%juMB / %juMB (%.1f%% used)", cache_used_mb, max_in_mb, percent_used); } +#if 0 // Copy static items into cache and add to the skip list that prevents their purging // Note that there is no de-duplication nor other validation of the list. void LLDiskCache::prepopulateCacheWithStatic() @@ -391,6 +378,7 @@ void LLDiskCache::prepopulateCacheWithStatic() } } } +#endif void LLDiskCache::clearCache() { diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index 60d568a1339..46bdb72b909 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -130,8 +130,10 @@ class LLDiskCache final : */ void purge(); +#if 0 // copy from distribution into cache to replace static content void prepopulateCacheWithStatic(); +#endif /** * Clear the cache by removing all the files in the specified cache diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 7387ce34bd5..34e355d3a08 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -53,14 +53,19 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_ if (mode == LLFileSystem::READ) { // build the filename (TODO: we do this in a few places - perhaps we should factor into a single function) - const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type); +#if LL_WINDOWS + boost::filesystem::path filename(ll_convert_string_to_wide(LLDiskCache::metaDataToFilepath(file_id, file_type))); +#else + boost::filesystem::path filename(LLDiskCache::metaDataToFilepath(file_id, file_type)); +#endif // update the last access time for the file if it exists - this is required // even though we are reading and not writing because this is the // way the cache works - it relies on a valid "last accessed time" for // each file so it knows how to remove the oldest, unused files - bool exists = gDirUtilp->fileExists(filename); - if (exists) + boost::system::error_code ec; + bool exists = boost::filesystem::exists(filename, ec); + if (exists && !ec.failed()) { LLDiskCache::updateFileAccessTime(filename); } diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 82d28b8b488..38c321c324b 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1352,18 +1352,21 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) } aprfile->seek(APR_SET, (S32)sizeof(EntriesInfo)); } + + entries.resize(num_entries); + S32 total_entries_size = sizeof(Entry) * num_entries; + S32 bytes_read = aprfile->read((void*)entries.data(), total_entries_size); + if (bytes_read != total_entries_size) + { + LL_WARNS() << "Corrupted header entries, expected " << total_entries_size << " bytes but got " << bytes_read << " bytes" << LL_ENDL; + closeHeaderEntriesFile(); + purgeAllTextures(false); + return 0; + } + for (U32 idx=0; idx<num_entries; idx++) { - Entry entry; - S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry)); - if (bytes_read < sizeof(Entry)) - { - LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL; - closeHeaderEntriesFile(); - purgeAllTextures(false); - return 0; - } - entries.push_back(entry); + const Entry& entry = entries[idx]; // LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; if(entry.mImageSize > entry.mBodySize) { diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 94a4a305f5e..8d02a34d3ad 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -75,7 +75,7 @@ def construct(self): self.path("*.xml") # include static assets - self.path("static_assets") + # self.path("static_assets") # include the cube self.path("cube.dae") -- GitLab