revert EnvironmentTick back to orignal clock, since change may cause issues on some code paths. Clean a bit get mesh and get texture throttle
parent
fe0fce424c
commit
79e166e9aa
|
@ -2967,9 +2967,9 @@ namespace OpenSim.Framework
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Int32 EnvironmentTickCount()
|
public static Int32 EnvironmentTickCount()
|
||||||
{
|
{
|
||||||
double now = GetTimeStampMS();
|
return Environment.TickCount & EnvironmentTickCountMask;
|
||||||
return (int)now;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Int32 EnvironmentTickCountMask = 0x3fffffff;
|
const Int32 EnvironmentTickCountMask = 0x3fffffff;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2994,8 +2994,7 @@ namespace OpenSim.Framework
|
||||||
/// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
|
/// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
|
||||||
public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
|
public static Int32 EnvironmentTickCountSubtract(Int32 prevValue)
|
||||||
{
|
{
|
||||||
double now = GetTimeStampMS();
|
return EnvironmentTickCountSubtract(EnvironmentTickCount(), prevValue);
|
||||||
return EnvironmentTickCountSubtract((int)now, prevValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount
|
// Returns value of Tick Count A - TickCount B accounting for wrapping of TickCount
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
PollServiceMeshEventArgs args;
|
PollServiceMeshEventArgs args;
|
||||||
if (m_pollservices.TryGetValue(user, out args))
|
if (m_pollservices.TryGetValue(user, out args))
|
||||||
{
|
{
|
||||||
args.UpdateThrottle(imagethrottle, p);
|
args.UpdateThrottle(imagethrottle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,14 +238,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
base(null, uri, null, null, null, pId, int.MaxValue)
|
base(null, uri, null, null, null, pId, int.MaxValue)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId);
|
m_throttler = new MeshCapsDataThrottler(100000);
|
||||||
// x is request id, y is userid
|
// x is request id, y is userid
|
||||||
HasEvents = (x, y) =>
|
HasEvents = (x, y) =>
|
||||||
{
|
{
|
||||||
lock (responses)
|
lock (responses)
|
||||||
{
|
{
|
||||||
bool ret = m_throttler.hasEvents(x, responses);
|
bool ret = m_throttler.hasEvents(x, responses);
|
||||||
m_throttler.ProcessTime();
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -260,8 +259,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
m_throttler.ProcessTime();
|
|
||||||
responses.Remove(x);
|
responses.Remove(x);
|
||||||
|
m_throttler.PassTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -274,6 +273,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
reqinfo.request = y;
|
reqinfo.request = y;
|
||||||
|
|
||||||
m_queue.Enqueue(reqinfo);
|
m_queue.Enqueue(reqinfo);
|
||||||
|
m_throttler.PassTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
// this should never happen except possible on shutdown
|
// this should never happen except possible on shutdown
|
||||||
|
@ -335,12 +335,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
m_throttler.ProcessTime();
|
m_throttler.PassTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
|
internal void UpdateThrottle(int pthrottle)
|
||||||
{
|
{
|
||||||
m_throttler.UpdateThrottle(pimagethrottle, p);
|
int tmp = 2 * pthrottle;
|
||||||
|
if(tmp < 10000)
|
||||||
|
tmp = 10000;
|
||||||
|
m_throttler.ThrottleBytes = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,25 +397,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
internal sealed class MeshCapsDataThrottler
|
internal sealed class MeshCapsDataThrottler
|
||||||
{
|
{
|
||||||
|
private double lastTimeElapsed = 0;
|
||||||
|
private double BytesSent = 0;
|
||||||
|
|
||||||
private volatile int currenttime = 0;
|
public MeshCapsDataThrottler(int pBytes)
|
||||||
private volatile int lastTimeElapsed = 0;
|
|
||||||
private volatile int BytesSent = 0;
|
|
||||||
private int CapSetThrottle = 0;
|
|
||||||
private float CapThrottleDistributon = 0.30f;
|
|
||||||
private readonly Scene m_scene;
|
|
||||||
private ThrottleOutPacketType Throttle;
|
|
||||||
private readonly UUID User;
|
|
||||||
|
|
||||||
public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser)
|
|
||||||
{
|
{
|
||||||
|
if(pBytes < 10000)
|
||||||
|
pBytes = 10000;
|
||||||
ThrottleBytes = pBytes;
|
ThrottleBytes = pBytes;
|
||||||
if(ThrottleBytes < 10000)
|
lastTimeElapsed = Util.GetTimeStampMS();
|
||||||
ThrottleBytes = 10000;
|
|
||||||
lastTimeElapsed = Util.EnvironmentTickCount();
|
|
||||||
Throttle = ThrottleOutPacketType.Asset;
|
|
||||||
m_scene = pScene;
|
|
||||||
User = puser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
|
public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
|
||||||
|
@ -442,46 +435,22 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return haskey;
|
return haskey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessTime()
|
public void PassTime()
|
||||||
{
|
{
|
||||||
PassTime();
|
double currenttime = Util.GetTimeStampMS();
|
||||||
}
|
double timeElapsed = currenttime - lastTimeElapsed;
|
||||||
|
if(timeElapsed < 50.0)
|
||||||
private void PassTime()
|
return;
|
||||||
{
|
int add = (int)(ThrottleBytes * timeElapsed * 0.001);
|
||||||
currenttime = Util.EnvironmentTickCount();
|
if (add >= 1000)
|
||||||
int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
|
|
||||||
if (timeElapsed >= 100)
|
|
||||||
{
|
{
|
||||||
lastTimeElapsed = currenttime;
|
lastTimeElapsed = currenttime;
|
||||||
BytesSent -= (ThrottleBytes * timeElapsed / 1000);
|
BytesSent -= add;
|
||||||
if (BytesSent < 0) BytesSent = 0;
|
if (BytesSent < 0) BytesSent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AlterThrottle(int setting, ScenePresence p)
|
public int ThrottleBytes;
|
||||||
{
|
|
||||||
p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ThrottleBytes
|
|
||||||
{
|
|
||||||
get { return CapSetThrottle; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value > 10000)
|
|
||||||
CapSetThrottle = value;
|
|
||||||
else
|
|
||||||
CapSetThrottle = 10000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void UpdateThrottle(int pimagethrottle, ScenePresence p)
|
|
||||||
{
|
|
||||||
// Client set throttle !
|
|
||||||
CapSetThrottle = 2 * pimagethrottle;
|
|
||||||
ProcessTime();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
new Dictionary<UUID, aPollResponse>();
|
new Dictionary<UUID, aPollResponse>();
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000);
|
private CapsDataThrottler m_throttler = new CapsDataThrottler(100000);
|
||||||
public PollServiceTextureEventArgs(UUID pId, Scene scene) :
|
public PollServiceTextureEventArgs(UUID pId, Scene scene) :
|
||||||
base(null, "", null, null, null, pId, int.MaxValue)
|
base(null, "", null, null, null, pId, int.MaxValue)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,6 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
lock (responses)
|
lock (responses)
|
||||||
{
|
{
|
||||||
bool ret = m_throttler.hasEvents(x, responses);
|
bool ret = m_throttler.hasEvents(x, responses);
|
||||||
m_throttler.ProcessTime();
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,6 +246,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
responses.Remove(x);
|
responses.Remove(x);
|
||||||
|
m_throttler.PassTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -271,6 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_queue.Enqueue(reqinfo);
|
m_queue.Enqueue(reqinfo);
|
||||||
|
m_throttler.PassTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
// this should never happen except possible on shutdown
|
// this should never happen except possible on shutdown
|
||||||
|
@ -351,14 +352,15 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
m_throttler.ProcessTime();
|
m_throttler.PassTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateThrottle(int pimagethrottle)
|
internal void UpdateThrottle(int pimagethrottle)
|
||||||
{
|
{
|
||||||
m_throttler.ThrottleBytes = 2 * pimagethrottle;
|
int tmp = 2 * pimagethrottle;
|
||||||
if(m_throttler.ThrottleBytes < 10000)
|
if(tmp < 10000)
|
||||||
m_throttler.ThrottleBytes = 10000;
|
tmp = 10000;
|
||||||
|
m_throttler.ThrottleBytes = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,16 +428,14 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
internal sealed class CapsDataThrottler
|
internal sealed class CapsDataThrottler
|
||||||
{
|
{
|
||||||
|
private double lastTimeElapsed = 0;
|
||||||
private volatile int currenttime = 0;
|
|
||||||
private volatile int lastTimeElapsed = 0;
|
|
||||||
private volatile int BytesSent = 0;
|
private volatile int BytesSent = 0;
|
||||||
public CapsDataThrottler(int pBytes, int max, int min)
|
public CapsDataThrottler(int pBytes)
|
||||||
{
|
{
|
||||||
|
if(pBytes < 10000)
|
||||||
|
pBytes = 10000;
|
||||||
ThrottleBytes = pBytes;
|
ThrottleBytes = pBytes;
|
||||||
if(ThrottleBytes < 10000)
|
lastTimeElapsed = Util.GetTimeStampMS();
|
||||||
ThrottleBytes = 10000;
|
|
||||||
lastTimeElapsed = Util.EnvironmentTickCount();
|
|
||||||
}
|
}
|
||||||
public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses)
|
public bool hasEvents(UUID key, Dictionary<UUID, GetTextureModule.aPollResponse> responses)
|
||||||
{
|
{
|
||||||
|
@ -468,20 +468,17 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return haskey;
|
return haskey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessTime()
|
public void PassTime()
|
||||||
{
|
{
|
||||||
PassTime();
|
double currenttime = Util.GetTimeStampMS();
|
||||||
}
|
double timeElapsed = currenttime - lastTimeElapsed;
|
||||||
|
if(timeElapsed < 50.0)
|
||||||
private void PassTime()
|
return;
|
||||||
{
|
int add = (int)(ThrottleBytes * timeElapsed * 0.001);
|
||||||
currenttime = Util.EnvironmentTickCount();
|
if (add >= 1000)
|
||||||
int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed);
|
|
||||||
//processTimeBasedActions(responses);
|
|
||||||
if (timeElapsed >= 100)
|
|
||||||
{
|
{
|
||||||
lastTimeElapsed = currenttime;
|
lastTimeElapsed = currenttime;
|
||||||
BytesSent -= (ThrottleBytes * timeElapsed / 1000);
|
BytesSent -= add;
|
||||||
if (BytesSent < 0) BytesSent = 0;
|
if (BytesSent < 0) BytesSent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue