diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 54 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs | 114 |
3 files changed, 107 insertions, 63 deletions
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 | |||
469 | 469 | ||
470 | m_scene = (Scene)scene; | 470 | m_scene = (Scene)scene; |
471 | m_location = new Location(m_scene.RegionInfo.RegionHandle); | 471 | m_location = new Location(m_scene.RegionInfo.RegionHandle); |
472 | |||
473 | // XXX: These stats are also pool stats but we register them separately since they are currently not | ||
474 | // turned on and off by EnablePools()/DisablePools() | ||
475 | StatsManager.RegisterStat( | ||
476 | new PercentageStat( | ||
477 | "PacketsReused", | ||
478 | "Packets reused", | ||
479 | "Number of packets reused out of all requests to the packet pool", | ||
480 | "clientstack", | ||
481 | m_scene.Name, | ||
482 | StatType.Pull, | ||
483 | stat => | ||
484 | { PercentageStat pstat = (PercentageStat)stat; | ||
485 | pstat.Consequent = PacketPool.Instance.PacketsRequested; | ||
486 | pstat.Antecedent = PacketPool.Instance.PacketsReused; }, | ||
487 | StatVerbosity.Debug)); | ||
488 | |||
489 | StatsManager.RegisterStat( | ||
490 | new PercentageStat( | ||
491 | "PacketDataBlocksReused", | ||
492 | "Packet data blocks reused", | ||
493 | "Number of data blocks reused out of all requests to the packet pool", | ||
494 | "clientstack", | ||
495 | m_scene.Name, | ||
496 | StatType.Pull, | ||
497 | stat => | ||
498 | { PercentageStat pstat = (PercentageStat)stat; | ||
499 | pstat.Consequent = PacketPool.Instance.BlocksRequested; | ||
500 | pstat.Antecedent = PacketPool.Instance.BlocksReused; }, | ||
501 | StatVerbosity.Debug)); | ||
502 | |||
503 | StatsManager.RegisterStat( | ||
504 | new Stat( | ||
505 | "PacketsPoolCount", | ||
506 | "Objects within the packet pool", | ||
507 | "The number of objects currently stored within the packet pool", | ||
508 | "", | ||
509 | "clientstack", | ||
510 | m_scene.Name, | ||
511 | StatType.Pull, | ||
512 | stat => stat.Value = PacketPool.Instance.PacketsPooled, | ||
513 | StatVerbosity.Debug)); | ||
514 | |||
515 | StatsManager.RegisterStat( | ||
516 | new Stat( | ||
517 | "PacketDataBlocksPoolCount", | ||
518 | "Objects within the packet data block pool", | ||
519 | "The number of objects currently stored within the packet data block pool", | ||
520 | "", | ||
521 | "clientstack", | ||
522 | m_scene.Name, | ||
523 | StatType.Pull, | ||
524 | stat => stat.Value = PacketPool.Instance.BlocksPooled, | ||
525 | StatVerbosity.Debug)); | ||
472 | 526 | ||
473 | // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by | 527 | // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by |
474 | // scene name | 528 | // 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 | |||
334 | catch (ObjectDisposedException) { } | 334 | catch (ObjectDisposedException) { } |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } \ 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 | |||
41 | 41 | ||
42 | private static readonly PacketPool instance = new PacketPool(); | 42 | private static readonly PacketPool instance = new PacketPool(); |
43 | 43 | ||
44 | private bool packetPoolEnabled = true; | ||
45 | private bool dataBlockPoolEnabled = true; | ||
46 | |||
47 | private PercentageStat m_packetsReusedStat = new PercentageStat( | ||
48 | "PacketsReused", | ||
49 | "Packets reused", | ||
50 | "Number of packets reused out of all requests to the packet pool", | ||
51 | "clientstack", | ||
52 | "packetpool", | ||
53 | StatType.Push, | ||
54 | null, | ||
55 | StatVerbosity.Debug); | ||
56 | |||
57 | private PercentageStat m_blocksReusedStat = new PercentageStat( | ||
58 | "PacketDataBlocksReused", | ||
59 | "Packet data blocks reused", | ||
60 | "Number of data blocks reused out of all requests to the packet pool", | ||
61 | "clientstack", | ||
62 | "packetpool", | ||
63 | StatType.Push, | ||
64 | null, | ||
65 | StatVerbosity.Debug); | ||
66 | |||
67 | /// <summary> | 44 | /// <summary> |
68 | /// Pool of packets available for reuse. | 45 | /// Pool of packets available for reuse. |
69 | /// </summary> | 46 | /// </summary> |
@@ -76,46 +53,59 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
76 | get { return instance; } | 53 | get { return instance; } |
77 | } | 54 | } |
78 | 55 | ||
79 | public bool RecyclePackets | 56 | public bool RecyclePackets { get; set; } |
57 | |||
58 | public bool RecycleDataBlocks { get; set; } | ||
59 | |||
60 | /// <summary> | ||
61 | /// The number of packets pooled | ||
62 | /// </summary> | ||
63 | public int PacketsPooled | ||
80 | { | 64 | { |
81 | set { packetPoolEnabled = value; } | 65 | get |
82 | get { return packetPoolEnabled; } | 66 | { |
67 | lock (pool) | ||
68 | return pool.Count; | ||
69 | } | ||
83 | } | 70 | } |
84 | 71 | ||
85 | public bool RecycleDataBlocks | 72 | /// <summary> |
73 | /// The number of blocks pooled. | ||
74 | /// </summary> | ||
75 | public int BlocksPooled | ||
86 | { | 76 | { |
87 | set { dataBlockPoolEnabled = value; } | 77 | get |
88 | get { return dataBlockPoolEnabled; } | 78 | { |
79 | lock (DataBlocks) | ||
80 | return DataBlocks.Count; | ||
81 | } | ||
89 | } | 82 | } |
90 | 83 | ||
84 | /// <summary> | ||
85 | /// Number of packets requested. | ||
86 | /// </summary> | ||
87 | public long PacketsRequested { get; private set; } | ||
88 | |||
89 | /// <summary> | ||
90 | /// Number of packets reused. | ||
91 | /// </summary> | ||
92 | public long PacketsReused { get; private set; } | ||
93 | |||
94 | /// <summary> | ||
95 | /// Number of packet blocks requested. | ||
96 | /// </summary> | ||
97 | public long BlocksRequested { get; private set; } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Number of packet blocks reused. | ||
101 | /// </summary> | ||
102 | public long BlocksReused { get; private set; } | ||
103 | |||
91 | private PacketPool() | 104 | private PacketPool() |
92 | { | 105 | { |
93 | StatsManager.RegisterStat(m_packetsReusedStat); | 106 | // defaults |
94 | StatsManager.RegisterStat(m_blocksReusedStat); | 107 | RecyclePackets = true; |
95 | 108 | RecycleDataBlocks = true; | |
96 | StatsManager.RegisterStat( | ||
97 | new Stat( | ||
98 | "PacketsPoolCount", | ||
99 | "Objects within the packet pool", | ||
100 | "The number of objects currently stored within the packet pool", | ||
101 | "", | ||
102 | "clientstack", | ||
103 | "packetpool", | ||
104 | StatType.Pull, | ||
105 | stat => { lock (pool) { stat.Value = pool.Count; } }, | ||
106 | StatVerbosity.Debug)); | ||
107 | |||
108 | StatsManager.RegisterStat( | ||
109 | new Stat( | ||
110 | "PacketDataBlocksPoolCount", | ||
111 | "Objects within the packet data block pool", | ||
112 | "The number of objects currently stored within the packet data block pool", | ||
113 | "", | ||
114 | "clientstack", | ||
115 | "packetpool", | ||
116 | StatType.Pull, | ||
117 | stat => { lock (DataBlocks) { stat.Value = DataBlocks.Count; } }, | ||
118 | StatVerbosity.Debug)); | ||
119 | } | 109 | } |
120 | 110 | ||
121 | /// <summary> | 111 | /// <summary> |
@@ -125,11 +115,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
125 | /// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns> | 115 | /// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns> |
126 | public Packet GetPacket(PacketType type) | 116 | public Packet GetPacket(PacketType type) |
127 | { | 117 | { |
128 | m_packetsReusedStat.Consequent++; | 118 | PacketsRequested++; |
129 | 119 | ||
130 | Packet packet; | 120 | Packet packet; |
131 | 121 | ||
132 | if (!packetPoolEnabled) | 122 | if (!RecyclePackets) |
133 | return Packet.BuildPacket(type); | 123 | return Packet.BuildPacket(type); |
134 | 124 | ||
135 | lock (pool) | 125 | lock (pool) |
@@ -146,7 +136,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
146 | // m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type); | 136 | // m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type); |
147 | 137 | ||
148 | // Recycle old packages | 138 | // Recycle old packages |
149 | m_packetsReusedStat.Antecedent++; | 139 | PacketsReused++; |
150 | 140 | ||
151 | packet = pool[type].Pop(); | 141 | packet = pool[type].Pop(); |
152 | } | 142 | } |
@@ -215,7 +205,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
215 | /// <param name="packet"></param> | 205 | /// <param name="packet"></param> |
216 | public void ReturnPacket(Packet packet) | 206 | public void ReturnPacket(Packet packet) |
217 | { | 207 | { |
218 | if (dataBlockPoolEnabled) | 208 | if (RecycleDataBlocks) |
219 | { | 209 | { |
220 | switch (packet.Type) | 210 | switch (packet.Type) |
221 | { | 211 | { |
@@ -239,7 +229,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
239 | } | 229 | } |
240 | } | 230 | } |
241 | 231 | ||
242 | if (packetPoolEnabled) | 232 | if (RecyclePackets) |
243 | { | 233 | { |
244 | switch (packet.Type) | 234 | switch (packet.Type) |
245 | { | 235 | { |
@@ -277,7 +267,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
277 | { | 267 | { |
278 | lock (DataBlocks) | 268 | lock (DataBlocks) |
279 | { | 269 | { |
280 | m_blocksReusedStat.Consequent++; | 270 | BlocksRequested++; |
281 | 271 | ||
282 | Stack<Object> s; | 272 | Stack<Object> s; |
283 | 273 | ||
@@ -285,7 +275,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
285 | { | 275 | { |
286 | if (s.Count > 0) | 276 | if (s.Count > 0) |
287 | { | 277 | { |
288 | m_blocksReusedStat.Antecedent++; | 278 | BlocksReused++; |
289 | return (T)s.Pop(); | 279 | return (T)s.Pop(); |
290 | } | 280 | } |
291 | } | 281 | } |