diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Asset')
4 files changed, 45 insertions, 66 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 66ca7c2..1add0ab 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -155,14 +155,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
155 | private int m_hitCount; | 155 | private int m_hitCount; |
156 | 156 | ||
157 | /// <summary> | 157 | /// <summary> |
158 | /// Initialize asset cache module with default parameters. | ||
159 | /// </summary> | ||
160 | public void Initialize() | ||
161 | { | ||
162 | Initialize(DefaultMaxSize, DefaultMaxCount, DefaultExpirationTime); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Initialize asset cache module, with custom parameters. | 158 | /// Initialize asset cache module, with custom parameters. |
167 | /// </summary> | 159 | /// </summary> |
168 | /// <param name="maximalSize"> | 160 | /// <param name="maximalSize"> |
@@ -174,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
174 | /// <param name="expirationTime"> | 166 | /// <param name="expirationTime"> |
175 | /// Asset's expiration time. | 167 | /// Asset's expiration time. |
176 | /// </param> | 168 | /// </param> |
177 | public void Initialize(long maximalSize, int maximalCount, TimeSpan expirationTime) | 169 | protected void Initialize(long maximalSize, int maximalCount, TimeSpan expirationTime) |
178 | { | 170 | { |
179 | if (maximalSize <= 0 || maximalCount <= 0) | 171 | if (maximalSize <= 0 || maximalCount <= 0) |
180 | { | 172 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 0a7e736..7da5e7a 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
44 | LogManager.GetLogger( | 44 | LogManager.GetLogger( |
45 | MethodBase.GetCurrentMethod().DeclaringType); | 45 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private bool m_Enabled = false; | 47 | private bool m_Enabled; |
48 | private Cache m_Cache = new Cache(CacheMedium.Memory, | 48 | private Cache m_Cache; |
49 | CacheStrategy.Aggressive, | ||
50 | CacheFlags.AllowUpdate); | ||
51 | 49 | ||
52 | public string Name | 50 | public string Name |
53 | { | 51 | { |
@@ -77,6 +75,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
77 | return; | 75 | return; |
78 | } | 76 | } |
79 | 77 | ||
78 | m_Cache = new Cache(CacheMedium.Memory, CacheStrategy.Aggressive, CacheFlags.AllowUpdate); | ||
80 | m_Enabled = true; | 79 | m_Enabled = true; |
81 | 80 | ||
82 | m_log.Info("[ASSET CACHE]: Core asset cache enabled"); | 81 | m_log.Info("[ASSET CACHE]: Core asset cache enabled"); |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index d45c35c..cbdca16 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -61,24 +61,23 @@ namespace Flotsam.RegionModules.AssetCache | |||
61 | LogManager.GetLogger( | 61 | LogManager.GetLogger( |
62 | MethodBase.GetCurrentMethod().DeclaringType); | 62 | MethodBase.GetCurrentMethod().DeclaringType); |
63 | 63 | ||
64 | private bool m_Enabled = false; | 64 | private bool m_Enabled; |
65 | 65 | ||
66 | private const string m_ModuleName = "FlotsamAssetCache"; | 66 | private const string m_ModuleName = "FlotsamAssetCache"; |
67 | private const string m_DefaultCacheDirectory = m_ModuleName; | 67 | private const string m_DefaultCacheDirectory = m_ModuleName; |
68 | private string m_CacheDirectory = m_DefaultCacheDirectory; | 68 | private string m_CacheDirectory = m_DefaultCacheDirectory; |
69 | 69 | ||
70 | 70 | private readonly List<char> m_InvalidChars = new List<char>(); | |
71 | private List<char> m_InvalidChars = new List<char>(); | ||
72 | 71 | ||
73 | private int m_LogLevel = 1; | 72 | private int m_LogLevel = 1; |
74 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests | 73 | private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests |
75 | 74 | ||
76 | private static ulong m_Requests = 0; | 75 | private static ulong m_Requests; |
77 | private static ulong m_RequestsForInprogress = 0; | 76 | private static ulong m_RequestsForInprogress; |
78 | private static ulong m_DiskHits = 0; | 77 | private static ulong m_DiskHits; |
79 | private static ulong m_MemoryHits = 0; | 78 | private static ulong m_MemoryHits; |
80 | private static double m_HitRateMemory = 0.0; | 79 | private static double m_HitRateMemory; |
81 | private static double m_HitRateFile = 0.0; | 80 | private static double m_HitRateFile; |
82 | 81 | ||
83 | #if WAIT_ON_INPROGRESS_REQUESTS | 82 | #if WAIT_ON_INPROGRESS_REQUESTS |
84 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); | 83 | private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>(); |
@@ -87,7 +86,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
87 | private List<string> m_CurrentlyWriting = new List<string>(); | 86 | private List<string> m_CurrentlyWriting = new List<string>(); |
88 | #endif | 87 | #endif |
89 | 88 | ||
90 | private ExpiringCache<string, AssetBase> m_MemoryCache = new ExpiringCache<string, AssetBase>(); | 89 | private ExpiringCache<string, AssetBase> m_MemoryCache; |
91 | private bool m_MemoryCacheEnabled = true; | 90 | private bool m_MemoryCacheEnabled = true; |
92 | 91 | ||
93 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
@@ -101,12 +100,12 @@ namespace Flotsam.RegionModules.AssetCache | |||
101 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
102 | private static int m_CacheWarnAt = 30000; | 101 | private static int m_CacheWarnAt = 30000; |
103 | 102 | ||
104 | private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer(); | 103 | private System.Timers.Timer m_CacheCleanTimer; |
105 | 104 | ||
106 | private IAssetService m_AssetService = null; | 105 | private IAssetService m_AssetService; |
107 | private List<Scene> m_Scenes = new List<Scene>(); | 106 | private List<Scene> m_Scenes = new List<Scene>(); |
108 | 107 | ||
109 | private bool m_DeepScanBeforePurge = false; | 108 | private bool m_DeepScanBeforePurge; |
110 | 109 | ||
111 | public FlotsamAssetCache() | 110 | public FlotsamAssetCache() |
112 | { | 111 | { |
@@ -128,14 +127,15 @@ namespace Flotsam.RegionModules.AssetCache | |||
128 | { | 127 | { |
129 | IConfig moduleConfig = source.Configs["Modules"]; | 128 | IConfig moduleConfig = source.Configs["Modules"]; |
130 | 129 | ||
131 | |||
132 | if (moduleConfig != null) | 130 | if (moduleConfig != null) |
133 | { | 131 | { |
134 | string name = moduleConfig.GetString("AssetCaching", ""); | 132 | string name = moduleConfig.GetString("AssetCaching", String.Empty); |
135 | 133 | ||
136 | if (name == Name) | 134 | if (name == Name) |
137 | { | 135 | { |
136 | m_MemoryCache = new ExpiringCache<string, AssetBase>(); | ||
138 | m_Enabled = true; | 137 | m_Enabled = true; |
138 | |||
139 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} enabled", this.Name); | 139 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} enabled", this.Name); |
140 | 140 | ||
141 | IConfig assetConfig = source.Configs["AssetCache"]; | 141 | IConfig assetConfig = source.Configs["AssetCache"]; |
@@ -163,21 +163,11 @@ namespace Flotsam.RegionModules.AssetCache | |||
163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); | 163 | m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); |
164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) | 164 | if ((m_FileExpiration > TimeSpan.Zero) && (m_FileExpirationCleanupTimer > TimeSpan.Zero)) |
165 | { | 165 | { |
166 | m_CachCleanTimer.Interval = m_FileExpirationCleanupTimer.TotalMilliseconds; | 166 | m_CacheCleanTimer = new System.Timers.Timer(m_FileExpirationCleanupTimer.TotalMilliseconds); |
167 | m_CachCleanTimer.AutoReset = true; | 167 | m_CacheCleanTimer.AutoReset = true; |
168 | m_CachCleanTimer.Elapsed += CleanupExpiredFiles; | 168 | m_CacheCleanTimer.Elapsed += CleanupExpiredFiles; |
169 | m_CachCleanTimer.Enabled = true; | 169 | lock (m_CacheCleanTimer) |
170 | lock (m_CachCleanTimer) | 170 | m_CacheCleanTimer.Start(); |
171 | { | ||
172 | m_CachCleanTimer.Start(); | ||
173 | } | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | lock (m_CachCleanTimer) | ||
178 | { | ||
179 | m_CachCleanTimer.Enabled = false; | ||
180 | } | ||
181 | } | 171 | } |
182 | 172 | ||
183 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); | 173 | m_CacheDirectoryTiers = assetConfig.GetInt("CacheDirectoryTiers", 1); |
@@ -208,7 +198,6 @@ namespace Flotsam.RegionModules.AssetCache | |||
208 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); | 198 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); |
209 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); | 199 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); |
210 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); | 200 | MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire <datetime>", "Purge cached assets older then the specified date/time", HandleConsoleCommand); |
211 | |||
212 | } | 201 | } |
213 | } | 202 | } |
214 | } | 203 | } |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 4869f5d..1365e69 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -45,11 +45,13 @@ namespace OpenSim.Region.CoreModules.Asset | |||
45 | LogManager.GetLogger( | 45 | LogManager.GetLogger( |
46 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private bool m_Enabled = false; | 48 | private bool m_Enabled; |
49 | private ICache m_Cache = new GlynnTucker.Cache.SimpleMemoryCache(); | 49 | private ICache m_Cache; |
50 | private ulong m_Hits; | ||
51 | private ulong m_Requests; | ||
50 | 52 | ||
51 | // Instrumentation | 53 | // Instrumentation |
52 | private uint m_DebugRate = 0; | 54 | private uint m_DebugRate; |
53 | 55 | ||
54 | public Type ReplaceableInterface | 56 | public Type ReplaceableInterface |
55 | { | 57 | { |
@@ -72,6 +74,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
72 | 74 | ||
73 | if (name == Name) | 75 | if (name == Name) |
74 | { | 76 | { |
77 | m_Cache = new GlynnTucker.Cache.SimpleMemoryCache(); | ||
75 | m_Enabled = true; | 78 | m_Enabled = true; |
76 | 79 | ||
77 | m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled"); | 80 | m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled"); |
@@ -80,7 +83,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
80 | IConfig cacheConfig = source.Configs["AssetCache"]; | 83 | IConfig cacheConfig = source.Configs["AssetCache"]; |
81 | if (cacheConfig != null) | 84 | if (cacheConfig != null) |
82 | m_DebugRate = (uint)cacheConfig.GetInt("DebugRate", 0); | 85 | m_DebugRate = (uint)cacheConfig.GetInt("DebugRate", 0); |
83 | |||
84 | } | 86 | } |
85 | } | 87 | } |
86 | } | 88 | } |
@@ -117,24 +119,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
117 | m_Cache.AddOrUpdate(asset.ID, asset); | 119 | m_Cache.AddOrUpdate(asset.ID, asset); |
118 | } | 120 | } |
119 | 121 | ||
120 | private ulong m_Hits = 0; | ||
121 | private ulong m_Requests = 0; | ||
122 | private void Debug(Object asset) | ||
123 | { | ||
124 | // Temporary instrumentation to measure the hit/miss rate | ||
125 | if (m_DebugRate > 0) | ||
126 | { | ||
127 | m_Requests++; | ||
128 | if (asset != null) | ||
129 | m_Hits++; | ||
130 | |||
131 | if ((m_Requests % m_DebugRate) == 0) | ||
132 | m_log.DebugFormat("[ASSET CACHE]: Hit Rate {0} / {1} == {2}%", m_Hits, m_Requests, ((float)m_Hits / m_Requests) * 100); | ||
133 | |||
134 | } | ||
135 | // End instrumentation | ||
136 | } | ||
137 | |||
138 | public AssetBase Get(string id) | 122 | public AssetBase Get(string id) |
139 | { | 123 | { |
140 | Object asset = null; | 124 | Object asset = null; |
@@ -156,5 +140,20 @@ namespace OpenSim.Region.CoreModules.Asset | |||
156 | { | 140 | { |
157 | m_Cache.Clear(); | 141 | m_Cache.Clear(); |
158 | } | 142 | } |
143 | |||
144 | private void Debug(Object asset) | ||
145 | { | ||
146 | // Temporary instrumentation to measure the hit/miss rate | ||
147 | if (m_DebugRate > 0) | ||
148 | { | ||
149 | ++m_Requests; | ||
150 | if (asset != null) | ||
151 | ++m_Hits; | ||
152 | |||
153 | if ((m_Requests % m_DebugRate) == 0) | ||
154 | m_log.DebugFormat("[ASSET CACHE]: Hit Rate {0} / {1} == {2}%", m_Hits, m_Requests, ((float)m_Hits / (float)m_Requests) * 100.0f); | ||
155 | } | ||
156 | // End instrumentation | ||
157 | } | ||
159 | } | 158 | } |
160 | } | 159 | } |