From 2752a3525c6c57470024d0dddfd69d593abc4594 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Wed, 21 Oct 2009 15:22:23 -0700
Subject: * Changed the timing calculations for sending resends/acks/pings from
per-client back to per-scene * Testing a fix from Jim to make the cpu usage
fix cleaner
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 6 +-
.../Region/ClientStack/LindenUDP/LLUDPClient.cs | 13 +---
.../Region/ClientStack/LindenUDP/LLUDPServer.cs | 85 +++++++++++++++-------
3 files changed, 63 insertions(+), 41 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 997f38c..91afa4d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3558,7 +3558,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ProcessTextureRequests();
break;
case ThrottleOutPacketType.Task:
- if (Monitor.TryEnter(m_avatarTerseUpdates.SyncRoot, 1))
+ if (Monitor.TryEnter(m_avatarTerseUpdates.SyncRoot))
{
try
{
@@ -3573,7 +3573,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
break;
case ThrottleOutPacketType.State:
- if (Monitor.TryEnter(m_primFullUpdates.SyncRoot, 1))
+ if (Monitor.TryEnter(m_primFullUpdates.SyncRoot))
{
try
{
@@ -3586,7 +3586,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
finally { Monitor.Exit(m_primFullUpdates.SyncRoot); }
}
- if (Monitor.TryEnter(m_primTerseUpdates.SyncRoot, 1))
+ if (Monitor.TryEnter(m_primTerseUpdates.SyncRoot))
{
try
{
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index de67ca7..0a090b4 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -103,14 +103,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public bool IsPaused;
/// Environment.TickCount when the last packet was received for this client
public int TickLastPacketReceived;
- /// Environment.TickCount of the last time the outgoing packet handler executed for this client
- public int TickLastOutgoingPacketHandler;
- /// Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler executed for this client
- public int ElapsedMSOutgoingPacketHandler;
- /// Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed for this client
- public int Elapsed100MSOutgoingPacketHandler;
- /// Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed for this client
- public int Elapsed500MSOutgoingPacketHandler;
/// Smoothed round-trip time. A smoothed average of the round-trip time for sending a
/// reliable packet to the client and receiving an ACK
@@ -191,9 +183,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Initialize this to a sane value to prevent early disconnects
TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
- ElapsedMSOutgoingPacketHandler = 0;
- Elapsed100MSOutgoingPacketHandler = 0;
- Elapsed500MSOutgoingPacketHandler = 0;
}
///
@@ -553,7 +542,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
// HACK: Try spending some extra time here to slow down OnQueueEmpty calls
- System.Threading.Thread.Sleep(100);
+ //System.Threading.Thread.Sleep(100);
m_onQueueEmptyRunning[i] = false;
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index be6f7ef..4bdf132 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -125,6 +125,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// whether or not to sleep
private bool m_packetSent;
+ /// Environment.TickCount of the last time the outgoing packet handler executed
+ private int m_tickLastOutgoingPacketHandler;
+ /// Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped
+ private int m_elapsedMSOutgoingPacketHandler;
+ /// Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed
+ private int m_elapsed100MSOutgoingPacketHandler;
+ /// Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed
+ private int m_elapsed500MSOutgoingPacketHandler;
+
+ /// Flag to signal when clients should check for resends
+ private bool m_resendUnacked;
+ /// Flag to signal when clients should send ACKs
+ private bool m_sendAcks;
+ /// Flag to signal when clients should send pings
+ private bool m_sendPing;
+
public Socket Server { get { return null; } }
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
@@ -786,6 +802,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_packetSent = false;
+ #region Update Timers
+
+ m_resendUnacked = false;
+ m_sendAcks = false;
+ m_sendPing = false;
+
+ // Update elapsed time
+ int thisTick = Environment.TickCount & Int32.MaxValue;
+ if (m_tickLastOutgoingPacketHandler > thisTick)
+ m_elapsedMSOutgoingPacketHandler += ((Int32.MaxValue - m_tickLastOutgoingPacketHandler) + thisTick);
+ else
+ m_elapsedMSOutgoingPacketHandler += (thisTick - m_tickLastOutgoingPacketHandler);
+
+ m_tickLastOutgoingPacketHandler = thisTick;
+
+ // Check for pending outgoing resends every 100ms
+ if (m_elapsedMSOutgoingPacketHandler >= 100)
+ {
+ m_resendUnacked = true;
+ m_elapsedMSOutgoingPacketHandler = 0;
+ m_elapsed100MSOutgoingPacketHandler += 1;
+ }
+
+ // Check for pending outgoing ACKs every 500ms
+ if (m_elapsed100MSOutgoingPacketHandler >= 5)
+ {
+ m_sendAcks = true;
+ m_elapsed100MSOutgoingPacketHandler = 0;
+ m_elapsed500MSOutgoingPacketHandler += 1;
+ }
+
+ // Send pings to clients every 5000ms
+ if (m_elapsed500MSOutgoingPacketHandler >= 10)
+ {
+ m_sendPing = true;
+ m_elapsed500MSOutgoingPacketHandler = 0;
+ }
+
+ #endregion Update Timers
+
// Handle outgoing packets, resends, acknowledgements, and pings for each
// client. m_packetSent will be set to true if a packet is sent
m_scene.ClientManager.ForEachSync(ClientOutgoingPacketHandler);
@@ -810,44 +866,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
LLUDPClient udpClient = ((LLClientView)client).UDPClient;
- // Update ElapsedMSOutgoingPacketHandler
- int thisTick = Environment.TickCount & Int32.MaxValue;
- if (udpClient.TickLastOutgoingPacketHandler > thisTick)
- udpClient.ElapsedMSOutgoingPacketHandler += ((Int32.MaxValue - udpClient.TickLastOutgoingPacketHandler) + thisTick);
- else
- udpClient.ElapsedMSOutgoingPacketHandler += (thisTick - udpClient.TickLastOutgoingPacketHandler);
-
if (udpClient.IsConnected)
{
- // Check for pending outgoing resends every 100ms
- if (udpClient.ElapsedMSOutgoingPacketHandler >= 100)
- {
+ if (m_resendUnacked)
ResendUnacked(udpClient);
- udpClient.ElapsedMSOutgoingPacketHandler = 0;
- udpClient.Elapsed100MSOutgoingPacketHandler += 1;
- }
- // Check for pending outgoing ACKs every 500ms
- if (udpClient.Elapsed100MSOutgoingPacketHandler >= 5)
- {
+ if (m_sendAcks)
SendAcks(udpClient);
- udpClient.Elapsed100MSOutgoingPacketHandler = 0;
- udpClient.Elapsed500MSOutgoingPacketHandler += 1;
- }
- // Send pings to clients every 5000ms
- if (udpClient.Elapsed500MSOutgoingPacketHandler >= 10)
- {
+ if (m_sendPing)
SendPing(udpClient);
- udpClient.Elapsed500MSOutgoingPacketHandler = 0;
- }
// Dequeue any outgoing packets that are within the throttle limits
if (udpClient.DequeueOutgoing())
m_packetSent = true;
}
-
- udpClient.TickLastOutgoingPacketHandler = thisTick;
}
}
catch (Exception ex)
--
cgit v1.1