From f004db65726fc2e00fe14d9c343ef46136f350f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 03:45:16 +0100 Subject: fix our stats ( old schema ) --- OpenSim/Region/Framework/Scenes/Scene.cs | 47 ++++++++------- .../Region/Framework/Scenes/SimStatsReporter.cs | 67 +++++++++++++--------- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05af942..f501828 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -225,7 +225,6 @@ namespace OpenSim.Region.Framework.Scenes private int backupMS; private int terrainMS; private int landMS; - private int spareMS; /// /// Tick at which the last frame was processed. @@ -1434,16 +1433,20 @@ namespace OpenSim.Region.Framework.Scenes endFrame = Frame + frames; float physicsFPS = 0f; - int previousFrameTick, tmpMS; - int maintc = Util.EnvironmentTickCount(); + int tmpMS; + int previousFrameTick; + int maintc; + int sleepMS; + int framestart; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { + framestart = Util.EnvironmentTickCount(); ++Frame; // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); - agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; + agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; try { @@ -1495,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.UpdatePresences(); agentMS += Util.EnvironmentTickCountSubtract(tmpMS); + // Delete temp-on-rez stuff if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) @@ -1573,36 +1577,37 @@ namespace OpenSim.Region.Framework.Scenes Watchdog.UpdateThread(); + otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; + + StatsReporter.AddPhysicsFPS(physicsFPS); + StatsReporter.AddTimeDilation(TimeDilation); + StatsReporter.AddFPS(1); + + StatsReporter.addAgentMS(agentMS); + StatsReporter.addPhysicsMS(physicsMS + physicsMS2); + StatsReporter.addOtherMS(otherMS); + StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); + previousFrameTick = m_lastFrameTick; m_lastFrameTick = Util.EnvironmentTickCount(); - tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); + tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); tmpMS = (int)(MinFrameTime * 1000) - tmpMS; m_firstHeartbeat = false; + sleepMS = Util.EnvironmentTickCount(); + if (tmpMS > 0) - { Thread.Sleep(tmpMS); - spareMS += tmpMS; - } - frameMS = Util.EnvironmentTickCountSubtract(maintc); - maintc = Util.EnvironmentTickCount(); - - otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; + sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + frameMS = Util.EnvironmentTickCountSubtract(framestart); + StatsReporter.addSleepMS(sleepMS); + StatsReporter.addFrameMS(frameMS); // if (Frame%m_update_avatars == 0) // UpdateInWorldTime(); - StatsReporter.AddPhysicsFPS(physicsFPS); - StatsReporter.AddTimeDilation(TimeDilation); - StatsReporter.AddFPS(1); - StatsReporter.addFrameMS(frameMS); - StatsReporter.addAgentMS(agentMS); - StatsReporter.addPhysicsMS(physicsMS + physicsMS2); - StatsReporter.addOtherMS(otherMS); - StatsReporter.AddSpareMS(spareMS); - StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 18e6ece..d6ff5a2 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -164,7 +164,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[23]; private float m_pfps; /// @@ -178,12 +178,13 @@ namespace OpenSim.Region.Framework.Scenes private int m_objectUpdates; private int m_frameMS; - private int m_spareMS; + private int m_netMS; private int m_agentMS; private int m_physicsMS; private int m_imageMS; private int m_otherMS; + private int m_sleeptimeMS; //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. //Ckrinke private int m_scriptMS = 0; @@ -260,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes private void statsHeartBeat(object sender, EventArgs e) { - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); // Know what's not thread safe in Mono... modifying timers. @@ -298,6 +299,8 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion + float factor = 1 / m_statsUpdateFactor; + if (reportedFPS <= 0) reportedFPS = 1; @@ -308,9 +311,22 @@ namespace OpenSim.Region.Framework.Scenes float targetframetime = 1100.0f / (float)m_nominalReportedFps; float sparetime; + float sleeptime; + if (TotalFrameTime > targetframetime) { sparetime = 0; + sleeptime = 0; + } + else + { + sparetime = m_frameMS - m_physicsMS - m_agentMS; + sparetime *= perframe; + if (sparetime < 0) + sparetime = 0; + else if (sparetime > TotalFrameTime) + sparetime = TotalFrameTime; + sleeptime = m_sleeptimeMS * perframe; } m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); @@ -327,19 +343,11 @@ namespace OpenSim.Region.Framework.Scenes // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_imageMS m_netMS are not included in m_frameMS - m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; if (m_otherMS < 0) m_otherMS = 0; - uint thisFrame = m_scene.Frame; - float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; - m_lastUpdateFrame = thisFrame; - - // Avoid div-by-zero if somehow we've not updated any frames. - if (framesUpdated == 0) - framesUpdated = 1; - - for (int i = 0; i < 22; i++) + for (int i = 0; i < 23; i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -369,19 +377,19 @@ namespace OpenSim.Region.Framework.Scenes sb[7].StatValue = m_activePrim; sb[8].StatID = (uint)Stats.FrameMS; - sb[8].StatValue = m_frameMS / framesUpdated; + sb[8].StatValue = TotalFrameTime; sb[9].StatID = (uint)Stats.NetMS; - sb[9].StatValue = m_netMS / framesUpdated; + sb[9].StatValue = m_netMS * perframe; sb[10].StatID = (uint)Stats.PhysicsMS; - sb[10].StatValue = m_physicsMS / framesUpdated; + sb[10].StatValue = m_physicsMS * perframe; sb[11].StatID = (uint)Stats.ImageMS ; - sb[11].StatValue = m_imageMS / framesUpdated; + sb[11].StatValue = m_imageMS * perframe; sb[12].StatID = (uint)Stats.OtherMS; - sb[12].StatValue = m_otherMS / framesUpdated; + sb[12].StatValue = m_otherMS * perframe; sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); @@ -393,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes sb[15].StatValue = m_unAckedBytes; sb[16].StatID = (uint)Stats.AgentMS; - sb[16].StatValue = m_agentMS / framesUpdated; + sb[16].StatValue = m_agentMS * perframe; sb[17].StatID = (uint)Stats.PendingDownloads; sb[17].StatValue = m_pendingDownloads; @@ -408,7 +416,10 @@ namespace OpenSim.Region.Framework.Scenes sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; sb[21].StatID = (uint)Stats.SimSpareMs; - sb[21].StatValue = m_spareMS / framesUpdated; + sb[21].StatValue = sparetime; + + sb[22].StatID = (uint)Stats.SimSleepMs; + sb[22].StatValue = sleeptime; for (int i = 0; i < 22; i++) { @@ -441,13 +452,14 @@ namespace OpenSim.Region.Framework.Scenes // Need to change things so that stats source can indicate whether they are per second or // per frame. if (tuple.Key.EndsWith("MS")) - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; else m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; } } } +// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; ResetValues(); } } @@ -470,7 +482,8 @@ namespace OpenSim.Region.Framework.Scenes m_physicsMS = 0; m_imageMS = 0; m_otherMS = 0; - m_spareMS = 0; +// m_spareMS = 0; + m_sleeptimeMS = 0; //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. //Ckrinke m_scriptMS = 0; @@ -549,11 +562,6 @@ namespace OpenSim.Region.Framework.Scenes m_frameMS += ms; } - public void AddSpareMS(int ms) - { - m_spareMS += ms; - } - public void addNetMS(int ms) { m_netMS += ms; @@ -579,6 +587,11 @@ namespace OpenSim.Region.Framework.Scenes m_otherMS += ms; } + public void addSleepMS(int ms) + { + m_sleeptimeMS += ms; + } + public void AddPendingDownloads(int count) { m_pendingDownloads += count; -- cgit v1.1 From 1ff498266cd5ecc4ed8f3b1de86758b78a327f61 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 05:25:34 +0100 Subject: minor changes, removed extra parts physics updates on linking nonroot prims --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f1f94a7..6ab0027 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3066,7 +3066,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; // Compute the new position of this SOP relative to the group position - part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.OffsetPosition = newPos - AbsolutePosition; // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. // It would have the affect of setting the physics engine position multiple @@ -3087,7 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes // Since this SOP's state has changed, push those changes into the physics engine // and the simulator. - part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); + // done on caller +// part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); } /// -- cgit v1.1