aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2011-02-08 12:06:14 -0800
committerDiva Canto2011-02-08 12:06:14 -0800
commitac7bc78555c1dd51724790032f0711b24bc8c67d (patch)
tree6e208f4cb470c574d0094db93cb5bc3bdccb9e71
parentComment previous debug (diff)
downloadopensim-SC_OLD-ac7bc78555c1dd51724790032f0711b24bc8c67d.zip
opensim-SC_OLD-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.gz
opensim-SC_OLD-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.bz2
opensim-SC_OLD-ac7bc78555c1dd51724790032f0711b24bc8c67d.tar.xz
Added emergency monitoring of UDP Outgoing packets thread. Just type "emergency-monitoring on/off"
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs100
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs30
3 files changed, 130 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 5ff9aee..72257d2 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics;
30using System.IO; 31using System.IO;
31using System.Net; 32using System.Net;
32using System.Net.Sockets; 33using System.Net.Sockets;
@@ -1053,6 +1054,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1053 1054
1054 #endregion Update Timers 1055 #endregion Update Timers
1055 1056
1057 if (m_scene.EmergencyMonitoring)
1058 clientPacketHandler = MonitoredClientOutgoingPacketHandler;
1059
1056 // Handle outgoing packets, resends, acknowledgements, and pings for each 1060 // Handle outgoing packets, resends, acknowledgements, and pings for each
1057 // client. m_packetSent will be set to true if a packet is sent 1061 // client. m_packetSent will be set to true if a packet is sent
1058 m_scene.ForEachClient(clientPacketHandler); 1062 m_scene.ForEachClient(clientPacketHandler);
@@ -1068,6 +1072,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1068 { 1072 {
1069 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); 1073 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
1070 } 1074 }
1075
1071 } 1076 }
1072 1077
1073 Watchdog.RemoveThread(); 1078 Watchdog.RemoveThread();
@@ -1105,6 +1110,101 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1105 } 1110 }
1106 } 1111 }
1107 1112
1113 #region Emergency Monitoring
1114 private Stopwatch watch1 = new Stopwatch();
1115 private Stopwatch watch2 = new Stopwatch();
1116
1117 private float avgProcessingTicks = 0;
1118 private float avgResendUnackedTicks = 0;
1119 private float avgSendAcksTicks = 0;
1120 private float avgSendPingTicks = 0;
1121 private float avgDequeueTicks = 0;
1122 private long nticks = 0;
1123 private long nticksUnack = 0;
1124 private long nticksAck = 0;
1125 private long nticksPing = 0;
1126
1127 private void MonitoredClientOutgoingPacketHandler(IClientAPI client)
1128 {
1129 nticks++;
1130 watch1.Start();
1131 try
1132 {
1133 if (client is LLClientView)
1134 {
1135 LLUDPClient udpClient = ((LLClientView)client).UDPClient;
1136
1137 if (udpClient.IsConnected)
1138 {
1139 if (m_resendUnacked)
1140 {
1141 nticksUnack++;
1142 watch2.Start();
1143
1144 ResendUnacked(udpClient);
1145
1146 watch2.Stop();
1147 avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
1148 watch2.Reset();
1149 }
1150
1151 if (m_sendAcks)
1152 {
1153 nticksAck++;
1154 watch2.Start();
1155
1156 SendAcks(udpClient);
1157
1158 watch2.Stop();
1159 avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck);
1160 watch2.Reset();
1161 }
1162
1163 if (m_sendPing)
1164 {
1165 nticksPing++;
1166 watch2.Start();
1167
1168 SendPing(udpClient);
1169
1170 watch2.Stop();
1171 avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing);
1172 watch2.Reset();
1173 }
1174
1175 watch2.Start();
1176 // Dequeue any outgoing packets that are within the throttle limits
1177 if (udpClient.DequeueOutgoing())
1178 m_packetSent = true;
1179 watch2.Stop();
1180 avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
1181 watch2.Reset();
1182
1183 }
1184 else
1185 m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
1186 }
1187 }
1188 catch (Exception ex)
1189 {
1190 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
1191 " threw an exception: " + ex.Message, ex);
1192 }
1193 watch1.Stop();
1194 avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks);
1195 watch1.Reset();
1196
1197 // reuse this -- it's every 100ms
1198 if (m_scene.EmergencyMonitoring && nticks % 100 == 0)
1199 {
1200 m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (pack sent? {5})",
1201 avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, m_packetSent);
1202 }
1203
1204 }
1205
1206 #endregion
1207
1108 private void ProcessInPacket(object state) 1208 private void ProcessInPacket(object state)
1109 { 1209 {
1110 IncomingPacket incomingPacket = (IncomingPacket)state; 1210 IncomingPacket incomingPacket = (IncomingPacket)state;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4fca261..355671c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes
64 64
65 #region Fields 65 #region Fields
66 66
67 public bool EmergencyMonitoring = false;
68
67 public SynchronizeSceneHandler SynchronizeScene; 69 public SynchronizeSceneHandler SynchronizeScene;
68 public SimStatsReporter StatsReporter; 70 public SimStatsReporter StatsReporter;
69 public List<Border> NorthBorders = new List<Border>(); 71 public List<Border> NorthBorders = new List<Border>();
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 6630edb..53cebb2 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -95,7 +95,15 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
95 "Show throttle settings for each client and for the server overall", 95 "Show throttle settings for each client and for the server overall",
96 "Without the 'full' option, only root agents are shown." 96 "Without the 'full' option, only root agents are shown."
97 + " With the 'full' option child agents are also shown.", 97 + " With the 'full' option child agents are also shown.",
98 ShowThrottlesReport); 98 ShowThrottlesReport);
99
100 scene.AddCommand(
101 this, "emergency-monitoring",
102 "Go on/off emergency monitoring mode",
103 "Go on/off emergency monitoring mode",
104 "Go on/off emergency monitoring mode",
105 EmergencyMonitoring);
106
99 } 107 }
100 108
101 public void RemoveRegion(Scene scene) 109 public void RemoveRegion(Scene scene)
@@ -120,7 +128,25 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
120 { 128 {
121 MainConsole.Instance.Output(GetThrottlesReport(cmd)); 129 MainConsole.Instance.Output(GetThrottlesReport(cmd));
122 } 130 }
123 131
132 protected void EmergencyMonitoring(string module, string[] cmd)
133 {
134 bool mode = true;
135 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
136 {
137 mode = true;
138 MainConsole.Instance.Output("Emergency Monitoring ON");
139 }
140 else
141 {
142 mode = false;
143 MainConsole.Instance.Output("Emergency Monitoring OFF");
144 }
145
146 foreach (Scene s in m_scenes.Values)
147 s.EmergencyMonitoring = mode;
148 }
149
124 protected string GetColumnEntry(string entry, int maxLength, int columnPadding) 150 protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
125 { 151 {
126 return string.Format( 152 return string.Format(