Fix an issue where specifying both max client and server outgoing UDP throttles would cause client throttles to be lower than expected when total requests exceeded the scene limit.

This was because specifying a max client throttle would always request the max from the parent server throttle, no matter the actual total requests on the client throttle.
This would lead to a lower server multiplier than expected.
This change also adds a 'target' column to the "show throttles" output that shows the target rate (as set by client) if adaptive throttles is active.
This commit also re-adds the functionality lost in recent 5c1a1458 to set a max client throttle when adaptive is active.
This commit also adds TestClientThrottlePerClientAndRegionLimited and TestClientThrottleAdaptiveNoLimit regression tests
This commit is contained in:
Justin Clark-Casey (justincc)
2014-10-10 23:36:50 +01:00
parent ead32de790
commit d33964222a
8 changed files with 296 additions and 82 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse.Packets;
using OpenSim.Framework;
@@ -67,7 +68,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);
LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
// udpClient.ThrottleDebugLevel = 1;
udpServer.Throttle.DebugLevel = 1;
udpClient.ThrottleDebugLevel = 1;
int resendBytes = 1000;
int landBytes = 2000;
@@ -83,7 +86,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
ClientInfo ci = udpClient.GetClientInfo();
// We expect this to be lower because of the minimum bound set by MTU
float totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;
int totalBytes = LLUDPServer.MTU + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;
Assert.AreEqual(LLUDPServer.MTU, ci.resendThrottle);
Assert.AreEqual(landBytes, ci.landThrottle);
Assert.AreEqual(windBytes, ci.windThrottle);
@@ -92,6 +95,66 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
Assert.AreEqual(textureBytes, ci.textureThrottle);
Assert.AreEqual(assetBytes, ci.assetThrottle);
Assert.AreEqual(totalBytes, ci.totalThrottle);
Assert.AreEqual(0, ci.maxThrottle);
}
[Test]
public void TestClientThrottleAdaptiveNoLimit()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
Scene scene = new SceneHelpers().SetupScene();
IniConfigSource ics = new IniConfigSource();
IConfig config = ics.AddConfig("ClientStack.LindenUDP");
config.Set("enable_adaptive_throttles", true);
TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene, ics);
ScenePresence sp
= ClientStackHelpers.AddChildClient(
scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);
LLUDPClient udpClient = ((LLClientView)sp.ControllingClient).UDPClient;
udpServer.Throttle.DebugLevel = 1;
udpClient.ThrottleDebugLevel = 1;
// Total is 28000
int resendBytes = 10000;
int landBytes = 20000;
int windBytes = 30000;
int cloudBytes = 40000;
int taskBytes = 50000;
int textureBytes = 60000;
int assetBytes = 70000;
SetThrottles(
udpClient, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);
ClientInfo ci = udpClient.GetClientInfo();
// We expect individual throttle changes to currently have no effect under adaptive, since this is managed
// purely by that throttle. However, we expect the max to change.
// XXX: At the moment we check against defaults, but at some point there should be a better test to
// active see change over time.
ThrottleRates defaultRates = udpServer.ThrottleRates;
// Current total is 66750
int totalBytes = defaultRates.Resend + defaultRates.Land + defaultRates.Wind + defaultRates.Cloud + defaultRates.Task + defaultRates.Texture + defaultRates.Asset;
int totalMaxBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;
Assert.AreEqual(0, ci.maxThrottle);
Assert.AreEqual(totalMaxBytes, ci.targetThrottle);
Assert.AreEqual(defaultRates.Resend, ci.resendThrottle);
Assert.AreEqual(defaultRates.Land, ci.landThrottle);
Assert.AreEqual(defaultRates.Wind, ci.windThrottle);
Assert.AreEqual(defaultRates.Cloud, ci.cloudThrottle);
Assert.AreEqual(defaultRates.Task, ci.taskThrottle);
Assert.AreEqual(defaultRates.Texture, ci.textureThrottle);
Assert.AreEqual(defaultRates.Asset, ci.assetThrottle);
Assert.AreEqual(totalBytes, ci.totalThrottle);
}
/// <summary>
@@ -238,6 +301,101 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
Assert.AreEqual(totalBytes, ci.totalThrottle);
}
[Test]
public void TestClientThrottlePerClientAndRegionLimited()
{
TestHelpers.InMethod();
//TestHelpers.EnableLogging();
int resendBytes = 4000;
int landBytes = 6000;
int windBytes = 8000;
int cloudBytes = 10000;
int taskBytes = 12000;
int textureBytes = 14000;
int assetBytes = 16000;
// current total 70000
int totalBytes = resendBytes + landBytes + windBytes + cloudBytes + taskBytes + textureBytes + assetBytes;
Scene scene = new SceneHelpers().SetupScene();
TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(scene);
udpServer.ThrottleRates.Total = (int)(totalBytes * 1.1);
udpServer.Throttle.RequestedDripRate = (int)(totalBytes * 1.5);
ScenePresence sp1
= ClientStackHelpers.AddChildClient(
scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);
LLUDPClient udpClient1 = ((LLClientView)sp1.ControllingClient).UDPClient;
udpClient1.ThrottleDebugLevel = 1;
SetThrottles(
udpClient1, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);
{
ClientInfo ci = udpClient1.GetClientInfo();
// Console.WriteLine(
// "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}",
// ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle);
Assert.AreEqual(resendBytes, ci.resendThrottle);
Assert.AreEqual(landBytes, ci.landThrottle);
Assert.AreEqual(windBytes, ci.windThrottle);
Assert.AreEqual(cloudBytes, ci.cloudThrottle);
Assert.AreEqual(taskBytes, ci.taskThrottle);
Assert.AreEqual(textureBytes, ci.textureThrottle);
Assert.AreEqual(assetBytes, ci.assetThrottle);
Assert.AreEqual(totalBytes, ci.totalThrottle);
}
// Now add another client
ScenePresence sp2
= ClientStackHelpers.AddChildClient(
scene, udpServer, TestHelpers.ParseTail(0x10), TestHelpers.ParseTail(0x20), 123457);
LLUDPClient udpClient2 = ((LLClientView)sp2.ControllingClient).UDPClient;
udpClient2.ThrottleDebugLevel = 1;
SetThrottles(
udpClient2, resendBytes, landBytes, windBytes, cloudBytes, taskBytes, textureBytes, assetBytes);
{
ClientInfo ci = udpClient1.GetClientInfo();
// Console.WriteLine(
// "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}",
// ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle);
Assert.AreEqual(resendBytes * 0.75, ci.resendThrottle);
Assert.AreEqual(landBytes * 0.75, ci.landThrottle);
Assert.AreEqual(windBytes * 0.75, ci.windThrottle);
Assert.AreEqual(cloudBytes * 0.75, ci.cloudThrottle);
Assert.AreEqual(taskBytes * 0.75, ci.taskThrottle);
Assert.AreEqual(textureBytes * 0.75, ci.textureThrottle);
Assert.AreEqual(assetBytes * 0.75, ci.assetThrottle);
Assert.AreEqual(totalBytes * 0.75, ci.totalThrottle);
}
{
ClientInfo ci = udpClient2.GetClientInfo();
// Console.WriteLine(
// "Resend={0}, Land={1}, Wind={2}, Cloud={3}, Task={4}, Texture={5}, Asset={6}, TOTAL = {7}",
// ci.resendThrottle, ci.landThrottle, ci.windThrottle, ci.cloudThrottle, ci.taskThrottle, ci.textureThrottle, ci.assetThrottle, ci.totalThrottle);
Assert.AreEqual(resendBytes * 0.75, ci.resendThrottle);
Assert.AreEqual(landBytes * 0.75, ci.landThrottle);
Assert.AreEqual(windBytes * 0.75, ci.windThrottle);
Assert.AreEqual(cloudBytes * 0.75, ci.cloudThrottle);
Assert.AreEqual(taskBytes * 0.75, ci.taskThrottle);
Assert.AreEqual(textureBytes * 0.75, ci.textureThrottle);
Assert.AreEqual(assetBytes * 0.75, ci.assetThrottle);
Assert.AreEqual(totalBytes * 0.75, ci.totalThrottle);
}
}
private void SetThrottles(
LLUDPClient udpClient, int resendBytes, int landBytes, int windBytes, int cloudBytes, int taskBytes, int textureBytes, int assetBytes)
{