From 038528dc80e0fe03956d61872ba30a887b2890a1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 15 Nov 2012 02:02:59 +0000
Subject: Make PacketPool class stats pull stats instead of push stats so they
can be lifted up into LLUDPServer and be distiguished by scene name
---
.../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 54 ++++++++++
.../ClientStack/Linden/UDP/OpenSimUDPBase.cs | 2 +-
.../Region/ClientStack/Linden/UDP/PacketPool.cs | 114 ++++++++++-----------
3 files changed, 107 insertions(+), 63 deletions(-)
(limited to 'OpenSim/Region/ClientStack/Linden')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index f8391d7..fcc69c0 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -469,6 +469,60 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_scene = (Scene)scene;
m_location = new Location(m_scene.RegionInfo.RegionHandle);
+
+ // XXX: These stats are also pool stats but we register them separately since they are currently not
+ // turned on and off by EnablePools()/DisablePools()
+ StatsManager.RegisterStat(
+ new PercentageStat(
+ "PacketsReused",
+ "Packets reused",
+ "Number of packets reused out of all requests to the packet pool",
+ "clientstack",
+ m_scene.Name,
+ StatType.Pull,
+ stat =>
+ { PercentageStat pstat = (PercentageStat)stat;
+ pstat.Consequent = PacketPool.Instance.PacketsRequested;
+ pstat.Antecedent = PacketPool.Instance.PacketsReused; },
+ StatVerbosity.Debug));
+
+ StatsManager.RegisterStat(
+ new PercentageStat(
+ "PacketDataBlocksReused",
+ "Packet data blocks reused",
+ "Number of data blocks reused out of all requests to the packet pool",
+ "clientstack",
+ m_scene.Name,
+ StatType.Pull,
+ stat =>
+ { PercentageStat pstat = (PercentageStat)stat;
+ pstat.Consequent = PacketPool.Instance.BlocksRequested;
+ pstat.Antecedent = PacketPool.Instance.BlocksReused; },
+ StatVerbosity.Debug));
+
+ StatsManager.RegisterStat(
+ new Stat(
+ "PacketsPoolCount",
+ "Objects within the packet pool",
+ "The number of objects currently stored within the packet pool",
+ "",
+ "clientstack",
+ m_scene.Name,
+ StatType.Pull,
+ stat => stat.Value = PacketPool.Instance.PacketsPooled,
+ StatVerbosity.Debug));
+
+ StatsManager.RegisterStat(
+ new Stat(
+ "PacketDataBlocksPoolCount",
+ "Objects within the packet data block pool",
+ "The number of objects currently stored within the packet data block pool",
+ "",
+ "clientstack",
+ m_scene.Name,
+ StatType.Pull,
+ stat => stat.Value = PacketPool.Instance.BlocksPooled,
+ StatVerbosity.Debug));
// We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by
// scene name
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index 808d177..3f7ca2b 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
@@ -334,4 +334,4 @@ namespace OpenMetaverse
catch (ObjectDisposedException) { }
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
index 9f22fb4..1fdc410 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs
@@ -41,29 +41,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private static readonly PacketPool instance = new PacketPool();
- private bool packetPoolEnabled = true;
- private bool dataBlockPoolEnabled = true;
-
- private PercentageStat m_packetsReusedStat = new PercentageStat(
- "PacketsReused",
- "Packets reused",
- "Number of packets reused out of all requests to the packet pool",
- "clientstack",
- "packetpool",
- StatType.Push,
- null,
- StatVerbosity.Debug);
-
- private PercentageStat m_blocksReusedStat = new PercentageStat(
- "PacketDataBlocksReused",
- "Packet data blocks reused",
- "Number of data blocks reused out of all requests to the packet pool",
- "clientstack",
- "packetpool",
- StatType.Push,
- null,
- StatVerbosity.Debug);
-
///
/// Pool of packets available for reuse.
///
@@ -76,46 +53,59 @@ namespace OpenSim.Region.ClientStack.LindenUDP
get { return instance; }
}
- public bool RecyclePackets
+ public bool RecyclePackets { get; set; }
+
+ public bool RecycleDataBlocks { get; set; }
+
+ ///
+ /// The number of packets pooled
+ ///
+ public int PacketsPooled
{
- set { packetPoolEnabled = value; }
- get { return packetPoolEnabled; }
+ get
+ {
+ lock (pool)
+ return pool.Count;
+ }
}
- public bool RecycleDataBlocks
+ ///
+ /// The number of blocks pooled.
+ ///
+ public int BlocksPooled
{
- set { dataBlockPoolEnabled = value; }
- get { return dataBlockPoolEnabled; }
+ get
+ {
+ lock (DataBlocks)
+ return DataBlocks.Count;
+ }
}
+ ///
+ /// Number of packets requested.
+ ///
+ public long PacketsRequested { get; private set; }
+
+ ///
+ /// Number of packets reused.
+ ///
+ public long PacketsReused { get; private set; }
+
+ ///
+ /// Number of packet blocks requested.
+ ///
+ public long BlocksRequested { get; private set; }
+
+ ///
+ /// Number of packet blocks reused.
+ ///
+ public long BlocksReused { get; private set; }
+
private PacketPool()
{
- StatsManager.RegisterStat(m_packetsReusedStat);
- StatsManager.RegisterStat(m_blocksReusedStat);
-
- StatsManager.RegisterStat(
- new Stat(
- "PacketsPoolCount",
- "Objects within the packet pool",
- "The number of objects currently stored within the packet pool",
- "",
- "clientstack",
- "packetpool",
- StatType.Pull,
- stat => { lock (pool) { stat.Value = pool.Count; } },
- StatVerbosity.Debug));
-
- StatsManager.RegisterStat(
- new Stat(
- "PacketDataBlocksPoolCount",
- "Objects within the packet data block pool",
- "The number of objects currently stored within the packet data block pool",
- "",
- "clientstack",
- "packetpool",
- StatType.Pull,
- stat => { lock (DataBlocks) { stat.Value = DataBlocks.Count; } },
- StatVerbosity.Debug));
+ // defaults
+ RecyclePackets = true;
+ RecycleDataBlocks = true;
}
///
@@ -125,11 +115,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// Guaranteed to always return a packet, whether from the pool or newly constructed.
public Packet GetPacket(PacketType type)
{
- m_packetsReusedStat.Consequent++;
+ PacketsRequested++;
Packet packet;
- if (!packetPoolEnabled)
+ if (!RecyclePackets)
return Packet.BuildPacket(type);
lock (pool)
@@ -146,7 +136,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
// Recycle old packages
- m_packetsReusedStat.Antecedent++;
+ PacketsReused++;
packet = pool[type].Pop();
}
@@ -215,7 +205,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
///
public void ReturnPacket(Packet packet)
{
- if (dataBlockPoolEnabled)
+ if (RecycleDataBlocks)
{
switch (packet.Type)
{
@@ -239,7 +229,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
- if (packetPoolEnabled)
+ if (RecyclePackets)
{
switch (packet.Type)
{
@@ -277,7 +267,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
lock (DataBlocks)
{
- m_blocksReusedStat.Consequent++;
+ BlocksRequested++;
Stack