Merge pull request #7 from gamucf/moses.metricsPhase2

Moses.metrics phase2
fsassets
Michael Heilmann 2015-05-19 14:40:49 -04:00
commit 714c082ca8
7 changed files with 1012 additions and 751 deletions

52
OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs Normal file → Executable file
View File

@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using OpenMetaverse;
@ -71,6 +72,11 @@ namespace OpenSim.Framework.Monitoring
private volatile float pendingUploads;
private volatile float activeScripts;
private volatile float scriptLinesPerSecond;
private volatile float m_frameDilation;
private volatile float m_usersLoggingIn;
private volatile float m_totalGeoPrims;
private volatile float m_totalMeshes;
private volatile float m_inUseThreads;
// /// <summary>
// /// These statistics are being collected by push rather than pull. Pull would be simpler, but I had the
@ -249,6 +255,10 @@ namespace OpenSim.Framework.Monitoring
{
// FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
// SimStatsPacket that was being used).
// For an unknown reason the original designers decided not to
// include the spare MS statistic inside of this class, this is
// located inside the StatsBlock at location 21, thus it is skipped
timeDilation = stats.StatsBlock[0].StatValue;
simFps = stats.StatsBlock[1].StatValue;
physicsFps = stats.StatsBlock[2].StatValue;
@ -270,6 +280,11 @@ namespace OpenSim.Framework.Monitoring
pendingUploads = stats.StatsBlock[18].StatValue;
activeScripts = stats.StatsBlock[19].StatValue;
scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
m_frameDilation = stats.StatsBlock[22].StatValue;
m_usersLoggingIn = stats.StatsBlock[23].StatValue;
m_totalGeoPrims = stats.StatsBlock[24].StatValue;
m_totalMeshes = stats.StatsBlock[25].StatValue;
m_inUseThreads = stats.StatsBlock[26].StatValue;
}
/// <summary>
@ -407,6 +422,27 @@ Asset service request failures: {3}" + Environment.NewLine,
/// <returns></returns>
public override OSDMap OReport(string uptime, string version)
{
// Get the amount of physical memory, allocated with the instance of this program, in kilobytes;
// the working set is the set of memory pages currently visible to this program in physical RAM
// memory and includes both shared (e.g. system libraries) and private data
double memUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0;
// Get the number of threads from the system that are currently
// running
int numberThreadsRunning = 0;
foreach (ProcessThread currentThread in
Process.GetCurrentProcess().Threads)
{
// A known issue with the current process .Threads property is
// that it can return null threads, thus don't count those as
// running threads and prevent the program function from failing
if (currentThread != null &&
currentThread.ThreadState == ThreadState.Running)
{
numberThreadsRunning++;
}
}
OSDMap args = new OSDMap(30);
// args["AssetsInCache"] = OSD.FromString (String.Format ("{0:0.##}", AssetsInCache));
// args["TimeAfterCacheMiss"] = OSD.FromString (String.Format ("{0:0.##}",
@ -444,6 +480,22 @@ Asset service request failures: {3}" + Environment.NewLine,
args["Uptime"] = OSD.FromString (uptime);
args["Version"] = OSD.FromString (version);
args["FrameDilatn"] = OSD.FromString(String.Format("{0:0.##}", m_frameDilation));
args["Logging in Users"] = OSD.FromString(String.Format("{0:0.##}",
m_usersLoggingIn));
args["GeoPrims"] = OSD.FromString(String.Format("{0:0.##}",
m_totalGeoPrims));
args["Mesh Objects"] = OSD.FromString(String.Format("{0:0.##}",
m_totalMeshes));
args["XEngine Thread Count"] = OSD.FromString(String.Format("{0:0.##}",
m_inUseThreads));
args["Util Thread Count"] = OSD.FromString(String.Format("{0:0.##}",
Util.GetSmartThreadPoolInfo().InUseThreads));
args["System Thread Count"] = OSD.FromString(String.Format(
"{0:0.##}", numberThreadsRunning));
args["ProcMem"] = OSD.FromString(String.Format("{0:#,###,###.##}",
memUsage));
return args;
}
}

File diff suppressed because it is too large Load Diff

59
OpenSim/Region/Framework/Scenes/SceneGraph.cs Normal file → Executable file
View File

