From 5e0294815f7e3ec83b7e568e1468948ac0ff7331 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 17 Nov 2012 03:47:09 -0500 Subject: * Plumbing and basic setting of the GetMesh Cap Throttler. * Last step is to flip the throttle distribution. --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 90 +++++++++++++++++----- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 12 +++ .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 4 + 3 files changed, 88 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 8deff81..96b48ad 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -60,6 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_AssetService; private bool m_Enabled = true; private string m_URL; + struct aPollRequest { public PollServiceMeshEventArgs thepoll; @@ -71,6 +72,7 @@ namespace OpenSim.Region.ClientStack.Linden { public Hashtable response; public int bytes; + public int lod; } @@ -112,6 +114,7 @@ namespace OpenSim.Region.ClientStack.Linden // Cap doesn't exist if (m_URL != string.Empty) m_Enabled = true; + } public void AddRegion(Scene pScene) @@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceMeshEventArgs args; if (m_pollservices.TryGetValue(user, out args)) { - args.UpdateThrottle(imagethrottle); + args.UpdateThrottle(imagethrottle, p); } } @@ -242,11 +245,12 @@ namespace OpenSim.Region.ClientStack.Linden new Dictionary(); private Scene m_scene; - private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000, 10000); + private MeshCapsDataThrottler m_throttler; public PollServiceMeshEventArgs(UUID pId, Scene scene) : base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; + m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene); // x is request id, y is userid HasEvents = (x, y) => { @@ -268,6 +272,7 @@ namespace OpenSim.Region.ClientStack.Linden } finally { + m_throttler.ProcessTime(); responses.Remove(x); } } @@ -323,7 +328,7 @@ namespace OpenSim.Region.ClientStack.Linden response["reusecontext"] = false; lock (responses) - responses[requestID] = new aPollResponse() { bytes = 0, response = response }; + responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; return; } @@ -334,6 +339,7 @@ namespace OpenSim.Region.ClientStack.Linden responses[requestID] = new aPollResponse() { bytes = (int)response["int_bytes"], + lod = (int)response["int_lod"], response = response }; @@ -341,9 +347,9 @@ namespace OpenSim.Region.ClientStack.Linden m_throttler.ProcessTime(); } - internal void UpdateThrottle(int pimagethrottle) + internal void UpdateThrottle(int pimagethrottle, ScenePresence p) { - m_throttler.ThrottleBytes = pimagethrottle; + m_throttler.UpdateThrottle(pimagethrottle, p); } } @@ -398,18 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden } } - internal sealed class CapsDataThrottler + internal sealed class MeshCapsDataThrottler { private volatile int currenttime = 0; private volatile int lastTimeElapsed = 0; private volatile int BytesSent = 0; - private int oversizedImages = 0; - public CapsDataThrottler(int pBytes, int max, int min) + private int Lod3 = 0; + private int Lod2 = 0; + private int Lod1 = 0; + private int UserSetThrottle = 0; + private int UDPSetThrottle = 0; + private int CapSetThrottle = 0; + private float CapThrottleDistributon = 0.30f; + private readonly Scene m_scene; + private ThrottleOutPacketType Throttle; + + public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene) { ThrottleBytes = pBytes; lastTimeElapsed = Util.EnvironmentTickCount(); + Throttle = ThrottleOutPacketType.Task; + m_scene = pScene; } + + public bool hasEvents(UUID key, Dictionary responses) { PassTime(); @@ -427,17 +446,23 @@ namespace OpenSim.Region.ClientStack.Linden if (BytesSent + response.bytes <= ThrottleBytes) { BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; - //m_actions.Add(timeBasedAction); + + return true; + } + // Lod3 Over + else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1)) + { + Interlocked.Increment(ref Lod3); + BytesSent += response.bytes; + return true; } - // Big textures - else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) + // Lod2 Over + else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1)) { - Interlocked.Increment(ref oversizedImages); + Interlocked.Increment(ref Lod2); BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; - //m_actions.Add(timeBasedAction); + return true; } else @@ -448,6 +473,11 @@ namespace OpenSim.Region.ClientStack.Linden return haskey; } + public void SubtractBytes(int bytes,int lod) + { + BytesSent -= bytes; + } + public void ProcessTime() { PassTime(); @@ -459,18 +489,42 @@ namespace OpenSim.Region.ClientStack.Linden currenttime = Util.EnvironmentTickCount(); int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); //processTimeBasedActions(responses); - if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) + if (currenttime - timeElapsed >= 1000) { lastTimeElapsed = Util.EnvironmentTickCount(); BytesSent -= ThrottleBytes; if (BytesSent < 0) BytesSent = 0; if (BytesSent < ThrottleBytes) { - oversizedImages = 0; + Lod3 = 0; + Lod2 = 0; + Lod1 = 0; } } } - public int ThrottleBytes; + private void AlterThrottle(int setting, ScenePresence p) + { + p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); + } + + public int ThrottleBytes + { + get { return CapSetThrottle; } + set { CapSetThrottle = value; } + } + + internal void UpdateThrottle(int pimagethrottle, ScenePresence p) + { + // Client set throttle ! + UserSetThrottle = pimagethrottle; + CapSetThrottle = (int)(pimagethrottle*CapThrottleDistributon); + UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); + if (CapSetThrottle < 4068) + CapSetThrottle = 4068; // at least two discovery mesh + p.ControllingClient.SetAgentThrottleSilent((int) Throttle, UDPSetThrottle); + ProcessTime(); + + } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index ae9ed7f..533a1a8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -11884,6 +11884,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// + /// Sets the throttles from values supplied by the client + /// + /// + public void SetAgentThrottleSilent(int throttle, int setting) + { + m_udpClient.ForceThrottleSetting(throttle,setting); + //m_udpClient.SetThrottles(throttles); + + } + + + /// /// Get the current throttles for this client as a packed byte array /// /// Unused diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index c472176..f675377 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -682,6 +682,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_nextOnQueueEmpty == 0) m_nextOnQueueEmpty = 1; } + internal void ForceThrottleSetting(int throttle, int setting) + { + m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); ; + } /// /// Converts a integer to a -- cgit v1.1