diff options
author | Melanie | 2012-11-15 03:46:10 +0000 |
---|---|---|
committer | Melanie | 2012-11-15 03:46:10 +0000 |
commit | 5895c4cc6f698bcb415b08a96322f06fb44413ca (patch) | |
tree | 5b223f297b27ac3966c65526f422fc82095b9b86 /OpenSim/Region/ClientStack | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Improve inventory folder version updating for mssql database plugin. (diff) | |
download | opensim-SC-5895c4cc6f698bcb415b08a96322f06fb44413ca.zip opensim-SC-5895c4cc6f698bcb415b08a96322f06fb44413ca.tar.gz opensim-SC-5895c4cc6f698bcb415b08a96322f06fb44413ca.tar.bz2 opensim-SC-5895c4cc6f698bcb415b08a96322f06fb44413ca.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
Diffstat (limited to 'OpenSim/Region/ClientStack')
4 files changed, 206 insertions, 104 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 1f6af4a..81167ec 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -5415,9 +5415,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5415 | AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); | 5415 | AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); |
5416 | AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); | 5416 | AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); |
5417 | AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); | 5417 | AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); |
5418 | AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest, false); | 5418 | AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest); |
5419 | AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest, false); | 5419 | AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest); |
5420 | AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest, false); | 5420 | AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest); |
5421 | AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); | 5421 | AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); |
5422 | AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); | 5422 | AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); |
5423 | AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); | 5423 | AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index b8951d9..1ed6a74 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -70,6 +70,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
70 | public void AddScene(IScene scene) | 70 | public void AddScene(IScene scene) |
71 | { | 71 | { |
72 | m_udpServer.AddScene(scene); | 72 | m_udpServer.AddScene(scene); |
73 | |||
74 | StatsManager.RegisterStat( | ||
75 | new Stat( | ||
76 | "IncomingPacketsProcessedCount", | ||
77 | "Number of inbound UDP packets processed", | ||
78 | "Number of inbound UDP packets processed", | ||
79 | "", | ||
80 | "clientstack", | ||
81 | scene.Name, | ||
82 | StatType.Pull, | ||
83 | stat => stat.Value = m_udpServer.IncomingPacketsProcessed, | ||
84 | StatVerbosity.Debug)); | ||
73 | } | 85 | } |
74 | 86 | ||
75 | public bool HandlesRegion(Location x) | 87 | public bool HandlesRegion(Location x) |
@@ -173,6 +185,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
173 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); | 185 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); |
174 | private Pool<IncomingPacket> m_incomingPacketPool; | 186 | private Pool<IncomingPacket> m_incomingPacketPool; |
175 | 187 | ||
188 | /// <summary> | ||
189 | /// Stat for number of packets in the main pool awaiting use. | ||
190 | /// </summary> | ||
191 | private Stat m_poolCountStat; | ||
192 | |||
193 | /// <summary> | ||
194 | /// Stat for number of packets in the inbound packet pool awaiting use. | ||
195 | /// </summary> | ||
176 | private Stat m_incomingPacketPoolStat; | 196 | private Stat m_incomingPacketPoolStat; |
177 | 197 | ||
178 | private int m_defaultRTO = 0; | 198 | private int m_defaultRTO = 0; |
@@ -345,20 +365,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
345 | 365 | ||
346 | m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); | 366 | m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); |
347 | 367 | ||
348 | m_incomingPacketPoolStat | ||
349 | = new Stat( | ||
350 | "IncomingPacketPoolCount", | ||
351 | "Objects within incoming packet pool", | ||
352 | "The number of objects currently stored within the incoming packet pool", | ||
353 | "", | ||
354 | "clientstack", | ||
355 | "packetpool", | ||
356 | StatType.Pull, | ||
357 | stat => stat.Value = m_incomingPacketPool.Count, | ||
358 | StatVerbosity.Debug); | ||
359 | |||
360 | StatsManager.RegisterStat(m_incomingPacketPoolStat); | ||
361 | |||
362 | return true; | 368 | return true; |
363 | } | 369 | } |
364 | 370 | ||
@@ -382,6 +388,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
382 | } | 388 | } |
383 | 389 | ||
384 | /// <summary> | 390 | /// <summary> |
391 | /// This is a seperate method so that it can be called once we have an m_scene to distinguish different scene | ||
392 | /// stats. | ||
393 | /// </summary> | ||
394 | private void EnablePoolStats() | ||
395 | { | ||
396 | m_poolCountStat | ||
397 | = new Stat( | ||
398 | "UDPPacketBufferPoolCount", | ||
399 | "Objects within the UDPPacketBuffer pool", | ||
400 | "The number of objects currently stored within the UDPPacketBuffer pool", | ||
401 | "", | ||
402 | "clientstack", | ||
403 | m_scene.Name, | ||
404 | StatType.Pull, | ||
405 | stat => stat.Value = Pool.Count, | ||
406 | StatVerbosity.Debug); | ||
407 | |||
408 | StatsManager.RegisterStat(m_poolCountStat); | ||
409 | |||
410 | m_incomingPacketPoolStat | ||
411 | = new Stat( | ||
412 | "IncomingPacketPoolCount", | ||
413 | "Objects within incoming packet pool", | ||
414 | "The number of objects currently stored within the incoming packet pool", | ||
415 | "", | ||
416 | "clientstack", | ||
417 | m_scene.Name, | ||
418 | StatType.Pull, | ||
419 | stat => stat.Value = m_incomingPacketPool.Count, | ||
420 | StatVerbosity.Debug); | ||
421 | |||
422 | StatsManager.RegisterStat(m_incomingPacketPoolStat); | ||
423 | } | ||
424 | |||
425 | /// <summary> | ||
426 | /// Disables pool stats. | ||
427 | /// </summary> | ||
428 | private void DisablePoolStats() | ||
429 | { | ||
430 | StatsManager.DeregisterStat(m_poolCountStat); | ||
431 | m_poolCountStat = null; | ||
432 | |||
433 | StatsManager.DeregisterStat(m_incomingPacketPoolStat); | ||
434 | m_incomingPacketPoolStat = null; | ||
435 | } | ||
436 | |||
437 | /// <summary> | ||
385 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | 438 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. |
386 | /// </summary> | 439 | /// </summary> |
387 | /// <returns></returns> | 440 | /// <returns></returns> |
@@ -420,6 +473,65 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
420 | m_scene = (Scene)scene; | 473 | m_scene = (Scene)scene; |
421 | m_location = new Location(m_scene.RegionInfo.RegionHandle); | 474 | m_location = new Location(m_scene.RegionInfo.RegionHandle); |
422 | 475 | ||
476 | // XXX: These stats are also pool stats but we register them separately since they are currently not | ||
477 | // turned on and off by EnablePools()/DisablePools() | ||
478 | StatsManager.RegisterStat( | ||
479 | new PercentageStat( | ||
480 | "PacketsReused", | ||
481 | "Packets reused", | ||
482 | "Number of packets reused out of all requests to the packet pool", | ||
483 | "clientstack", | ||
484 | m_scene.Name, | ||
485 | StatType.Pull, | ||
486 | stat => | ||
487 | { PercentageStat pstat = (PercentageStat)stat; | ||
488 | pstat.Consequent = PacketPool.Instance.PacketsRequested; | ||
489 | pstat.Antecedent = PacketPool.Instance.PacketsReused; }, | ||
490 | StatVerbosity.Debug)); | ||
491 | |||
492 | StatsManager.RegisterStat( | ||
493 | new PercentageStat( | ||
494 | "PacketDataBlocksReused", | ||
495 | "Packet data blocks reused", | ||
496 | "Number of data blocks reused out of all requests to the packet pool", | ||
497 | "clientstack", | ||
498 | m_scene.Name, | ||
499 | StatType.Pull, | ||
500 | stat => | ||
501 | { PercentageStat pstat = (PercentageStat)stat; | ||
502 | pstat.Consequent = PacketPool.Instance.BlocksRequested; | ||
503 | pstat.Antecedent = PacketPool.Instance.BlocksReused; }, | ||
504 | StatVerbosity.Debug)); | ||
505 | |||
506 | StatsManager.RegisterStat( | ||
507 | new Stat( | ||
508 | "PacketsPoolCount", | ||
509 | "Objects within the packet pool", | ||
510 | "The number of objects currently stored within the packet pool", | ||
511 | "", | ||
512 | "clientstack", | ||
513 | m_scene.Name, | ||
514 | StatType.Pull, | ||
515 | stat => stat.Value = PacketPool.Instance.PacketsPooled, | ||
516 | StatVerbosity.Debug)); | ||
517 | |||
518 | StatsManager.RegisterStat( | ||
519 | new Stat( | ||
520 | "PacketDataBlocksPoolCount", | ||
521 | "Objects within the packet data block pool", | ||
522 | "The number of objects currently stored within the packet data block pool", | ||
523 | "", | ||
524 | "clientstack", | ||
525 | m_scene.Name, | ||
526 | StatType.Pull, | ||
527 | stat => stat.Value = PacketPool.Instance.BlocksPooled, | ||
528 | StatVerbosity.Debug)); | ||
529 | |||
530 | // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by | ||
531 | // scene name | ||
532 | if (UsePools) | ||
533 | EnablePoolStats(); | ||
534 | |||
423 | MainConsole.Instance.Commands.AddCommand( | 535 | MainConsole.Instance.Commands.AddCommand( |
424 | "Debug", | 536 | "Debug", |
425 | false, | 537 | false, |
@@ -508,12 +620,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
508 | if (enabled == "on") | 620 | if (enabled == "on") |
509 | { | 621 | { |
510 | if (EnablePools()) | 622 | if (EnablePools()) |
623 | { | ||
624 | EnablePoolStats(); | ||
511 | MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name); | 625 | MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name); |
626 | } | ||
512 | } | 627 | } |
513 | else if (enabled == "off") | 628 | else if (enabled == "off") |
514 | { | 629 | { |
515 | if (DisablePools()) | 630 | if (DisablePools()) |
631 | { | ||
632 | DisablePoolStats(); | ||
516 | MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name); | 633 | MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name); |
634 | } | ||
517 | } | 635 | } |
518 | else | 636 | else |
519 | { | 637 | { |
@@ -1621,6 +1739,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1621 | private int npacksSent = 0; | 1739 | private int npacksSent = 0; |
1622 | private int npackNotSent = 0; | 1740 | private int npackNotSent = 0; |
1623 | 1741 | ||
1742 | /// <summary> | ||
1743 | /// Number of inbound packets processed since startup. | ||
1744 | /// </summary> | ||
1745 | public long IncomingPacketsProcessed { get; private set; } | ||
1746 | |||
1624 | private void MonitoredClientOutgoingPacketHandler(IClientAPI client) | 1747 | private void MonitoredClientOutgoingPacketHandler(IClientAPI client) |
1625 | { | 1748 | { |
1626 | nticks++; | 1749 | nticks++; |
@@ -1680,7 +1803,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1680 | npacksSent++; | 1803 | npacksSent++; |
1681 | } | 1804 | } |
1682 | else | 1805 | else |
1806 | { | ||
1683 | npackNotSent++; | 1807 | npackNotSent++; |
1808 | } | ||
1684 | 1809 | ||
1685 | watch2.Stop(); | 1810 | watch2.Stop(); |
1686 | avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); | 1811 | avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); |
@@ -1688,7 +1813,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1688 | 1813 | ||
1689 | } | 1814 | } |
1690 | else | 1815 | else |
1816 | { | ||
1691 | m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); | 1817 | m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); |
1818 | } | ||
1692 | } | 1819 | } |
1693 | } | 1820 | } |
1694 | catch (Exception ex) | 1821 | catch (Exception ex) |
@@ -1752,6 +1879,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1752 | // "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", | 1879 | // "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", |
1753 | // packet.Type, client.Name, m_scene.RegionInfo.RegionName); | 1880 | // packet.Type, client.Name, m_scene.RegionInfo.RegionName); |
1754 | // } | 1881 | // } |
1882 | |||
1883 | IncomingPacketsProcessed++; | ||
1755 | } | 1884 | } |
1756 | 1885 | ||
1757 | protected void LogoutHandler(IClientAPI client) | 1886 | protected void LogoutHandler(IClientAPI client) |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 8bd3461..2aeb4cc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -61,14 +61,14 @@ namespace OpenMetaverse | |||
61 | private bool m_asyncPacketHandling; | 61 | private bool m_asyncPacketHandling; |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Pool to use for handling data. May be null if UsePools = false; | 64 | /// Are we to use object pool(s) to reduce memory churn when receiving data? |
65 | /// </summary> | 65 | /// </summary> |
66 | protected OpenSim.Framework.Pool<UDPPacketBuffer> m_pool; | 66 | public bool UsePools { get; protected set; } |
67 | 67 | ||
68 | /// <summary> | 68 | /// <summary> |
69 | /// Are we to use object pool(s) to reduce memory churn when receiving data? | 69 | /// Pool to use for handling data. May be null if UsePools = false; |
70 | /// </summary> | 70 | /// </summary> |
71 | public bool UsePools { get; protected set; } | 71 | protected OpenSim.Framework.Pool<UDPPacketBuffer> Pool { get; private set; } |
72 | 72 | ||
73 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> | 73 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> |
74 | public bool IsRunningInbound { get; private set; } | 74 | public bool IsRunningInbound { get; private set; } |
@@ -77,8 +77,6 @@ namespace OpenMetaverse | |||
77 | /// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks> | 77 | /// <remarks>If IsRunningOut = false, then any request to send a packet is simply dropped.</remarks> |
78 | public bool IsRunningOutbound { get; private set; } | 78 | public bool IsRunningOutbound { get; private set; } |
79 | 79 | ||
80 | private Stat m_poolCountStat; | ||
81 | |||
82 | /// <summary> | 80 | /// <summary> |
83 | /// Default constructor | 81 | /// Default constructor |
84 | /// </summary> | 82 | /// </summary> |
@@ -178,21 +176,7 @@ namespace OpenMetaverse | |||
178 | { | 176 | { |
179 | if (!UsePools) | 177 | if (!UsePools) |
180 | { | 178 | { |
181 | m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | 179 | Pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); |
182 | |||
183 | m_poolCountStat | ||
184 | = new Stat( | ||
185 | "UDPPacketBufferPoolCount", | ||
186 | "Objects within the UDPPacketBuffer pool", | ||
187 | "The number of objects currently stored within the UDPPacketBuffer pool", | ||
188 | "", | ||
189 | "clientstack", | ||
190 | "packetpool", | ||
191 | StatType.Pull, | ||
192 | stat => stat.Value = m_pool.Count, | ||
193 | StatVerbosity.Debug); | ||
194 | |||
195 | StatsManager.RegisterStat(m_poolCountStat); | ||
196 | 180 | ||
197 | UsePools = true; | 181 | UsePools = true; |
198 | 182 | ||
@@ -207,7 +191,6 @@ namespace OpenMetaverse | |||
207 | if (UsePools) | 191 | if (UsePools) |
208 | { | 192 | { |
209 | UsePools = false; | 193 | UsePools = false; |
210 | StatsManager.DeregisterStat(m_poolCountStat); | ||
211 | 194 | ||
212 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | 195 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. |
213 | 196 | ||
@@ -222,7 +205,7 @@ namespace OpenMetaverse | |||
222 | UDPPacketBuffer buf; | 205 | UDPPacketBuffer buf; |
223 | 206 | ||
224 | if (UsePools) | 207 | if (UsePools) |
225 | buf = m_pool.GetObject(); | 208 | buf = Pool.GetObject(); |
226 | else | 209 | else |
227 | buf = new UDPPacketBuffer(); | 210 | buf = new UDPPacketBuffer(); |
228 | 211 | ||
@@ -305,7 +288,7 @@ namespace OpenMetaverse | |||
305 | finally | 288 | finally |
306 | { | 289 | { |
307 | if (UsePools) | 290 | if (UsePools) |
308 | m_pool.ReturnObject(buffer); | 291 | Pool.ReturnObject(buffer); |
309 | 292 | ||
310 | // Synchronous mode waits until the packet callback completes | 293 | // Synchronous mode waits until the packet callback completes |
311 | // before starting the receive to fetch another packet | 294 | // before starting the receive to fetch another packet |
@@ -347,4 +330,4 @@ namespace OpenMetaverse | |||
347 | catch (ObjectDisposedException) { } | 330 | catch (ObjectDisposedException) { } |
348 | } | 331 | } |
349 | } | 332 | } |
350 | } | 333 | } \ 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 | } |