@ -67,7 +67,9 @@ namespace OpenSim.Region.Framework.Scenes
protected Scene m_parentScene;
protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
protected int m_numRootAgents = 0;
protected int m_numTotalPrim = 0;
protected int m_numPrim = 0;
protected int m_numMesh = 0;
protected int m_numChildAgents = 0;
protected int m_physicalPrim = 0;
@ -368,7 +370,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart[] parts = sceneObject.Parts;
// Clamp child prim sizes and add child prims to the m_numPrim count
// Clamp the sizes (scales) of the child prims and add the child prims to the count of all primitives
// (meshes and geometric primitives) in the scene; add child prims to m_numTotalPrim count
if (m_parentScene.m_clampPrimSize)
{
foreach (SceneObjectPart part in parts)
@ -382,7 +385,19 @@ namespace OpenSim.Region.Framework.Scenes
part.Shape.Scale = scale;
}
}
m_numPrim += parts.Length;
m_numTotalPrim += parts.Length;
// Go through all parts (geometric primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in parts)
{
// Keep track of the total number of meshes or geometric primitives now in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh++;
else
m_numPrim++;
}
sceneObject.AttachToScene(m_parentScene);
@ -437,7 +452,21 @@ namespace OpenSim.Region.Framework.Scenes
if (!resultOfObjectLinked)
{
m_numPrim -= grp.PrimCount;
// Decrement the total number of primitives (meshes and geometric primitives)
// that are part of the Scene Object being removed
m_numTotalPrim -= grp.PrimCount;
// Go through all parts (primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in grp.Parts)
{
// Keep track of the total number of meshes or geometric primitives left in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh--;
else
m_numPrim--;
}
if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
RemovePhysicalPrim(grp.PrimCount);
@ -686,10 +715,20 @@ namespace OpenSim.Region.Framework.Scenes
}
public int GetTotalObjectsCount()
{
return m_numTotalPrim;
}
public int GetTotalPrimObjectsCount()
{
return m_numPrim;
}
public int GetTotalMeshObjectsCount()
{
return m_numMesh;
}
public int GetActiveObjectsCount()
{
return m_physicalPrim;
@ -1970,7 +2009,19 @@ namespace OpenSim.Region.Framework.Scenes
// think it's selected, so it will never send a deselect...
copy.IsSelected = false;
m_numPrim += copy.Parts.Length;
m_numTotalPrim += copy.Parts.Length;
// Go through all parts (primitives and meshes) of this Scene Object
foreach (SceneObjectPart part in copy.Parts)
{
// Keep track of the total number of meshes or geometric primitives now in the scene;
// determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
// a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
if (part.GetPrimType() == PrimType.SCULPT)
m_numMesh++;
else
m_numPrim++;
}
if (rot != Quaternion.Identity)
{

View File

@ -61,6 +61,10 @@ namespace OpenSim.Region.Framework.Scenes
private YourStatsAreWrong handlerStatsIncorrect;
// Determines the size of the array that is used to collect StatBlocks
// for sending to the SimStats and SimExtraStatsCollector
private const int m_statisticArraySize = 27;
/// <summary>
/// These are the IDs of stats sent in the StatsPacket to the viewer.
/// </summary>
@ -104,7 +108,12 @@ namespace OpenSim.Region.Framework.Scenes
ScriptEps = 31,
SimSpareMs = 32,
SimSleepMs = 33,
SimIoPumpTime = 34
SimIoPumpTime = 34,
FrameDilation = 35,
UsersLoggingIn = 36,
TotalGeoPrim = 37,
TotalMesh = 38,
ThreadCount = 39
}
/// <summary>
@ -175,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
// saved last reported value so there is something available for llGetRegionFPS
private float lastReportedSimFPS;
private float[] lastReportedSimStats = new float[22];
private float[] lastReportedSimStats = new float[m_statisticArraySize];
private float m_pfps;
/// <summary>
@ -202,6 +211,8 @@ namespace OpenSim.Region.Framework.Scenes
private int m_rootAgents;
private int m_childAgents;
private int m_numPrim;
private int m_numGeoPrim;
private int m_numMesh;
private int m_inPacketsPerSecond;
private int m_outPacketsPerSecond;
private int m_activePrim;
@ -234,6 +245,13 @@ namespace OpenSim.Region.Framework.Scenes
// update for physics
private int m_numberPhysicsFrames;
// The current number of users attempting to login to the region
private int m_usersLoggingIn;
// The last reported value of threads from the SmartThreadPool inside of
// XEngine
private int m_inUseThreads;
private Scene m_scene;
private RegionInfo ReportingRegion;
@ -246,11 +264,13 @@ namespace OpenSim.Region.Framework.Scenes
{
// Initialize the different frame time arrays to the correct sizes
m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
m_simulationFrameTimeMilliseconds = new
double[m_numberFramesStored];
m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored];
m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
// Initialize the current number of users logging into the region
m_usersLoggingIn = 0;
m_scene = scene;
m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@ -284,13 +304,14 @@ namespace OpenSim.Region.Framework.Scenes
StatsManager.RegisterStat(SlowFramesStat);
}
public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
{
// Store the number of frames from the OpenSim.ini configuration
// file
// Store the number of frames from the OpenSim.ini configuration file
m_numberFramesStored = numberOfFrames;
}
public void Close()
{
m_report.Elapsed -= TriggerStatsHeartbeat;
@ -328,11 +349,17 @@ namespace OpenSim.Region.Framework.Scenes
double simulationSumFrameTime;
double physicsSumFrameTime;
double networkSumFrameTime;
float frameDilation;
int currentFrame;
if (!m_scene.Active)
return;
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
// Create arrays to hold the statistics for this current scene,
// these will be passed to the SimExtraStatsCollector, they are also
// sent to the SimStats class
SimStatsPacket.StatBlock[] sb = new
SimStatsPacket.StatBlock[m_statisticArraySize];
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
// Know what's not thread safe in Mono... modifying timers.
@ -354,21 +381,21 @@ namespace OpenSim.Region.Framework.Scenes
#region various statistic googly moogly
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window, this will be done as a
// new section given the title of our current project
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window, this will be done as a
// new section given the title of our current project
// We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently
// locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
//int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
int reportedFPS = m_fps;
int reportedFPS = m_fps;
// save the reported value so there is something available for llGetRegionFPS
lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window
//float physfps = ((m_pfps / 1000));
float physfps = m_numberPhysicsFrames;
float physfps = m_numberPhysicsFrames;
//if (physfps > 600)
//physfps = physfps - (physfps - 600);
@ -381,6 +408,8 @@ namespace OpenSim.Region.Framework.Scenes
m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount();
m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
@ -406,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
if (framesUpdated == 0)
framesUpdated = 1;
for (int i = 0; i < 22; i++)
for (int i = 0; i < m_statisticArraySize; i++)
{
sb[i] = new SimStatsPacket.StatBlock();
}
@ -431,6 +460,19 @@ namespace OpenSim.Region.Framework.Scenes
networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
}
// Get the index that represents the current frame based on the next one known; go back
// to the last index if next one is stated to restart at 0
if (m_nextLocation == 0)
currentFrame = m_numberFramesStored - 1;
else
currentFrame = m_nextLocation - 1;
// Calculate the frame dilation; which is currently based on the ratio between the sum of the
// physics and simulation rate, and the set minimum time to run a scene's frame
frameDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] +
m_physicsFrameTimeMilliseconds[currentFrame]) / m_scene.MinFrameTicks;
// ORIGINAL code commented out until we have time to add our own
sb[0].StatID = (uint) Stats.TimeDilation;
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
@ -455,30 +497,27 @@ namespace OpenSim.Region.Framework.Scenes
sb[7].StatID = (uint) Stats.ActivePrim;
sb[7].StatValue = m_activePrim;
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window
// ORIGINAL code commented out until we have time to add our own
// statistics to the statistics window
sb[8].StatID = (uint)Stats.FrameMS;
//sb[8].StatValue = m_frameMS / framesUpdated;
sb[8].StatValue = (float) totalSumFrameTime /
m_numberFramesStored;
sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored;
sb[9].StatID = (uint)Stats.NetMS;
//sb[9].StatValue = m_netMS / framesUpdated;
sb[9].StatValue = (float) networkSumFrameTime /
m_numberFramesStored;
sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored;
sb[10].StatID = (uint)Stats.PhysicsMS;
//sb[10].StatValue = m_physicsMS / framesUpdated;
sb[10].StatValue = (float) physicsSumFrameTime /
m_numberFramesStored;
sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored;
sb[11].StatID = (uint)Stats.ImageMS ;
sb[11].StatValue = m_imageMS / framesUpdated;
sb[12].StatID = (uint)Stats.OtherMS;
//sb[12].StatValue = m_otherMS / framesUpdated;
sb[12].StatValue = (float) simulationSumFrameTime /
m_numberFramesStored;
sb[12].StatValue = (float) simulationSumFrameTime /
m_numberFramesStored;
sb[13].StatID = (uint)Stats.InPacketsPerSecond;
sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
@ -507,7 +546,28 @@ namespace OpenSim.Region.Framework.Scenes
sb[21].StatID = (uint)Stats.SimSpareMs;
sb[21].StatValue = m_spareMS / framesUpdated;
for (int i = 0; i < 22; i++)
// Current ratio between the sum of physics and sim rate, and the
// minimum time to run a scene's frame
sb[22].StatID = (uint)Stats.FrameDilation;
sb[22].StatValue = frameDilation;
// Current number of users currently attemptint to login to region
sb[23].StatID = (uint)Stats.UsersLoggingIn;
sb[23].StatValue = m_usersLoggingIn;
// Total number of geometric primitives in the scene
sb[24].StatID = (uint)Stats.TotalGeoPrim;
sb[24].StatValue = m_numGeoPrim;
// Total number of mesh objects in the scene
sb[25].StatID = (uint)Stats.TotalMesh;
sb[25].StatValue = m_numMesh;
// Current number of threads that XEngine is using
sb[26].StatID = (uint)Stats.ThreadCount;
sb[26].StatValue = m_inUseThreads;
for (int i = 0; i < m_statisticArraySize; i++)
{
lastReportedSimStats[i] = sb[i].StatValue;
}
@ -686,31 +746,31 @@ namespace OpenSim.Region.Framework.Scenes
m_otherMS += ms;
}
public void addPhysicsFrame(int frames)
{
// Add the number of physics frames to the correct total physics
// frames
m_numberPhysicsFrames += frames;
}
public void addPhysicsFrame(int frames)
{
// Add the number of physics frames to the correct total physics
// frames
m_numberPhysicsFrames += frames;
}
public void addFrameTimeMilliseconds(double total, double simulation,
double physics, double network)
{
// Save the frame times from the current frame into the appropriate
// arrays
m_totalFrameTimeMilliseconds[m_nextLocation] = total;
m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
m_networkFrameTimeMilliseconds[m_nextLocation] = network;
public void addFrameTimeMilliseconds(double total, double simulation,
double physics, double network)
{
// Save the frame times from the current frame into the appropriate
// arrays
m_totalFrameTimeMilliseconds[m_nextLocation] = total;
m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
m_networkFrameTimeMilliseconds[m_nextLocation] = network;
// Update to the next location in the list
m_nextLocation++;
// Update to the next location in the list
m_nextLocation++;
// Since the list will begin to overwrite the oldest frame values
// first, the next location needs to loop back to the beginning of the
// list whenever it reaches the end
m_nextLocation = m_nextLocation % m_numberFramesStored;
}
// Since the list will begin to overwrite the oldest frame values
// first, the next location needs to loop back to the beginning of the
// list whenever it reaches the end
m_nextLocation = m_nextLocation % m_numberFramesStored;
}
public void AddPendingDownloads(int count)
{
@ -734,6 +794,31 @@ namespace OpenSim.Region.Framework.Scenes
AddunAckedBytes(unAckedBytes);
}
public void UpdateUsersLoggingIn(bool isLoggingIn)
{
// Determine whether the user has started logging in or has completed
// logging into the region
if (isLoggingIn)
{
// The user is starting to login to the region so increment the
// number of users attempting to login to the region
m_usersLoggingIn++;
}
else
{
// The user has finished logging into the region so decrement the
// number of users logging into the region
m_usersLoggingIn--;
}
}
public void SetThreadCount(int inUseThreads)
{
// Save the new number of threads to our member variable to send to
// the extra stats collector
m_inUseThreads = inUseThreads;
}
#endregion
public Dictionary<string, float> GetExtraSimStats()

