aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-02-22 20:50:30 +0000
committerJustin Clarke Casey2008-02-22 20:50:30 +0000
commit30eea2618dcc0a43d1d4d764590100c19bd7c05d (patch)
tree95d743afebbc8310ba15949131ab11a1d52c21fa /OpenSim
parentSome misplaced code made scripts never start :) (diff)
downloadopensim-SC-30eea2618dcc0a43d1d4d764590100c19bd7c05d.zip
opensim-SC-30eea2618dcc0a43d1d4d764590100c19bd7c05d.tar.gz
opensim-SC-30eea2618dcc0a43d1d4d764590100c19bd7c05d.tar.bz2
opensim-SC-30eea2618dcc0a43d1d4d764590100c19bd7c05d.tar.xz
* Implement packet queue statistics
* This will show the packets waiting in each queue for each client logged into a region server * These are displayed using 'show stats' on the region command line * This is in pursuit of a memory leak. * This will require a prebuild
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Statistics/SimExtraStatsReporter.cs95
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs2
-rw-r--r--OpenSim/Region/ClientStack/PacketQueue.cs37
3 files changed, 124 insertions, 10 deletions
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs b/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
index c8b8223..acf2ecb 100644
--- a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
+++ b/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs
@@ -26,12 +26,19 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
29using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Statistics.Interfaces;
35
36using libsecondlife;
30 37
31namespace OpenSim.Framework.Statistics 38namespace OpenSim.Framework.Statistics
32{ 39{
33 public class SimExtraStatsReporter 40 public class SimExtraStatsReporter
34 { 41 {
35 private long assetsInCache; 42 private long assetsInCache;
36 private long texturesInCache; 43 private long texturesInCache;
37 private long assetCacheMemoryUsage; 44 private long assetCacheMemoryUsage;
@@ -42,6 +49,12 @@ namespace OpenSim.Framework.Statistics
42 public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } 49 public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
43 public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } 50 public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
44 51
52 /// <summary>
53 /// Retain a dictionary of all packet queues stats reporters
54 /// </summary>
55 private IDictionary<LLUUID, PacketQueueStatsReporter> packetQueueStatsReporters
56 = new Dictionary<LLUUID, PacketQueueStatsReporter>();
57
45 public void AddAsset(AssetBase asset) 58 public void AddAsset(AssetBase asset)
46 { 59 {
47 assetsInCache++; 60 assetsInCache++;
@@ -56,19 +69,87 @@ namespace OpenSim.Framework.Statistics
56 texturesInCache++; 69 texturesInCache++;
57 textureCacheMemoryUsage += image.Data.Length; 70 textureCacheMemoryUsage += image.Data.Length;
58 } 71 }
59 } 72 }
73
74 /// <summary>
75 /// Register as a packet queue stats provider
76 /// </summary>
77 /// <param name="uuid">An agent LLUUID</param>
78 /// <param name="provider"></param>
79 public void RegisterPacketQueueStatsProvider(LLUUID uuid, IPullStatsProvider provider)
80 {
81 lock (packetQueueStatsReporters)
82 {
83 packetQueueStatsReporters[uuid] = new PacketQueueStatsReporter(provider);
84 }
85 }
86
87 /// <summary>
88 /// Deregister a packet queue stats provider
89 /// </summary>
90 /// <param name="uuid">An agent LLUUID</param>
91 public void DeregisterPacketQueueStatsProvider(LLUUID uuid)
92 {
93 lock (packetQueueStatsReporters)
94 {
95 packetQueueStatsReporters.Remove(uuid);
96 }
97 }
60 98
61 /// <summary> 99 /// <summary>
62 /// Report back collected statistical information. 100 /// Report back collected statistical information.
63 /// </summary> 101 /// </summary>
64 /// <returns></returns> 102 /// <returns></returns>
65 public string Report() 103 public string Report()
66 { 104 {
67 return string.Format( 105 StringBuilder sb = new StringBuilder(Environment.NewLine);
106 sb.Append("PACKET QUEUE STATISTICS");
107 sb.Append(Environment.NewLine);
108 sb.Append(
109 string.Format(
68@"Asset cache contains {0,6} assets using {1,10:0.000}K 110@"Asset cache contains {0,6} assets using {1,10:0.000}K
69Texture cache contains {2,6} textures using {3,10:0.000}K", 111Texture cache contains {2,6} textures using {3,10:0.000}K" + Environment.NewLine,
70 AssetsInCache, AssetCacheMemoryUsage / 1024.0, 112 AssetsInCache, AssetCacheMemoryUsage / 1024.0,
71 TexturesInCache, TextureCacheMemoryUsage / 1024.0); 113 TexturesInCache, TextureCacheMemoryUsage / 1024.0));
114
115 sb.Append(Environment.NewLine);
116 sb.Append("PACKET QUEUE STATISTICS");
117 sb.Append(Environment.NewLine);
118 sb.Append("Agent UUID ");
119 sb.Append(" Send In Out Resend ");
120 sb.Append(" Land Wind Cloud Task Texture Asset");
121 sb.Append(Environment.NewLine);
122
123 foreach (LLUUID key in packetQueueStatsReporters.Keys)
124 {
125 sb.Append(string.Format("{0}: ", key));
126 sb.Append(packetQueueStatsReporters[key].Report());
127 sb.Append(Environment.NewLine);
128 }
129
130 return sb.ToString();
72 } 131 }
73 } 132 }
133
134 /// <summary>
135 /// Pull packet queue stats from packet queues and report
136 /// </summary>
137 public class PacketQueueStatsReporter
138 {
139 private IPullStatsProvider m_statsProvider;
140
141 public PacketQueueStatsReporter(IPullStatsProvider provider)
142 {
143 m_statsProvider = provider;
144 }
145
146 /// <summary>
147 /// Report back collected statistical information.
148 /// </summary>
149 /// <returns></returns>
150 public string Report()
151 {
152 return m_statsProvider.GetStats();
153 }
154 }
74} 155}
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 2cedc81..8bdbe89 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -317,7 +317,7 @@ namespace OpenSim.Region.ClientStack
317 // in it to process. It's an on-purpose threadlock though because 317 // in it to process. It's an on-purpose threadlock though because
318 // without it, the clientloop will suck up all sim resources. 318 // without it, the clientloop will suck up all sim resources.
319 319
320 m_packetQueue = new PacketQueue(); 320 m_packetQueue = new PacketQueue(agentId);
321 321
322 RegisterLocalPacketHandlers(); 322 RegisterLocalPacketHandlers();
323 323
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs
index 06ed32e..4673082 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/PacketQueue.cs
@@ -29,13 +29,16 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using System.Timers; 31using System.Timers;
32using libsecondlife;
32using libsecondlife.Packets; 33using libsecondlife.Packets;
33using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Statistics;
36using OpenSim.Framework.Statistics.Interfaces;
34using Timer=System.Timers.Timer; 37using Timer=System.Timers.Timer;
35 38
36namespace OpenSim.Region.ClientStack 39namespace OpenSim.Region.ClientStack
37{ 40{
38 public class PacketQueue 41 public class PacketQueue : IPullStatsProvider
39 { 42 {
40 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 43 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
41 44
@@ -76,8 +79,10 @@ namespace OpenSim.Region.ClientStack
76 // private long LastThrottle; 79 // private long LastThrottle;
77 // private long ThrottleInterval; 80 // private long ThrottleInterval;
78 private Timer throttleTimer; 81 private Timer throttleTimer;
82
83 private LLUUID m_agentId;
79 84
80 public PacketQueue() 85 public PacketQueue(LLUUID agentId)
81 { 86 {
82 // While working on this, the BlockingQueue had me fooled for a bit. 87 // While working on this, the BlockingQueue had me fooled for a bit.
83 // The Blocking queue causes the thread to stop until there's something 88 // The Blocking queue causes the thread to stop until there's something
@@ -116,6 +121,13 @@ namespace OpenSim.Region.ClientStack
116 // TIMERS needed for this 121 // TIMERS needed for this
117 // LastThrottle = DateTime.Now.Ticks; 122 // LastThrottle = DateTime.Now.Ticks;
118 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); 123 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);
124
125 m_agentId = agentId;
126
127 if (StatsManager.SimExtraStats != null)
128 {
129 StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this);
130 }
119 } 131 }
120 132
121 /* STANDARD QUEUE MANIPULATION INTERFACES */ 133 /* STANDARD QUEUE MANIPULATION INTERFACES */
@@ -214,6 +226,11 @@ namespace OpenSim.Region.ClientStack
214 { 226 {
215 m_enabled = false; 227 m_enabled = false;
216 throttleTimer.Stop(); 228 throttleTimer.Stop();
229
230 if (StatsManager.SimExtraStats != null)
231 {
232 StatsManager.SimExtraStats.DeregisterPacketQueueStatsProvider(m_agentId);
233 }
217 } 234 }
218 235
219 private void ResetCounters() 236 private void ResetCounters()
@@ -483,5 +500,21 @@ namespace OpenSim.Region.ClientStack
483 // effectively wiggling the slider causes things reset 500 // effectively wiggling the slider causes things reset
484 ResetCounters(); 501 ResetCounters();
485 } 502 }
503
504 // See IPullStatsProvider
505 public string GetStats()
506 {
507 return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
508 SendQueue.Count(),
509 IncomingPacketQueue.Count,
510 OutgoingPacketQueue.Count,
511 ResendOutgoingPacketQueue.Count,
512 LandOutgoingPacketQueue.Count,
513 WindOutgoingPacketQueue.Count,
514 CloudOutgoingPacketQueue.Count,
515 TaskOutgoingPacketQueue.Count,
516 TextureOutgoingPacketQueue.Count,
517 AssetOutgoingPacketQueue.Count);
518 }
486 } 519 }
487} 520}