aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-10-23 02:44:15 +0100
committerJustin Clark-Casey (justincc)2012-10-23 02:44:15 +0100
commit319ebaca06db3d4a38beff74725d321b7c836157 (patch)
treea75a30d49042353bc963c5c7ccbf11b3e7b7020d /OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
parentAdd object count stats for new IncomingPacket and UDPPacketBuffer pools if th... (diff)
downloadopensim-SC-319ebaca06db3d4a38beff74725d321b7c836157.zip
opensim-SC-319ebaca06db3d4a38beff74725d321b7c836157.tar.gz
opensim-SC-319ebaca06db3d4a38beff74725d321b7c836157.tar.bz2
opensim-SC-319ebaca06db3d4a38beff74725d321b7c836157.tar.xz
Make it possible to turn the base UDP object packet pools on and off whilst running via the "debug lludp pool <on|off>" console command. For debug purposes.
This does not currently apply to the higher LLUDP packetpool.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs103
1 files changed, 86 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index bcfd392..14cc863 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -170,6 +170,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
170 170
171 private Pool<IncomingPacket> m_incomingPacketPool; 171 private Pool<IncomingPacket> m_incomingPacketPool;
172 172
173 private Stat m_incomingPacketPoolStat;
174
173 private int m_defaultRTO = 0; 175 private int m_defaultRTO = 0;
174 private int m_maxRTO = 0; 176 private int m_maxRTO = 0;
175 private int m_ackTimeout = 0; 177 private int m_ackTimeout = 0;
@@ -214,6 +216,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
214 216
215 m_circuitManager = circuitManager; 217 m_circuitManager = circuitManager;
216 int sceneThrottleBps = 0; 218 int sceneThrottleBps = 0;
219 bool usePools = false;
217 220
218 IConfig config = configSource.Configs["ClientStack.LindenUDP"]; 221 IConfig config = configSource.Configs["ClientStack.LindenUDP"];
219 if (config != null) 222 if (config != null)
@@ -246,7 +249,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
246 { 249 {
247 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 250 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
248 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 251 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
249 UsePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", false); 252 usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools);
250 } 253 }
251 254
252 #region BinaryStats 255 #region BinaryStats
@@ -277,22 +280,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
277 m_throttle = new TokenBucket(null, sceneThrottleBps); 280 m_throttle = new TokenBucket(null, sceneThrottleBps);
278 ThrottleRates = new ThrottleRates(configSource); 281 ThrottleRates = new ThrottleRates(configSource);
279 282
280 if (UsePools) 283 if (usePools)
281 { 284 EnablePools();
282 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
283
284 StatsManager.RegisterStat(
285 new Stat(
286 "IncomingPacketPoolCount",
287 "Objects within incoming packet pool",
288 "The number of objects currently stored within the incoming packet pool",
289 "",
290 "clientstack",
291 "packetpool",
292 StatType.Pull,
293 stat => stat.Value = m_incomingPacketPool.Count,
294 StatVerbosity.Debug));
295 }
296 } 285 }
297 286
298 public void Start() 287 public void Start()
@@ -345,6 +334,50 @@ namespace OpenSim.Region.ClientStack.LindenUDP
345 base.StopInbound(); 334 base.StopInbound();
346 } 335 }
347 336
337 protected override bool EnablePools()
338 {
339 if (!UsePools)
340 {
341 base.EnablePools();
342
343 m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500);
344
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;
360 }
361
362 return false;
363 }
364
365 protected override bool DisablePools()
366 {
367 if (UsePools)
368 {
369 base.DisablePools();
370
371 StatsManager.DeregisterStat(m_incomingPacketPoolStat);
372
373 // We won't null out the pool to avoid a race condition with code that may be in the middle of using it.
374
375 return true;
376 }
377
378 return false;
379 }
380
348 /// <summary> 381 /// <summary>
349 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. 382 /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
350 /// </summary> 383 /// </summary>
@@ -411,6 +444,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
411 MainConsole.Instance.Commands.AddCommand( 444 MainConsole.Instance.Commands.AddCommand(
412 "Debug", 445 "Debug",
413 false, 446 false,
447 "debug lludp pool",
448 "debug lludp pool <on|off>",
449 "Turn object pooling within the lludp component on or off.",
450 HandlePoolCommand);
451
452 MainConsole.Instance.Commands.AddCommand(
453 "Debug",
454 false,
414 "debug lludp status", 455 "debug lludp status",
415 "debug lludp status", 456 "debug lludp status",
416 "Return status of LLUDP packet processing.", 457 "Return status of LLUDP packet processing.",
@@ -451,6 +492,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
451 StopOutbound(); 492 StopOutbound();
452 } 493 }
453 494
495 private void HandlePoolCommand(string module, string[] args)
496 {
497 if (args.Length != 4)
498 {
499 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
500 return;
501 }
502
503 string enabled = args[3];
504
505 if (enabled == "on")
506 {
507 if (EnablePools())
508 MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name);
509 }
510 else if (enabled == "off")
511 {
512 if (DisablePools())
513 MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name);
514 }
515 else
516 {
517 MainConsole.Instance.Output("Usage: debug lludp pool <on|off>");
518 }
519 }
520
454 private void HandleStatusCommand(string module, string[] args) 521 private void HandleStatusCommand(string module, string[] args)
455 { 522 {
456 MainConsole.Instance.OutputFormat( 523 MainConsole.Instance.OutputFormat(
@@ -458,6 +525,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
458 525
459 MainConsole.Instance.OutputFormat( 526 MainConsole.Instance.OutputFormat(
460 "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled"); 527 "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled");
528
529 MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off");
461 } 530 }
462 531
463 public bool HandlesRegion(Location x) 532 public bool HandlesRegion(Location x)