aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs19
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs39
2 files changed, 56 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index f5c0b05..d3823f3 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -70,8 +70,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
70 StatsManager.RegisterStat( 70 StatsManager.RegisterStat(
71 new Stat( 71 new Stat(
72 "IncomingPacketsProcessedCount", 72 "IncomingPacketsProcessedCount",
73 "Number of inbound UDP packets processed", 73 "Number of inbound LL protocol packets processed",
74 "Number of inbound UDP packets processed", 74 "Number of inbound LL protocol packets processed",
75 "", 75 "",
76 "clientstack", 76 "clientstack",
77 scene.Name, 77 scene.Name,
@@ -79,6 +79,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
79 MeasuresOfInterest.AverageChangeOverTime, 79 MeasuresOfInterest.AverageChangeOverTime,
80 stat => stat.Value = m_udpServer.IncomingPacketsProcessed, 80 stat => stat.Value = m_udpServer.IncomingPacketsProcessed,
81 StatVerbosity.Debug)); 81 StatVerbosity.Debug));
82
83 StatsManager.RegisterStat(
84 new Stat(
85 "AverageUDPProcessTime",
86 "Average number of milliseconds taken to process each incoming UDP packet in a sample.",
87 "This is for initial receive processing which is separate from the later client LL packet processing stage.",
88 "ms",
89 "clientstack",
90 scene.Name,
91 StatType.Pull,
92 MeasuresOfInterest.None,
93 stat => stat.Value = m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond,
94// stat =>
95// stat.Value = Math.Round(m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond, 7),
96 StatVerbosity.Debug));
82 } 97 }
83 98
84 public bool HandlesRegion(Location x) 99 public bool HandlesRegion(Location x)
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index a919141..46a3261 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -78,6 +78,26 @@ namespace OpenMetaverse
78 public bool IsRunningOutbound { get; private set; } 78 public bool IsRunningOutbound { get; private set; }
79 79
80 /// <summary> 80 /// <summary>
81 /// Number of receives over which to establish a receive time average.
82 /// </summary>
83 private readonly static int s_receiveTimeSamples = 500;
84
85 /// <summary>
86 /// Current number of samples taken to establish a receive time average.
87 /// </summary>
88 private int m_currentReceiveTimeSamples;
89
90 /// <summary>
91 /// Cumulative receive time for the sample so far.
92 /// </summary>
93 private int m_receiveTicksInCurrentSamplePeriod;
94
95 /// <summary>
96 /// The average time taken for each require receive in the last sample.
97 /// </summary>
98 public float AverageReceiveTicksForLastSamplePeriod { get; private set; }
99
100 /// <summary>
81 /// Default constructor 101 /// Default constructor
82 /// </summary> 102 /// </summary>
83 /// <param name="bindAddress">Local IP address to bind the server to</param> 103 /// <param name="bindAddress">Local IP address to bind the server to</param>
@@ -286,6 +306,8 @@ namespace OpenMetaverse
286 306
287 try 307 try
288 { 308 {
309 int startTick = Util.EnvironmentTickCount();
310
289 // get the length of data actually read from the socket, store it with the 311 // get the length of data actually read from the socket, store it with the
290 // buffer 312 // buffer
291 buffer.DataLength = m_udpSocket.EndReceiveFrom(iar, ref buffer.RemoteEndPoint); 313 buffer.DataLength = m_udpSocket.EndReceiveFrom(iar, ref buffer.RemoteEndPoint);
@@ -293,6 +315,23 @@ namespace OpenMetaverse
293 // call the abstract method PacketReceived(), passing the buffer that 315 // call the abstract method PacketReceived(), passing the buffer that
294 // has just been filled from the socket read. 316 // has just been filled from the socket read.
295 PacketReceived(buffer); 317 PacketReceived(buffer);
318
319 // If more than one thread can be calling AsyncEndReceive() at once (e.g. if m_asyncPacketHandler)
320 // then a particular stat may be inaccurate due to a race condition. We won't worry about this
321 // since this should be rare and won't cause a runtime problem.
322 if (m_currentReceiveTimeSamples >= s_receiveTimeSamples)
323 {
324 AverageReceiveTicksForLastSamplePeriod
325 = (float)m_receiveTicksInCurrentSamplePeriod / s_receiveTimeSamples;
326
327 m_receiveTicksInCurrentSamplePeriod = 0;
328 m_currentReceiveTimeSamples = 0;
329 }
330 else
331 {
332 m_receiveTicksInCurrentSamplePeriod += Util.EnvironmentTickCountSubtract(startTick);
333 m_currentReceiveTimeSamples++;
334 }
296 } 335 }
297 catch (SocketException) { } 336 catch (SocketException) { }
298 catch (ObjectDisposedException) { } 337 catch (ObjectDisposedException) { }