aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-15 01:14:18 +0000
committerJustin Clark-Casey (justincc)2012-11-15 01:14:18 +0000
commit2c36106675ad984ba5af674cbb970b17ffa320bb (patch)
treef579f670e29f267611acfb25cbcd92e3d4f550c3 /OpenSim/Region
parentAdded AssemblyInfos in the OpenSim.Server namespace dlls. (diff)
downloadopensim-SC_OLD-2c36106675ad984ba5af674cbb970b17ffa320bb.zip
opensim-SC_OLD-2c36106675ad984ba5af674cbb970b17ffa320bb.tar.gz
opensim-SC_OLD-2c36106675ad984ba5af674cbb970b17ffa320bb.tar.bz2
opensim-SC_OLD-2c36106675ad984ba5af674cbb970b17ffa320bb.tar.xz
Add IncomingPacketsProcessedCount stat for diagnostics.
Also puts some packet processing counts in a container named after the scene so that stats can be collected from more than one scene.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs103
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs31
2 files changed, 96 insertions, 38 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 14cc863..f8391d7 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)
@@ -170,6 +182,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
170 182
171 private Pool<IncomingPacket> m_incomingPacketPool; 183 private Pool<IncomingPacket> m_incomingPacketPool;
172 184
185 /// <summary>
186 /// Stat for number of packets in the main pool awaiting use.
187 /// </summary>
188 private Stat m_poolCountStat;
189
190 /// <summary>
191 /// Stat for number of packets in the inbound packet pool awaiting use.
192 /// </summary>
173 private Stat m_incomingPacketPoolStat; 193 private Stat m_incomingPacketPoolStat;
174 194
175 private int m_defaultRTO = 0; 195 private int m_defaultRTO = 0;
@@ -342,20 +362,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
342 362
343 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); 363 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
344 364
345 m_incomingPacketPoolStat
346 = new Stat(
347 "IncomingPacketPoolCount",
348 "Objects within incoming packet pool",
349 "The number of objects currently stored within the incoming packet pool",
350 "",
351 "clientstack",
352 "packetpool",
353 StatType.Pull,
354 stat => stat.Value = m_incomingPacketPool.Count,
355 StatVerbosity.Debug);
356
357 StatsManager.RegisterStat(m_incomingPacketPoolStat);
358
359 return true; 365 return true;
360 } 366 }
361 367
@@ -379,6 +385,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP
379 } 385 }
380 386
381 /// <summary> 387 /// <summary>
388 /// This is a seperate method so that it can be called once we have an m_scene to distinguish different scene
389 /// stats.
390 /// </summary>
391 private void EnablePoolStats()
392 {
393 m_poolCountStat
394 = new Stat(
395 "UDPPacketBufferPoolCount",
396 "Objects within the UDPPacketBuffer pool",
397 "The number of objects currently stored within the UDPPacketBuffer pool",
398 "",
399 "clientstack",
400 m_scene.Name,
401 StatType.Pull,
402 stat => stat.Value = Pool.Count,
403 StatVerbosity.Debug);
404
405 StatsManager.RegisterStat(m_poolCountStat);
406
407 m_incomingPacketPoolStat
408 = new Stat(
409 "IncomingPacketPoolCount",
410 "Objects within incoming packet pool",
411 "The number of objects currently stored within the incoming packet pool",
412 "",
413 "clientstack",
414 m_scene.Name,
415 StatType.Pull,
416 stat => stat.Value = m_incomingPacketPool.Count,
417 StatVerbosity.Debug);
418
419 StatsManager.RegisterStat(m_incomingPacketPoolStat);
420 }
421
422 /// <summary>
423 /// Disables pool stats.
424 /// </summary>
425 private void DisablePoolStats()
426 {
427 StatsManager.DeregisterStat(m_poolCountStat);
428 m_poolCountStat = null;
429
430 StatsManager.DeregisterStat(m_incomingPacketPoolStat);
431 m_incomingPacketPoolStat = null;
432 }
433
434 /// <summary>
382 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. 435 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
383 /// </summary> 436 /// </summary>
384 /// <returns></returns> 437 /// <returns></returns>
@@ -416,6 +469,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
416 469
417 m_scene = (Scene)scene; 470 m_scene = (Scene)scene;
418 m_location = new Location(m_scene.RegionInfo.RegionHandle); 471 m_location = new Location(m_scene.RegionInfo.RegionHandle);
472
473 // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by
474 // scene name
475 if (UsePools)
476 EnablePoolStats();
419 477
420 MainConsole.Instance.Commands.AddCommand( 478 MainConsole.Instance.Commands.AddCommand(
421 "Debug", 479 "Debug",
@@ -505,12 +563,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
505 if (enabled == "on") 563 if (enabled == "on")
506 { 564 {
507 if (EnablePools()) 565 if (EnablePools())
566 {
567 EnablePoolStats();
508 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name); 568 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name);
569 }
509 } 570 }
510 else if (enabled == "off") 571 else if (enabled == "off")
511 { 572 {
512 if (DisablePools()) 573 if (DisablePools())
574 {
575 DisablePoolStats();
513 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name); 576 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name);
577 }
514 } 578 }
515 else 579 else
516 { 580 {
@@ -1556,6 +1620,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1556 private int npacksSent = 0; 1620 private int npacksSent = 0;
1557 private int npackNotSent = 0; 1621 private int npackNotSent = 0;
1558 1622
1623 /// <summary>
1624 /// Number of inbound packets processed since startup.
1625 /// </summary>
1626 public long IncomingPacketsProcessed { get; private set; }
1627
1559 private void MonitoredClientOutgoingPacketHandler(IClientAPI client) 1628 private void MonitoredClientOutgoingPacketHandler(IClientAPI client)
1560 { 1629 {
1561 nticks++; 1630 nticks++;
@@ -1615,7 +1684,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1615 npacksSent++; 1684 npacksSent++;
1616 } 1685 }
1617 else 1686 else
1687 {
1618 npackNotSent++; 1688 npackNotSent++;
1689 }
1619 1690
1620 watch2.Stop(); 1691 watch2.Stop();
1621 avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); 1692 avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
@@ -1623,7 +1694,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1623 1694
1624 } 1695 }
1625 else 1696 else
1697 {
1626 m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); 1698 m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
1699 }
1627 } 1700 }
1628 } 1701 }
1629 catch (Exception ex) 1702 catch (Exception ex)
@@ -1687,6 +1760,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1687 "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", 1760 "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
1688 packet.Type, client.Name, m_scene.RegionInfo.RegionName); 1761 packet.Type, client.Name, m_scene.RegionInfo.RegionName);
1689 } 1762 }
1763
1764 IncomingPacketsProcessed++;
1690 } 1765 }
1691 1766
1692 protected void LogoutHandler(IClientAPI client) 1767 protected void LogoutHandler(IClientAPI client)
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs
index 85cbb06..808d177 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>
@@ -182,21 +180,7 @@ namespace OpenMetaverse
182 { 180 {
183 if (!UsePools) 181 if (!UsePools)
184 { 182 {
185 m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); 183 Pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500);
186
187 m_poolCountStat
188 = new Stat(
189 "UDPPacketBufferPoolCount",
190 "Objects within the UDPPacketBuffer pool",
191 "The number of objects currently stored within the UDPPacketBuffer pool",
192 "",
193 "clientstack",
194 "packetpool",
195 StatType.Pull,
196 stat => stat.Value = m_pool.Count,
197 StatVerbosity.Debug);
198
199 StatsManager.RegisterStat(m_poolCountStat);
200 184
201 UsePools = true; 185 UsePools = true;
202 186
@@ -211,7 +195,6 @@ namespace OpenMetaverse
211 if (UsePools) 195 if (UsePools)
212 { 196 {
213 UsePools = false; 197 UsePools = false;
214 StatsManager.DeregisterStat(m_poolCountStat);
215 198
216 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. 199 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
217 200
@@ -226,7 +209,7 @@ namespace OpenMetaverse
226 UDPPacketBuffer buf; 209 UDPPacketBuffer buf;
227 210
228 if (UsePools) 211 if (UsePools)
229 buf = m_pool.GetObject(); 212 buf = Pool.GetObject();
230 else 213 else
231 buf = new UDPPacketBuffer(); 214 buf = new UDPPacketBuffer();
232 215
@@ -309,7 +292,7 @@ namespace OpenMetaverse
309 finally 292 finally
310 { 293 {
311 if (UsePools) 294 if (UsePools)
312 m_pool.ReturnObject(buffer); 295 Pool.ReturnObject(buffer);
313 296
314 // Synchronous mode waits until the packet callback completes 297 // Synchronous mode waits until the packet callback completes
315 // before starting the receive to fetch another packet 298 // before starting the receive to fetch another packet