From c9d7eb30dbecbe85ada990c97eaa2a95a1afb861 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 2 Oct 2014 23:49:37 +0100 Subject: [PATCH] Add OutgoingPacketsQueuedCount clientstack stat. This is the total of queued outgoing packets across all connections, as also seen in the "show queues" command. Gives some early indication of whether the simulator can't send all outgoing packets fast enough. Though then one would want to check that this isn't due to a few bad client connections. --- .../ClientStack/Linden/UDP/LLUDPClient.cs | 27 +++++++++++++++++++ .../ClientStack/Linden/UDP/LLUDPServer.cs | 26 ++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index d8ca343293..3f2a34001c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -319,6 +319,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP throw new NotImplementedException(); } + /// + /// Get the total number of pakcets queued for this client. + /// + /// + public int GetTotalPacketsQueuedCount() + { + int total = 0; + + for (int i = 0; i <= (int)ThrottleOutPacketType.Asset; i++) + total += m_packetOutboxes[i].Count; + + return total; + } + + /// + /// Get the number of packets queued for the given throttle type. + /// + /// + /// + public int GetPacketsQueuedCount(ThrottleOutPacketType throttleType) + { + if ((int)throttleType > 0) + return m_packetOutboxes[(int)throttleType].Count; + else + return 0; + } + /// /// Return statistics information about client packet queues. /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index fc6fb3eaa2..664e23e55f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -688,6 +688,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatType.Pull, stat => stat.Value = PacketPool.Instance.BlocksPooled, StatVerbosity.Debug)); + + StatsManager.RegisterStat( + new Stat( + "OutgoingPacketsQueuedCount", + "Packets queued for outgoing send", + "Number of queued outgoing packets across all connections", + "", + "clientstack", + Scene.Name, + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + stat => stat.Value = GetTotalQueuedOutgoingPackets(), + StatVerbosity.Info)); // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by // scene name @@ -703,6 +716,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP return x == m_location; } + public int GetTotalQueuedOutgoingPackets() + { + int total = 0; + + foreach (ScenePresence sp in Scene.GetScenePresences()) + { + LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient; + total += udpClient.GetTotalPacketsQueuedCount(); + } + + return total; + } + // public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) // { // // CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way