From 5dd741267eae5c7dfcd20372ba1b43904dd4503a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 16 Jan 2008 05:48:40 +0000 Subject: [PATCH] * Added Agent Time, Pending Downloads, and made Agent Updates/Sec actually accurate. * We're only missing, the script related sim stats counters and the Images time counter and the Pending Uploads counter. The rest of them are actually implemented now. --- .../Modules/TextureDownloadModule.cs | 3 ++ OpenSim/Region/Environment/Scenes/Scene.cs | 15 ++++++- .../Environment/Scenes/ScenePresence.cs | 44 ++++++++++++++++++- .../Environment/Scenes/SimStatsReporter.cs | 41 +++++++++++++---- 4 files changed, 93 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 6ebf47fbe7..98a3287826 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -137,7 +137,9 @@ namespace OpenSim.Region.Environment.Modules if (TryGetUserTextureService(client.AgentId, out textureService)) { textureService.HandleTextureRequest(client, e); + m_scene.AddPendingDownloads(1); } + } public void ProcessTextureSenders() @@ -169,6 +171,7 @@ namespace OpenSim.Region.Environment.Modules private void TextureSent(TextureSender sender) { sender.Sending = false; + m_scene.AddPendingDownloads(-1); } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 16055ded3c..f1a1843313 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -607,7 +607,6 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.AddPhysicsFPS(physicsFPS); m_statsReporter.SetTimeDilation(m_timedilation); m_statsReporter.AddFPS(1); - m_statsReporter.AddAgentUpdates(1); m_statsReporter.AddInPackets(0); m_statsReporter.SetRootAgents(m_innerScene.GetRootAgentCount()); m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); @@ -1766,6 +1765,20 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.AddOutPackets(outPackets); m_statsReporter.AddunAckedBytes(unAckedBytes); } + public void AddAgentTime(int ms) + { + m_statsReporter.addFrameMS(ms); + m_statsReporter.addAgentMS(ms); + } + public void AddAgentUpdates(int count) + { + m_statsReporter.AddAgentUpdates(count); + } + + public void AddPendingDownloads(int count) + { + m_statsReporter.addPendingDownload(count); + } #endregion diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 2e2bb628d1..30ad4a541e 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -56,6 +56,8 @@ namespace OpenSim.Region.Environment.Scenes private float m_sitAvatarHeight = 2.0f; private float m_godlevel = 0; + private int m_perfMonMS = 0; + private bool m_setAlwaysRun = false; private Quaternion m_bodyRot; @@ -402,12 +404,16 @@ namespace OpenSim.Region.Environment.Scenes // this.UpdateQuadTreeNode(); //this.RefreshQuadObject(); //} + m_perfMonMS = System.Environment.TickCount; + if (!m_gotAllObjectsInScene) { if (!m_isChildAgent || m_scene.m_sendTasksToChild) { + m_scene.SendAllSceneObjectsToClient(this); m_gotAllObjectsInScene = true; + } } if (m_partsUpdateQueue.Count > 0) @@ -464,6 +470,8 @@ namespace OpenSim.Region.Environment.Scenes } } } + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } public void forceAvatarMovement(Vector3 position, Quaternion rotation) @@ -634,6 +642,8 @@ namespace OpenSim.Region.Environment.Scenes // Must check for standing up even when PhysicsActor is null, // since sitting currently removes avatar from physical scene + m_perfMonMS = System.Environment.TickCount; + uint flags = agentData.AgentData.ControlFlags; LLQuaternion bodyRotation = agentData.AgentData.BodyRotation; @@ -760,8 +770,10 @@ namespace OpenSim.Region.Environment.Scenes UpdateMovementAnimations(update_movementflag); } } - + m_scene.EventManager.TriggerOnClientMovement(this); + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } /// @@ -1008,6 +1020,8 @@ namespace OpenSim.Region.Environment.Scenes /// protected void UpdateMovementAnimations(bool update_movementflag) { + + if (update_movementflag) { // Are we moving? @@ -1081,6 +1095,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + } /// @@ -1093,6 +1108,9 @@ namespace OpenSim.Region.Environment.Scenes Console.WriteLine("DEBUG: AddNewMovement: child agent"); return; } + + m_perfMonMS = System.Environment.TickCount; + m_rotation = rotation; NewForce newVelocity = new NewForce(); Vector3 direc = rotation*vec; @@ -1134,6 +1152,8 @@ namespace OpenSim.Region.Environment.Scenes newVelocity.Y = direc.y; newVelocity.Z = direc.z; m_forcesList.Add(newVelocity); + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } #endregion @@ -1190,11 +1210,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendTerseUpdateToClient(IClientAPI remoteClient) { + m_perfMonMS = System.Environment.TickCount; + LLVector3 pos = m_pos; LLVector3 vel = Velocity; LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentUpdates(1); } /// @@ -1202,11 +1227,18 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendTerseUpdateToAllClients() { + m_perfMonMS = System.Environment.TickCount; + m_scene.Broadcast(SendTerseUpdateToClient); + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + } public void SendCoarseLocations() { + m_perfMonMS = System.Environment.TickCount; + List CoarseLocations = new List(); List avatars = m_scene.GetAvatars(); for (int i = 0; i < avatars.Count; i++) @@ -1218,6 +1250,8 @@ namespace OpenSim.Region.Environment.Scenes } m_controllingClient.SendCoarseLocationUpdate(CoarseLocations); + + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } public void CoarseLocationChange() @@ -1234,6 +1268,7 @@ namespace OpenSim.Region.Environment.Scenes remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); + m_scene.AddAgentUpdates(1); } /// @@ -1241,6 +1276,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendFullUpdateToAllClients() { + m_perfMonMS = System.Environment.TickCount; + List avatars = m_scene.GetScenePresences(); foreach (ScenePresence avatar in avatars) { @@ -1254,6 +1291,8 @@ namespace OpenSim.Region.Environment.Scenes } } } + m_scene.AddAgentUpdates(avatars.Count); + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } /// @@ -1289,6 +1328,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAppearanceToAllOtherAgents() { + m_perfMonMS=System.Environment.TickCount; + m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { if (scenePresence.UUID != UUID) @@ -1296,6 +1337,7 @@ namespace OpenSim.Region.Environment.Scenes m_appearance.SendAppearanceToOtherAgent(scenePresence); } }); + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } public void SendAppearanceToOtherAgent(ScenePresence avatar) diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index 36c28686bb..38e32181a2 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -57,6 +57,8 @@ namespace OpenSim.Region.Environment.Scenes ChildAgents = 14, InPacketsPerSecond = 17, OutPacketsPerSecond = 18, + PendingDownloads = 19, + PendingUploads = 20, UnAckedBytes = 24 } @@ -64,9 +66,10 @@ namespace OpenSim.Region.Environment.Scenes private float m_timeDilation = 0; private int m_fps = 0; private float m_pfps = 0; - private float m_agentUpdates = 0; + private int m_agentUpdates = 0; private int m_frameMS = 0; private int m_netMS = 0; + private int m_agentMS = 0; private int m_physicsMS = 0; private int m_imageMS = 0; private int m_otherMS = 0; @@ -77,8 +80,11 @@ namespace OpenSim.Region.Environment.Scenes private int m_outPacketsPerSecond = 0; private int m_activePrim = 0; private int m_unAckedBytes = 0; + private int m_pendingDownloads = 0; + private int m_pendingUploads = 0; + - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[16]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[19]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); SimStatsPacket statpack = (SimStatsPacket)PacketPool.Instance.GetPacket(PacketType.SimStats); @@ -91,7 +97,7 @@ namespace OpenSim.Region.Environment.Scenes public SimStatsReporter(RegionInfo regionData) { ReportingRegion = regionData; - for (int i = 0; i<16;i++) + for (int i = 0; i<19;i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -157,7 +163,7 @@ namespace OpenSim.Region.Environment.Scenes sb[3].StatValue = (m_agentUpdates); //sb[4] = sbb; - //sb[4].StatID = (uint) Stats.Agents; + sb[4].StatID = (uint) Stats.Agents; sb[4].StatValue = m_rootAgents; //sb[5] = sbb; @@ -188,17 +194,26 @@ namespace OpenSim.Region.Environment.Scenes sb[12].StatValue = m_otherMS; //sb[8] = sbb; - sb[13].StatID = (uint) Stats.InPacketsPerSecond; + sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond); //sb[9] = sbb; - sb[14].StatID = (uint) Stats.OutPacketsPerSecond; + sb[14].StatID = (uint)Stats.OutPacketsPerSecond; sb[14].StatValue = (m_outPacketsPerSecond); //sb[10] = sbb; - sb[15].StatID = (uint) Stats.UnAckedBytes; + sb[15].StatID = (uint)Stats.UnAckedBytes; sb[15].StatValue = m_unAckedBytes; + sb[16].StatID = (uint)Stats.AgentMS; + sb[16].StatValue = m_agentMS; + + sb[17].StatID = (uint)Stats.PendingDownloads; + sb[17].StatValue = m_pendingDownloads; + + sb[18].StatID = (uint)Stats.PendingUploads; + sb[18].StatValue = m_pendingUploads; + statpack.Stat = sb; if (OnSendStatsResult != null) @@ -218,6 +233,7 @@ namespace OpenSim.Region.Environment.Scenes m_outPacketsPerSecond = 0; m_unAckedBytes = 0; m_frameMS = 0; + m_agentMS = 0; m_netMS = 0; m_physicsMS = 0; m_imageMS = 0; @@ -266,7 +282,7 @@ namespace OpenSim.Region.Environment.Scenes m_pfps += frames; } - public void AddAgentUpdates(float numUpdates) + public void AddAgentUpdates(int numUpdates) { m_agentUpdates += numUpdates; } @@ -294,6 +310,10 @@ namespace OpenSim.Region.Environment.Scenes { m_netMS += ms; } + public void addAgentMS(int ms) + { + m_agentMS += ms; + } public void addPhysicsMS(int ms) { m_physicsMS += ms; @@ -306,5 +326,10 @@ namespace OpenSim.Region.Environment.Scenes { m_otherMS += ms; } + public void addPendingDownload(int count) + { + m_pendingDownloads += count; + } + } }