let extra stats travel side by side with viewers ones... try to fix damm array indexes all over the place

avinationmerge
UbitUmarov 2015-09-06 00:32:20 +01:00
parent 4b1ecc90fc
commit 0ddcc55166
5 changed files with 123 additions and 64 deletions

View File

@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework.Monitoring.Interfaces;
namespace OpenSim.Framework.Monitoring
{
/// <summary>
@ -71,6 +72,11 @@ namespace OpenSim.Framework.Monitoring
private volatile float pendingDownloads;
private volatile float pendingUploads;
private volatile float activeScripts;
private volatile float spareTime;
private volatile float sleepTime;
private volatile float physicsStep;
private volatile float scriptLinesPerSecond;
private volatile float m_frameDilation;
private volatile float m_usersLoggingIn;
@ -253,7 +259,7 @@ namespace OpenSim.Framework.Monitoring
/// <param name="pack"></param>
public void ReceiveClassicSimStatsPacket(SimStats stats)
{
// FIXME: SimStats shouldn't allow an arbitrary stat packing order (which is inherited from the original
// 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
@ -270,8 +276,8 @@ namespace OpenSim.Framework.Monitoring
totalFrameTime = stats.StatsBlock[8].StatValue;
netFrameTime = stats.StatsBlock[9].StatValue;
physicsFrameTime = stats.StatsBlock[10].StatValue;
otherFrameTime = stats.StatsBlock[11].StatValue;
imageFrameTime = stats.StatsBlock[12].StatValue;
imageFrameTime = stats.StatsBlock[11].StatValue;
otherFrameTime = stats.StatsBlock[12].StatValue;
inPacketsPerSecond = stats.StatsBlock[13].StatValue;
outPacketsPerSecond = stats.StatsBlock[14].StatValue;
unackedBytes = stats.StatsBlock[15].StatValue;
@ -279,12 +285,16 @@ namespace OpenSim.Framework.Monitoring
pendingDownloads = stats.StatsBlock[17].StatValue;
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;
sleepTime = stats.StatsBlock[20].StatValue;
spareTime = stats.StatsBlock[21].StatValue;
physicsStep = stats.StatsBlock[22].StatValue;
scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
m_frameDilation = stats.ExtraStatsBlock[1].StatValue;
m_usersLoggingIn = stats.ExtraStatsBlock[2].StatValue;
m_totalGeoPrims = stats.ExtraStatsBlock[3].StatValue;
m_totalMeshes = stats.ExtraStatsBlock[4].StatValue;
m_inUseThreads = stats.ExtraStatsBlock[5].StatValue;
}
/// <summary>

View File

@ -55,13 +55,19 @@ namespace OpenSim.Framework
get { return m_regionBlock; }
}
private SimStatsPacket.RegionBlock m_regionBlock;
public SimStatsPacket.StatBlock[] StatsBlock
{
get { return m_statsBlock; }
}
private SimStatsPacket.StatBlock[] m_statsBlock;
public SimStatsPacket.StatBlock[] ExtraStatsBlock
{
get { return m_extraStatsBlock; }
}
private SimStatsPacket.StatBlock[] m_extraStatsBlock;
public uint RegionFlags
{
get { return m_regionFlags; }
@ -82,7 +88,8 @@ namespace OpenSim.Framework
public SimStats(
uint regionX, uint regionY, uint regionFlags, uint objectCapacity,
SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock, UUID pRUUID)
SimStatsPacket.RegionBlock regionBlock, SimStatsPacket.StatBlock[] statsBlock,
SimStatsPacket.StatBlock[] ExtraStatsBlock, UUID pRUUID)
{
regionUUID = pRUUID;
m_regionX = regionX;
@ -91,6 +98,7 @@ namespace OpenSim.Framework
m_objectCapacity = objectCapacity;
m_regionBlock = regionBlock;
m_statsBlock = statsBlock;
m_extraStatsBlock = ExtraStatsBlock;
}
}
}

View File

@ -301,7 +301,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
m_scene,
"SpareFrameTimeMonitor",
"Spare Frame Time",
m => m.Scene.StatsReporter.LastReportedSimStats[21],
m => m.Scene.StatsReporter.LastReportedSimStats[37],
m => string.Format("{0} ms", m.GetValue())));
m_alerts.Add(new DeadlockAlert(m_staticMonitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor));

View File

