aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorMelanie Thielker2008-12-17 09:52:52 +0000
committerMelanie Thielker2008-12-17 09:52:52 +0000
commite394e1c06f60e4805928eea2c8f0b054f81881e9 (patch)
tree8829450500c9193d251e74161d9ac8309c1608a6 /OpenSim/Region/ClientStack
parentAvoid checking the throttle limit for empty queues (diff)
downloadopensim-SC-e394e1c06f60e4805928eea2c8f0b054f81881e9.zip
opensim-SC-e394e1c06f60e4805928eea2c8f0b054f81881e9.tar.gz
opensim-SC-e394e1c06f60e4805928eea2c8f0b054f81881e9.tar.bz2
opensim-SC-e394e1c06f60e4805928eea2c8f0b054f81881e9.tar.xz
Remove a major bottleneck in throttling code.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs39
1 files changed, 15 insertions, 24 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs
index f73892a..70a9dec 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs
@@ -34,6 +34,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
34 private int m_currentThrottle; 34 private int m_currentThrottle;
35 private const int m_throttleTimeDivisor = 7; 35 private const int m_throttleTimeDivisor = 7;
36 private int m_currentBitsSent; 36 private int m_currentBitsSent;
37 private int m_throttleBits;
37 38
38 /// <value> 39 /// <value>
39 /// Value with which to multiply all the throttle fields 40 /// Value with which to multiply all the throttle fields
@@ -55,10 +56,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
55 public LLPacketThrottle(int min, int max, int throttle, float throttleMultiplier) 56 public LLPacketThrottle(int min, int max, int throttle, float throttleMultiplier)
56 { 57 {
57 m_throttleMultiplier = throttleMultiplier; 58 m_throttleMultiplier = throttleMultiplier;
58 m_maxAllowableThrottle = (int)(max * throttleMultiplier); 59 m_maxAllowableThrottle = max;
59 m_minAllowableThrottle = (int)(min * throttleMultiplier); 60 m_minAllowableThrottle = min;
60 m_currentThrottle = (int)(throttle * throttleMultiplier); 61 m_currentThrottle = throttle;
61 m_currentBitsSent = 0; 62 m_currentBitsSent = 0;
63
64 CalcBits();
65 }
66
67 public void CalcBits()
68 {
69 m_throttleBits = (int)((float)m_currentThrottle*m_throttleMultiplier/(float)m_throttleTimeDivisor);
62 } 70 }
63 71
64 public void Reset() 72 public void Reset()
@@ -68,15 +76,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
68 76
69 public bool UnderLimit() 77 public bool UnderLimit()
70 { 78 {
71 return (m_currentBitsSent < (m_currentThrottle/m_throttleTimeDivisor)); 79 return m_currentBitsSent < m_throttleBits;
72 } 80 }
73 81
74// public int AddBits(int bits)
75// {
76// m_currentBitsSent += bits;
77// return m_currentBitsSent;
78// }
79
80 public int AddBytes(int bytes) 82 public int AddBytes(int bytes)
81 { 83 {
82 m_currentBitsSent += bytes * 8; 84 m_currentBitsSent += bytes * 8;
@@ -98,20 +100,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
98 get { return m_currentThrottle; } 100 get { return m_currentThrottle; }
99 set 101 set
100 { 102 {
101 int multipliedValue = (int)(value * m_throttleMultiplier); 103 m_currentThrottle = value;
102 104
103 if (multipliedValue > m_maxAllowableThrottle) 105 CalcBits();
104 {
105 m_currentThrottle = m_maxAllowableThrottle;
106 }
107 else if (multipliedValue < m_minAllowableThrottle)
108 {
109 m_currentThrottle = m_minAllowableThrottle;
110 }
111 else
112 {
113 m_currentThrottle = multipliedValue;
114 }
115 } 106 }
116 } 107 }
117 } 108 }