Make "fcache status" command also display information on disk/mem cache hit rate that is currently only displayed if LogLevel >=1 in [AssetCache] config

link-sitting
Justin Clark-Casey (justincc) 2013-10-30 18:57:51 +00:00
parent 28f36d8db5
commit fdd1c63c3c
1 changed files with 38 additions and 18 deletions

View File

@ -31,6 +31,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
@ -74,8 +75,6 @@ namespace OpenSim.Region.CoreModules.Asset
private static ulong m_RequestsForInprogress;
private static ulong m_DiskHits;
private static ulong m_MemoryHits;
private static double m_HitRateMemory;
private static double m_HitRateFile;
#if WAIT_ON_INPROGRESS_REQUESTS
private Dictionary<string, ManualResetEvent> m_CurrentlyWriting = new Dictionary<string, ManualResetEvent>();
@ -427,18 +426,9 @@ namespace OpenSim.Region.CoreModules.Asset
if (((m_LogLevel >= 1)) && (m_HitRateDisplay != 0) && (m_Requests % m_HitRateDisplay == 0))
{
m_HitRateFile = (double)m_DiskHits / m_Requests * 100.0;
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Get :: {0} :: {1}", id, asset == null ? "Miss" : "Hit");
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: File Hit Rate {0}% for {1} requests", m_HitRateFile.ToString("0.00"), m_Requests);
if (m_MemoryCacheEnabled)
{
m_HitRateMemory = (double)m_MemoryHits / m_Requests * 100.0;
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Memory Hit Rate {0}% for {1} requests", m_HitRateMemory.ToString("0.00"), m_Requests);
}
m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0} unnessesary requests due to requests for assets that are currently downloading.", m_RequestsForInprogress);
GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
}
return asset;
@ -805,6 +795,30 @@ namespace OpenSim.Region.CoreModules.Asset
}
}
private List<string> GenerateCacheHitReport()
{
List<string> outputLines = new List<string>();
double fileHitRate = (double)m_DiskHits / m_Requests * 100.0;
outputLines.Add(
string.Format("File Hit Rate: {0}% for {1} requests", fileHitRate.ToString("0.00"), m_Requests));
if (m_MemoryCacheEnabled)
{
double memHitRate = (double)m_MemoryHits / m_Requests * 100.0;
outputLines.Add(
string.Format("Memory Hit Rate: {0}% for {1} requests", memHitRate.ToString("0.00"), m_Requests));
}
outputLines.Add(
string.Format(
"Unnecessary requests due to requests for assets that are currently downloading: {0}",
m_RequestsForInprogress));
return outputLines;
}
#region Console Commands
private void HandleConsoleCommand(string module, string[] cmdparams)
{
@ -826,6 +840,16 @@ namespace OpenSim.Region.CoreModules.Asset
{
int fileCount = GetFileCacheCount(m_CacheDirectory);
con.OutputFormat("File Cache: {0} assets", fileCount);
}
else
{
con.Output("File cache disabled");
}
GenerateCacheHitReport().ForEach(l => con.Output(l));
if (m_FileCacheEnabled)
{
con.Output("Deep scans have previously been performed on the following regions:");
foreach (string s in Directory.GetFiles(m_CacheDirectory, "*.fac"))
@ -835,10 +859,6 @@ namespace OpenSim.Region.CoreModules.Asset
con.OutputFormat("Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss"));
}
}
else
{
con.Output("File cache disabled");
}
break;