From b0ff3236be6a2ec55444944232d2a36d993a6a91 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Dec 2014 00:09:01 +0000 Subject: Make "fache assets" console command more efficient by only updating access times on each cached asset once, not for every reference. --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 24d5d00..6564b4d 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -776,8 +776,8 @@ namespace OpenSim.Region.CoreModules.Asset { UuidGatherer gatherer = new UuidGatherer(m_AssetService); - HashSet uniqueUuids = new HashSet(); - Dictionary assets = new Dictionary(); + Dictionary assetIdsToCheck = new Dictionary(); + Dictionary assetsFound = new Dictionary(); foreach (Scene s in m_Scenes) { @@ -785,33 +785,40 @@ namespace OpenSim.Region.CoreModules.Asset s.ForEachSOG(delegate(SceneObjectGroup e) { - gatherer.GatherAssetUuids(e, assets); + gatherer.GatherAssetUuids(e, assetIdsToCheck); - foreach (UUID assetID in assets.Keys) + foreach (UUID assetID in assetIdsToCheck.Keys) { - uniqueUuids.Add(assetID); - - string filename = GetFileName(assetID.ToString()); - - if (File.Exists(filename)) + if (!assetsFound.ContainsKey(assetID)) { - UpdateFileLastAccessTime(filename); + string filename = GetFileName(assetID.ToString()); + + if (File.Exists(filename)) + { + UpdateFileLastAccessTime(filename); + } + else if (storeUncached) + { + AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); + if (cachedAsset == null && assetIdsToCheck[assetID] != (sbyte)AssetType.Unknown) + assetsFound[assetID] = false; + else + assetsFound[assetID] = true; + } } - else if (storeUncached) + else if (!assetsFound[assetID]) { - AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); - if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) - m_log.DebugFormat( + m_log.DebugFormat( "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", - assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); + assetID, assetIdsToCheck[assetID], e.Name, e.AbsolutePosition, s.Name); } } - assets.Clear(); + assetIdsToCheck.Clear(); }); } - return uniqueUuids.Count; + return assetsFound.Count; } /// -- cgit v1.1