36
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs Normal file → Executable file
View File

@ -1872,6 +1872,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
IScriptInstance instance = GetInstance(itemID);
if (instance != null)
instance.ApiResetScript();
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public void ResetScript(UUID itemID)
@ -1879,6 +1885,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
IScriptInstance instance = GetInstance(itemID);
if (instance != null)
instance.ResetScript(m_WaitForEventCompletionOnScriptStop);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public void StartScript(UUID itemID)
@ -1888,6 +1900,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Start();
else
m_runFlags.AddOrUpdate(itemID, true, 240);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public void StopScript(UUID itemID)
@ -1903,6 +1921,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name);
m_runFlags.AddOrUpdate(itemID, false, 240);
}
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public DetectParams GetDetectParams(UUID itemID, int idx)
@ -2393,6 +2417,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Suspend();
// else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public void ResumeScript(UUID itemID)
@ -2404,6 +2434,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instance.Resume();
// else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
// Send the new number of threads that are in use by the thread
// pool, I believe that by adding them to the locations where the
// script is changing states that I will catch all changes to the
// thread pool
m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
}
public bool HasScript(UUID itemID, out bool running)

0
bin/LukeSkywalker.IPNetwork.dll Normal file → Executable file
View File

2
bin/OpenSimDefaults.ini Normal file → Executable file
View File

@ -296,7 +296,7 @@
; Simulator Stats URI
; Enable JSON simulator data by setting a URI name (case sensitive)
; Returns regular sim stats (SimFPS, ...)
; Stats_URI = "jsonSimStats"
Stats_URI = "jsonSimStats"
; Simulator StatsManager URI
; Enable fetch of StatsManager registered stats. Fetch is query which can optionally