Make it possible to turn the base UDP object packet pools on and off whilst running via the "debug lludp pool <on|off>" console command. For debug purposes.
This does not currently apply to the higher LLUDP packetpool.integration
parent
4578ff74fe
commit
319ebaca06
|
@ -207,7 +207,7 @@ namespace OpenSim.Framework.Monitoring
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
newContainer = new Dictionary<string, Stat>(container);
|
newContainer = new Dictionary<string, Stat>(container);
|
||||||
newContainer.Remove(stat.UniqueName);
|
newContainer.Remove(stat.ShortName);
|
||||||
|
|
||||||
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
|
newCategory = new Dictionary<string, Dictionary<string, Stat>>(category);
|
||||||
newCategory.Remove(stat.Container);
|
newCategory.Remove(stat.Container);
|
||||||
|
@ -278,11 +278,6 @@ namespace OpenSim.Framework.Monitoring
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Stat
|
public class Stat
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Unique stat name used for indexing. Each ShortName in a Category must be unique.
|
|
||||||
/// </summary>
|
|
||||||
public string UniqueName { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Category of this stat (e.g. cache, scene, etc).
|
/// Category of this stat (e.g. cache, scene, etc).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -376,13 +371,6 @@ namespace OpenSim.Framework.Monitoring
|
||||||
PullAction = pullAction;
|
PullAction = pullAction;
|
||||||
|
|
||||||
Verbosity = verbosity;
|
Verbosity = verbosity;
|
||||||
|
|
||||||
UniqueName = GenUniqueName(Container, Category, ShortName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GenUniqueName(string container, string category, string shortName)
|
|
||||||
{
|
|
||||||
return string.Format("{0}+{1}+{2}", container, category, shortName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string ToConsoleString()
|
public virtual string ToConsoleString()
|
||||||
|
|
|
@ -170,6 +170,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private Pool<IncomingPacket> m_incomingPacketPool;
|
private Pool<IncomingPacket> m_incomingPacketPool;
|
||||||
|
|
||||||
|
private Stat m_incomingPacketPoolStat;
|
||||||
|
|
||||||
private int m_defaultRTO = 0;
|
private int m_defaultRTO = 0;
|
||||||
private int m_maxRTO = 0;
|
private int m_maxRTO = 0;
|
||||||
private int m_ackTimeout = 0;
|
private int m_ackTimeout = 0;
|
||||||
|
@ -214,6 +216,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
m_circuitManager = circuitManager;
|
m_circuitManager = circuitManager;
|
||||||
int sceneThrottleBps = 0;
|
int sceneThrottleBps = 0;
|
||||||
|
bool usePools = false;
|
||||||
|
|
||||||
IConfig config = configSource.Configs["ClientStack.LindenUDP"];
|
IConfig config = configSource.Configs["ClientStack.LindenUDP"];
|
||||||
if (config != null)
|
if (config != null)
|
||||||
|
@ -246,7 +249,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
|
PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
|
||||||
PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
|
PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
|
||||||
UsePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", false);
|
usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region BinaryStats
|
#region BinaryStats
|
||||||
|
@ -277,22 +280,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_throttle = new TokenBucket(null, sceneThrottleBps);
|
m_throttle = new TokenBucket(null, sceneThrottleBps);
|
||||||
ThrottleRates = new ThrottleRates(configSource);
|
ThrottleRates = new ThrottleRates(configSource);
|
||||||
|
|
||||||
if (UsePools)
|
if (usePools)
|
||||||
{
|
EnablePools();
|
||||||
m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
|
|
||||||
|
|
||||||
StatsManager.RegisterStat(
|
|
||||||
new Stat(
|
|
||||||
"IncomingPacketPoolCount",
|
|
||||||
"Objects within incoming packet pool",
|
|
||||||
"The number of objects currently stored within the incoming packet pool",
|
|
||||||
"",
|
|
||||||
"clientstack",
|
|
||||||
"packetpool",
|
|
||||||
StatType.Pull,
|
|
||||||
stat => stat.Value = m_incomingPacketPool.Count,
|
|
||||||
StatVerbosity.Debug));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
@ -345,6 +334,50 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
base.StopInbound();
|
base.StopInbound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool EnablePools()
|
||||||
|
{
|
||||||
|
if (!UsePools)
|
||||||
|
{
|
||||||
|
base.EnablePools();
|
||||||
|
|
||||||
|
m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
|
||||||
|
|
||||||
|
m_incomingPacketPoolStat
|
||||||
|
= new Stat(
|
||||||
|
"IncomingPacketPoolCount",
|
||||||
|
"Objects within incoming packet pool",
|
||||||
|
"The number of objects currently stored within the incoming packet pool",
|
||||||
|
"",
|
||||||
|
"clientstack",
|
||||||
|
"packetpool",
|
||||||
|
StatType.Pull,
|
||||||
|
stat => stat.Value = m_incomingPacketPool.Count,
|
||||||
|
StatVerbosity.Debug);
|
||||||
|
|
||||||
|
StatsManager.RegisterStat(m_incomingPacketPoolStat);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool DisablePools()
|
||||||
|
{
|
||||||
|
if (UsePools)
|
||||||
|
{
|
||||||
|
base.DisablePools();
|
||||||
|
|
||||||
|
StatsManager.DeregisterStat(m_incomingPacketPoolStat);
|
||||||
|
|
||||||
|
// We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
|
/// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -408,6 +441,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
+ "all - stop in and outbound processing.\n",
|
+ "all - stop in and outbound processing.\n",
|
||||||
HandleStopCommand);
|
HandleStopCommand);
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
|
"Debug",
|
||||||
|
false,
|
||||||
|
"debug lludp pool",
|
||||||
|
"debug lludp pool <on|off>",
|
||||||
|
"Turn object pooling within the lludp component on or off.",
|
||||||
|
HandlePoolCommand);
|
||||||
|
|
||||||
MainConsole.Instance.Commands.AddCommand(
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
"Debug",
|
"Debug",
|
||||||
false,
|
false,
|
||||||
|
@ -451,6 +492,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
StopOutbound();
|
StopOutbound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandlePoolCommand(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length != 4)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string enabled = args[3];
|
||||||
|
|
||||||
|
if (enabled == "on")
|
||||||
|
{
|
||||||
|
if (EnablePools())
|
||||||
|
MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name);
|
||||||
|
}
|
||||||
|
else if (enabled == "off")
|
||||||
|
{
|
||||||
|
if (DisablePools())
|
||||||
|
MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void HandleStatusCommand(string module, string[] args)
|
private void HandleStatusCommand(string module, string[] args)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
|
@ -458,6 +525,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
"OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
|
"OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
|
||||||
|
|
||||||
|
MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HandlesRegion(Location x)
|
public bool HandlesRegion(Location x)
|
||||||
|
|
|
@ -77,6 +77,8 @@ namespace OpenMetaverse
|
||||||
/// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks>
|
/// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks>
|
||||||
public bool IsRunningOutbound { get; private set; }
|
public bool IsRunningOutbound { get; private set; }
|
||||||
|
|
||||||
|
private Stat m_poolCountStat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -107,27 +109,6 @@ namespace OpenMetaverse
|
||||||
/// necessary</remarks>
|
/// necessary</remarks>
|
||||||
public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
|
public void StartInbound(int recvBufferSize, bool asyncPacketHandling)
|
||||||
{
|
{
|
||||||
if (UsePools)
|
|
||||||
{
|
|
||||||
m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
|
|
||||||
|
|
||||||
StatsManager.RegisterStat(
|
|
||||||
new Stat(
|
|
||||||
"UDPPacketBufferPoolCount",
|
|
||||||
"Objects within the UDPPacketBuffer pool",
|
|
||||||
"The number of objects currently stored within the UDPPacketBuffer pool",
|
|
||||||
"",
|
|
||||||
"clientstack",
|
|
||||||
"packetpool",
|
|
||||||
StatType.Pull,
|
|
||||||
stat => stat.Value = m_pool.Count,
|
|
||||||
StatVerbosity.Debug));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pool = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_asyncPacketHandling = asyncPacketHandling;
|
m_asyncPacketHandling = asyncPacketHandling;
|
||||||
|
|
||||||
if (!IsRunningInbound)
|
if (!IsRunningInbound)
|
||||||
|
@ -197,6 +178,49 @@ namespace OpenMetaverse
|
||||||
IsRunningOutbound = false;
|
IsRunningOutbound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool EnablePools()
|
||||||
|
{
|
||||||
|
if (!UsePools)
|
||||||
|
{
|
||||||
|
m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
|
||||||
|
|
||||||
|
m_poolCountStat
|
||||||
|
= new Stat(
|
||||||
|
"UDPPacketBufferPoolCount",
|
||||||
|
"Objects within the UDPPacketBuffer pool",
|
||||||
|
"The number of objects currently stored within the UDPPacketBuffer pool",
|
||||||
|
"",
|
||||||
|
"clientstack",
|
||||||
|
"packetpool",
|
||||||
|
StatType.Pull,
|
||||||
|
stat => stat.Value = m_pool.Count,
|
||||||
|
StatVerbosity.Debug);
|
||||||
|
|
||||||
|
StatsManager.RegisterStat(m_poolCountStat);
|
||||||
|
|
||||||
|
UsePools = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual bool DisablePools()
|
||||||
|
{
|
||||||
|
if (UsePools)
|
||||||
|
{
|
||||||
|
UsePools = false;
|
||||||
|
StatsManager.DeregisterStat(m_poolCountStat);
|
||||||
|
|
||||||
|
// We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void AsyncBeginReceive()
|
private void AsyncBeginReceive()
|
||||||
{
|
{
|
||||||
UDPPacketBuffer buf;
|
UDPPacketBuffer buf;
|
||||||
|
|
Loading…
Reference in New Issue