From 438798202fc1f578864a2796cb8a66b3199a77e0 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 29 Aug 2014 13:26:30 +0100
Subject: replace the tick() by a limit on the maximum number of tokens that
can be acumulated ( variable named BurtRate, not exactly a rate...)
---
.../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 2 -
.../Region/ClientStack/Linden/UDP/TokenBucket.cs | 52 ++++++++++++++++------
2 files changed, 39 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index e760513..89a9401 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
@@ -616,8 +616,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
// No packets in this queue. Fire the queue empty callback
// if it has not been called recently
-
- bucket.Tick(); // tick the bucket
emptyCategories |= CategoryToFlag(i);
}
}
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index a2ff884..3147095 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -53,10 +53,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected const Int32 m_ticksPerQuantum = 1000;
///
- /// This is the number of quantums worth of packets that can
- /// be accommodated during a burst
+ /// This is the number of m_minimumDripRate bytes
+ /// allowed in a burst
+ /// roughtly, with this settings, the maximum time system will take
+ /// to recheck a bucket in ms
+ ///
///
- protected const Double m_quantumsPerBurst = 1.5;
+ protected const Double m_quantumsPerBurst = 15;
///
///
@@ -91,22 +94,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
///
- /// Maximum burst rate in bytes per second. This is the maximum number
+ /// This is the maximum number
/// of tokens that can accumulate in the bucket at any one time. This
/// also sets the total request for leaf nodes
+ /// this is not a rate.
///
protected Int64 m_burstRate;
public Int64 RequestedBurstRate
{
get { return m_burstRate; }
- set { m_burstRate = (value < 0 ? 0 : value); }
+ set {
+ double rate = (value < 0 ? 0 : value);
+ if (rate < m_minimumDripRate)
+ rate = m_minimumDripRate;
+ else if (rate > m_minimumDripRate * m_quantumsPerBurst)
+ rate = m_minimumDripRate * m_quantumsPerBurst;
+
+ m_burstRate = (Int64)rate;
+ }
}
public Int64 BurstRate
{
get {
double rate = RequestedBurstRate * BurstRateModifier();
- if (rate < m_minimumDripRate * m_quantumsPerBurst)
+ if (rate < m_minimumDripRate)
+ rate = m_minimumDripRate;
+ else if (rate > m_minimumDripRate * m_quantumsPerBurst)
rate = m_minimumDripRate * m_quantumsPerBurst;
return (Int64) rate;
@@ -126,8 +140,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
get { return (m_dripRate == 0 ? m_totalDripRequest : m_dripRate); }
set {
m_dripRate = (value < 0 ? 0 : value);
- m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
m_totalDripRequest = m_dripRate;
+
+ double rate = m_dripRate;
+ if (rate > m_minimumDripRate * m_quantumsPerBurst)
+ rate = m_minimumDripRate * m_quantumsPerBurst;
+ else if (rate < m_minimumDripRate)
+ rate = m_minimumDripRate;
+
+ m_burstRate = (Int64)rate;
+
+ m_tokenCount = 0;
+
if (m_parent != null)
m_parent.RegisterRequest(this,m_dripRate);
}
@@ -325,11 +349,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Deposit(deltaMS * DripRate / m_ticksPerQuantum);
}
-
- public void Tick()
- {
- m_lastDrip = Util.EnvironmentTickCount();
- }
}
public class AdaptiveTokenBucket : TokenBucket
@@ -364,7 +383,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
get { return m_dripRate; }
set {
m_dripRate = OpenSim.Framework.Util.Clamp(value,m_minimumFlow,MaxDripRate);
- m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
+
+ double rate = m_dripRate;
+ if (rate > m_minimumDripRate * m_quantumsPerBurst)
+ rate = m_minimumDripRate * m_quantumsPerBurst;
+ else if (rate < m_minimumDripRate)
+ rate = m_minimumDripRate;
+ m_burstRate = (Int64)rate;
+
if (m_parent != null)
m_parent.RegisterRequest(this,m_dripRate);
}
--
cgit v1.1