aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorteravus2012-11-17 03:47:09 -0500
committerteravus2012-11-17 03:47:09 -0500
commit5e0294815f7e3ec83b7e568e1468948ac0ff7331 (patch)
treed6a436877fd6df204bbe99f22d896947d58f5aed /OpenSim
parentRevert "Merge master into teravuswork", it should have been avination, not ma... (diff)
downloadopensim-SC_OLD-5e0294815f7e3ec83b7e568e1468948ac0ff7331.zip
opensim-SC_OLD-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.gz
opensim-SC_OLD-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.bz2
opensim-SC_OLD-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.xz
* Plumbing and basic setting of the GetMesh Cap Throttler.
* Last step is to flip the throttle distribution.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs21
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs90
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs12
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs5
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs6
8 files changed, 127 insertions, 19 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
index da59294..380705f 100644
--- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
@@ -152,6 +152,7 @@ namespace OpenSim.Capabilities.Handlers
152 responsedata["keepalive"] = false; 152 responsedata["keepalive"] = false;
153 responsedata["str_response_string"] = "This range doesnt exist."; 153 responsedata["str_response_string"] = "This range doesnt exist.";
154 responsedata["reusecontext"] = false; 154 responsedata["reusecontext"] = false;
155 responsedata["int_lod"] = 3;
155 return responsedata; 156 return responsedata;
156 } 157 }
157 else 158 else
@@ -162,14 +163,28 @@ namespace OpenSim.Capabilities.Handlers
162 163
163 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); 164 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
164 165
165 166 if (start > 20000)
167 {
168 responsedata["int_lod"] = 3;
169 }
170 else if (start < 4097)
171 {
172 responsedata["int_lod"] = 1;
173 }
174 else
175 {
176 responsedata["int_lod"] = 2;
177 }
166 178
179
167 if (start == 0 && len == mesh.Data.Length) // well redudante maybe 180 if (start == 0 && len == mesh.Data.Length) // well redudante maybe
168 { 181 {
169 responsedata["int_response_code"] = (int) System.Net.HttpStatusCode.OK; 182 responsedata["int_response_code"] = (int) System.Net.HttpStatusCode.OK;
170 responsedata["bin_response_data"] = mesh.Data; 183 responsedata["bin_response_data"] = mesh.Data;
171 responsedata["int_bytes"] = mesh.Data.Length; 184 responsedata["int_bytes"] = mesh.Data.Length;
172 responsedata["reusecontext"] = false; 185 responsedata["reusecontext"] = false;
186 responsedata["int_lod"] = 3;
187
173 } 188 }
174 else 189 else
175 { 190 {
@@ -193,6 +208,7 @@ namespace OpenSim.Capabilities.Handlers
193 responsedata["content_type"] = "application/vnd.ll.mesh"; 208 responsedata["content_type"] = "application/vnd.ll.mesh";
194 responsedata["int_response_code"] = 200; 209 responsedata["int_response_code"] = 200;
195 responsedata["reusecontext"] = false; 210 responsedata["reusecontext"] = false;
211 responsedata["int_lod"] = 3;
196 } 212 }
197 } 213 }
198 else 214 else
@@ -201,6 +217,7 @@ namespace OpenSim.Capabilities.Handlers
201 responsedata["content_type"] = "application/vnd.ll.mesh"; 217 responsedata["content_type"] = "application/vnd.ll.mesh";
202 responsedata["int_response_code"] = 200; 218 responsedata["int_response_code"] = 200;
203 responsedata["reusecontext"] = false; 219 responsedata["reusecontext"] = false;
220 responsedata["int_lod"] = 3;
204 } 221 }
205 } 222 }
206 // Optionally add additional mesh types here 223 // Optionally add additional mesh types here
@@ -211,6 +228,7 @@ namespace OpenSim.Capabilities.Handlers
211 responsedata["keepalive"] = false; 228 responsedata["keepalive"] = false;
212 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; 229 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
213 responsedata["reusecontext"] = false; 230 responsedata["reusecontext"] = false;
231 responsedata["int_lod"] = 1;
214 return responsedata; 232 return responsedata;
215 } 233 }
216 } 234 }
@@ -221,6 +239,7 @@ namespace OpenSim.Capabilities.Handlers
221 responsedata["keepalive"] = false; 239 responsedata["keepalive"] = false;
222 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; 240 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
223 responsedata["reusecontext"] = false; 241 responsedata["reusecontext"] = false;
242 responsedata["int_lod"] = 0;
224 return responsedata; 243 return responsedata;
225 } 244 }
226 } 245 }
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index e31c7f6..6559638 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1135,6 +1135,8 @@ namespace OpenSim.Framework
1135 1135
1136 void SetChildAgentThrottle(byte[] throttle); 1136 void SetChildAgentThrottle(byte[] throttle);
1137 1137
1138 void SetAgentThrottleSilent(int throttle, int setting);
1139
1138 void SendAvatarDataImmediate(ISceneEntity avatar); 1140 void SendAvatarDataImmediate(ISceneEntity avatar);
1139 1141
1140 /// <summary> 1142 /// <summary>
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
60 private IAssetService m_AssetService; 60 private IAssetService m_AssetService;
61 private bool m_Enabled = true; 61 private bool m_Enabled = true;
62 private string m_URL; 62 private string m_URL;
63
63 struct aPollRequest 64 struct aPollRequest
64 { 65 {
65 public PollServiceMeshEventArgs thepoll; 66 public PollServiceMeshEventArgs thepoll;
@@ -71,6 +72,7 @@ namespace OpenSim.Region.ClientStack.Linden
71 { 72 {
72 public Hashtable response; 73 public Hashtable response;
73 public int bytes; 74 public int bytes;
75 public int lod;
74 } 76 }
75 77
76 78
@@ -112,6 +114,7 @@ namespace OpenSim.Region.ClientStack.Linden
112 // Cap doesn't exist 114 // Cap doesn't exist
113 if (m_URL != string.Empty) 115 if (m_URL != string.Empty)
114 m_Enabled = true; 116 m_Enabled = true;
117
115 } 118 }
116 119
117 public void AddRegion(Scene pScene) 120 public void AddRegion(Scene pScene)
@@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden
192 PollServiceMeshEventArgs args; 195 PollServiceMeshEventArgs args;
193 if (m_pollservices.TryGetValue(user, out args)) 196 if (m_pollservices.TryGetValue(user, out args))
194 { 197 {
195 args.UpdateThrottle(imagethrottle); 198 args.UpdateThrottle(imagethrottle, p);
196 } 199 }
197 } 200 }
198 201
@@ -242,11 +245,12 @@ namespace OpenSim.Region.ClientStack.Linden
242 new Dictionary<UUID, aPollResponse>(); 245 new Dictionary<UUID, aPollResponse>();
243 246
244 private Scene m_scene; 247 private Scene m_scene;
245 private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000, 10000); 248 private MeshCapsDataThrottler m_throttler;
246 public PollServiceMeshEventArgs(UUID pId, Scene scene) : 249 public PollServiceMeshEventArgs(UUID pId, Scene scene) :
247 base(null, null, null, null, pId, int.MaxValue) 250 base(null, null, null, null, pId, int.MaxValue)
248 { 251 {
249 m_scene = scene; 252 m_scene = scene;
253 m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene);
250 // x is request id, y is userid 254 // x is request id, y is userid
251 HasEvents = (x, y) => 255 HasEvents = (x, y) =>
252 { 256 {
@@ -268,6 +272,7 @@ namespace OpenSim.Region.ClientStack.Linden
268 } 272 }
269 finally 273 finally
270 { 274 {
275 m_throttler.ProcessTime();
271 responses.Remove(x); 276 responses.Remove(x);
272 } 277 }
273 } 278 }
@@ -323,7 +328,7 @@ namespace OpenSim.Region.ClientStack.Linden
323 response["reusecontext"] = false; 328 response["reusecontext"] = false;
324 329
325 lock (responses) 330 lock (responses)
326 responses[requestID] = new aPollResponse() { bytes = 0, response = response }; 331 responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 };
327 332
328 return; 333 return;
329 } 334 }
@@ -334,6 +339,7 @@ namespace OpenSim.Region.ClientStack.Linden
334 responses[requestID] = new aPollResponse() 339 responses[requestID] = new aPollResponse()
335 { 340 {
336 bytes = (int)response["int_bytes"], 341 bytes = (int)response["int_bytes"],
342 lod = (int)response["int_lod"],
337 response = response 343 response = response
338 }; 344 };
339 345
@@ -341,9 +347,9 @@ namespace OpenSim.Region.ClientStack.Linden
341 m_throttler.ProcessTime(); 347 m_throttler.ProcessTime();
342 } 348 }
343 349
344 internal void UpdateThrottle(int pimagethrottle) 350 internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
345 { 351 {
346 m_throttler.ThrottleBytes = pimagethrottle; 352 m_throttler.UpdateThrottle(pimagethrottle, p);
347 } 353 }
348 } 354 }
349 355
@@ -398,18 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden
398 } 404 }
399 } 405 }
400 406
401 internal sealed class CapsDataThrottler 407 internal sealed class MeshCapsDataThrottler
402 { 408 {
403 409
404 private volatile int currenttime = 0; 410 private volatile int currenttime = 0;
405 private volatile int lastTimeElapsed = 0; 411 private volatile int lastTimeElapsed = 0;
406 private volatile int BytesSent = 0; 412 private volatile int BytesSent = 0;
407 private int oversizedImages = 0; 413 private int Lod3 = 0;
408 public CapsDataThrottler(int pBytes, int max, int min) 414 private int Lod2 = 0;
415 private int Lod1 = 0;
416 private int UserSetThrottle = 0;
417 private int UDPSetThrottle = 0;
418 private int CapSetThrottle = 0;
419 private float CapThrottleDistributon = 0.30f;
420 private readonly Scene m_scene;
421 private ThrottleOutPacketType Throttle;
422
423 public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene)
409 { 424 {
410 ThrottleBytes = pBytes; 425 ThrottleBytes = pBytes;
411 lastTimeElapsed = Util.EnvironmentTickCount(); 426 lastTimeElapsed = Util.EnvironmentTickCount();
427 Throttle = ThrottleOutPacketType.Task;
428 m_scene = pScene;
412 } 429 }
430
431
413 public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) 432 public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
414 { 433 {
415 PassTime(); 434 PassTime();
@@ -427,17 +446,23 @@ namespace OpenSim.Region.ClientStack.Linden
427 if (BytesSent + response.bytes <= ThrottleBytes) 446 if (BytesSent + response.bytes <= ThrottleBytes)
428 { 447 {
429 BytesSent += response.bytes; 448 BytesSent += response.bytes;
430 //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; 449
431 //m_actions.Add(timeBasedAction); 450 return true;
451 }
452 // Lod3 Over
453 else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1))
454 {
455 Interlocked.Increment(ref Lod3);
456 BytesSent += response.bytes;
457
432 return true; 458 return true;
433 } 459 }
434 // Big textures 460 // Lod2 Over
435 else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) 461 else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1))
436 { 462 {
437 Interlocked.Increment(ref oversizedImages); 463 Interlocked.Increment(ref Lod2);
438 BytesSent += response.bytes; 464 BytesSent += response.bytes;
439 //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; 465
440 //m_actions.Add(timeBasedAction);
441 return true; 466 return true;
442 } 467 }
443 else 468 else
@@ -448,6 +473,11 @@ namespace OpenSim.Region.ClientStack.Linden
448 473
449 return haskey; 474 return haskey;
450 } 475 }
476 public void SubtractBytes(int bytes,int lod)
477 {
478 BytesSent -= bytes;
479 }
480
451 public void ProcessTime() 481 public void ProcessTime()
452 { 482 {
453 PassTime(); 483 PassTime();
@@ -459,18 +489,42 @@ namespace OpenSim.Region.ClientStack.Linden
459 currenttime = Util.EnvironmentTickCount(); 489 currenttime = Util.EnvironmentTickCount();
460 int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); 490 int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
461 //processTimeBasedActions(responses); 491 //processTimeBasedActions(responses);
462 if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) 492 if (currenttime - timeElapsed >= 1000)
463 { 493 {
464 lastTimeElapsed = Util.EnvironmentTickCount(); 494 lastTimeElapsed = Util.EnvironmentTickCount();
465 BytesSent -= ThrottleBytes; 495 BytesSent -= ThrottleBytes;
466 if (BytesSent < 0) BytesSent = 0; 496 if (BytesSent < 0) BytesSent = 0;
467 if (BytesSent < ThrottleBytes) 497 if (BytesSent < ThrottleBytes)
468 { 498 {
469 oversizedImages = 0; 499 Lod3 = 0;
500 Lod2 = 0;
501 Lod1 = 0;
470 } 502 }
471 } 503 }
472 } 504 }
473 public int ThrottleBytes; 505 private void AlterThrottle(int setting, ScenePresence p)
506 {
507 p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
508 }
509
510 public int ThrottleBytes
511 {
512 get { return CapSetThrottle; }
513 set { CapSetThrottle = value; }
514 }
515
516 internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
517 {
518 // Client set throttle !
519 UserSetThrottle = pimagethrottle;
520 CapSetThrottle = (int)(pimagethrottle*CapThrottleDistributon);
521 UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon));
522 if (CapSetThrottle < 4068)
523 CapSetThrottle = 4068; // at least two discovery mesh
524 p.ControllingClient.SetAgentThrottleSilent((int) Throttle, UDPSetThrottle);
525 ProcessTime();
526
527 }
474 } 528 }
475 529
476 } 530 }
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
11884 } 11884 }
11885 11885
11886 /// <summary> 11886 /// <summary>
11887 /// Sets the throttles from values supplied by the client
11888 /// </summary>
11889 /// <param name="throttles"></param>
11890 public void SetAgentThrottleSilent(int throttle, int setting)
11891 {
11892 m_udpClient.ForceThrottleSetting(throttle,setting);
11893 //m_udpClient.SetThrottles(throttles);
11894
11895 }
11896
11897
11898 /// <summary>
11887 /// Get the current throttles for this client as a packed byte array 11899 /// Get the current throttles for this client as a packed byte array
11888 /// </summary> 11900 /// </summary>
11889 /// <param name="multiplier">Unused</param> 11901 /// <param name="multiplier">Unused</param>
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
682 if (m_nextOnQueueEmpty == 0) 682 if (m_nextOnQueueEmpty == 0)
683 m_nextOnQueueEmpty = 1; 683 m_nextOnQueueEmpty = 1;
684 } 684 }
685 internal void ForceThrottleSetting(int throttle, int setting)
686 {
687 m_throttleCategories[throttle].RequestedDripRate = Math.Max(setting, LLUDPServer.MTU); ;
688 }
685 689
686 /// <summary> 690 /// <summary>
687 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a 691 /// Converts a <seealso cref="ThrottleOutPacketType"/> integer to a
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 28b8293..563fd12 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -1428,6 +1428,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1428 1428
1429 } 1429 }
1430 1430
1431 public void SetAgentThrottleSilent(int throttle, int setting)
1432 {
1433
1434
1435 }
1431 public byte[] GetThrottlesPacked(float multiplier) 1436 public byte[] GetThrottlesPacked(float multiplier)
1432 { 1437 {
1433 return new byte[0]; 1438 return new byte[0];
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 6c8e2fc..ef53c48 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -597,6 +597,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC
597 public virtual void SetChildAgentThrottle(byte[] throttle) 597 public virtual void SetChildAgentThrottle(byte[] throttle)
598 { 598 {
599 } 599 }
600
601 public void SetAgentThrottleSilent(int throttle, int setting)
602 {
603
604
605 }
600 public byte[] GetThrottlesPacked(float multiplier) 606 public byte[] GetThrottlesPacked(float multiplier)
601 { 607 {
602 return new byte[0]; 608 return new byte[0];
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 78bb18e..d1af0fc 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -521,6 +521,12 @@ namespace OpenSim.Tests.Common.Mock
521 public virtual void SetChildAgentThrottle(byte[] throttle) 521 public virtual void SetChildAgentThrottle(byte[] throttle)
522 { 522 {
523 } 523 }
524
525 public void SetAgentThrottleSilent(int throttle, int setting)
526 {
527
528
529 }
524 public byte[] GetThrottlesPacked(float multiplier) 530 public byte[] GetThrottlesPacked(float multiplier)
525 { 531 {
526 return new byte[0]; 532 return new byte[0];