aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SimStatsReporter.cs219
1 files changed, 152 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 0eab898..8918c3b 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 = 27;
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,12 @@ 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 FrameDilation = 35,
113 UsersLoggingIn = 36,
114 TotalGeoPrim = 37,
115 TotalMesh = 38,
116 ThreadCount = 39
108 } 117 }
109 118
110 /// <summary> 119 /// <summary>
@@ -175,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
175 184
176 // saved last reported value so there is something available for llGetRegionFPS 185 // saved last reported value so there is something available for llGetRegionFPS
177 private float lastReportedSimFPS; 186 private float lastReportedSimFPS;
178 private float[] lastReportedSimStats = new float[22]; 187 private float[] lastReportedSimStats = new float[m_statisticArraySize];
179 private float m_pfps; 188 private float m_pfps;
180 189
181 /// <summary> 190 /// <summary>
@@ -202,6 +211,8 @@ namespace OpenSim.Region.Framework.Scenes
202 private int m_rootAgents; 211 private int m_rootAgents;
203 private int m_childAgents; 212 private int m_childAgents;
204 private int m_numPrim; 213 private int m_numPrim;
214 private int m_numGeoPrim;
215 private int m_numMesh;
205 private int m_inPacketsPerSecond; 216 private int m_inPacketsPerSecond;
206 private int m_outPacketsPerSecond; 217 private int m_outPacketsPerSecond;
207 private int m_activePrim; 218 private int m_activePrim;
@@ -214,26 +225,33 @@ namespace OpenSim.Region.Framework.Scenes
214 private int m_objectCapacity = 45000; 225 private int m_objectCapacity = 45000;
215 226
216 // This is the number of frames that will be stored and then averaged for 227 // This is the number of frames that will be stored and then averaged for
217 // the Total, Simulation, Physics, and Network Frame Time; It is set to 228 // the Total, Simulation, Physics, and Network Frame Time; It is set to
218 // 10 by default but can be changed by the OpenSim.ini configuration file 229 // 10 by default but can be changed by the OpenSim.ini configuration file
219 // NumberOfFrames parameter 230 // NumberOfFrames parameter
220 private int m_numberFramesStored = Scene.m_defaultNumberFramesStored; 231 private int m_numberFramesStored = Scene.m_defaultNumberFramesStored;
221 232
222 // The arrays that will hold the time it took to run the past N frames, 233 // The arrays that will hold the time it took to run the past N frames,
223 // where N is the num_frames_to_average given by the configuration file 234 // where N is the num_frames_to_average given by the configuration file
224 private double[] m_totalFrameTimeMilliseconds; 235 private double[] m_totalFrameTimeMilliseconds;
225 private double[] m_simulationFrameTimeMilliseconds; 236 private double[] m_simulationFrameTimeMilliseconds;
226 private double[] m_physicsFrameTimeMilliseconds; 237 private double[] m_physicsFrameTimeMilliseconds;
227 private double[] m_networkFrameTimeMilliseconds; 238 private double[] m_networkFrameTimeMilliseconds;
228 239
229 // The location of the next time in milliseconds that will be 240 // The location of the next time in milliseconds that will be
230 // (over)written when the next frame completes 241 // (over)written when the next frame completes
231 private int m_nextLocation = 0; 242 private int m_nextLocation = 0;
232 243
233 // The correct number of frames that have completed since the last stats 244 // The correct number of frames that have completed since the last stats
234 // update for physics 245 // update for physics
235 private int m_numberPhysicsFrames; 246 private int m_numberPhysicsFrames;
236 247
248 // The current number of users attempting to login to the region
249 private int m_usersLoggingIn;
250
251 // The last reported value of threads from the SmartThreadPool inside of
252 // XEngine
253 private int m_inUseThreads;
254
237 private Scene m_scene; 255 private Scene m_scene;
238 256
239 private RegionInfo ReportingRegion; 257 private RegionInfo ReportingRegion;
@@ -246,11 +264,13 @@ namespace OpenSim.Region.Framework.Scenes
246 { 264 {
247 // Initialize the different frame time arrays to the correct sizes 265 // Initialize the different frame time arrays to the correct sizes
248 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored]; 266 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
249 m_simulationFrameTimeMilliseconds = new 267 m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored];
250 double[m_numberFramesStored];
251 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored]; 268 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
252 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored]; 269 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
253 270
271 // Initialize the current number of users logging into the region
272 m_usersLoggingIn = 0;
273
254 m_scene = scene; 274 m_scene = scene;
255 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; 275 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
256 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); 276 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@@ -284,13 +304,14 @@ namespace OpenSim.Region.Framework.Scenes
284 StatsManager.RegisterStat(SlowFramesStat); 304 StatsManager.RegisterStat(SlowFramesStat);
285 } 305 }
286 306
307
287 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene) 308 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
288 { 309 {
289 // Store the number of frames from the OpenSim.ini configuration 310 // Store the number of frames from the OpenSim.ini configuration file
290 // file 311 m_numberFramesStored = numberOfFrames;
291 m_numberFramesStored = numberOfFrames;
292 } 312 }
293 313
314
294 public void Close() 315 public void Close()
295 { 316 {
296 m_report.Elapsed -= TriggerStatsHeartbeat; 317 m_report.Elapsed -= TriggerStatsHeartbeat;
@@ -328,11 +349,17 @@ namespace OpenSim.Region.Framework.Scenes
328 double simulationSumFrameTime; 349 double simulationSumFrameTime;
329 double physicsSumFrameTime; 350 double physicsSumFrameTime;
330 double networkSumFrameTime; 351 double networkSumFrameTime;
331 352 float frameDilation;
353 int currentFrame;
354
332 if (!m_scene.Active) 355 if (!m_scene.Active)
333 return; 356 return;
334 357
335 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 358 // Create arrays to hold the statistics for this current scene,
359 // these will be passed to the SimExtraStatsCollector, they are also
360 // sent to the SimStats class
361 SimStatsPacket.StatBlock[] sb = new
362 SimStatsPacket.StatBlock[m_statisticArraySize];
336 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 363 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
337 364
338 // Know what's not thread safe in Mono... modifying timers. 365 // Know what's not thread safe in Mono... modifying timers.
@@ -354,21 +381,21 @@ namespace OpenSim.Region.Framework.Scenes
354 381
355#region various statistic googly moogly 382#region various statistic googly moogly
356 383
357 // ORIGINAL code commented out until we have time to add our own 384 // ORIGINAL code commented out until we have time to add our own
358 // statistics to the statistics window, this will be done as a 385 // statistics to the statistics window, this will be done as a
359 // new section given the title of our current project 386 // new section given the title of our current project
360 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently 387 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently
361 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. 388 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
362 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 389 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
363 int reportedFPS = m_fps; 390 int reportedFPS = m_fps;
364 391
365 // save the reported value so there is something available for llGetRegionFPS 392 // save the reported value so there is something available for llGetRegionFPS
366 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 393 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
367 394
368 // ORIGINAL code commented out until we have time to add our own 395 // ORIGINAL code commented out until we have time to add our own
369 // statistics to the statistics window 396 // statistics to the statistics window
370 //float physfps = ((m_pfps / 1000)); 397 //float physfps = ((m_pfps / 1000));
371 float physfps = m_numberPhysicsFrames; 398 float physfps = m_numberPhysicsFrames;
372 399
373 //if (physfps > 600) 400 //if (physfps > 600)
374 //physfps = physfps - (physfps - 600); 401 //physfps = physfps - (physfps - 600);
@@ -381,6 +408,8 @@ namespace OpenSim.Region.Framework.Scenes
381 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 408 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
382 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 409 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
383 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); 410 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
411 m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount();
412 m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
384 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); 413 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
385 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); 414 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
386 415
@@ -406,11 +435,11 @@ namespace OpenSim.Region.Framework.Scenes
406 if (framesUpdated == 0) 435 if (framesUpdated == 0)
407 framesUpdated = 1; 436 framesUpdated = 1;
408 437
409 for (int i = 0; i < 22; i++) 438 for (int i = 0; i < m_statisticArraySize; i++)
410 { 439 {
411 sb[i] = new SimStatsPacket.StatBlock(); 440 sb[i] = new SimStatsPacket.StatBlock();
412 } 441 }
413 442
414 // Resetting the sums of the frame times to prevent any errors 443 // Resetting the sums of the frame times to prevent any errors
415 // in calculating the moving average for frame time 444 // in calculating the moving average for frame time
416 totalSumFrameTime = 0; 445 totalSumFrameTime = 0;
@@ -425,12 +454,25 @@ namespace OpenSim.Region.Framework.Scenes
425 // Sum up each frame time in order to calculate the moving 454 // Sum up each frame time in order to calculate the moving
426 // average of frame time 455 // average of frame time
427 totalSumFrameTime += m_totalFrameTimeMilliseconds[i]; 456 totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
428 simulationSumFrameTime += 457 simulationSumFrameTime +=
429 m_simulationFrameTimeMilliseconds[i]; 458 m_simulationFrameTimeMilliseconds[i];
430 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i]; 459 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
431 networkSumFrameTime += m_networkFrameTimeMilliseconds[i]; 460 networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
432 } 461 }
433 462
463 // Get the index that represents the current frame based on the next one known; go back
464 // to the last index if next one is stated to restart at 0
465 if (m_nextLocation == 0)
466 currentFrame = m_numberFramesStored - 1;
467 else
468 currentFrame = m_nextLocation - 1;
469
470 // Calculate the frame dilation; which is currently based on the ratio between the sum of the
471 // physics and simulation rate, and the set minimum time to run a scene's frame
472 frameDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] +
473 m_physicsFrameTimeMilliseconds[currentFrame]) / m_scene.MinFrameTicks;
474
475 // ORIGINAL code commented out until we have time to add our own
434 sb[0].StatID = (uint) Stats.TimeDilation; 476 sb[0].StatID = (uint) Stats.TimeDilation;
435 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));
436 478
@@ -455,31 +497,28 @@ namespace OpenSim.Region.Framework.Scenes
455 sb[7].StatID = (uint) Stats.ActivePrim; 497 sb[7].StatID = (uint) Stats.ActivePrim;
456 sb[7].StatValue = m_activePrim; 498 sb[7].StatValue = m_activePrim;
457 499
458 // ORIGINAL code commented out until we have time to add our own 500 // ORIGINAL code commented out until we have time to add our own
459 // statistics to the statistics window 501 // statistics to the statistics window
460 sb[8].StatID = (uint)Stats.FrameMS; 502 sb[8].StatID = (uint)Stats.FrameMS;
461 //sb[8].StatValue = m_frameMS / framesUpdated; 503 //sb[8].StatValue = m_frameMS / framesUpdated;
462 sb[8].StatValue = (float) totalSumFrameTime / 504 sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored;
463 m_numberFramesStored;
464 505
465 sb[9].StatID = (uint)Stats.NetMS; 506 sb[9].StatID = (uint)Stats.NetMS;
466 //sb[9].StatValue = m_netMS / framesUpdated; 507 //sb[9].StatValue = m_netMS / framesUpdated;
467 sb[9].StatValue = (float) networkSumFrameTime / 508 sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored;
468 m_numberFramesStored;
469 509
470 sb[10].StatID = (uint)Stats.PhysicsMS; 510 sb[10].StatID = (uint)Stats.PhysicsMS;
471 //sb[10].StatValue = m_physicsMS / framesUpdated; 511 //sb[10].StatValue = m_physicsMS / framesUpdated;
472 sb[10].StatValue = (float) physicsSumFrameTime / 512 sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored;
473 m_numberFramesStored;
474 513
475 sb[11].StatID = (uint)Stats.ImageMS ; 514 sb[11].StatID = (uint)Stats.ImageMS ;
476 sb[11].StatValue = m_imageMS / framesUpdated; 515 sb[11].StatValue = m_imageMS / framesUpdated;
477 516
478 sb[12].StatID = (uint)Stats.OtherMS; 517 sb[12].StatID = (uint)Stats.OtherMS;
479 //sb[12].StatValue = m_otherMS / framesUpdated; 518 //sb[12].StatValue = m_otherMS / framesUpdated;
480 sb[12].StatValue = (float) simulationSumFrameTime / 519 sb[12].StatValue = (float) simulationSumFrameTime /
481 m_numberFramesStored; 520 m_numberFramesStored;
482 521
483 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 522 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
484 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 523 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
485 524
@@ -507,7 +546,28 @@ namespace OpenSim.Region.Framework.Scenes
507 sb[21].StatID = (uint)Stats.SimSpareMs; 546 sb[21].StatID = (uint)Stats.SimSpareMs;
508 sb[21].StatValue = m_spareMS / framesUpdated; 547 sb[21].StatValue = m_spareMS / framesUpdated;
509 548
510 for (int i = 0; i < 22; i++) 549 // Current ratio between the sum of physics and sim rate, and the
550 // minimum time to run a scene's frame
551 sb[22].StatID = (uint)Stats.FrameDilation;
552 sb[22].StatValue = frameDilation;
553
554 // Current number of users currently attemptint to login to region
555 sb[23].StatID = (uint)Stats.UsersLoggingIn;
556 sb[23].StatValue = m_usersLoggingIn;
557
558 // Total number of geometric primitives in the scene
559 sb[24].StatID = (uint)Stats.TotalGeoPrim;
560 sb[24].StatValue = m_numGeoPrim;
561
562 // Total number of mesh objects in the scene
563 sb[25].StatID = (uint)Stats.TotalMesh;
564 sb[25].StatValue = m_numMesh;
565
566 // Current number of threads that XEngine is using
567 sb[26].StatID = (uint)Stats.ThreadCount;
568 sb[26].StatValue = m_inUseThreads;
569
570 for (int i = 0; i < m_statisticArraySize; i++)
511 { 571 {
512 lastReportedSimStats[i] = sb[i].StatValue; 572 lastReportedSimStats[i] = sb[i].StatValue;
513 } 573 }
@@ -554,8 +614,8 @@ namespace OpenSim.Region.Framework.Scenes
554 { 614 {
555 // Reset the number of frames that the physics library has 615 // Reset the number of frames that the physics library has
556 // processed since the last stats report 616 // processed since the last stats report
557 m_numberPhysicsFrames = 0; 617 m_numberPhysicsFrames = 0;
558 618
559 m_timeDilation = 0; 619 m_timeDilation = 0;
560 m_fps = 0; 620 m_fps = 0;
561 m_pfps = 0; 621 m_pfps = 0;
@@ -686,32 +746,32 @@ namespace OpenSim.Region.Framework.Scenes
686 m_otherMS += ms; 746 m_otherMS += ms;
687 } 747 }
688 748
689 public void addPhysicsFrame(int frames) 749 public void addPhysicsFrame(int frames)
690 { 750 {
691 // Add the number of physics frames to the correct total physics 751 // Add the number of physics frames to the correct total physics
692 // frames 752 // frames
693 m_numberPhysicsFrames += frames; 753 m_numberPhysicsFrames += frames;
694 } 754 }
695 755
696 public void addFrameTimeMilliseconds(double total, double simulation, 756 public void addFrameTimeMilliseconds(double total, double simulation,
697 double physics, double network) 757 double physics, double network)
698 { 758 {
699 // Save the frame times from the current frame into the appropriate 759 // Save the frame times from the current frame into the appropriate
700 // arrays 760 // arrays
701 m_totalFrameTimeMilliseconds[m_nextLocation] = total; 761 m_totalFrameTimeMilliseconds[m_nextLocation] = total;
702 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation; 762 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
703 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics; 763 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
704 m_networkFrameTimeMilliseconds[m_nextLocation] = network; 764 m_networkFrameTimeMilliseconds[m_nextLocation] = network;
705 765
706 // Update to the next location in the list 766 // Update to the next location in the list
707 m_nextLocation++; 767 m_nextLocation++;
768
769 // Since the list will begin to overwrite the oldest frame values
770 // first, the next location needs to loop back to the beginning of the
771 // list whenever it reaches the end
772 m_nextLocation = m_nextLocation % m_numberFramesStored;
773 }
708 774
709 // Since the list will begin to overwrite the oldest frame values
710 // first, the next location needs to loop back to the beginning of the
711 // list whenever it reaches the end
712 m_nextLocation = m_nextLocation % m_numberFramesStored;
713 }
714
715 public void AddPendingDownloads(int count) 775 public void AddPendingDownloads(int count)
716 { 776 {
717 m_pendingDownloads += count; 777 m_pendingDownloads += count;
@@ -734,6 +794,31 @@ namespace OpenSim.Region.Framework.Scenes
734 AddunAckedBytes(unAckedBytes); 794 AddunAckedBytes(unAckedBytes);
735 } 795 }
736 796
797 public void UpdateUsersLoggingIn(bool isLoggingIn)
798 {
799 // Determine whether the user has started logging in or has completed
800 // logging into the region
801 if (isLoggingIn)
802 {
803 // The user is starting to login to the region so increment the
804 // number of users attempting to login to the region
805 m_usersLoggingIn++;
806 }
807 else
808 {
809 // The user has finished logging into the region so decrement the
810 // number of users logging into the region
811 m_usersLoggingIn--;
812 }
813 }
814
815 public void SetThreadCount(int inUseThreads)
816 {
817 // Save the new number of threads to our member variable to send to
818 // the extra stats collector
819 m_inUseThreads = inUseThreads;
820 }
821
737 #endregion 822 #endregion
738 823
739 public Dictionary<string, float> GetExtraSimStats() 824 public Dictionary<string, float> GetExtraSimStats()