mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Enable runtime configuration of the minimum rate for adaptive
throttles. Setting adaptive_throttle_min_bps will change the minimum rate that the adapative throttles will drop to in case of network packet loss. The current rate default rate is 256kbps. The viewer can throttle rates under that amount, but the dynamic adaptation will not.
This commit is contained in:
@@ -229,7 +229,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_throttleClient
|
||||
= new AdaptiveTokenBucket(
|
||||
string.Format("adaptive throttle for {0} in {1}", AgentID, server.Scene.Name),
|
||||
parentThrottle, 0, rates.Total, rates.AdaptiveThrottlesEnabled);
|
||||
parentThrottle, 0, rates.Total, rates.MinimumAdaptiveThrottleRate, rates.AdaptiveThrottlesEnabled);
|
||||
|
||||
// Create an array of token buckets for this clients different throttle categories
|
||||
m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT];
|
||||
|
||||
@@ -58,7 +58,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
/// <summary>Flag used to enable adaptive throttles</summary>
|
||||
public bool AdaptiveThrottlesEnabled;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the minimum rate that the adaptive throttles can set. The viewer
|
||||
/// can still throttle lower than this, but the adaptive throttles will
|
||||
/// never decrease rates below this no matter how many packets are dropped
|
||||
/// </summary>
|
||||
public Int64 MinimumAdaptiveThrottleRate;
|
||||
|
||||
/// <summary>Amount of the texture throttle to steal for the task throttle</summary>
|
||||
public double CannibalizeTextureRate;
|
||||
|
||||
@@ -84,7 +91,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Total = throttleConfig.GetInt("client_throttle_max_bps", 0);
|
||||
|
||||
AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false);
|
||||
|
||||
MinimumAdaptiveThrottleRate = throttleConfig.GetInt("adaptive_throttle_min_bps", 32000);
|
||||
|
||||
CannibalizeTextureRate = (double)throttleConfig.GetFloat("CannibalizeTextureRate", 0.0f);
|
||||
CannibalizeTextureRate = Util.Clamp<double>(CannibalizeTextureRate,0.0, 0.9);
|
||||
}
|
||||
|
||||
@@ -392,13 +392,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum rate for flow control. Minimum drip rate is one
|
||||
/// packet per second. Open the throttle to 15 packets per second
|
||||
/// or about 160kbps.
|
||||
/// The minimum rate for adaptive flow control.
|
||||
/// </summary>
|
||||
protected const Int64 m_minimumFlow = m_minimumDripRate * 15;
|
||||
protected Int64 m_minimumFlow = 32000;
|
||||
public Int64 MinimumFlow
|
||||
{
|
||||
get { return m_minimumFlow; }
|
||||
set
|
||||
{
|
||||
m_minimumFlow = value;
|
||||
TargetDripRate = Math.Max(m_minimumFlow, TargetDripRate);
|
||||
AdjustedDripRate = Math.Max(m_minimumFlow, AdjustedDripRate);
|
||||
}
|
||||
}
|
||||
|
||||
public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, bool enabled)
|
||||
/// <summary>
|
||||
/// Constructor for the AdaptiveTokenBucket class
|
||||
/// <param name="identifier">Unique identifier for the client</param>
|
||||
/// <param name="parent">Parent bucket in the hierarchy</param>
|
||||
/// <param name="requestedDripRate"></param>
|
||||
/// <param name="maxDripRate">The ceiling rate for adaptation</param>
|
||||
/// <param name="minDripRate">The floor rate for adaptation</param>
|
||||
/// </summary>
|
||||
public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, Int64 minDripRate, bool enabled)
|
||||
: base(identifier, parent, requestedDripRate, maxDripRate)
|
||||
{
|
||||
AdaptiveEnabled = enabled;
|
||||
@@ -406,34 +422,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
if (AdaptiveEnabled)
|
||||
{
|
||||
// m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled");
|
||||
m_minimumFlow = minDripRate;
|
||||
TargetDripRate = m_minimumFlow;
|
||||
AdjustedDripRate = m_minimumFlow;
|
||||
}
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Reliable packets sent to the client for which we never received an ack adjust the drip rate down.
|
||||
// </summary>
|
||||
public void ExpirePackets(Int32 count)
|
||||
/// <summary>
|
||||
/// Reliable packets sent to the client for which we never received an ack adjust the drip rate down.
|
||||
/// <param name="packets">Number of packets that expired without successful delivery</param>
|
||||
/// </summary>
|
||||
public void ExpirePackets(Int32 packets)
|
||||
{
|
||||
if (AdaptiveEnabled)
|
||||
{
|
||||
if (DebugLevel > 0)
|
||||
m_log.WarnFormat(
|
||||
"[ADAPTIVEBUCKET] drop {0} by {1} expired packets for {2}",
|
||||
AdjustedDripRate, count, Identifier);
|
||||
AdjustedDripRate, packets, Identifier);
|
||||
|
||||
AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count));
|
||||
AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,packets));
|
||||
}
|
||||
}
|
||||
|
||||
// <summary>
|
||||
// Reliable packets acked by the client adjust the drip rate up.
|
||||
// </summary>
|
||||
public void AcknowledgePackets(Int32 count)
|
||||
/// <summary>
|
||||
/// Reliable packets acked by the client adjust the drip rate up.
|
||||
/// <param name="bytes">Number of bytes acknowledged</param>
|
||||
/// </summary>
|
||||
public void AcknowledgePackets(Int32 bytes)
|
||||
{
|
||||
if (AdaptiveEnabled)
|
||||
AdjustedDripRate = AdjustedDripRate + count;
|
||||
AdjustedDripRate = AdjustedDripRate + bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user