@ -63,10 +63,9 @@ namespace OpenSim.Region.Framework.Scenes
// 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 = 23;
private const int m_statisticViewerArraySize = 37;
// size of LastReportedSimFPS with extra stats.
private const int m_statisticExtraArraySize = m_statisticViewerArraySize +
(int)(Stats.SimExtraCountEnd - Stats.SimExtraCountStart);
private const int m_statisticExtraArraySize = (int)(Stats.SimExtraCountEnd - Stats.SimExtraCountStart);
/// <summary>
/// These are the IDs of stats sent in the StatsPacket to the viewer.
@ -196,7 +195,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[m_statisticExtraArraySize];
private float[] lastReportedSimStats = new float[m_statisticExtraArraySize + m_statisticViewerArraySize];
private float m_pfps;
/// <summary>
@ -234,28 +233,7 @@ namespace OpenSim.Region.Framework.Scenes
private int m_objectCapacity = 45000;
// This is the number of frames that will be stored and then averaged for
// the Total, Simulation, Physics, and Network Frame Time; It is set to
// 10 by default but can be changed by the OpenSim.ini configuration file
// NumberOfFrames parameter
private int m_numberFramesStored;
// The arrays that will hold the time it took to run the past N frames,
// where N is the num_frames_to_average given by the configuration file
private double[] m_totalFrameTimeMilliseconds;
private double[] m_simulationFrameTimeMilliseconds;
private double[] m_physicsFrameTimeMilliseconds;
private double[] m_networkFrameTimeMilliseconds;
// The location of the next time in milliseconds that will be
// (over)written when the next frame completes
private int m_nextLocation = 0;
// The correct number of frames that have completed since the last stats
// update for physics
private int m_numberPhysicsFrames;
// The current number of users attempting to login to the region
// 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
@ -339,18 +317,12 @@ namespace OpenSim.Region.Framework.Scenes
private void statsHeartBeat(object sender, EventArgs e)
{
double totalSumFrameTime;
double simulationSumFrameTime;
double physicsSumFrameTime;
double networkSumFrameTime;
float frameDilation;
int currentFrame;
if (!m_scene.Active)
if (!m_scene.Active)
return;
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
SimStatsPacket.StatBlock[] sbex = new SimStatsPacket.StatBlock[m_statisticExtraArraySize];
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
// Know what's not thread safe in Mono... modifying timers.
// m_log.Debug("Firing Stats Heart Beat");
@ -431,7 +403,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_otherMS < 0)
m_otherMS = 0;
for (int i = 0; i < 23; i++)
for (int i = 0; i < m_statisticViewerArraySize; i++)
{
sb[i] = new SimStatsPacket.StatBlock();
}
@ -506,25 +478,95 @@ namespace OpenSim.Region.Framework.Scenes
sb[22].StatID = (uint)Stats.SimPhysicsStepMs;
sb[22].StatValue = 20;
for (int i = 0; i < 23; i++)
// 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 should have this
sb[28].StatValue = 0;
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;
for (int i = 0; i < 37; i++)
{
lastReportedSimStats[i] = sb[i].StatValue;
}
// add extra stats for internal use
for (int i = 0; i < m_statisticExtraArraySize; i++)
{
sbex[i] = new SimStatsPacket.StatBlock();
}
sbex[0].StatID = (uint)Stats.LSLScriptLinesPerSecond;
sbex[0].StatValue = m_scriptLinesPerSecond * updateFactor;
lastReportedSimStats[37] = m_scriptLinesPerSecond * updateFactor;
sbex[1].StatID = (uint)Stats.FrameDilation2;
sbex[1].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation;
lastReportedSimStats[38] = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation;
sbex[2].StatID = (uint)Stats.UsersLoggingIn;
sbex[2].StatValue = m_usersLoggingIn;
lastReportedSimStats[39] = m_usersLoggingIn;
sbex[3].StatID = (uint)Stats.TotalGeoPrim;
sbex[3].StatValue = m_numGeoPrim;
lastReportedSimStats[40] = m_numGeoPrim;
sbex[4].StatID = (uint)Stats.TotalMesh;
sbex[4].StatValue = m_numMesh;
lastReportedSimStats[41] = m_numMesh;
sbex[5].StatID = (uint)Stats.ThreadCount;
sbex[5].StatValue = m_inUseThreads;
lastReportedSimStats[42] = m_inUseThreads;
SimStats simStats
= new SimStats(
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
rb, sb, m_scene.RegionInfo.originRegionID);
rb, sb, sbex, m_scene.RegionInfo.originRegionID);
// add extra stats for internal use
lastReportedSimStats[23] = m_scriptLinesPerSecond * updateFactor;
lastReportedSimStats[24] = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation;
lastReportedSimStats[24] = m_usersLoggingIn;
lastReportedSimStats[25] = m_numGeoPrim;
lastReportedSimStats[26] = m_numMesh;
lastReportedSimStats[27] = m_inUseThreads;
handlerSendStatResult = OnSendStatsResult;
handlerSendStatResult = OnSendStatsResult;
if (handlerSendStatResult != null)
{
handlerSendStatResult(simStats);
@ -565,7 +607,6 @@ namespace OpenSim.Region.Framework.Scenes
{
// Reset the number of frames that the physics library has
// processed since the last stats report
m_numberPhysicsFrames = 0;
m_timeDilation = 0;
m_fps = 0;

View File

@ -1200,7 +1200,7 @@ VALUES
m_pendingDownloads = stats.StatsBlock[17].StatValue;
m_pendingUploads = stats.StatsBlock[18].StatValue;
m_activeScripts = stats.StatsBlock[19].StatValue;
m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
m_scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
}
}
}