From 0094556d04add28d5a36c653b39901b93f0a69ba Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 28 May 2009 21:04:10 +0000 Subject: Instrumenting GlynnTuckerCache to find out the hit rate. --- .../CoreModules/Asset/GlynnTuckerAssetCache.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim') 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 private bool m_Enabled = false; private ICache m_Cache = new GlynnTucker.Cache.SimpleMemoryCache(); + // Instrumentation + private uint m_DebugRate = 0; + public string Name { get { return "GlynnTuckerAssetCache"; } @@ -68,6 +71,11 @@ namespace OpenSim.Region.CoreModules.Asset m_log.Info("[ASSET CACHE]: GlynnTucker asset cache enabled"); + // Instrumentation + IConfig cacheConfig = source.Configs["AssetCache"]; + if (cacheConfig != null) + m_DebugRate = (uint)cacheConfig.GetInt("DebugRate", 0); + } } } @@ -104,10 +112,31 @@ namespace OpenSim.Region.CoreModules.Asset m_Cache.AddOrUpdate(asset.ID, asset); } + private ulong m_Hits = 0; + private ulong m_Requests = 0; + private void Debug(Object asset) + { + // Temporary instrumentation to measure the hit/miss rate + if (m_DebugRate > 0) + { + m_Requests++; + if (asset != null) + m_Hits++; + + if ((m_Requests % m_DebugRate) == 0) + m_log.DebugFormat("[ASSET CACHE]: Hit Rate {0} / {1} == {2}%", m_Hits, m_Requests, ((float)m_Hits / m_Requests) * 100); + + } + // End instrumentation + } + public AssetBase Get(string id) { Object asset = null; m_Cache.TryGet(id, out asset); + + Debug(asset); + return (AssetBase)asset; } -- cgit v1.1