aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-21 16:21:08 -0700
committerJohn Hurliman2009-10-21 16:21:08 -0700
commitb06f258319f088bcf6658880ed371ef313bac3b6 (patch)
tree938a7e9b2b07e40627acd74723aa1d2c8f661a67 /OpenSim
parent* Changed the timing calculations for sending resends/acks/pings from per-cli... (diff)
downloadopensim-SC_OLD-b06f258319f088bcf6658880ed371ef313bac3b6.zip
opensim-SC_OLD-b06f258319f088bcf6658880ed371ef313bac3b6.tar.gz
opensim-SC_OLD-b06f258319f088bcf6658880ed371ef313bac3b6.tar.bz2
opensim-SC_OLD-b06f258319f088bcf6658880ed371ef313bac3b6.tar.xz
* FireQueueEmpty now checks if a measurable amount of time has passed, and if not it sleeps for a small amount of time. This throttles OnQueueEmpty calls where there is no callback or the callback is doing very little work
* Changed HandleQueueEmpty()'s Monitor.TryEnter() calls to locks. We want to take our time in this function and do all the work necessary, since returning too fast will induce a sleep anyways
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs42
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs8
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs4
3 files changed, 16 insertions, 38 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 91afa4d..0bb7a71 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3558,45 +3558,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3558 ProcessTextureRequests(); 3558 ProcessTextureRequests();
3559 break; 3559 break;
3560 case ThrottleOutPacketType.Task: 3560 case ThrottleOutPacketType.Task:
3561 if (Monitor.TryEnter(m_avatarTerseUpdates.SyncRoot)) 3561 lock (m_avatarTerseUpdates.SyncRoot)
3562 { 3562 {
3563 try 3563 if (m_avatarTerseUpdates.Count > 0)
3564 { 3564 ProcessAvatarTerseUpdates();
3565 if (m_avatarTerseUpdates.Count > 0)
3566 {
3567
3568 ProcessAvatarTerseUpdates();
3569 return;
3570 }
3571 }
3572 finally { Monitor.Exit(m_avatarTerseUpdates.SyncRoot); }
3573 } 3565 }
3574 break; 3566 break;
3575 case ThrottleOutPacketType.State: 3567 case ThrottleOutPacketType.State:
3576 if (Monitor.TryEnter(m_primFullUpdates.SyncRoot)) 3568 lock (m_primFullUpdates.SyncRoot)
3577 { 3569 {
3578 try 3570 if (m_primFullUpdates.Count > 0)
3579 { 3571 ProcessPrimFullUpdates();
3580 if (m_primFullUpdates.Count > 0)
3581 {
3582 ProcessPrimFullUpdates();
3583 return;
3584 }
3585 }
3586 finally { Monitor.Exit(m_primFullUpdates.SyncRoot); }
3587 } 3572 }
3588 3573
3589 if (Monitor.TryEnter(m_primTerseUpdates.SyncRoot)) 3574 lock (m_primTerseUpdates.SyncRoot)
3590 { 3575 {
3591 try 3576 if (m_primTerseUpdates.Count > 0)
3592 { 3577 ProcessPrimTerseUpdates();
3593 if (m_primTerseUpdates.Count > 0)
3594 {
3595 ProcessPrimTerseUpdates();
3596 return;
3597 }
3598 }
3599 finally { Monitor.Exit(m_primTerseUpdates.SyncRoot); }
3600 } 3578 }
3601 break; 3579 break;
3602 } 3580 }
@@ -10344,7 +10322,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10344 { 10322 {
10345 if (lookup.Heap.ContainsHandle(lookup.Handle)) 10323 if (lookup.Heap.ContainsHandle(lookup.Handle))
10346 lookup.Heap[lookup.Handle] = 10324 lookup.Heap[lookup.Handle] =
10347 new MinHeapItem(priority, item.Value, item.LocalID); 10325 new MinHeapItem(priority, item.Value, item.LocalID, this.m_comparison);
10348 } 10326 }
10349 else 10327 else
10350 { 10328 {
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index 0a090b4..71f4c47 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -535,14 +535,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
535 ThrottleOutPacketType type = (ThrottleOutPacketType)i; 535 ThrottleOutPacketType type = (ThrottleOutPacketType)i;
536 QueueEmpty callback = OnQueueEmpty; 536 QueueEmpty callback = OnQueueEmpty;
537 537
538 int start = Environment.TickCount;
539
538 if (callback != null) 540 if (callback != null)
539 { 541 {
540 try { callback(type); } 542 try { callback(type); }
541 catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); } 543 catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); }
542 } 544 }
543 545
544 // HACK: Try spending some extra time here to slow down OnQueueEmpty calls 546 // Make sure all queue empty calls take at least a measurable amount of time,
545 //System.Threading.Thread.Sleep(100); 547 // otherwise we'll peg a CPU trying to fire these too fast
548 if (Environment.TickCount == start)
549 System.Threading.Thread.Sleep((int)m_udpServer.TickCountResolution);
546 550
547 m_onQueueEmptyRunning[i] = false; 551 m_onQueueEmptyRunning[i] = false;
548 } 552 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
index bd5fe1c..016712f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs
@@ -125,10 +125,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
125 expiredPackets = new List<OutgoingPacket>(); 125 expiredPackets = new List<OutgoingPacket>();
126 expiredPackets.Add(packet); 126 expiredPackets.Add(packet);
127 } 127 }
128 /*else
129 {
130 break;
131 }*/
132 } 128 }
133 } 129 }
134 130