diff options
author | UbitUmarov | 2016-11-30 07:43:17 +0000 |
---|---|---|
committer | UbitUmarov | 2016-11-30 07:43:17 +0000 |
commit | 1863bb29dfa95479aba8fb6251e18cdcf09a7562 (patch) | |
tree | 0dfcaa92df8ad3e104537c982ea32564c9362456 /OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |
parent | The new Constant: integer OBJECT_TEMP_ATTACHED = 34; (diff) | |
download | opensim-SC-1863bb29dfa95479aba8fb6251e18cdcf09a7562.zip opensim-SC-1863bb29dfa95479aba8fb6251e18cdcf09a7562.tar.gz opensim-SC-1863bb29dfa95479aba8fb6251e18cdcf09a7562.tar.bz2 opensim-SC-1863bb29dfa95479aba8fb6251e18cdcf09a7562.tar.xz |
slow down automatic floatsamAssetCache CleanupExpiredFiles LOT to reduce impact on simulation and to give GC more changes of preventing it from eating up all avaialble physcical memory on loaded machines.
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 85 |
1 files changed, 72 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c4abc99..025d3ce 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -62,6 +62,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
62 | MethodBase.GetCurrentMethod().DeclaringType); | 62 | MethodBase.GetCurrentMethod().DeclaringType); |
63 | 63 | ||
64 | private bool m_Enabled; | 64 | private bool m_Enabled; |
65 | private bool m_Running; | ||
65 | 66 | ||
66 | private const string m_ModuleName = "FlotsamAssetCache"; | 67 | private const string m_ModuleName = "FlotsamAssetCache"; |
67 | private const string m_DefaultCacheDirectory = "./assetcache"; | 68 | private const string m_DefaultCacheDirectory = "./assetcache"; |
@@ -94,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
94 | private const double m_DefaultFileExpiration = 48; | 95 | private const double m_DefaultFileExpiration = 48; |
95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); | 96 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); |
96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); | 97 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); |
97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(0.166); | 98 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(1.0); |
98 | 99 | ||
99 | private static int m_CacheDirectoryTiers = 1; | 100 | private static int m_CacheDirectoryTiers = 1; |
100 | private static int m_CacheDirectoryTierLen = 3; | 101 | private static int m_CacheDirectoryTierLen = 3; |
@@ -104,7 +105,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
104 | 105 | ||
105 | private IAssetService m_AssetService; | 106 | private IAssetService m_AssetService; |
106 | private List<Scene> m_Scenes = new List<Scene>(); | 107 | private List<Scene> m_Scenes = new List<Scene>(); |
107 | 108 | private object timerLock = new object(); | |
109 | |||
108 | public FlotsamAssetCache() | 110 | public FlotsamAssetCache() |
109 | { | 111 | { |
110 | m_InvalidChars.AddRange(Path.GetInvalidPathChars()); | 112 | m_InvalidChars.AddRange(Path.GetInvalidPathChars()); |
@@ -170,14 +172,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
170 | 172 | ||
171 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); | 173 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory {0}", m_CacheDirectory); |
172 | 174 | ||
173 | if (m_FileCacheEnabled && (m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | ||
174 | { | ||
175 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); | ||
176 | m_CacheCleanTimer.AutoReset = true; | ||
177 | m_CacheCleanTimer.Elapsed += CleanupExpiredFiles; | ||
178 | lock (m_CacheCleanTimer) | ||
179 | m_CacheCleanTimer.Start(); | ||
180 | } | ||
181 | 175 | ||
182 | if (m_CacheDirectoryTiers < 1) | 176 | if (m_CacheDirectoryTiers < 1) |
183 | { | 177 | { |
@@ -219,7 +213,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
219 | { | 213 | { |
220 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); | 214 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); |
221 | m_Scenes.Add(scene); | 215 | m_Scenes.Add(scene); |
222 | |||
223 | } | 216 | } |
224 | } | 217 | } |
225 | 218 | ||
@@ -229,13 +222,39 @@ namespace OpenSim.Region.CoreModules.Asset | |||
229 | { | 222 | { |
230 | scene.UnregisterModuleInterface<IImprovedAssetCache>(this); | 223 | scene.UnregisterModuleInterface<IImprovedAssetCache>(this); |
231 | m_Scenes.Remove(scene); | 224 | m_Scenes.Remove(scene); |
225 | lock(timerLock) | ||
226 | { | ||
227 | if(m_Scenes.Count <= 0) | ||
228 | { | ||
229 | m_Running = false; | ||
230 | m_CacheCleanTimer.Stop(); | ||
231 | m_CacheCleanTimer.Close(); | ||
232 | } | ||
233 | } | ||
232 | } | 234 | } |
233 | } | 235 | } |
234 | 236 | ||
235 | public void RegionLoaded(Scene scene) | 237 | public void RegionLoaded(Scene scene) |
236 | { | 238 | { |
237 | if (m_Enabled && m_AssetService == null) | 239 | if (m_Enabled) |
238 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | 240 | { |
241 | if(m_AssetService == null) | ||
242 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | ||
243 | lock(timerLock) | ||
244 | { | ||
245 | if(!m_Running) | ||
246 | { | ||
247 | if (m_FileCacheEnabled && (m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | ||
248 | { | ||
249 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); | ||
250 | m_CacheCleanTimer.AutoReset = false; | ||
251 | m_CacheCleanTimer.Elapsed += CleanupExpiredFiles; | ||
252 | m_CacheCleanTimer.Start(); | ||
253 | } | ||
254 | m_Running = true; | ||
255 | } | ||
256 | } | ||
257 | } | ||
239 | } | 258 | } |
240 | 259 | ||
241 | //////////////////////////////////////////////////////////// | 260 | //////////////////////////////////////////////////////////// |
@@ -542,6 +561,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
542 | if (m_LogLevel >= 2) | 561 | if (m_LogLevel >= 2) |
543 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration); | 562 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration); |
544 | 563 | ||
564 | if(!m_Running) | ||
565 | return; | ||
545 | // Purge all files last accessed prior to this point | 566 | // Purge all files last accessed prior to this point |
546 | DateTime purgeLine = DateTime.Now - m_FileExpiration; | 567 | DateTime purgeLine = DateTime.Now - m_FileExpiration; |
547 | 568 | ||
@@ -554,6 +575,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
554 | { | 575 | { |
555 | CleanExpiredFiles(dir, purgeLine); | 576 | CleanExpiredFiles(dir, purgeLine); |
556 | } | 577 | } |
578 | |||
579 | lock(timerLock) | ||
580 | { | ||
581 | if(m_Running) | ||
582 | m_CacheCleanTimer.Start(); | ||
583 | } | ||
557 | } | 584 | } |
558 | 585 | ||
559 | /// <summary> | 586 | /// <summary> |
@@ -789,9 +816,15 @@ namespace OpenSim.Region.CoreModules.Asset | |||
789 | 816 | ||
790 | s.ForEachSOG(delegate(SceneObjectGroup e) | 817 | s.ForEachSOG(delegate(SceneObjectGroup e) |
791 | { | 818 | { |
819 | if(!m_Running && !storeUncached) | ||
820 | return; | ||
821 | |||
792 | gatherer.AddForInspection(e); | 822 | gatherer.AddForInspection(e); |
793 | gatherer.GatherAll(); | 823 | gatherer.GatherAll(); |
794 | 824 | ||
825 | if(!m_Running && !storeUncached) | ||
826 | return; | ||
827 | |||
795 | foreach (UUID assetID in gatherer.GatheredUuids.Keys) | 828 | foreach (UUID assetID in gatherer.GatheredUuids.Keys) |
796 | { | 829 | { |
797 | if (!assetsFound.ContainsKey(assetID)) | 830 | if (!assetsFound.ContainsKey(assetID)) |
@@ -820,7 +853,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
820 | } | 853 | } |
821 | 854 | ||
822 | gatherer.GatheredUuids.Clear(); | 855 | gatherer.GatheredUuids.Clear(); |
856 | if(!m_Running && !storeUncached) | ||
857 | return; | ||
858 | |||
859 | if(!storeUncached) | ||
860 | Thread.Sleep(50); | ||
823 | }); | 861 | }); |
862 | if(!m_Running && !storeUncached) | ||
863 | break; | ||
824 | } | 864 | } |
825 | 865 | ||
826 | return assetsFound.Count; | 866 | return assetsFound.Count; |
@@ -982,7 +1022,26 @@ namespace OpenSim.Region.CoreModules.Asset | |||
982 | 1022 | ||
983 | WorkManager.RunInThread(delegate | 1023 | WorkManager.RunInThread(delegate |
984 | { | 1024 | { |
1025 | bool wasRunning= false; | ||
1026 | lock(timerLock) | ||
1027 | { | ||
1028 | if(m_Running) | ||
1029 | { | ||
1030 | m_CacheCleanTimer.Stop(); | ||
1031 | m_Running = false; | ||
1032 | wasRunning = true; | ||
1033 | Thread.Sleep(100); | ||
1034 | } | ||
1035 | } | ||
985 | int assetReferenceTotal = TouchAllSceneAssets(true); | 1036 | int assetReferenceTotal = TouchAllSceneAssets(true); |
1037 | lock(timerLock) | ||
1038 | { | ||
1039 | if(wasRunning) | ||
1040 | { | ||
1041 | m_CacheCleanTimer.Start(); | ||
1042 | m_Running = true; | ||
1043 | } | ||
1044 | } | ||
986 | con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal); | 1045 | con.OutputFormat("Completed check with {0} assets.", assetReferenceTotal); |
987 | }, null, "TouchAllSceneAssets"); | 1046 | }, null, "TouchAllSceneAssets"); |
988 | 1047 | ||