diff options
author | Justin Clark-Casey (justincc) | 2012-10-23 02:44:15 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-23 02:44:15 +0100 |
commit | 319ebaca06db3d4a38beff74725d321b7c836157 (patch) | |
tree | a75a30d49042353bc963c5c7ccbf11b3e7b7020d /OpenSim/Region/ClientStack/Linden/UDP | |
parent | Add object count stats for new IncomingPacket and UDPPacketBuffer pools if th... (diff) | |
download | opensim-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.cs | 103 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 66 |
2 files changed, 131 insertions, 38 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) |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 18abfd6..85cbb06 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -77,6 +77,8 @@ 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 | |||
80 | /// <summary> | 82 | /// <summary> |
81 | /// Default constructor | 83 | /// Default constructor |
82 | /// </summary> | 84 | /// </summary> |
@@ -107,27 +109,6 @@ namespace OpenMetaverse | |||
107 | /// necessary</remarks> | 109 | /// necessary</remarks> |
108 | public void StartInbound(int recvBufferSize, bool asyncPacketHandling) | 110 | public void StartInbound(int recvBufferSize, bool asyncPacketHandling) |
109 | { | 111 | { |
110 | if (UsePools) | ||
111 | { | ||
112 | m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | ||
113 | |||
114 | StatsManager.RegisterStat( | ||
115 | new Stat( | ||
116 | "UDPPacketBufferPoolCount", | ||
117 | "Objects within the UDPPacketBuffer pool", | ||
118 | "The number of objects currently stored within the UDPPacketBuffer pool", | ||
119 | "", | ||
120 | "clientstack", | ||
121 | "packetpool", | ||
122 | StatType.Pull, | ||
123 | stat => stat.Value = m_pool.Count, | ||
124 | StatVerbosity.Debug)); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_pool = null; | ||
129 | } | ||
130 | |||
131 | m_asyncPacketHandling = asyncPacketHandling; | 112 | m_asyncPacketHandling = asyncPacketHandling; |
132 | 113 | ||
133 | if (!IsRunningInbound) | 114 | if (!IsRunningInbound) |
@@ -197,6 +178,49 @@ namespace OpenMetaverse | |||
197 | IsRunningOutbound = false; | 178 | IsRunningOutbound = false; |
198 | } | 179 | } |
199 | 180 | ||
181 | protected virtual bool EnablePools() | ||
182 | { | ||
183 | if (!UsePools) | ||
184 | { | ||
185 | m_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 | |||
201 | UsePools = true; | ||
202 | |||
203 | return true; | ||
204 | } | ||
205 | |||
206 | return false; | ||
207 | } | ||
208 | |||
209 | protected virtual bool DisablePools() | ||
210 | { | ||
211 | if (UsePools) | ||
212 | { | ||
213 | UsePools = false; | ||
214 | StatsManager.DeregisterStat(m_poolCountStat); | ||
215 | |||
216 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | ||
217 | |||
218 | return true; | ||
219 | } | ||
220 | |||
221 | return false; | ||
222 | } | ||
223 | |||
200 | private void AsyncBeginReceive() | 224 | private void AsyncBeginReceive() |
201 | { | 225 | { |
202 | UDPPacketBuffer buf; | 226 | UDPPacketBuffer buf; |