diff options
author | Justin Clark-Casey (justincc) | 2014-12-05 00:09:01 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-12-05 00:09:01 +0000 |
commit | b0ff3236be6a2ec55444944232d2a36d993a6a91 (patch) | |
tree | fbd8e9d3b30502cf5ceaed977daa0810c20f30d1 | |
parent | refactor: Make IteratingUUIDGatherer take a dictionary in its constructor lik... (diff) | |
download | opensim-SC_OLD-b0ff3236be6a2ec55444944232d2a36d993a6a91.zip opensim-SC_OLD-b0ff3236be6a2ec55444944232d2a36d993a6a91.tar.gz opensim-SC_OLD-b0ff3236be6a2ec55444944232d2a36d993a6a91.tar.bz2 opensim-SC_OLD-b0ff3236be6a2ec55444944232d2a36d993a6a91.tar.xz |
Make "fache assets" console command more efficient by only updating access times on each cached asset once, not for every reference.
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 41 |
1 files changed, 24 insertions, 17 deletions
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 | |||
776 | { | 776 | { |
777 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 777 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
778 | 778 | ||
779 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); | 779 | Dictionary<UUID, sbyte> assetIdsToCheck = new Dictionary<UUID, sbyte>(); |
780 | Dictionary<UUID, sbyte> assets = new Dictionary<UUID, sbyte>(); | 780 | Dictionary<UUID, bool> assetsFound = new Dictionary<UUID, bool>(); |
781 | 781 | ||
782 | foreach (Scene s in m_Scenes) | 782 | foreach (Scene s in m_Scenes) |
783 | { | 783 | { |
@@ -785,33 +785,40 @@ namespace OpenSim.Region.CoreModules.Asset | |||
785 | 785 | ||
786 | s.ForEachSOG(delegate(SceneObjectGroup e) | 786 | s.ForEachSOG(delegate(SceneObjectGroup e) |
787 | { | 787 | { |
788 | gatherer.GatherAssetUuids(e, assets); | 788 | gatherer.GatherAssetUuids(e, assetIdsToCheck); |
789 | 789 | ||
790 | foreach (UUID assetID in assets.Keys) | 790 | foreach (UUID assetID in assetIdsToCheck.Keys) |
791 | { | 791 | { |
792 | uniqueUuids.Add(assetID); | 792 | if (!assetsFound.ContainsKey(assetID)) |
793 | |||
794 | string filename = GetFileName(assetID.ToString()); | ||
795 | |||
796 | if (File.Exists(filename)) | ||
797 | { | 793 | { |
798 | UpdateFileLastAccessTime(filename); | 794 | string filename = GetFileName(assetID.ToString()); |
795 | |||
796 | if (File.Exists(filename)) | ||
797 | { | ||
798 | UpdateFileLastAccessTime(filename); | ||
799 | } | ||
800 | else if (storeUncached) | ||
801 | { | ||
802 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | ||
803 | if (cachedAsset == null && assetIdsToCheck[assetID] != (sbyte)AssetType.Unknown) | ||
804 | assetsFound[assetID] = false; | ||
805 | else | ||
806 | assetsFound[assetID] = true; | ||
807 | } | ||
799 | } | 808 | } |
800 | else if (storeUncached) | 809 | else if (!assetsFound[assetID]) |
801 | { | 810 | { |
802 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | 811 | m_log.DebugFormat( |
803 | if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) | ||
804 | m_log.DebugFormat( | ||
805 | "[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", | 812 | "[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", |
806 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); | 813 | assetID, assetIdsToCheck[assetID], e.Name, e.AbsolutePosition, s.Name); |
807 | } | 814 | } |
808 | } | 815 | } |
809 | 816 | ||
810 | assets.Clear(); | 817 | assetIdsToCheck.Clear(); |
811 | }); | 818 | }); |
812 | } | 819 | } |
813 | 820 | ||
814 | return uniqueUuids.Count; | 821 | return assetsFound.Count; |
815 | } | 822 | } |
816 | 823 | ||
817 | /// <summary> | 824 | /// <summary> |