Reapply the packet optimization patch, with changes

0.6.1-post-fixes
Melanie Thielker 2008-12-17 21:00:18 +00:00
parent dce11e4685
commit a9e38bcafc
3 changed files with 42 additions and 57 deletions

View File

@ -99,26 +99,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//
private Dictionary<uint, uint> m_PendingAcks = new Dictionary<uint, uint>();
// Dictionary of the packets that need acks from the client.
//
private class AckData
{
public AckData(Packet packet, Object identifier, int tickCount, int resends)
{
Packet = packet;
Identifier = identifier;
TickCount = tickCount;
Resends = resends;
}
public Packet Packet;
public Object Identifier;
public int TickCount;
public int Resends;
}
private Dictionary<uint, AckData> m_NeedAck =
new Dictionary<uint, AckData>();
private Dictionary<uint, LLQueItem> m_NeedAck =
new Dictionary<uint, LLQueItem>();
/// <summary>
/// The number of milliseconds that can pass before a packet that needs an ack is resent.
@ -314,6 +296,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
item.throttleType = throttlePacketType;
item.TickCount = System.Environment.TickCount;
item.Identifier = id;
item.Resends = 0;
item.Length = packet.ToBytes().Length;
m_PacketQueue.Enqueue(item);
m_PacketsSent++;
@ -333,7 +317,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (m_DropSafeTimeout > now ||
intervalMs > 500) // We were frozen!
{
foreach (AckData data in new List<AckData>
foreach (LLQueItem data in new List<LLQueItem>
(m_NeedAck.Values))
{
if (m_DropSafeTimeout > now)
@ -364,7 +348,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int resent = 0;
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
{
Packet packet = data.Packet;
@ -630,7 +614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void ProcessAck(uint id)
{
AckData data;
LLQueItem data;
Packet packet;
lock (m_NeedAck)
@ -640,11 +624,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!m_NeedAck.TryGetValue(id, out data))
return;
packet = data.Packet;
m_NeedAck.Remove(id);
m_UnackedBytes -= packet.ToBytes().Length;
PacketPool.Instance.ReturnPacket(data.Packet);
m_UnackedBytes -= data.Length;
}
}
@ -697,7 +679,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public void SetClientInfo(ClientInfo info)
{
m_PendingAcks = info.pendingAcks;
m_NeedAck = new Dictionary<uint, AckData>();
m_NeedAck = new Dictionary<uint, LLQueItem>();
Packet packet = null;
int packetEnd = 0;
@ -716,7 +698,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
}
m_NeedAck.Add(key, new AckData(packet, null, System.Environment.TickCount, 0));
LLQueItem item = new LLQueItem();
item.Packet = packet;
item.Incoming = false;
item.throttleType = 0;
item.TickCount = System.Environment.TickCount;
item.Identifier = 0;
item.Resends = 0;
item.Length = packet.ToBytes().Length;
m_NeedAck.Add(key, item);
}
m_Sequence = info.sequence;
@ -740,7 +730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void DropResend(Object id)
{
foreach (AckData data in new List<AckData>(m_NeedAck.Values))
foreach (LLQueItem data in new List<LLQueItem>(m_NeedAck.Values))
{
if (data.Identifier != null && data.Identifier == id)
{
@ -777,12 +767,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// We want to see that packet arrive if it's reliable
if (packet.Header.Reliable)
{
m_UnackedBytes += packet.ToBytes().Length;
m_UnackedBytes += item.Length;
// Keep track of when this packet was sent out
m_NeedAck[packet.Header.Sequence] = new AckData(packet,
item.Identifier, System.Environment.TickCount,
0);
item.TickCount = System.Environment.TickCount;
m_NeedAck[packet.Header.Sequence] = item;
}
}
}
@ -792,7 +782,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Abort();
// Actually make the byte array and send it
byte[] sendbuffer = packet.ToBytes();
byte[] sendbuffer = item.Packet.ToBytes();
//m_log.DebugFormat(
// "[CLIENT]: In {0} sending packet {1}",

View File

@ -345,9 +345,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
ResendThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
ResendThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -357,9 +356,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = LandOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
LandThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
LandThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -368,9 +366,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = WindOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
WindThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
WindThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -379,9 +376,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
CloudThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
CloudThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -399,9 +395,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
SendQueue.Enqueue(qpack);
}
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
TaskThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
TaskThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -410,9 +405,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
TextureThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
TextureThrottle.AddBytes(qpack.Length);
qchanged = true;
}
@ -421,9 +415,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue();
SendQueue.Enqueue(qpack);
int qpackSize = qpack.Packet.ToBytes().Length;
TotalThrottle.AddBytes(qpackSize);
AssetThrottle.AddBytes(qpackSize);
TotalThrottle.AddBytes(qpack.Length);
AssetThrottle.AddBytes(qpack.Length);
qchanged = true;
}
}
@ -451,8 +444,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try
{
Monitor.Enter(this);
throttle.AddBytes(item.Packet.ToBytes().Length);
TotalThrottle.AddBytes(item.Packet.ToBytes().Length);
throttle.AddBytes(item.Length);
TotalThrottle.AddBytes(item.Length);
SendQueue.Enqueue(item);
}
catch (Exception e)

View File

@ -42,5 +42,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public ThrottleOutPacketType throttleType;
public int TickCount;
public Object Identifier;
public int Resends;
public int Length;
}
}