mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
several changes to statistics. How they are stored, passed around, referenced; do some fixes for multi regions per instance,...
This commit is contained in:
@@ -62,76 +62,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
private YourStatsAreWrong handlerStatsIncorrect;
|
||||
|
||||
// Determines the size of the array that is used to collect StatBlocks
|
||||
// for sending viewer compatible stats must be conform with sb array filling below
|
||||
private const int m_statisticViewerArraySize = 38;
|
||||
// size of LastReportedSimFPS with extra stats.
|
||||
private const int m_statisticExtraArraySize = (int)(Stats.SimExtraCountEnd - Stats.SimExtraCountStart);
|
||||
|
||||
/// <summary>
|
||||
/// These are the IDs of stats sent in the StatsPacket to the viewer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators
|
||||
/// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky).
|
||||
/// </remarks>
|
||||
public enum Stats : uint
|
||||
{
|
||||
// viewers defined IDs
|
||||
TimeDilation = 0,
|
||||
SimFPS = 1,
|
||||
PhysicsFPS = 2,
|
||||
AgentUpdates = 3,
|
||||
FrameMS = 4,
|
||||
NetMS = 5,
|
||||
OtherMS = 6,
|
||||
PhysicsMS = 7,
|
||||
AgentMS = 8,
|
||||
ImageMS = 9,
|
||||
ScriptMS = 10,
|
||||
TotalPrim = 11,
|
||||
ActivePrim = 12,
|
||||
Agents = 13,
|
||||
ChildAgents = 14,
|
||||
ActiveScripts = 15,
|
||||
LSLScriptLinesPerSecond = 16, // viewers don't like this anymore
|
||||
InPacketsPerSecond = 17,
|
||||
OutPacketsPerSecond = 18,
|
||||
PendingDownloads = 19,
|
||||
PendingUploads = 20,
|
||||
VirtualSizeKb = 21,
|
||||
ResidentSizeKb = 22,
|
||||
PendingLocalUploads = 23,
|
||||
UnAckedBytes = 24,
|
||||
PhysicsPinnedTasks = 25,
|
||||
PhysicsLodTasks = 26,
|
||||
SimPhysicsStepMs = 27,
|
||||
SimPhysicsShapeMs = 28,
|
||||
SimPhysicsOtherMs = 29,
|
||||
SimPhysicsMemory = 30,
|
||||
ScriptEps = 31,
|
||||
SimSpareMs = 32,
|
||||
SimSleepMs = 33,
|
||||
SimIoPumpTime = 34,
|
||||
SimPCTSscriptsRun = 35,
|
||||
SimRegionIdle = 36, // dataserver only
|
||||
SimRegionIdlePossible = 37, // dataserver only
|
||||
SimAIStepTimeMS = 38,
|
||||
SimSkippedSillouet_PS = 39,
|
||||
SimSkippedCharsPerC = 40,
|
||||
|
||||
// extra stats IDs irrelevant, just far from viewer defined ones
|
||||
SimExtraCountStart = 1000,
|
||||
|
||||
internalLSLScriptLinesPerSecond = 1000,
|
||||
FrameDilation2 = 1001,
|
||||
UsersLoggingIn = 1002,
|
||||
TotalGeoPrim = 1003,
|
||||
TotalMesh = 1004,
|
||||
ThreadCount = 1005,
|
||||
|
||||
SimExtraCountEnd = 1006
|
||||
}
|
||||
private const int m_statisticExtraArraySize = (int)(StatsIndex.ArraySize - StatsIndex.ViewerArraySize);
|
||||
|
||||
/// <summary>
|
||||
/// This is for llGetRegionFPS
|
||||
@@ -201,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private float m_targetFrameTime = 0.1f;
|
||||
// saved last reported value so there is something available for llGetRegionFPS
|
||||
private float lastReportedSimFPS;
|
||||
private float[] lastReportedSimStats = new float[m_statisticExtraArraySize + m_statisticViewerArraySize];
|
||||
private float[] lastReportedSimStats = new float[(int)StatsIndex.ViewerArraySize];
|
||||
private float m_pfps;
|
||||
|
||||
/// <summary>
|
||||
@@ -342,10 +274,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if(Monitor.TryEnter(m_statsLock))
|
||||
{
|
||||
// m_log.Debug("Firing Stats Heart Beat");
|
||||
float[] newvalues = new float[(int)StatsIndex.ArraySize];
|
||||
|
||||
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
|
||||
SimStatsPacket.StatBlock[] sbex = new SimStatsPacket.StatBlock[m_statisticExtraArraySize];
|
||||
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
|
||||
uint regionFlags = 0;
|
||||
|
||||
try
|
||||
@@ -367,7 +297,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// factor to consider updates integration time
|
||||
float updateTimeFactor = 1.0f / updateElapsed;
|
||||
|
||||
|
||||
// scene frame stats
|
||||
float reportedFPS;
|
||||
float physfps;
|
||||
@@ -463,178 +392,51 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// so that stat numbers are always consistent.
|
||||
CheckStatSanity();
|
||||
|
||||
for (int i = 0; i < m_statisticViewerArraySize; i++)
|
||||
{
|
||||
sb[i] = new SimStatsPacket.StatBlock();
|
||||
}
|
||||
|
||||
sb[0].StatID = (uint) Stats.TimeDilation;
|
||||
sb[0].StatValue = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation,3);
|
||||
|
||||
sb[1].StatID = (uint) Stats.SimFPS;
|
||||
sb[1].StatValue = (float)Math.Round(reportedFPS,1);;
|
||||
|
||||
sb[2].StatID = (uint) Stats.PhysicsFPS;
|
||||
sb[2].StatValue = (float)Math.Round(physfps,1);
|
||||
|
||||
sb[3].StatID = (uint) Stats.AgentUpdates;
|
||||
sb[3].StatValue = m_agentUpdates * updateTimeFactor;
|
||||
|
||||
sb[4].StatID = (uint) Stats.Agents;
|
||||
sb[4].StatValue = m_rootAgents;
|
||||
|
||||
sb[5].StatID = (uint) Stats.ChildAgents;
|
||||
sb[5].StatValue = m_childAgents;
|
||||
|
||||
sb[6].StatID = (uint) Stats.TotalPrim;
|
||||
sb[6].StatValue = m_numPrim;
|
||||
|
||||
sb[7].StatID = (uint) Stats.ActivePrim;
|
||||
sb[7].StatValue = m_activePrim;
|
||||
|
||||
sb[8].StatID = (uint)Stats.FrameMS;
|
||||
sb[8].StatValue = totalFrameTime;
|
||||
|
||||
sb[9].StatID = (uint)Stats.NetMS;
|
||||
sb[9].StatValue = m_netMS * perframefactor;
|
||||
|
||||
sb[10].StatID = (uint)Stats.PhysicsMS;
|
||||
sb[10].StatValue = physicsMS;
|
||||
|
||||
sb[11].StatID = (uint)Stats.ImageMS ;
|
||||
sb[11].StatValue = m_imageMS * perframefactor;
|
||||
|
||||
sb[12].StatID = (uint)Stats.OtherMS;
|
||||
sb[12].StatValue = otherMS;
|
||||
|
||||
sb[13].StatID = (uint)Stats.InPacketsPerSecond;
|
||||
sb[13].StatValue = (float)Math.Round(m_inPacketsPerSecond * updateTimeFactor);
|
||||
|
||||
sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
|
||||
sb[14].StatValue = (float)Math.Round(m_outPacketsPerSecond * updateTimeFactor);
|
||||
|
||||
sb[15].StatID = (uint)Stats.UnAckedBytes;
|
||||
sb[15].StatValue = m_unAckedBytes;
|
||||
|
||||
sb[16].StatID = (uint)Stats.AgentMS;
|
||||
sb[16].StatValue = agentMS;
|
||||
|
||||
sb[17].StatID = (uint)Stats.PendingDownloads;
|
||||
sb[17].StatValue = m_pendingDownloads;
|
||||
|
||||
sb[18].StatID = (uint)Stats.PendingUploads;
|
||||
sb[18].StatValue = m_pendingUploads;
|
||||
|
||||
sb[19].StatID = (uint)Stats.ActiveScripts;
|
||||
sb[19].StatValue = m_activeScripts;
|
||||
|
||||
sb[20].StatID = (uint)Stats.SimSleepMs;
|
||||
sb[20].StatValue = sleeptime;
|
||||
|
||||
sb[21].StatID = (uint)Stats.SimSpareMs;
|
||||
sb[21].StatValue = sparetime;
|
||||
|
||||
// this should came from phys engine
|
||||
sb[22].StatID = (uint)Stats.SimPhysicsStepMs;
|
||||
sb[22].StatValue = 20;
|
||||
|
||||
// send the ones we dont have as zeros, to clean viewers state
|
||||
// specially arriving from regions with wrond IDs in use
|
||||
|
||||
sb[23].StatID = (uint)Stats.VirtualSizeKb;
|
||||
sb[23].StatValue = 0;
|
||||
|
||||
sb[24].StatID = (uint)Stats.ResidentSizeKb;
|
||||
sb[24].StatValue = 0;
|
||||
|
||||
sb[25].StatID = (uint)Stats.PendingLocalUploads;
|
||||
sb[25].StatValue = 0;
|
||||
|
||||
sb[26].StatID = (uint)Stats.PhysicsPinnedTasks;
|
||||
sb[26].StatValue = 0;
|
||||
|
||||
sb[27].StatID = (uint)Stats.PhysicsLodTasks;
|
||||
sb[27].StatValue = 0;
|
||||
|
||||
sb[28].StatID = (uint)Stats.ScriptEps; // we actually have this, but not messing array order AGAIN
|
||||
sb[28].StatValue = (float)Math.Round(m_scriptEventsPerSecond * updateTimeFactor);
|
||||
|
||||
sb[29].StatID = (uint)Stats.SimAIStepTimeMS;
|
||||
sb[29].StatValue = 0;
|
||||
|
||||
sb[30].StatID = (uint)Stats.SimIoPumpTime;
|
||||
sb[30].StatValue = 0;
|
||||
|
||||
sb[31].StatID = (uint)Stats.SimPCTSscriptsRun;
|
||||
sb[31].StatValue = 0;
|
||||
|
||||
sb[32].StatID = (uint)Stats.SimRegionIdle;
|
||||
sb[32].StatValue = 0;
|
||||
|
||||
sb[33].StatID = (uint)Stats.SimRegionIdlePossible;
|
||||
sb[33].StatValue = 0;
|
||||
|
||||
sb[34].StatID = (uint)Stats.SimSkippedSillouet_PS;
|
||||
sb[34].StatValue = 0;
|
||||
|
||||
sb[35].StatID = (uint)Stats.SimSkippedCharsPerC;
|
||||
sb[35].StatValue = 0;
|
||||
|
||||
sb[36].StatID = (uint)Stats.SimPhysicsMemory;
|
||||
sb[36].StatValue = 0;
|
||||
|
||||
sb[37].StatID = (uint)Stats.ScriptMS;
|
||||
sb[37].StatValue = scriptTimeMS;
|
||||
|
||||
for (int i = 0; i < m_statisticViewerArraySize; i++)
|
||||
{
|
||||
lastReportedSimStats[i] = sb[i].StatValue;
|
||||
}
|
||||
|
||||
newvalues[(int)StatsIndex.TimeDilation] = (Single.IsNaN(timeDilation)) ? 0.0f : (float)Math.Round(timeDilation, 3);
|
||||
newvalues[(int)StatsIndex.SimFPS] = (float)Math.Round(reportedFPS, 1);
|
||||
newvalues[(int)StatsIndex.PhysicsFPS] = (float)Math.Round(physfps, 1);
|
||||
newvalues[(int)StatsIndex.AgentUpdates] = m_agentUpdates * updateTimeFactor;
|
||||
newvalues[(int)StatsIndex.Agents] = m_rootAgents;
|
||||
newvalues[(int)StatsIndex.ChildAgents] = m_childAgents;
|
||||
newvalues[(int)StatsIndex.TotalPrim] = m_numPrim;
|
||||
newvalues[(int)StatsIndex.ActivePrim] = m_activePrim;
|
||||
newvalues[(int)StatsIndex.FrameMS] = totalFrameTime;
|
||||
newvalues[(int)StatsIndex.NetMS] = (float)Math.Round(m_netMS * perframefactor, 3);
|
||||
newvalues[(int)StatsIndex.PhysicsMS] = (float)Math.Round(physicsMS, 3);
|
||||
newvalues[(int)StatsIndex.ImageMS] = (float)Math.Round(m_imageMS * perframefactor, 3);
|
||||
newvalues[(int)StatsIndex.OtherMS] = (float)Math.Round(otherMS, 3);
|
||||
newvalues[(int)StatsIndex.InPacketsPerSecond] = (float)Math.Round(m_inPacketsPerSecond * updateTimeFactor);
|
||||
newvalues[(int)StatsIndex.OutPacketsPerSecond] = (float)Math.Round(m_outPacketsPerSecond * updateTimeFactor);
|
||||
newvalues[(int)StatsIndex.UnAckedBytes] = m_unAckedBytes;
|
||||
newvalues[(int)StatsIndex.AgentMS] = agentMS;
|
||||
newvalues[(int)StatsIndex.PendingDownloads] = m_pendingDownloads;
|
||||
newvalues[(int)StatsIndex.PendingUploads] = m_pendingUploads;
|
||||
newvalues[(int)StatsIndex.ActiveScripts] = m_activeScripts;
|
||||
newvalues[(int)StatsIndex.SimSleepMs] = (float)Math.Round(sleeptime, 3);
|
||||
newvalues[(int)StatsIndex.SimSpareMs] = (float)Math.Round(sparetime, 3);
|
||||
newvalues[(int)StatsIndex.SimPhysicsStepMs] = 20; // this should came from phys engine
|
||||
newvalues[(int)StatsIndex.ScriptMS] = scriptTimeMS;
|
||||
|
||||
// add extra stats for internal use
|
||||
newvalues[(int)StatsIndex.LSLScriptLinesPerSecond] = (float)Math.Round(m_scriptLinesPerSecond * updateTimeFactor, 3);
|
||||
newvalues[(int)StatsIndex.FrameDilation2] = (Single.IsNaN(timeDilation)) ? 0.1f : (float)Math.Round(timeDilation, 1);
|
||||
newvalues[(int)StatsIndex.UsersLoggingIn] = m_usersLoggingIn;
|
||||
newvalues[(int)StatsIndex.TotalGeoPrim] = m_numGeoPrim;
|
||||
newvalues[(int)StatsIndex.TotalMesh] = m_numMesh;
|
||||
newvalues[(int)StatsIndex.ScriptEngineThreadCount] = m_inUseThreads;
|
||||
|
||||
for (int i = 0; i < m_statisticExtraArraySize; i++)
|
||||
{
|
||||
sbex[i] = new SimStatsPacket.StatBlock();
|
||||
}
|
||||
lastReportedSimStats = newvalues;
|
||||
|
||||
sbex[0].StatID = (uint)Stats.LSLScriptLinesPerSecond;
|
||||
sbex[0].StatValue = m_scriptLinesPerSecond * updateTimeFactor;
|
||||
lastReportedSimStats[38] = m_scriptLinesPerSecond * updateTimeFactor;
|
||||
OnSendStatsResult?.Invoke(new SimStats(
|
||||
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY,
|
||||
ReportingRegion.RegionSizeX, ReportingRegion.RegionSizeY,
|
||||
regionFlags, (uint)m_objectCapacity,
|
||||
newvalues,
|
||||
m_scene.RegionInfo.originRegionID,
|
||||
m_scene.RegionInfo.RegionName)
|
||||
);
|
||||
|
||||
sbex[1].StatID = (uint)Stats.FrameDilation2;
|
||||
sbex[1].StatValue = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
|
||||
lastReportedSimStats[39] = (Single.IsNaN(timeDilation)) ? 0.1f : timeDilation;
|
||||
|
||||
sbex[2].StatID = (uint)Stats.UsersLoggingIn;
|
||||
sbex[2].StatValue = m_usersLoggingIn;
|
||||
lastReportedSimStats[40] = m_usersLoggingIn;
|
||||
|
||||
sbex[3].StatID = (uint)Stats.TotalGeoPrim;
|
||||
sbex[3].StatValue = m_numGeoPrim;
|
||||
lastReportedSimStats[41] = m_numGeoPrim;
|
||||
|
||||
sbex[4].StatID = (uint)Stats.TotalMesh;
|
||||
sbex[4].StatValue = m_numMesh;
|
||||
lastReportedSimStats[42] = m_numMesh;
|
||||
|
||||
sbex[5].StatID = (uint)Stats.ThreadCount;
|
||||
sbex[5].StatValue = m_inUseThreads;
|
||||
lastReportedSimStats[43] = m_inUseThreads;
|
||||
|
||||
SimStats simStats
|
||||
= new SimStats(
|
||||
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
|
||||
rb, sb, sbex, m_scene.RegionInfo.originRegionID);
|
||||
|
||||
handlerSendStatResult = OnSendStatsResult;
|
||||
if (handlerSendStatResult != null)
|
||||
{
|
||||
handlerSendStatResult(simStats);
|
||||
}
|
||||
|
||||
// Extra statistics that aren't currently sent to clients
|
||||
// Extra statistics that aren't currently sent elsewhere
|
||||
if (m_scene.PhysicsScene != null)
|
||||
{
|
||||
lock (m_lastReportedExtraSimStats)
|
||||
|
||||
Reference in New Issue
Block a user