diff options
Merge branch 'avination' into careminster
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 90 |
1 files changed, 72 insertions, 18 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index e6d7db8..d2c2ab2 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 | } |