aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordiva2009-05-28 21:04:10 +0000
committerdiva2009-05-28 21:04:10 +0000
commit0094556d04add28d5a36c653b39901b93f0a69ba (patch)
treecdd94c1f19f1f114b09dac7f24983b947824b16d /OpenSim
parent* Tweak to above (diff)
downloadopensim-SC_OLD-0094556d04add28d5a36c653b39901b93f0a69ba.zip
opensim-SC_OLD-0094556d04add28d5a36c653b39901b93f0a69ba.tar.gz
opensim-SC_OLD-0094556d04add28d5a36c653b39901b93f0a69ba.tar.bz2
opensim-SC_OLD-0094556d04add28d5a36c653b39901b93f0a69ba.tar.xz
Instrumenting GlynnTuckerCache to find out the hit rate.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index f784c1b..9f02868 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -48,6 +48,9 @@ namespace OpenSim.Region.CoreModules.Asset
48 private bool m_Enabled = false; 48 private bool m_Enabled = false;
49 private ICache m_Cache = new GlynnTucker.Cache.SimpleMemoryCache(); 49 private ICache m_Cache = new GlynnTucker.Cache.SimpleMemoryCache();
50 50
51 // Instrumentation
52 private uint m_DebugRate = 0;
53
51 public string Name 54 public string Name
52 { 55 {
53 get { return "GlynnTuckerAssetCache"; } 56 get { return "GlynnTuckerAssetCache"; }
@@ -68,6 +71,11 @@ namespace OpenSim.Region.CoreModules.Asset
68 71
69 m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled"); 72 m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled");
70 73
74 // Instrumentation
75 IConfig cacheConfig = source.Configs["AssetCache"];
76 if (cacheConfig != null)
77 m_DebugRate = (uint)cacheConfig.GetInt("DebugRate", 0);
78
71 } 79 }
72 } 80 }
73 } 81 }
@@ -104,10 +112,31 @@ namespace OpenSim.Region.CoreModules.Asset
104 m_Cache.AddOrUpdate(asset.ID, asset); 112 m_Cache.AddOrUpdate(asset.ID, asset);
105 } 113 }
106 114
115 private ulong m_Hits = 0;
116 private ulong m_Requests = 0;
117 private void Debug(Object asset)
118 {
119 // Temporary instrumentation to measure the hit/miss rate
120 if (m_DebugRate > 0)
121 {
122 m_Requests++;
123 if (asset != null)
124 m_Hits++;
125
126 if ((m_Requests % m_DebugRate) == 0)
127 m_log.DebugFormat("[ASSET CACHE]: Hit Rate {0} / {1} == {2}%", m_Hits, m_Requests, ((float)m_Hits / m_Requests) * 100);
128
129 }
130 // End instrumentation
131 }
132
107 public AssetBase Get(string id) 133 public AssetBase Get(string id)
108 { 134 {
109 Object asset = null; 135 Object asset = null;
110 m_Cache.TryGet(id, out asset); 136 m_Cache.TryGet(id, out asset);
137
138 Debug(asset);
139
111 return (AssetBase)asset; 140 return (AssetBase)asset;
112 } 141 }
113 142