* While this is not producing any problems.. and does help in low bandwidth situations I can't demonstrate that it's better then just letting the client request what it needs in terms of responsiveness of the mesh in the scene yet.

avinationmerge
teravus 2012-11-22 08:13:35 -05:00
parent 0bf66434bc
commit 98b0cb8df8
1 changed files with 35 additions and 7 deletions

View File

@ -250,7 +250,7 @@ namespace OpenSim.Region.ClientStack.Linden
base(null, null, null, null, pId, int.MaxValue) base(null, null, null, null, pId, int.MaxValue)
{ {
m_scene = scene; m_scene = scene;
m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene); m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId);
// x is request id, y is userid // x is request id, y is userid
HasEvents = (x, y) => HasEvents = (x, y) =>
{ {
@ -419,21 +419,35 @@ namespace OpenSim.Region.ClientStack.Linden
private float CapThrottleDistributon = 0.30f; private float CapThrottleDistributon = 0.30f;
private readonly Scene m_scene; private readonly Scene m_scene;
private ThrottleOutPacketType Throttle; private ThrottleOutPacketType Throttle;
private readonly UUID User;
public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene) public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser)
{ {
ThrottleBytes = pBytes; ThrottleBytes = pBytes;
lastTimeElapsed = Util.EnvironmentTickCount(); lastTimeElapsed = Util.EnvironmentTickCount();
Throttle = ThrottleOutPacketType.Task; Throttle = ThrottleOutPacketType.Task;
m_scene = pScene; m_scene = pScene;
User = puser;
} }
public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
{ {
const float ThirtyPercent = 0.30f;
const float FivePercent = 0.05f;
PassTime(); PassTime();
// Note, this is called IN LOCK // Note, this is called IN LOCK
bool haskey = responses.ContainsKey(key); bool haskey = responses.ContainsKey(key);
if (responses.Count > 2)
{
SplitThrottle(ThirtyPercent);
}
else
{
SplitThrottle(FivePercent);
}
if (!haskey) if (!haskey)
{ {
return false; return false;
@ -441,7 +455,8 @@ namespace OpenSim.Region.ClientStack.Linden
aPollResponse response; aPollResponse response;
if (responses.TryGetValue(key, out response)) if (responses.TryGetValue(key, out response))
{ {
float LOD3Over = (((ThrottleBytes*CapThrottleDistributon)%50000) + 1);
float LOD2Over = (((ThrottleBytes*CapThrottleDistributon)%10000) + 1);
// Normal // Normal
if (BytesSent + response.bytes <= ThrottleBytes) if (BytesSent + response.bytes <= ThrottleBytes)
{ {
@ -449,16 +464,16 @@ namespace OpenSim.Region.ClientStack.Linden
return true; return true;
} }
// Lod3 Over // Lod3 Over Throttle protection to keep things processing even when the throttle bandwidth is set too little.
else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1)) else if (response.bytes > ThrottleBytes && Lod3 <= ((LOD3Over < 1)? 1: LOD3Over) )
{ {
Interlocked.Increment(ref Lod3); Interlocked.Increment(ref Lod3);
BytesSent += response.bytes; BytesSent += response.bytes;
return true; return true;
} }
// Lod2 Over // Lod2 Over Throttle protection to keep things processing even when the throttle bandwidth is set too little.
else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1)) else if (response.bytes > ThrottleBytes && Lod2 <= ((LOD2Over < 1) ? 1 : LOD2Over))
{ {
Interlocked.Increment(ref Lod2); Interlocked.Increment(ref Lod2);
BytesSent += response.bytes; BytesSent += response.bytes;
@ -477,7 +492,20 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
BytesSent -= bytes; BytesSent -= bytes;
} }
private void SplitThrottle(float percentMultiplier)
{
if (CapThrottleDistributon != percentMultiplier) // don't switch it if it's already set at the % multipler
{
CapThrottleDistributon = percentMultiplier;
ScenePresence p;
if (m_scene.TryGetScenePresence(User, out p)) // If we don't get a user they're not here anymore.
{
AlterThrottle(UserSetThrottle, p);
}
}
}
public void ProcessTime() public void ProcessTime()
{ {
PassTime(); PassTime();