diff options
author | UbitUmarov | 2017-06-19 05:22:38 +0100 |
---|---|---|
committer | UbitUmarov | 2017-06-19 05:22:38 +0100 |
commit | 79e166e9aaf56b6798e27201962f6e109925c697 (patch) | |
tree | 4b2dfcc5f59b3def086e7eeafec85ff1fae7a721 /OpenSim | |
parent | a defual can me comented out (diff) | |
download | opensim-SC-79e166e9aaf56b6798e27201962f6e109925c697.zip opensim-SC-79e166e9aaf56b6798e27201962f6e109925c697.tar.gz opensim-SC-79e166e9aaf56b6798e27201962f6e109925c697.tar.bz2 opensim-SC-79e166e9aaf56b6798e27201962f6e109925c697.tar.xz |
revert EnvironmentTick back to orignal clock, since change may cause issues on some code paths. Clean a bit get mesh and get texture throttle
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 81 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 45 |
3 files changed, 49 insertions, 84 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index a855767..af14939 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -2967,9 +2967,9 @@ namespace OpenSim.Framework | |||
2967 | /// <returns></returns> | 2967 | /// <returns></returns> |
2968 | public static Int32 EnvironmentTickCount() | 2968 | public static Int32 EnvironmentTickCount() |
2969 | { | 2969 | { |
2970 | double now = GetTimeStampMS(); | 2970 | return Environment.TickCount & EnvironmentTickCountMask; |
2971 | return (int)now; | ||
2972 | } | 2971 | } |
2972 | |||
2973 | const Int32 EnvironmentTickCountMask = 0x3fffffff; | 2973 | const Int32 EnvironmentTickCountMask = 0x3fffffff; |
2974 | 2974 | ||
2975 | /// <summary> | 2975 | /// <summary> |
@@ -2994,8 +2994,7 @@ namespace OpenSim.Framework | |||
2994 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> | 2994 | /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns> |
2995 | public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) | 2995 | public static Int32 EnvironmentTickCountSubtract(Int32 prevValue) |
2996 | { | 2996 | { |
2997 | double now = GetTimeStampMS(); | 2997 | return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue); |
2998 | return EnvironmentTickCountSubtract((int)now, prevValue); | ||
2999 | } | 2998 | } |
3000 | 2999 | ||
3001 | // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount | 3000 | // Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index a721454..ba917e39 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -221,7 +221,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
221 | PollServiceMeshEventArgs args; | 221 | PollServiceMeshEventArgs args; |
222 | if (m_pollservices.TryGetValue(user, out args)) | 222 | if (m_pollservices.TryGetValue(user, out args)) |
223 | { | 223 | { |
224 | args.UpdateThrottle(imagethrottle, p); | 224 | args.UpdateThrottle(imagethrottle); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
@@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
238 | base(null, uri, null, null, null, pId, int.MaxValue) | 238 | base(null, uri, null, null, null, pId, int.MaxValue) |
239 | { | 239 | { |
240 | m_scene = scene; | 240 | m_scene = scene; |
241 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); | 241 | m_throttler = new MeshCapsDataThrottler(100000); |
242 | // x is request id, y is userid | 242 | // x is request id, y is userid |
243 | HasEvents = (x, y) => | 243 | HasEvents = (x, y) => |
244 | { | 244 | { |
245 | lock (responses) | 245 | lock (responses) |
246 | { | 246 | { |
247 | bool ret = m_throttler.hasEvents(x, responses); | 247 | bool ret = m_throttler.hasEvents(x, responses); |
248 | m_throttler.ProcessTime(); | ||
249 | return ret; | 248 | return ret; |
250 | 249 | ||
251 | } | 250 | } |
@@ -260,8 +259,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
260 | } | 259 | } |
261 | finally | 260 | finally |
262 | { | 261 | { |
263 | m_throttler.ProcessTime(); | ||
264 | responses.Remove(x); | 262 | responses.Remove(x); |
263 | m_throttler.PassTime(); | ||
265 | } | 264 | } |
266 | } | 265 | } |
267 | }; | 266 | }; |
@@ -274,6 +273,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
274 | reqinfo.request = y; | 273 | reqinfo.request = y; |
275 | 274 | ||
276 | m_queue.Enqueue(reqinfo); | 275 | m_queue.Enqueue(reqinfo); |
276 | m_throttler.PassTime(); | ||
277 | }; | 277 | }; |
278 | 278 | ||
279 | // this should never happen except possible on shutdown | 279 | // this should never happen except possible on shutdown |
@@ -335,12 +335,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
335 | }; | 335 | }; |
336 | 336 | ||
337 | } | 337 | } |
338 | m_throttler.ProcessTime(); | 338 | m_throttler.PassTime(); |
339 | } | 339 | } |
340 | 340 | ||
341 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | 341 | internal void UpdateThrottle(int pthrottle) |
342 | { | 342 | { |
343 | m_throttler.UpdateThrottle(pimagethrottle, p); | 343 | int tmp = 2 * pthrottle; |
344 | if(tmp < 10000) | ||
345 | tmp = 10000; | ||
346 | m_throttler.ThrottleBytes = tmp; | ||
344 | } | 347 | } |
345 | } | 348 | } |
346 | 349 | ||
@@ -394,25 +397,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
394 | 397 | ||
395 | internal sealed class MeshCapsDataThrottler | 398 | internal sealed class MeshCapsDataThrottler |
396 | { | 399 | { |
400 | private double lastTimeElapsed = 0; | ||
401 | private double BytesSent = 0; | ||
397 | 402 | ||
398 | private volatile int currenttime = 0; | 403 | public MeshCapsDataThrottler(int pBytes) |
399 | private volatile int lastTimeElapsed = 0; | ||
400 | private volatile int BytesSent = 0; | ||
401 | private int CapSetThrottle = 0; | ||
402 | private float CapThrottleDistributon = 0.30f; | ||
403 | private readonly Scene m_scene; | ||
404 | private ThrottleOutPacketType Throttle; | ||
405 | private readonly UUID User; | ||
406 | |||
407 | public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser) | ||
408 | { | 404 | { |
405 | if(pBytes < 10000) | ||
406 | pBytes = 10000; | ||
409 | ThrottleBytes = pBytes; | 407 | ThrottleBytes = pBytes; |
410 | if(ThrottleBytes < 10000) | 408 | lastTimeElapsed = Util.GetTimeStampMS(); |
411 | ThrottleBytes = 10000; | ||
412 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
413 | Throttle = ThrottleOutPacketType.Asset; | ||
414 | m_scene = pScene; | ||
415 | User = puser; | ||
416 | } | 409 | } |
417 | 410 | ||
418 | public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) | 411 | public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) |
@@ -442,46 +435,22 @@ namespace OpenSim.Region.ClientStack.Linden | |||
442 | return haskey; | 435 | return haskey; |
443 | } | 436 | } |
444 | 437 | ||
445 | public void ProcessTime() | 438 | public void PassTime() |
446 | { | ||
447 | PassTime(); | ||
448 | } | ||
449 | |||
450 | private void PassTime() | ||
451 | { | 439 | { |
452 | currenttime = Util.EnvironmentTickCount(); | 440 | double currenttime = Util.GetTimeStampMS(); |
453 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | 441 | double timeElapsed = currenttime - lastTimeElapsed; |
454 | if (timeElapsed >= 100) | 442 | if(timeElapsed < 50.0) |
443 | return; | ||
444 | int add = (int)(ThrottleBytes * timeElapsed * 0.001); | ||
445 | if (add >= 1000) | ||
455 | { | 446 | { |
456 | lastTimeElapsed = currenttime; | 447 | lastTimeElapsed = currenttime; |
457 | BytesSent -= (ThrottleBytes * timeElapsed / 1000); | 448 | BytesSent -= add; |
458 | if (BytesSent < 0) BytesSent = 0; | 449 | if (BytesSent < 0) BytesSent = 0; |
459 | } | 450 | } |
460 | } | 451 | } |
461 | 452 | ||
462 | private void AlterThrottle(int setting, ScenePresence p) | 453 | public int ThrottleBytes; |
463 | { | ||
464 | p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); | ||
465 | } | ||
466 | |||
467 | public int ThrottleBytes | ||
468 | { | ||
469 | get { return CapSetThrottle; } | ||
470 | set | ||
471 | { | ||
472 | if (value > 10000) | ||
473 | CapSetThrottle = value; | ||
474 | else | ||
475 | CapSetThrottle = 10000; | ||
476 | } | ||
477 | } | ||
478 | |||
479 | internal void UpdateThrottle(int pimagethrottle, ScenePresence p) | ||
480 | { | ||
481 | // Client set throttle ! | ||
482 | CapSetThrottle = 2 * pimagethrottle; | ||
483 | ProcessTime(); | ||
484 | } | ||
485 | } | 454 | } |
486 | } | 455 | } |
487 | } | 456 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index ce9798b..b01c7dc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
220 | new Dictionary<UUID, aPollResponse>(); | 220 | new Dictionary<UUID, aPollResponse>(); |
221 | 221 | ||
222 | private Scene m_scene; | 222 | private Scene m_scene; |
223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); | 223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000); |
224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : | 224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : |
225 | base(null, "", null, null, null, pId, int.MaxValue) | 225 | base(null, "", null, null, null, pId, int.MaxValue) |
226 | { | 226 | { |
@@ -231,7 +231,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
231 | lock (responses) | 231 | lock (responses) |
232 | { | 232 | { |
233 | bool ret = m_throttler.hasEvents(x, responses); | 233 | bool ret = m_throttler.hasEvents(x, responses); |
234 | m_throttler.ProcessTime(); | ||
235 | return ret; | 234 | return ret; |
236 | 235 | ||
237 | } | 236 | } |
@@ -247,6 +246,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
247 | finally | 246 | finally |
248 | { | 247 | { |
249 | responses.Remove(x); | 248 | responses.Remove(x); |
249 | m_throttler.PassTime(); | ||
250 | } | 250 | } |
251 | } | 251 | } |
252 | }; | 252 | }; |
@@ -271,6 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
271 | } | 271 | } |
272 | } | 272 | } |
273 | m_queue.Enqueue(reqinfo); | 273 | m_queue.Enqueue(reqinfo); |
274 | m_throttler.PassTime(); | ||
274 | }; | 275 | }; |
275 | 276 | ||
276 | // this should never happen except possible on shutdown | 277 | // this should never happen except possible on shutdown |
@@ -351,14 +352,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
351 | }; | 352 | }; |
352 | 353 | ||
353 | } | 354 | } |
354 | m_throttler.ProcessTime(); | 355 | m_throttler.PassTime(); |
355 | } | 356 | } |
356 | 357 | ||
357 | internal void UpdateThrottle(int pimagethrottle) | 358 | internal void UpdateThrottle(int pimagethrottle) |
358 | { | 359 | { |
359 | m_throttler.ThrottleBytes = 2 * pimagethrottle; | 360 | int tmp = 2 * pimagethrottle; |
360 | if(m_throttler.ThrottleBytes < 10000) | 361 | if(tmp < 10000) |
361 | m_throttler.ThrottleBytes = 10000; | 362 | tmp = 10000; |
363 | m_throttler.ThrottleBytes = tmp; | ||
362 | } | 364 | } |
363 | } | 365 | } |
364 | 366 | ||
@@ -426,16 +428,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
426 | 428 | ||
427 | internal sealed class CapsDataThrottler | 429 | internal sealed class CapsDataThrottler |
428 | { | 430 | { |
429 | 431 | private double lastTimeElapsed = 0; | |
430 | private volatile int currenttime = 0; | ||
431 | private volatile int lastTimeElapsed = 0; | ||
432 | private volatile int BytesSent = 0; | 432 | private volatile int BytesSent = 0; |
433 | public CapsDataThrottler(int pBytes, int max, int min) | 433 | public CapsDataThrottler(int pBytes) |
434 | { | 434 | { |
435 | if(pBytes < 10000) | ||
436 | pBytes = 10000; | ||
435 | ThrottleBytes = pBytes; | 437 | ThrottleBytes = pBytes; |
436 | if(ThrottleBytes < 10000) | 438 | lastTimeElapsed = Util.GetTimeStampMS(); |
437 | ThrottleBytes = 10000; | ||
438 | lastTimeElapsed = Util.EnvironmentTickCount(); | ||
439 | } | 439 | } |
440 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) | 440 | public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses) |
441 | { | 441 | { |
@@ -468,20 +468,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
468 | return haskey; | 468 | return haskey; |
469 | } | 469 | } |
470 | 470 | ||
471 | public void ProcessTime() | 471 | public void PassTime() |
472 | { | ||
473 | PassTime(); | ||
474 | } | ||
475 | |||
476 | private void PassTime() | ||
477 | { | 472 | { |
478 | currenttime = Util.EnvironmentTickCount(); | 473 | double currenttime = Util.GetTimeStampMS(); |
479 | int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); | 474 | double timeElapsed = currenttime - lastTimeElapsed; |
480 | //processTimeBasedActions(responses); | 475 | if(timeElapsed < 50.0) |
481 | if (timeElapsed >= 100) | 476 | return; |
477 | int add = (int)(ThrottleBytes * timeElapsed * 0.001); | ||
478 | if (add >= 1000) | ||
482 | { | 479 | { |
483 | lastTimeElapsed = currenttime; | 480 | lastTimeElapsed = currenttime; |
484 | BytesSent -= (ThrottleBytes * timeElapsed / 1000); | 481 | BytesSent -= add; |
485 | if (BytesSent < 0) BytesSent = 0; | 482 | if (BytesSent < 0) BytesSent = 0; |
486 | } | 483 | } |
487 | } | 484 | } |