Fix packetpool for ImprovedTerseObjectUpdate packets.
These were neither being returned or in many places reused. Getting packets from a pool rather than deallocating and reallocating reduces memory churn which in turn reduces garbage collection time and frequency.connector_plugin
parent
f5f5f2e3fb
commit
2e9ef015f7
|
@ -126,8 +126,7 @@ namespace OpenSim.Framework.Monitoring
|
||||||
{
|
{
|
||||||
foreach (Stat stat in container.Values)
|
foreach (Stat stat in container.Values)
|
||||||
{
|
{
|
||||||
con.OutputFormat(
|
con.Output(stat.ToConsoleString());
|
||||||
"{0}.{1}.{2} : {3}{4}", stat.Category, stat.Container, stat.ShortName, stat.Value, stat.UnitName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,6 +329,12 @@ namespace OpenSim.Framework.Monitoring
|
||||||
{
|
{
|
||||||
return string.Format("{0}+{1}+{2}", container, category, shortName);
|
return string.Format("{0}+{1}+{2}", container, category, shortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string ToConsoleString()
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
"{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PercentageStat : Stat
|
public class PercentageStat : Stat
|
||||||
|
@ -358,8 +363,13 @@ namespace OpenSim.Framework.Monitoring
|
||||||
|
|
||||||
public PercentageStat(
|
public PercentageStat(
|
||||||
string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
|
string shortName, string name, string category, string container, StatVerbosity verbosity, string description)
|
||||||
: base(shortName, name, "%", category, container, verbosity, description)
|
: base(shortName, name, "%", category, container, verbosity, description) {}
|
||||||
|
|
||||||
|
public override string ToConsoleString()
|
||||||
{
|
{
|
||||||
|
return string.Format(
|
||||||
|
"{0}.{1}.{2} : {3:0.###}{4} ({5}/{6})",
|
||||||
|
Category, Container, ShortName, Value, UnitName, Antecedent, Consequent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3922,7 +3922,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
|
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
|
||||||
|
|
||||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
ImprovedTerseObjectUpdatePacket packet
|
||||||
|
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
|
||||||
|
|
||||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
packet.RegionData.TimeDilation = timeDilation;
|
packet.RegionData.TimeDilation = timeDilation;
|
||||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
||||||
|
@ -3967,7 +3969,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
|
List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
|
||||||
|
|
||||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
ImprovedTerseObjectUpdatePacket packet
|
||||||
|
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
|
||||||
|
PacketType.ImprovedTerseObjectUpdate);
|
||||||
|
|
||||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
packet.RegionData.TimeDilation = timeDilation;
|
packet.RegionData.TimeDilation = timeDilation;
|
||||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
|
||||||
|
@ -12286,7 +12291,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
|
ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
|
||||||
ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
|
ImprovedTerseObjectUpdatePacket packet
|
||||||
|
= (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
|
||||||
|
PacketType.ImprovedTerseObjectUpdate);
|
||||||
|
|
||||||
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
|
||||||
packet.RegionData.TimeDilation = timeDilation;
|
packet.RegionData.TimeDilation = timeDilation;
|
||||||
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
|
packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
|
||||||
|
|
|
@ -420,6 +420,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
byte[] data = packet.ToBytes();
|
byte[] data = packet.ToBytes();
|
||||||
SendPacketData(udpClient, data, packet.Type, category, method);
|
SendPacketData(udpClient, data, packet.Type, category, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PacketPool.Instance.ReturnPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
private PercentageStat m_packetsReusedStat = new PercentageStat(
|
private PercentageStat m_packetsReusedStat = new PercentageStat(
|
||||||
"PacketsReused",
|
"PacketsReused",
|
||||||
"Packets reused",
|
"Packets reused",
|
||||||
"simulator",
|
"clientstack",
|
||||||
"simulator",
|
"simulator",
|
||||||
StatVerbosity.Debug,
|
StatVerbosity.Debug,
|
||||||
"Number of packets reused out of all requests to the packet pool");
|
"Number of packets reused out of all requests to the packet pool");
|
||||||
|
@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
private PercentageStat m_blocksReusedStat = new PercentageStat(
|
private PercentageStat m_blocksReusedStat = new PercentageStat(
|
||||||
"BlocksReused",
|
"BlocksReused",
|
||||||
"Blocks reused",
|
"Blocks reused",
|
||||||
"simulator",
|
"clientstack",
|
||||||
"simulator",
|
"simulator",
|
||||||
StatVerbosity.Debug,
|
StatVerbosity.Debug,
|
||||||
"Number of data blocks reused out of all requests to the packet pool");
|
"Number of data blocks reused out of all requests to the packet pool");
|
||||||
|
|
Loading…
Reference in New Issue