Skip to content
Snippets Groups Projects
Commit 9d259a03 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Various cache code tweaks

parent b84f8f33
No related branches found
No related tags found
No related merge requests found
...@@ -279,3 +279,7 @@ option(ENABLE_TIMING "Enable all fast timers" ON) ...@@ -279,3 +279,7 @@ option(ENABLE_TIMING "Enable all fast timers" ON)
if(ENABLE_TIMING) if(ENABLE_TIMING)
add_compile_definitions(AL_ENABLE_ALL_TIMERS=1) add_compile_definitions(AL_ENABLE_ALL_TIMERS=1)
endif() endif()
if(HAVOK OR HAVOK_TPV)
add_compile_definitions(LL_HAVOK=1)
endif()
...@@ -26,7 +26,6 @@ if (HAVOK) ...@@ -26,7 +26,6 @@ if (HAVOK)
set(LLPHYSICSEXTENSIONS_SRC_DIR ${LIBS_PREBUILT_DIR}/llphysicsextensions/src) set(LLPHYSICSEXTENSIONS_SRC_DIR ${LIBS_PREBUILT_DIR}/llphysicsextensions/src)
target_link_libraries( llphysicsextensions_impl INTERFACE llphysicsextensions) target_link_libraries( llphysicsextensions_impl INTERFACE llphysicsextensions)
target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions) target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions)
target_compile_definitions( llphysicsextensions_impl INTERFACE LL_HAVOK=1)
elseif (HAVOK_TPV) elseif (HAVOK_TPV)
use_prebuilt_binary(llphysicsextensions_tpv) use_prebuilt_binary(llphysicsextensions_tpv)
if(WINDOWS) if(WINDOWS)
...@@ -35,7 +34,6 @@ elseif (HAVOK_TPV) ...@@ -35,7 +34,6 @@ elseif (HAVOK_TPV)
target_link_libraries( llphysicsextensions_impl INTERFACE ${ARCH_PREBUILT_DIRS}/libllphysicsextensions_tpv.a) target_link_libraries( llphysicsextensions_impl INTERFACE ${ARCH_PREBUILT_DIRS}/libllphysicsextensions_tpv.a)
endif() endif()
target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions) target_include_directories( llphysicsextensions_impl INTERFACE ${LIBS_PREBUILT_DIR}/include/llphysicsextensions)
target_compile_definitions( llphysicsextensions_impl INTERFACE LL_HAVOK=1)
else (HAVOK) else (HAVOK)
if (NOT USE_LL_STUBS) if (NOT USE_LL_STUBS)
use_prebuilt_binary( ndPhysicsStub ) use_prebuilt_binary( ndPhysicsStub )
......
...@@ -62,7 +62,9 @@ void LLDiskCache::createCache() ...@@ -62,7 +62,9 @@ void LLDiskCache::createCache()
{ {
LLFile::mkdir(fmt::format("{}{}{}", sCacheDir, gDirUtilp->getDirDelimiter(), prefixchar)); LLFile::mkdir(fmt::format("{}{}{}", sCacheDir, gDirUtilp->getDirDelimiter(), prefixchar));
} }
#if 0
prepopulateCacheWithStatic(); prepopulateCacheWithStatic();
#endif
} }
// WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must // WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must
...@@ -118,7 +120,6 @@ void LLDiskCache::purge() ...@@ -118,7 +120,6 @@ void LLDiskCache::purge()
{ {
for (auto& entry : boost::make_iterator_range(dir_iter, {})) for (auto& entry : boost::make_iterator_range(dir_iter, {}))
{ {
ec.clear();
if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed()) if (boost::filesystem::is_regular_file(entry, ec) && !ec.failed())
{ {
if (entry.path().string().rfind(sCacheFilenameExt) != std::string::npos) if (entry.path().string().rfind(sCacheFilenameExt) != std::string::npos)
...@@ -156,9 +157,6 @@ void LLDiskCache::purge() ...@@ -156,9 +157,6 @@ void LLDiskCache::purge()
{ {
file_removed.reserve(file_info.size()); file_removed.reserve(file_info.size());
} }
int keep{0};
int del{0};
int skip{0};
uintmax_t file_size_total = 0; uintmax_t file_size_total = 0;
for (const file_info_t& entry : file_info) for (const file_info_t& entry : file_info)
{ {
...@@ -170,24 +168,17 @@ void LLDiskCache::purge() ...@@ -170,24 +168,17 @@ void LLDiskCache::purge()
file_removed.push_back(should_remove); file_removed.push_back(should_remove);
} }
std::string action = "";
if (should_remove) if (should_remove)
{ {
action = "DELETE:";
auto uuid_as_string = LLUUID(gDirUtilp->getBaseFileName(entry.second.second.string(), true)); auto uuid_as_string = LLUUID(gDirUtilp->getBaseFileName(entry.second.second.string(), true));
// LL_INFOS() << "checking UUID=" <<uuid_as_string<< LL_ENDL; // LL_INFOS() << "checking UUID=" <<uuid_as_string<< LL_ENDL;
if (uuid_as_string.notNull() && mSkipList.find(uuid_as_string) != mSkipList.end()) if (uuid_as_string.notNull() && mSkipList.find(uuid_as_string) != mSkipList.end())
{ {
// this is one of our protected items so no purging // 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 updateFileAccessTime(entry.second.second); // force these to the front of the list next time so that purge size works
} }
else else
{ {
del++; // Extra accounting to track the retention of static assets
boost::filesystem::remove(entry.second.second, ec); boost::filesystem::remove(entry.second.second, ec);
if (ec.failed()) if (ec.failed())
{ {
...@@ -196,10 +187,6 @@ void LLDiskCache::purge() ...@@ -196,10 +187,6 @@ void LLDiskCache::purge()
} }
} }
} }
else
{
keep++;
}
} }
if (mEnableCacheDebugInfo) if (mEnableCacheDebugInfo)
...@@ -228,7 +215,6 @@ void LLDiskCache::purge() ...@@ -228,7 +215,6 @@ void LLDiskCache::purge()
LL_INFOS() << "Total dir size after purge is " << dirFileSize(sCacheDir) << LL_ENDL; 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() << "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() ...@@ -343,6 +329,7 @@ const std::string LLDiskCache::getCacheInfo()
return llformat("%juMB / %juMB (%.1f%% used)", cache_used_mb, max_in_mb, percent_used); 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 // 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. // Note that there is no de-duplication nor other validation of the list.
void LLDiskCache::prepopulateCacheWithStatic() void LLDiskCache::prepopulateCacheWithStatic()
...@@ -391,6 +378,7 @@ void LLDiskCache::prepopulateCacheWithStatic() ...@@ -391,6 +378,7 @@ void LLDiskCache::prepopulateCacheWithStatic()
} }
} }
} }
#endif
void LLDiskCache::clearCache() void LLDiskCache::clearCache()
{ {
......
...@@ -130,8 +130,10 @@ class LLDiskCache final : ...@@ -130,8 +130,10 @@ class LLDiskCache final :
*/ */
void purge(); void purge();
#if 0
// copy from distribution into cache to replace static content // copy from distribution into cache to replace static content
void prepopulateCacheWithStatic(); void prepopulateCacheWithStatic();
#endif
/** /**
* Clear the cache by removing all the files in the specified cache * Clear the cache by removing all the files in the specified cache
......
...@@ -53,14 +53,19 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_ ...@@ -53,14 +53,19 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_
if (mode == LLFileSystem::READ) if (mode == LLFileSystem::READ)
{ {
// build the filename (TODO: we do this in a few places - perhaps we should factor into a single function) // 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 // 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 // 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 // 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 // each file so it knows how to remove the oldest, unused files
bool exists = gDirUtilp->fileExists(filename); boost::system::error_code ec;
if (exists) bool exists = boost::filesystem::exists(filename, ec);
if (exists && !ec.failed())
{ {
LLDiskCache::updateFileAccessTime(filename); LLDiskCache::updateFileAccessTime(filename);
} }
......
...@@ -1352,18 +1352,21 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) ...@@ -1352,18 +1352,21 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries)
} }
aprfile->seek(APR_SET, (S32)sizeof(EntriesInfo)); 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++) for (U32 idx=0; idx<num_entries; idx++)
{ {
Entry entry; const Entry& entry = entries[idx];
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);
// LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; // LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL;
if(entry.mImageSize > entry.mBodySize) if(entry.mImageSize > entry.mBodySize)
{ {
......
...@@ -75,7 +75,7 @@ def construct(self): ...@@ -75,7 +75,7 @@ def construct(self):
self.path("*.xml") self.path("*.xml")
# include static assets # include static assets
self.path("static_assets") # self.path("static_assets")
# include the cube # include the cube
self.path("cube.dae") self.path("cube.dae")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment