From 4e04f6b3a5a875c7d8820c679bcbcdcfba1227bf Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Wed, 21 Oct 2009 17:02:55 -0700
Subject: * Clarified what FireQueueEmpty is doing with a MIN_CALLBACK_MS
constant and upped it to 30ms * Removed the unused PacketSent() function *
Switched UnackedPacketCollection from a SortedDictionary to a Dictionary now
that the sorting is no longer needed. Big performance improvement for
ResendUnacked()
---
OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 11 +++++++----
OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 ----
OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 9 ---------
.../Region/ClientStack/LindenUDP/UnackedPacketCollection.cs | 2 +-
4 files changed, 8 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region/ClientStack/LindenUDP')
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 71f4c47..2d86a40 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -531,11 +531,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// as an object to match the WaitCallback delegate signature
private void FireQueueEmpty(object o)
{
+ const int MIN_CALLBACK_MS = 30;
+
int i = (int)o;
ThrottleOutPacketType type = (ThrottleOutPacketType)i;
QueueEmpty callback = OnQueueEmpty;
- int start = Environment.TickCount;
+ int start = Environment.TickCount & Int32.MaxValue;
if (callback != null)
{
@@ -543,10 +545,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); }
}
- // Make sure all queue empty calls take at least a measurable amount of time,
+ // Make sure all queue empty calls take at least some amount of time,
// otherwise we'll peg a CPU trying to fire these too fast
- if (Environment.TickCount == start)
- System.Threading.Thread.Sleep((int)m_udpServer.TickCountResolution);
+ int elapsedMS = (Environment.TickCount & Int32.MaxValue) - start;
+ if (elapsedMS < MIN_CALLBACK_MS)
+ System.Threading.Thread.Sleep(MIN_CALLBACK_MS - elapsedMS);
m_onQueueEmptyRunning[i] = false;
}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 4bdf132..40d3771 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -674,10 +674,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
packetInbox.Enqueue(new IncomingPacket(udpClient, packet));
}
- protected override void PacketSent(UDPPacketBuffer buffer, int bytesSent)
- {
- }
-
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
{
PacketAckPacket ack = new PacketAckPacket();
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
index d16837d..552cc4a 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs
@@ -45,13 +45,6 @@ namespace OpenMetaverse
///
/// Incoming packet buffer
protected abstract void PacketReceived(UDPPacketBuffer buffer);
-
- ///
- /// This method is called when an outgoing packet is sent
- ///
- /// Outgoing packet buffer
- /// Number of bytes written to the wire
- protected abstract void PacketSent(UDPPacketBuffer buffer, int bytesSent);
/// UDP port to bind to in server mode
protected int m_udpPort;
@@ -279,8 +272,6 @@ namespace OpenMetaverse
{
UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState;
int bytesSent = m_udpSocket.EndSendTo(result);
-
- PacketSent(buf, bytesSent);
}
catch (SocketException) { }
catch (ObjectDisposedException) { }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index 016712f..3e2e81c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
/// Holds the actual unacked packet data, sorted by sequence number
- private SortedDictionary m_packets = new SortedDictionary();
+ private Dictionary m_packets = new Dictionary();
/// Holds packets that need to be added to the unacknowledged list
private LocklessQueue m_pendingAdds = new LocklessQueue();
/// Holds information about pending acknowledgements
--
cgit v1.1