aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-07-22 23:30:09 +0100
committerJustin Clark-Casey (justincc)2013-07-23 00:35:09 +0100
commitbf517899a7a63278d4ed22d5485c37d61d47bb58 (patch)
tree0deda695b605f06cde0e7e404cad0e6287749723 /OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
parentAdded check for user movement specification before discarding an incoming (diff)
downloadopensim-SC_OLD-bf517899a7a63278d4ed22d5485c37d61d47bb58.zip
opensim-SC_OLD-bf517899a7a63278d4ed22d5485c37d61d47bb58.tar.gz
opensim-SC_OLD-bf517899a7a63278d4ed22d5485c37d61d47bb58.tar.bz2
opensim-SC_OLD-bf517899a7a63278d4ed22d5485c37d61d47bb58.tar.xz
Add AverageUDPProcessTime stat to try and get a handle on how long we're taking on the initial processing of a UDP packet.
If we're not receiving packets with multiple threads (m_asyncPacketHandling) then this is critical since it will limit the number of incoming UDP requests that the region can handle and affects packet loss. If m_asyncPacketHandling then this is less critical though a long process will increase the scope for threads to race. This is an experimental stat which may be changed.
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs39
1 files changed, 39 insertions, 0 deletions
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) { }