aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-16 14:17:13 -0700
committerJohn Hurliman2009-10-16 14:17:13 -0700
commit1bd9202f2439ac73a70fa2a881f824797f61f589 (patch)
treeed09eb3671f5bbdec15baf4aaf9069f6ea203902 /OpenSim
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim into priorit... (diff)
downloadopensim-SC-1bd9202f2439ac73a70fa2a881f824797f61f589.zip
opensim-SC-1bd9202f2439ac73a70fa2a881f824797f61f589.tar.gz
opensim-SC-1bd9202f2439ac73a70fa2a881f824797f61f589.tar.bz2
opensim-SC-1bd9202f2439ac73a70fa2a881f824797f61f589.tar.xz
* Simplified the prioritization packet creation code to reduce CPU usage and increase throughput. Apologies to Jim for hacking on your code while it's only halfway done, I'll take responsibility for the manual merge
* Changed LLUDP to use its own MTU value of 1400 instead of the 1200 value pulled from the currently shipped libomv
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs101
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs20
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs9
3 files changed, 35 insertions, 95 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 630b6e6..383eac0 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -347,10 +347,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
347 protected Dictionary<UUID,ulong> m_groupPowers = new Dictionary<UUID, ulong>(); 347 protected Dictionary<UUID,ulong> m_groupPowers = new Dictionary<UUID, ulong>();
348 protected int m_terrainCheckerCount; 348 protected int m_terrainCheckerCount;
349 349
350 // LL uses these limits, apparently. Compressed terse would be 23, but we don't have that yet 350 // These numbers are guesses at a decent tradeoff between responsiveness
351 protected int m_primTerseUpdatesPerPacket = 10; 351 // of the interest list and throughput. Lower is more responsive, higher
352 protected int m_primFullUpdatesPerPacket = 14; 352 // is better throughput
353 protected int m_avatarTerseUpdatesPerPacket = 5; 353 protected int m_primTerseUpdatesPerPacket = 25;
354 protected int m_primFullUpdatesPerPacket = 100;
355 protected int m_avatarTerseUpdatesPerPacket = 10;
354 /// <summary>Number of texture packets to put on the queue each time the 356 /// <summary>Number of texture packets to put on the queue each time the
355 /// OnQueueEmpty event is triggered for the texture category</summary> 357 /// OnQueueEmpty event is triggered for the texture category</summary>
356 protected int m_textureSendLimit = 20; 358 protected int m_textureSendLimit = 20;
@@ -3415,33 +3417,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3415 terse.RegionData.TimeDilation = 3417 terse.RegionData.TimeDilation =
3416 (ushort)(Scene.TimeDilation * ushort.MaxValue); 3418 (ushort)(Scene.TimeDilation * ushort.MaxValue);
3417 3419
3418 int max = m_avatarTerseUpdatesPerPacket; 3420 int count = Math.Min(m_avatarTerseUpdates.Count, m_avatarTerseUpdatesPerPacket);
3419 if (max > m_avatarTerseUpdates.Count)
3420 max = m_avatarTerseUpdates.Count;
3421
3422 int count = 0;
3423 int size = 0;
3424
3425 byte[] zerobuffer = new byte[1024];
3426 byte[] blockbuffer = new byte[1024];
3427
3428 Queue<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> updates = new Queue<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
3429
3430 for (count = 0 ; count < max ; count++)
3431 {
3432 int length = 0;
3433 m_avatarTerseUpdates.Peek().ToBytes(blockbuffer, ref length);
3434 length = Helpers.ZeroEncode(blockbuffer, length, zerobuffer);
3435 if (size + length > Packet.MTU)
3436 break;
3437 size += length;
3438 updates.Enqueue(m_avatarTerseUpdates.Dequeue());
3439 }
3440 3421
3441 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[count]; 3422 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[count];
3442 3423 for (int i = 0; i < count; i++)
3443 for (int i = 0 ; i < count ; i++) 3424 terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue();
3444 terse.ObjectData[i] = updates.Dequeue();
3445 3425
3446 terse.Header.Reliable = false; 3426 terse.Header.Reliable = false;
3447 terse.Header.Zerocoded = true; 3427 terse.Header.Zerocoded = true;
@@ -3656,34 +3636,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3656 outPacket.RegionData.TimeDilation = 3636 outPacket.RegionData.TimeDilation =
3657 (ushort)(Scene.TimeDilation * ushort.MaxValue); 3637 (ushort)(Scene.TimeDilation * ushort.MaxValue);
3658 3638
3659 int max = m_primFullUpdates.Count; 3639 int count = Math.Min(m_primFullUpdates.Count, m_primFullUpdatesPerPacket);
3660 if (max > m_primFullUpdatesPerPacket)
3661 max = m_primFullUpdatesPerPacket;
3662
3663 int count = 0;
3664 int size = 0;
3665 3640
3666 byte[] zerobuffer = new byte[1024]; 3641 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count];
3667 byte[] blockbuffer = new byte[1024]; 3642 for (int i = 0; i < count; i++)
3668 3643 outPacket.ObjectData[i] = m_primFullUpdates.Dequeue();
3669 Queue<ObjectUpdatePacket.ObjectDataBlock> updates = new Queue<ObjectUpdatePacket.ObjectDataBlock>();
3670
3671 for (count = 0 ; count < max ; count++)
3672 {
3673 int length = 0;
3674 m_primFullUpdates.Peek().ToBytes(blockbuffer, ref length);
3675 length = Helpers.ZeroEncode(blockbuffer, length, zerobuffer);
3676 if (size + length > Packet.MTU)
3677 break;
3678 size += length;
3679 updates.Enqueue(m_primFullUpdates.Dequeue());
3680 }
3681
3682 outPacket.ObjectData =
3683 new ObjectUpdatePacket.ObjectDataBlock[count];
3684
3685 for (int index = 0 ; index < count ; index++)
3686 outPacket.ObjectData[index] = updates.Dequeue();
3687 3644
3688 outPacket.Header.Zerocoded = true; 3645 outPacket.Header.Zerocoded = true;
3689 OutPacket(outPacket, ThrottleOutPacketType.State); 3646 OutPacket(outPacket, ThrottleOutPacketType.State);
@@ -3733,35 +3690,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3733 outPacket.RegionData.TimeDilation = 3690 outPacket.RegionData.TimeDilation =
3734 (ushort)(Scene.TimeDilation * ushort.MaxValue); 3691 (ushort)(Scene.TimeDilation * ushort.MaxValue);
3735 3692
3736 int max = m_primTerseUpdates.Count; 3693 int count = Math.Min(m_primTerseUpdates.Count, m_primTerseUpdatesPerPacket);
3737 if (max > m_primTerseUpdatesPerPacket)
3738 max = m_primTerseUpdatesPerPacket;
3739
3740 int count = 0;
3741 int size = 0;
3742
3743 byte[] zerobuffer = new byte[1024];
3744 byte[] blockbuffer = new byte[1024];
3745
3746 Queue<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> updates = new Queue<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
3747
3748 for (count = 0 ; count < max ; count++)
3749 {
3750 int length = 0;
3751 m_primTerseUpdates.Peek().ToBytes(blockbuffer, ref length);
3752 length = Helpers.ZeroEncode(blockbuffer, length, zerobuffer);
3753 if (size + length > Packet.MTU)
3754 break;
3755 size += length;
3756 updates.Enqueue(m_primTerseUpdates.Dequeue());
3757 }
3758
3759 outPacket.ObjectData =
3760 new ImprovedTerseObjectUpdatePacket.
3761 ObjectDataBlock[count];
3762 3694
3763 for (int index = 0 ; index < count ; index++) 3695 outPacket.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[count];
3764 outPacket.ObjectData[index] = updates.Dequeue(); 3696 for (int i = 0; i < count; i++)
3697 outPacket.ObjectData[i] = m_primTerseUpdates.Dequeue();
3765 3698
3766 outPacket.Header.Reliable = false; 3699 outPacket.Header.Reliable = false;
3767 outPacket.Header.Zerocoded = true; 3700 outPacket.Header.Zerocoded = true;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 8c42ca4..9476eed 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -297,14 +297,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
297 297
298 // Make sure none of the throttles are set below our packet MTU, 298 // Make sure none of the throttles are set below our packet MTU,
299 // otherwise a throttle could become permanently clogged 299 // otherwise a throttle could become permanently clogged
300 resend = Math.Max(resend, Packet.MTU); 300 resend = Math.Max(resend, LLUDPServer.MTU);
301 land = Math.Max(land, Packet.MTU); 301 land = Math.Max(land, LLUDPServer.MTU);
302 wind = Math.Max(wind, Packet.MTU); 302 wind = Math.Max(wind, LLUDPServer.MTU);
303 cloud = Math.Max(cloud, Packet.MTU); 303 cloud = Math.Max(cloud, LLUDPServer.MTU);
304 task = Math.Max(task, Packet.MTU); 304 task = Math.Max(task, LLUDPServer.MTU);
305 texture = Math.Max(texture, Packet.MTU); 305 texture = Math.Max(texture, LLUDPServer.MTU);
306 asset = Math.Max(asset, Packet.MTU); 306 asset = Math.Max(asset, LLUDPServer.MTU);
307 state = Math.Max(state, Packet.MTU); 307 state = Math.Max(state, LLUDPServer.MTU);
308 308
309 int total = resend + land + wind + cloud + task + texture + asset + state; 309 int total = resend + land + wind + cloud + task + texture + asset + state;
310 310
@@ -404,9 +404,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
404 TokenBucket bucket; 404 TokenBucket bucket;
405 bool packetSent = false; 405 bool packetSent = false;
406 406
407 //string queueDebugOutput = String.Empty; // Serious debug business
408
407 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) 409 for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++)
408 { 410 {
409 bucket = m_throttleCategories[i]; 411 bucket = m_throttleCategories[i];
412 //queueDebugOutput += m_packetOutboxes[i].Count + " "; // Serious debug business
410 413
411 if (m_nextPackets[i] != null) 414 if (m_nextPackets[i] != null)
412 { 415 {
@@ -458,6 +461,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
458 } 461 }
459 } 462 }
460 463
464 //m_log.Info("[LLUDPCLIENT]: Queues: " + queueDebugOutput); // Serious debug business
461 return packetSent; 465 return packetSent;
462 } 466 }
463 467
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index b11a80d..f2b8720 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -89,6 +89,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
89 /// </summary> 89 /// </summary>
90 public class LLUDPServer : OpenSimUDPBase 90 public class LLUDPServer : OpenSimUDPBase
91 { 91 {
92 /// <summary>Maximum transmission unit, or UDP packet size, for the LLUDP protocol</summary>
93 public const int MTU = 1400;
94
92 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 95 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
93 96
94 /// <summary>Handlers for incoming packets</summary> 97 /// <summary>Handlers for incoming packets</summary>
@@ -272,7 +275,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
272 // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting 275 // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting
273 // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here 276 // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here
274 // to accomodate for both common scenarios and provide ample room for ACK appending in both 277 // to accomodate for both common scenarios and provide ample room for ACK appending in both
275 int bufferSize = (dataLength > 180) ? Packet.MTU : 200; 278 int bufferSize = (dataLength > 180) ? LLUDPServer.MTU : 200;
276 279
277 UDPPacketBuffer buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize); 280 UDPPacketBuffer buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize);
278 281
@@ -569,9 +572,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
569 // client.BytesSinceLastACK. Lockless thread safety 572 // client.BytesSinceLastACK. Lockless thread safety
570 int bytesSinceLastACK = Interlocked.Exchange(ref udpClient.BytesSinceLastACK, 0); 573 int bytesSinceLastACK = Interlocked.Exchange(ref udpClient.BytesSinceLastACK, 0);
571 bytesSinceLastACK += buffer.DataLength; 574 bytesSinceLastACK += buffer.DataLength;
572 if (bytesSinceLastACK > Packet.MTU * 2) 575 if (bytesSinceLastACK > LLUDPServer.MTU * 2)
573 { 576 {
574 bytesSinceLastACK -= Packet.MTU * 2; 577 bytesSinceLastACK -= LLUDPServer.MTU * 2;
575 SendAcks(udpClient); 578 SendAcks(udpClient);
576 } 579 }
577 Interlocked.Add(ref udpClient.BytesSinceLastACK, bytesSinceLastACK); 580 Interlocked.Add(ref udpClient.BytesSinceLastACK, bytesSinceLastACK);