* 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 cleanerprioritization
parent
62f1bfd136
commit
2752a3525c
|
@ -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
|
||||
{
|
||||
|
|
|
@ -103,14 +103,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
public bool IsPaused;
|
||||
/// <summary>Environment.TickCount when the last packet was received for this client</summary>
|
||||
public int TickLastPacketReceived;
|
||||
/// <summary>Environment.TickCount of the last time the outgoing packet handler executed for this client</summary>
|
||||
public int TickLastOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler executed for this client</summary>
|
||||
public int ElapsedMSOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed for this client</summary>
|
||||
public int Elapsed100MSOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed for this client</summary>
|
||||
public int Elapsed500MSOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Smoothed round-trip time. A smoothed average of the round-trip time for sending a
|
||||
/// reliable packet to the client and receiving an ACK</summary>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// whether or not to sleep</summary>
|
||||
private bool m_packetSent;
|
||||
|
||||
/// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
|
||||
private int m_tickLastOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
|
||||
private int m_elapsedMSOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed</summary>
|
||||
private int m_elapsed100MSOutgoingPacketHandler;
|
||||
/// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed</summary>
|
||||
private int m_elapsed500MSOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Flag to signal when clients should check for resends</summary>
|
||||
private bool m_resendUnacked;
|
||||
/// <summary>Flag to signal when clients should send ACKs</summary>
|
||||
private bool m_sendAcks;
|
||||
/// <summary>Flag to signal when clients should send pings</summary>
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue