From 314c554ed40fe015397cf0fa6981e47b5025b6f8 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 16 Jan 2008 02:48:39 +0000 Subject: [PATCH] * Refactored the SimStatsReporter to reuse the same packet and packet blocks over and over again instead of creating 1 a second. * Added frame Milliseconds, Physics Milliseconds and Other Milliseconds to the Sim Stats Reporter so we can start to figure out what the slowdowns are. (these were the most convenient to get and had just about no overhead. --- OpenSim/Region/Environment/Scenes/Scene.cs | 23 +++- .../Environment/Scenes/SceneObjectPart.cs | 2 +- .../Environment/Scenes/SimStatsReporter.cs | 110 ++++++++++++++---- 3 files changed, 110 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 86f43b3cdd..9af43f5c56 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -125,6 +125,12 @@ namespace OpenSim.Region.Environment.Scenes private int m_update_land = 1; private int m_update_avatars = 1; + private int frameMS = 0; + private int physicsMS2 = 0; + private int physicsMS = 0; + private int otherMS = 0; + + #endregion #region Properties @@ -551,6 +557,8 @@ namespace OpenSim.Region.Environment.Scenes // Aquire a lock so only one update call happens at once updateLock.WaitOne(); float physicsFPS = 0; + + frameMS = System.Environment.TickCount; try { // Increment the frame counter @@ -559,18 +567,26 @@ namespace OpenSim.Region.Environment.Scenes // Loop it if (m_frame == Int32.MaxValue) m_frame = 0; + + physicsMS2 = System.Environment.TickCount; if (m_frame%m_update_physics == 0) m_innerScene.UpdatePreparePhysics(); + physicsMS2 = System.Environment.TickCount - physicsMS2; if (m_frame%m_update_entitymovement == 0) m_innerScene.UpdateEntityMovement(); + physicsMS = System.Environment.TickCount; if (m_frame%m_update_physics == 0) physicsFPS = m_innerScene.UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); + + physicsMS = System.Environment.TickCount - physicsMS; + physicsMS += physicsMS2; + otherMS = System.Environment.TickCount; if (m_frame%m_update_entities == 0) m_innerScene.UpdateEntities(); @@ -585,7 +601,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_frame%m_update_land == 0) UpdateLand(); - + otherMS = System.Environment.TickCount - otherMS; // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); m_statsReporter.AddPhysicsFPS(physicsFPS); @@ -597,6 +613,11 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); + frameMS = System.Environment.TickCount - frameMS; + m_statsReporter.addFrameMS(frameMS); + m_statsReporter.addPhysicsMS(physicsMS); + m_statsReporter.addOtherMS(otherMS); + } catch (NotImplementedException) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 60ea4805db..660deaf787 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -327,7 +327,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - // Child prim we have to calculate it's world rotation + // Child prim we have to calculate it's world rotationwel LLQuaternion resultingrotation = GetWorldRotation(); PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z); //MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString()); diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 1b2ff9a830..36c28686bb 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -45,6 +45,12 @@ namespace OpenSim.Region.Environment.Scenes SimFPS = 1, PhysicsFPS = 2, AgentUpdates = 3, + FrameMS = 4, + NetMS = 5, + OtherMS = 6, + PhysicsMS = 7, + AgentMS = 8, + ImageMS = 9, TotalPrim = 11, ActivePrim = 12, Agents = 13, @@ -59,6 +65,11 @@ namespace OpenSim.Region.Environment.Scenes private int m_fps = 0; private float m_pfps = 0; private float m_agentUpdates = 0; + private int m_frameMS = 0; + private int m_netMS = 0; + private int m_physicsMS = 0; + private int m_imageMS = 0; + private int m_otherMS = 0; private int m_rootAgents = 0; private int m_childAgents = 0; private int m_numPrim = 0; @@ -66,6 +77,12 @@ namespace OpenSim.Region.Environment.Scenes private int m_outPacketsPerSecond = 0; private int m_activePrim = 0; private int m_unAckedBytes = 0; + + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[16]; + SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); + SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats); + + private RegionInfo ReportingRegion; private Timer m_report = new Timer(); @@ -74,6 +91,10 @@ namespace OpenSim.Region.Environment.Scenes public SimStatsReporter(RegionInfo regionData) { ReportingRegion = regionData; + for (int i = 0; i<16;i++) + { + sb[i] = new SimStatsPacket.StatBlock(); + } m_report.AutoReset = true; m_report.Interval = statsUpdatesEveryMS; m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); @@ -83,11 +104,11 @@ namespace OpenSim.Region.Environment.Scenes private void statsHeartBeat(object sender, EventArgs e) { m_report.Enabled = false; - SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats); - // TODO: don't create new blocks if recycling an old packet + + // Packet is already initialized and ready for data insert - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[11]; - statpack.Region = new SimStatsPacket.RegionBlock(); + + statpack.Region = rb; statpack.Region.RegionX = ReportingRegion.RegionLocX; statpack.Region.RegionY = ReportingRegion.RegionLocY; try @@ -119,49 +140,64 @@ namespace OpenSim.Region.Environment.Scenes #endregion - sb[0] = new SimStatsPacket.StatBlock(); + //sb[0] = sbb; sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatValue = (m_timeDilation); - sb[1] = new SimStatsPacket.StatBlock(); + //sb[1] = sbb; sb[1].StatID = (uint) Stats.SimFPS; sb[1].StatValue = simfps; - sb[2] = new SimStatsPacket.StatBlock(); + //sb[2] = sbb; sb[2].StatID = (uint) Stats.PhysicsFPS; sb[2].StatValue = physfps; - sb[3] = new SimStatsPacket.StatBlock(); + //sb[3] = sbb; sb[3].StatID = (uint) Stats.AgentUpdates; - sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS); + sb[3].StatValue = (m_agentUpdates); - sb[4] = new SimStatsPacket.StatBlock(); - sb[4].StatID = (uint) Stats.Agents; + //sb[4] = sbb; + //sb[4].StatID = (uint) Stats.Agents; sb[4].StatValue = m_rootAgents; - sb[5] = new SimStatsPacket.StatBlock(); + //sb[5] = sbb; sb[5].StatID = (uint) Stats.ChildAgents; sb[5].StatValue = m_childAgents; - sb[6] = new SimStatsPacket.StatBlock(); + //sb[6] = sbb; sb[6].StatID = (uint) Stats.TotalPrim; sb[6].StatValue = m_numPrim; - sb[7] = new SimStatsPacket.StatBlock(); + //sb[7] = sbb; sb[7].StatID = (uint) Stats.ActivePrim; sb[7].StatValue = m_activePrim; - sb[8] = new SimStatsPacket.StatBlock(); - sb[8].StatID = (uint) Stats.InPacketsPerSecond; - sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS); + sb[8].StatID = (uint)Stats.FrameMS; + sb[8].StatValue = m_frameMS; - sb[9] = new SimStatsPacket.StatBlock(); - sb[9].StatID = (uint) Stats.OutPacketsPerSecond; - sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS); + sb[9].StatID = (uint)Stats.NetMS; + sb[9].StatValue = m_netMS; - sb[10] = new SimStatsPacket.StatBlock(); - sb[10].StatID = (uint) Stats.UnAckedBytes; - sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS); + sb[10].StatID = (uint)Stats.PhysicsMS; + sb[10].StatValue = m_physicsMS; + + sb[11].StatID = (uint)Stats.ImageMS ; + sb[11].StatValue = m_imageMS; + + sb[12].StatID = (uint)Stats.OtherMS; + sb[12].StatValue = m_otherMS; + + //sb[8] = sbb; + sb[13].StatID = (uint) Stats.InPacketsPerSecond; + sb[13].StatValue = (m_inPacketsPerSecond); + + //sb[9] = sbb; + sb[14].StatID = (uint) Stats.OutPacketsPerSecond; + sb[14].StatValue = (m_outPacketsPerSecond); + + //sb[10] = sbb; + sb[15].StatID = (uint) Stats.UnAckedBytes; + sb[15].StatValue = m_unAckedBytes; statpack.Stat = sb; @@ -181,8 +217,15 @@ namespace OpenSim.Region.Environment.Scenes m_inPacketsPerSecond = 0; m_outPacketsPerSecond = 0; m_unAckedBytes = 0; + m_frameMS = 0; + m_netMS = 0; + m_physicsMS = 0; + m_imageMS = 0; + m_otherMS = 0; } + + public void SetTimeDilation(float td) { m_timeDilation = td; @@ -242,5 +285,26 @@ namespace OpenSim.Region.Environment.Scenes { m_unAckedBytes += numBytes; } + + public void addFrameMS(int ms) + { + m_frameMS += ms; + } + public void addNetMS(int ms) + { + m_netMS += ms; + } + public void addPhysicsMS(int ms) + { + m_physicsMS += ms; + } + public void addImageMS(int ms) + { + m_imageMS += ms; + } + public void addOtherMS(int ms) + { + m_otherMS += ms; + } } }