diff options
author | teravus | 2012-11-17 03:47:09 -0500 |
---|---|---|
committer | teravus | 2012-11-17 03:47:09 -0500 |
commit | 5e0294815f7e3ec83b7e568e1468948ac0ff7331 (patch) | |
tree | d6a436877fd6df204bbe99f22d896947d58f5aed /OpenSim/Region | |
parent | Revert "Merge master into teravuswork", it should have been avination, not ma... (diff) | |
download | opensim-SC-5e0294815f7e3ec83b7e568e1468948ac0ff7331.zip opensim-SC-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.gz opensim-SC-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.bz2 opensim-SC-5e0294815f7e3ec83b7e568e1468948ac0ff7331.tar.xz |
* Plumbing and basic setting of the GetMesh Cap Throttler.
* Last step is to flip the throttle distribution.
Diffstat (limited to 'OpenSim/Region')
5 files changed, 99 insertions, 18 deletions
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]; |