diff options
author | Glenn Martin | 2015-04-20 14:55:00 -0400 |
---|---|---|
committer | Glenn Martin | 2015-04-21 14:29:17 -0400 |
commit | 1959eb8372b6c8e35e1afa435504e9ef41dec958 (patch) | |
tree | d9cb670464215a7baeaee11638544635237f5eb7 /OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |
parent | Revert "Enable grab feature (Ctrl+Drag) for non-physical link-sets and add co... (diff) | |
download | opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.zip opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.gz opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.bz2 opensim-SC_OLD-1959eb8372b6c8e35e1afa435504e9ef41dec958.tar.xz |
Moved over metrics from previous OpenSim 0.8.0.3 repository (this new repository is now the master branch from OpenSim).
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rwxr-xr-x[-rw-r--r--] | OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 216 |
1 files changed, 203 insertions, 13 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 8f1e345..b6da636 100644..100755 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -61,6 +61,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | 61 | ||
62 | private YourStatsAreWrong handlerStatsIncorrect; | 62 | private YourStatsAreWrong handlerStatsIncorrect; |
63 | 63 | ||
64 | // Determines the size of the array that is used to collect StatBlocks | ||
65 | // for sending to the SimStats and SimExtraStatsCollector | ||
66 | private const int m_statisticArraySize = 26; | ||
67 | |||
64 | /// <summary> | 68 | /// <summary> |
65 | /// These are the IDs of stats sent in the StatsPacket to the viewer. | 69 | /// These are the IDs of stats sent in the StatsPacket to the viewer. |
66 | /// </summary> | 70 | /// </summary> |
@@ -104,7 +108,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | ScriptEps = 31, | 108 | ScriptEps = 31, |
105 | SimSpareMs = 32, | 109 | SimSpareMs = 32, |
106 | SimSleepMs = 33, | 110 | SimSleepMs = 33, |
107 | SimIoPumpTime = 34 | 111 | SimIoPumpTime = 34, |
112 | UsersLoggingIn = 35, | ||
113 | TotalGeoPrim = 36, | ||
114 | TotalMesh = 37, | ||
115 | ThreadCount = 38 | ||
108 | } | 116 | } |
109 | 117 | ||
110 | /// <summary> | 118 | /// <summary> |
@@ -175,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
175 | 183 | ||
176 | // saved last reported value so there is something available for llGetRegionFPS | 184 | // saved last reported value so there is something available for llGetRegionFPS |
177 | private float lastReportedSimFPS; | 185 | private float lastReportedSimFPS; |
178 | private float[] lastReportedSimStats = new float[22]; | 186 | private float[] lastReportedSimStats = new float[m_statisticArraySize]; |
179 | private float m_pfps; | 187 | private float m_pfps; |
180 | 188 | ||
181 | /// <summary> | 189 | /// <summary> |
@@ -202,6 +210,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
202 | private int m_rootAgents; | 210 | private int m_rootAgents; |
203 | private int m_childAgents; | 211 | private int m_childAgents; |
204 | private int m_numPrim; | 212 | private int m_numPrim; |
213 | private int m_numGeoPrim; | ||
214 | private int m_numMesh; | ||
205 | private int m_inPacketsPerSecond; | 215 | private int m_inPacketsPerSecond; |
206 | private int m_outPacketsPerSecond; | 216 | private int m_outPacketsPerSecond; |
207 | private int m_activePrim; | 217 | private int m_activePrim; |
@@ -213,6 +223,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | 223 | ||
214 | private int m_objectCapacity = 45000; | 224 | private int m_objectCapacity = 45000; |
215 | 225 | ||
226 | // This is the number of frames that will be stored and then averaged for | ||
227 | // the Total, Simulation, Physics, and Network Frame Time; It is set to | ||
228 | // 10 by default but can be changed by the OpenSim.ini configuration file | ||
229 | // NumberOfFrames parameter | ||
230 | private int m_numberFramesStored = 10; | ||
231 | |||
232 | // The arrays that will hold the time it took to run the past N frames, | ||
233 | // where N is the num_frames_to_average given by the configuration file | ||
234 | private double[] m_totalFrameTimeMilliseconds; | ||
235 | private double[] m_simulationFrameTimeMilliseconds; | ||
236 | private double[] m_physicsFrameTimeMilliseconds; | ||
237 | private double[] m_networkFrameTimeMilliseconds; | ||
238 | |||
239 | // The location of the next time in milliseconds that will be | ||
240 | // (over)written when the next frame completes | ||
241 | private int m_nextLocation = 0; | ||
242 | |||
243 | // The correct number of frames that have completed since the last stats | ||
244 | // update for physics | ||
245 | private int m_numberPhysicsFrames; | ||
246 | |||
247 | // The current number of users attempting to login to the region | ||
248 | private int m_usersLoggingIn; | ||
249 | |||
250 | // The last reported value of threads from the SmartThreadPool inside of | ||
251 | // XEngine | ||
252 | private int m_inUseThreads; | ||
253 | |||
216 | private Scene m_scene; | 254 | private Scene m_scene; |
217 | 255 | ||
218 | private RegionInfo ReportingRegion; | 256 | private RegionInfo ReportingRegion; |
@@ -223,6 +261,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
223 | 261 | ||
224 | public SimStatsReporter(Scene scene) | 262 | public SimStatsReporter(Scene scene) |
225 | { | 263 | { |
264 | // Initialize the different frame time arrays to the correct sizes | ||
265 | m_totalFrameTimeMilliseconds = new double[m_numberFramesStored]; | ||
266 | m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored]; | ||
267 | m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored]; | ||
268 | m_networkFrameTimeMilliseconds = new double[m_numberFramesStored]; | ||
269 | |||
270 | // Initialize the current number of users logging into the region | ||
271 | m_usersLoggingIn = 0; | ||
272 | |||
226 | m_scene = scene; | 273 | m_scene = scene; |
227 | m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; | 274 | m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; |
228 | m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); | 275 | m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); |
@@ -256,6 +303,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
256 | StatsManager.RegisterStat(SlowFramesStat); | 303 | StatsManager.RegisterStat(SlowFramesStat); |
257 | } | 304 | } |
258 | 305 | ||
306 | |||
307 | public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene) | ||
308 | { | ||
309 | // Store the number of frames from the OpenSim.ini configuration file | ||
310 | m_numberFramesStored = numberOfFrames; | ||
311 | } | ||
312 | |||
313 | |||
259 | public void Close() | 314 | public void Close() |
260 | { | 315 | { |
261 | m_report.Elapsed -= TriggerStatsHeartbeat; | 316 | m_report.Elapsed -= TriggerStatsHeartbeat; |
@@ -289,10 +344,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
289 | 344 | ||
290 | private void statsHeartBeat(object sender, EventArgs e) | 345 | private void statsHeartBeat(object sender, EventArgs e) |
291 | { | 346 | { |
347 | double totalSumFrameTime; | ||
348 | double simulationSumFrameTime; | ||
349 | double physicsSumFrameTime; | ||
350 | double networkSumFrameTime; | ||
351 | float timeDilation; | ||
352 | int currentFrame; | ||
353 | |||
292 | if (!m_scene.Active) | 354 | if (!m_scene.Active) |
293 | return; | 355 | return; |
294 | 356 | ||
295 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 357 | // Create arrays to hold the statistics for this current scene, |
358 | // these will be passed to the SimExtraStatsCollector, they are also | ||
359 | // sent to the SimStats class | ||
360 | SimStatsPacket.StatBlock[] sb = new | ||
361 | SimStatsPacket.StatBlock[m_statisticArraySize]; | ||
296 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 362 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
297 | 363 | ||
298 | // Know what's not thread safe in Mono... modifying timers. | 364 | // Know what's not thread safe in Mono... modifying timers. |
@@ -314,14 +380,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
314 | 380 | ||
315 | #region various statistic googly moogly | 381 | #region various statistic googly moogly |
316 | 382 | ||
383 | // ORIGINAL code commented out until we have time to add our own | ||
384 | // statistics to the statistics window, this will be done as a | ||
385 | // new section given the title of our current project | ||
317 | // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently | 386 | // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently |
318 | // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. | 387 | // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. |
319 | int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); | 388 | //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); |
389 | int reportedFPS = m_fps; | ||
320 | 390 | ||
321 | // save the reported value so there is something available for llGetRegionFPS | 391 | // save the reported value so there is something available for llGetRegionFPS |
322 | lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; | 392 | lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; |
323 | 393 | ||
324 | float physfps = ((m_pfps / 1000)); | 394 | // ORIGINAL code commented out until we have time to add our own |
395 | // statistics to the statistics window | ||
396 | //float physfps = ((m_pfps / 1000)); | ||
397 | float physfps = m_numberPhysicsFrames; | ||
325 | 398 | ||
326 | //if (physfps > 600) | 399 | //if (physfps > 600) |
327 | //physfps = physfps - (physfps - 600); | 400 | //physfps = physfps - (physfps - 600); |
@@ -334,6 +407,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
334 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 407 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
335 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 408 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
336 | m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); | 409 | m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); |
410 | m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount(); | ||
411 | m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount(); | ||
337 | m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); | 412 | m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); |
338 | m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); | 413 | m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); |
339 | 414 | ||
@@ -359,13 +434,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | if (framesUpdated == 0) | 434 | if (framesUpdated == 0) |
360 | framesUpdated = 1; | 435 | framesUpdated = 1; |
361 | 436 | ||
362 | for (int i = 0; i < 22; i++) | 437 | for (int i = 0; i < m_statisticArraySize; i++) |
363 | { | 438 | { |
364 | sb[i] = new SimStatsPacket.StatBlock(); | 439 | sb[i] = new SimStatsPacket.StatBlock(); |
365 | } | 440 | } |
366 | 441 | ||
442 | // Resetting the sums of the frame times to prevent any errors | ||
443 | // in calculating the moving average for frame time | ||
444 | totalSumFrameTime = 0; | ||
445 | simulationSumFrameTime = 0; | ||
446 | physicsSumFrameTime = 0; | ||
447 | networkSumFrameTime = 0; | ||
448 | |||
449 | // Loop through all the frames that were stored for the current | ||
450 | // heartbeat to process the moving average of frame times | ||
451 | for (int i = 0; i < m_numberFramesStored; i++) | ||
452 | { | ||
453 | // Sum up each frame time in order to calculate the moving | ||
454 | // average of frame time | ||
455 | totalSumFrameTime += m_totalFrameTimeMilliseconds[i]; | ||
456 | simulationSumFrameTime += | ||
457 | m_simulationFrameTimeMilliseconds[i]; | ||
458 | physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i]; | ||
459 | networkSumFrameTime += m_networkFrameTimeMilliseconds[i]; | ||
460 | } | ||
461 | |||
462 | // Get the index that represents the current frame based on the next one known; go back | ||
463 | // to the last index if next one is stated to restart at 0 | ||
464 | if (m_nextLocation == 0) | ||
465 | currentFrame = m_numberFramesStored - 1; | ||
466 | else | ||
467 | currentFrame = m_nextLocation - 1; | ||
468 | |||
469 | // Calculate the time dilation; which is currently based on the ratio between the sum of the | ||
470 | // physics and simulation rate, and the set minimum time to run the scene's update; minFrameTime | ||
471 | // is given in seconds so multiply by 1000 to convert it to milliseconds | ||
472 | timeDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] + | ||
473 | m_physicsFrameTimeMilliseconds[currentFrame]) / (m_scene.MinFrameTime * 1000); | ||
474 | |||
475 | // ORIGINAL code commented out until we have time to add our own | ||
367 | sb[0].StatID = (uint) Stats.TimeDilation; | 476 | sb[0].StatID = (uint) Stats.TimeDilation; |
368 | sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); | 477 | //sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); |
478 | sb[0].StatValue = timeDilation; | ||
369 | 479 | ||
370 | sb[1].StatID = (uint) Stats.SimFPS; | 480 | sb[1].StatID = (uint) Stats.SimFPS; |
371 | sb[1].StatValue = reportedFPS / m_statsUpdateFactor; | 481 | sb[1].StatValue = reportedFPS / m_statsUpdateFactor; |
@@ -388,20 +498,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
388 | sb[7].StatID = (uint) Stats.ActivePrim; | 498 | sb[7].StatID = (uint) Stats.ActivePrim; |
389 | sb[7].StatValue = m_activePrim; | 499 | sb[7].StatValue = m_activePrim; |
390 | 500 | ||
501 | // ORIGINAL code commented out until we have time to add our own | ||
502 | // statistics to the statistics window | ||
391 | sb[8].StatID = (uint)Stats.FrameMS; | 503 | sb[8].StatID = (uint)Stats.FrameMS; |
392 | sb[8].StatValue = m_frameMS / framesUpdated; | 504 | //sb[8].StatValue = m_frameMS / framesUpdated; |
505 | sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; | ||
393 | 506 | ||
394 | sb[9].StatID = (uint)Stats.NetMS; | 507 | sb[9].StatID = (uint)Stats.NetMS; |
395 | sb[9].StatValue = m_netMS / framesUpdated; | 508 | //sb[9].StatValue = m_netMS / framesUpdated; |
509 | sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored; | ||
396 | 510 | ||
397 | sb[10].StatID = (uint)Stats.PhysicsMS; | 511 | sb[10].StatID = (uint)Stats.PhysicsMS; |
398 | sb[10].StatValue = m_physicsMS / framesUpdated; | 512 | //sb[10].StatValue = m_physicsMS / framesUpdated; |
513 | sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; | ||
399 | 514 | ||
400 | sb[11].StatID = (uint)Stats.ImageMS ; | 515 | sb[11].StatID = (uint)Stats.ImageMS ; |
401 | sb[11].StatValue = m_imageMS / framesUpdated; | 516 | sb[11].StatValue = m_imageMS / framesUpdated; |
402 | 517 | ||
403 | sb[12].StatID = (uint)Stats.OtherMS; | 518 | sb[12].StatID = (uint)Stats.OtherMS; |
404 | sb[12].StatValue = m_otherMS / framesUpdated; | 519 | //sb[12].StatValue = m_otherMS / framesUpdated; |
520 | sb[12].StatValue = (float) simulationSumFrameTime / | ||
521 | m_numberFramesStored; | ||
405 | 522 | ||
406 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 523 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
407 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 524 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -430,7 +547,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
430 | sb[21].StatID = (uint)Stats.SimSpareMs; | 547 | sb[21].StatID = (uint)Stats.SimSpareMs; |
431 | sb[21].StatValue = m_spareMS / framesUpdated; | 548 | sb[21].StatValue = m_spareMS / framesUpdated; |
432 | 549 | ||
433 | for (int i = 0; i < 22; i++) | 550 | // Added to track the number of users currently attempting to |
551 | // login to the region | ||
552 | sb[22].StatID = (uint)Stats.UsersLoggingIn; | ||
553 | sb[22].StatValue = m_usersLoggingIn; | ||
554 | |||
555 | // Total number of geometric primitives in the scene | ||
556 | sb[23].StatID = (uint)Stats.TotalGeoPrim; | ||
557 | sb[23].StatValue = m_numGeoPrim; | ||
558 | |||
559 | // Total number of mesh objects in the scene | ||
560 | sb[24].StatID = (uint)Stats.TotalMesh; | ||
561 | sb[24].StatValue = m_numMesh; | ||
562 | |||
563 | // Added to track the current number of threads that XEngine is | ||
564 | // using | ||
565 | sb[25].StatID = (uint)Stats.ThreadCount; | ||
566 | sb[25].StatValue = m_inUseThreads; | ||
567 | |||
568 | for (int i = 0; i < m_statisticArraySize; i++) | ||
434 | { | 569 | { |
435 | lastReportedSimStats[i] = sb[i].StatValue; | 570 | lastReportedSimStats[i] = sb[i].StatValue; |
436 | } | 571 | } |
@@ -475,6 +610,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | 610 | ||
476 | private void ResetValues() | 611 | private void ResetValues() |
477 | { | 612 | { |
613 | // Reset the number of frames that the physics library has | ||
614 | // processed since the last stats report | ||
615 | m_numberPhysicsFrames = 0; | ||
616 | |||
478 | m_timeDilation = 0; | 617 | m_timeDilation = 0; |
479 | m_fps = 0; | 618 | m_fps = 0; |
480 | m_pfps = 0; | 619 | m_pfps = 0; |
@@ -605,6 +744,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
605 | m_otherMS += ms; | 744 | m_otherMS += ms; |
606 | } | 745 | } |
607 | 746 | ||
747 | public void addPhysicsFrame(int frames) | ||
748 | { | ||
749 | // Add the number of physics frames to the correct total physics | ||
750 | // frames | ||
751 | m_numberPhysicsFrames += frames; | ||
752 | } | ||
753 | |||
754 | public void addFrameTimeMilliseconds(double total, double simulation, | ||
755 | double physics, double network) | ||
756 | { | ||
757 | // Save the frame times from the current frame into the appropriate | ||
758 | // arrays | ||
759 | m_totalFrameTimeMilliseconds[m_nextLocation] = total; | ||
760 | m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation; | ||
761 | m_physicsFrameTimeMilliseconds[m_nextLocation] = physics; | ||
762 | m_networkFrameTimeMilliseconds[m_nextLocation] = network; | ||
763 | |||
764 | // Update to the next location in the list | ||
765 | m_nextLocation++; | ||
766 | |||
767 | // Since the list will begin to overwrite the oldest frame values | ||
768 | // first, the next location needs to loop back to the beginning of the | ||
769 | // list whenever it reaches the end | ||
770 | m_nextLocation = m_nextLocation % m_numberFramesStored; | ||
771 | } | ||
772 | |||
608 | public void AddPendingDownloads(int count) | 773 | public void AddPendingDownloads(int count) |
609 | { | 774 | { |
610 | m_pendingDownloads += count; | 775 | m_pendingDownloads += count; |
@@ -627,6 +792,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | AddunAckedBytes(unAckedBytes); | 792 | AddunAckedBytes(unAckedBytes); |
628 | } | 793 | } |
629 | 794 | ||
795 | public void UpdateUsersLoggingIn(bool isLoggingIn) | ||
796 | { | ||
797 | // Determine whether the user has started logging in or has completed | ||
798 | // logging into the region | ||
799 | if (isLoggingIn) | ||
800 | { | ||
801 | // The user is starting to login to the region so increment the | ||
802 | // number of users attempting to login to the region | ||
803 | m_usersLoggingIn++; | ||
804 | } | ||
805 | else | ||
806 | { | ||
807 | // The user has finished logging into the region so decrement the | ||
808 | // number of users logging into the region | ||
809 | m_usersLoggingIn--; | ||
810 | } | ||
811 | } | ||
812 | |||
813 | public void SetThreadCount(int inUseThreads) | ||
814 | { | ||
815 | // Save the new number of threads to our member variable to send to | ||
816 | // the extra stats collector | ||
817 | m_inUseThreads = inUseThreads; | ||
818 | } | ||
819 | |||
630 | #endregion | 820 | #endregion |
631 | 821 | ||
632 | public Dictionary<string, float> GetExtraSimStats() | 822 | public Dictionary<string, float> GetExtraSimStats() |