aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/SimStatsReporter.cs259
1 files changed, 232 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index b9d615e..3effee7 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 = 28;
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>
@@ -167,15 +176,20 @@ namespace OpenSim.Region.Framework.Scenes
167 /// Parameter to adjust reported scene fps 176 /// Parameter to adjust reported scene fps
168 /// </summary> 177 /// </summary>
169 /// <remarks> 178 /// <remarks>
170 /// Our scene loop runs slower than other server implementations, apparantly because we work somewhat differently. 179 /// The close we have to a frame rate as expected by viewers, users and scripts
171 /// However, we will still report an FPS that's closer to what people are used to seeing. A lower FPS might 180 /// is heartbeat rate.
172 /// affect clients and monitoring scripts/software. 181 /// heartbeat rate default value is very diferent from the expected one
182 /// and can be changed from region to region acording to its specific simulation needs
183 /// since this creates incompatibility with expected values,
184 /// this scale factor can be used to normalize values to a Virtual FPS.
185 /// original decision was to use a value of 55fps for all opensim
186 /// corresponding, with default heartbeat rate, to a value of 5.
173 /// </remarks> 187 /// </remarks>
174 private float m_reportedFpsCorrectionFactor = 5; 188 private float m_statisticsFPSfactor = 5.0f;
175 189
176 // saved last reported value so there is something available for llGetRegionFPS 190 // saved last reported value so there is something available for llGetRegionFPS
177 private float lastReportedSimFPS; 191 private float lastReportedSimFPS;
178 private float[] lastReportedSimStats = new float[22]; 192 private float[] lastReportedSimStats = new float[m_statisticArraySize];
179 private float m_pfps; 193 private float m_pfps;
180 194
181 /// <summary> 195 /// <summary>
@@ -195,13 +209,13 @@ namespace OpenSim.Region.Framework.Scenes
195 private int m_physicsMS; 209 private int m_physicsMS;
196 private int m_imageMS; 210 private int m_imageMS;
197 private int m_otherMS; 211 private int m_otherMS;
198 212 private int m_scriptMS;
199//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
200//Ckrinke private int m_scriptMS = 0;
201 213
202 private int m_rootAgents; 214 private int m_rootAgents;
203 private int m_childAgents; 215 private int m_childAgents;
204 private int m_numPrim; 216 private int m_numPrim;
217 private int m_numGeoPrim;
218 private int m_numMesh;
205 private int m_inPacketsPerSecond; 219 private int m_inPacketsPerSecond;
206 private int m_outPacketsPerSecond; 220 private int m_outPacketsPerSecond;
207 private int m_activePrim; 221 private int m_activePrim;
@@ -213,6 +227,34 @@ namespace OpenSim.Region.Framework.Scenes
213 227
214 private int m_objectCapacity = 45000; 228 private int m_objectCapacity = 45000;
215 229
230 // This is the number of frames that will be stored and then averaged for
231 // the Total, Simulation, Physics, and Network Frame Time; It is set to
232 // 10 by default but can be changed by the OpenSim.ini configuration file
233 // NumberOfFrames parameter
234 private int m_numberFramesStored;
235
236 // The arrays that will hold the time it took to run the past N frames,
237 // where N is the num_frames_to_average given by the configuration file
238 private double[] m_totalFrameTimeMilliseconds;
239 private double[] m_simulationFrameTimeMilliseconds;
240 private double[] m_physicsFrameTimeMilliseconds;
241 private double[] m_networkFrameTimeMilliseconds;
242
243 // The location of the next time in milliseconds that will be
244 // (over)written when the next frame completes
245 private int m_nextLocation = 0;
246
247 // The correct number of frames that have completed since the last stats
248 // update for physics
249 private int m_numberPhysicsFrames;
250
251 // The current number of users attempting to login to the region
252 private int m_usersLoggingIn;
253
254 // The last reported value of threads from the SmartThreadPool inside of
255 // XEngine
256 private int m_inUseThreads;
257
216 private Scene m_scene; 258 private Scene m_scene;
217 259
218 private RegionInfo ReportingRegion; 260 private RegionInfo ReportingRegion;
@@ -222,12 +264,34 @@ namespace OpenSim.Region.Framework.Scenes
222 private IEstateModule estateModule; 264 private IEstateModule estateModule;
223 265
224 public SimStatsReporter(Scene scene) 266 public SimStatsReporter(Scene scene)
267 : this(scene, Scene.m_defaultNumberFramesStored)
268 {
269 }
270
271 public SimStatsReporter(Scene scene, int numberOfFrames)
225 { 272 {
273 // Store the number of frames from the OpenSim.ini configuration file
274 m_numberFramesStored = numberOfFrames;
275
276 // Initialize the different frame time arrays to the correct sizes
277 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
278 m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored];
279 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
280 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
281
282 // Initialize the current number of users logging into the region
283 m_usersLoggingIn = 0;
284
226 m_scene = scene; 285 m_scene = scene;
227 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; 286
228 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); 287 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
229 ReportingRegion = scene.RegionInfo; 288 ReportingRegion = scene.RegionInfo;
230 289
290 if(scene.Normalized55FPS)
291 m_statisticsFPSfactor = 55.0f * m_scene.MinFrameTicks / 1000.0f;
292 else
293 m_statisticsFPSfactor = 1.0f;
294
231 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 295 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
232 m_report.AutoReset = true; 296 m_report.AutoReset = true;
233 m_report.Interval = m_statsUpdatesEveryMS; 297 m_report.Interval = m_statsUpdatesEveryMS;
@@ -239,7 +303,7 @@ namespace OpenSim.Region.Framework.Scenes
239 303
240 /// At the moment, we'll only report if a frame is over 120% of target, since commonly frames are a bit 304 /// At the moment, we'll only report if a frame is over 120% of target, since commonly frames are a bit
241 /// longer than ideal (which in itself is a concern). 305 /// longer than ideal (which in itself is a concern).
242 SlowFramesStatReportThreshold = (int)Math.Ceiling(m_scene.MinFrameTime * 1000 * 1.2); 306 SlowFramesStatReportThreshold = (int)Math.Ceiling(scene.MinFrameTicks * 1.2);
243 307
244 SlowFramesStat 308 SlowFramesStat
245 = new Stat( 309 = new Stat(
@@ -254,8 +318,10 @@ namespace OpenSim.Region.Framework.Scenes
254 StatVerbosity.Info); 318 StatVerbosity.Info);
255 319
256 StatsManager.RegisterStat(SlowFramesStat); 320 StatsManager.RegisterStat(SlowFramesStat);
321
257 } 322 }
258 323
324
259 public void Close() 325 public void Close()
260 { 326 {
261 m_report.Elapsed -= TriggerStatsHeartbeat; 327 m_report.Elapsed -= TriggerStatsHeartbeat;
@@ -289,7 +355,21 @@ namespace OpenSim.Region.Framework.Scenes
289 355
290 private void statsHeartBeat(object sender, EventArgs e) 356 private void statsHeartBeat(object sender, EventArgs e)
291 { 357 {
292 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 358 double totalSumFrameTime;
359 double simulationSumFrameTime;
360 double physicsSumFrameTime;
361 double networkSumFrameTime;
362 float frameDilation;
363 int currentFrame;
364
365 if (!m_scene.Active)
366 return;
367
368 // Create arrays to hold the statistics for this current scene,
369 // these will be passed to the SimExtraStatsCollector, they are also
370 // sent to the SimStats class
371 SimStatsPacket.StatBlock[] sb = new
372 SimStatsPacket.StatBlock[m_statisticArraySize];
293 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 373 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
294 374
295 // Know what's not thread safe in Mono... modifying timers. 375 // Know what's not thread safe in Mono... modifying timers.
@@ -311,14 +391,15 @@ namespace OpenSim.Region.Framework.Scenes
311 391
312#region various statistic googly moogly 392#region various statistic googly moogly
313 393
314 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently 394 int reportedFPS = (int)(m_fps * m_statisticsFPSfactor);
315 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
316 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
317 395
318 // save the reported value so there is something available for llGetRegionFPS 396 // save the reported value so there is something available for llGetRegionFPS
319 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 397 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
320 398
321 float physfps = ((m_pfps / 1000)); 399 // ORIGINAL code commented out until we have time to add our own
400 // statistics to the statistics window
401 //float physfps = ((m_pfps / 1000));
402 float physfps = m_numberPhysicsFrames * m_statisticsFPSfactor;
322 403
323 //if (physfps > 600) 404 //if (physfps > 600)
324 //physfps = physfps - (physfps - 600); 405 //physfps = physfps - (physfps - 600);
@@ -331,6 +412,8 @@ namespace OpenSim.Region.Framework.Scenes
331 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 412 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
332 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 413 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
333 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); 414 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
415 m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount();
416 m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
334 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); 417 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
335 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); 418 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
336 419
@@ -349,18 +432,52 @@ namespace OpenSim.Region.Framework.Scenes
349 // values to X-per-second values. 432 // values to X-per-second values.
350 433
351 uint thisFrame = m_scene.Frame; 434 uint thisFrame = m_scene.Frame;
352 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; 435 uint numFrames = thisFrame - m_lastUpdateFrame;
436 float framesUpdated = (float)numFrames * m_statisticsFPSfactor;
353 m_lastUpdateFrame = thisFrame; 437 m_lastUpdateFrame = thisFrame;
354 438
355 // Avoid div-by-zero if somehow we've not updated any frames. 439 // Avoid div-by-zero if somehow we've not updated any frames.
356 if (framesUpdated == 0) 440 if (framesUpdated == 0)
357 framesUpdated = 1; 441 framesUpdated = 1;
358 442
359 for (int i = 0; i < 22; i++) 443 for (int i = 0; i < m_statisticArraySize; i++)
360 { 444 {
361 sb[i] = new SimStatsPacket.StatBlock(); 445 sb[i] = new SimStatsPacket.StatBlock();
362 } 446 }
363 447
448 // Resetting the sums of the frame times to prevent any errors
449 // in calculating the moving average for frame time
450 totalSumFrameTime = 0;
451 simulationSumFrameTime = 0;
452 physicsSumFrameTime = 0;
453 networkSumFrameTime = 0;
454
455 // Loop through all the frames that were stored for the current
456 // heartbeat to process the moving average of frame times
457 for (int i = 0; i < m_numberFramesStored; i++)
458 {
459 // Sum up each frame time in order to calculate the moving
460 // average of frame time
461 totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
462 simulationSumFrameTime +=
463 m_simulationFrameTimeMilliseconds[i];
464 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
465 networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
466 }
467
468 // Get the index that represents the current frame based on the next one known; go back
469 // to the last index if next one is stated to restart at 0
470 if (m_nextLocation == 0)
471 currentFrame = m_numberFramesStored - 1;
472 else
473 currentFrame = m_nextLocation - 1;
474
475 // Calculate the frame dilation; which is currently based on the ratio between the sum of the
476 // physics and simulation rate, and the set minimum time to run a scene's frame
477 frameDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] +
478 m_physicsFrameTimeMilliseconds[currentFrame]) / m_scene.MinFrameTicks;
479
480 // ORIGINAL code commented out until we have time to add our own
364 sb[0].StatID = (uint) Stats.TimeDilation; 481 sb[0].StatID = (uint) Stats.TimeDilation;
365 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 482 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
366 483
@@ -385,20 +502,26 @@ namespace OpenSim.Region.Framework.Scenes
385 sb[7].StatID = (uint) Stats.ActivePrim; 502 sb[7].StatID = (uint) Stats.ActivePrim;
386 sb[7].StatValue = m_activePrim; 503 sb[7].StatValue = m_activePrim;
387 504
505 // ORIGINAL code commented out until we have time to add our own
506 // statistics to the statistics window
388 sb[8].StatID = (uint)Stats.FrameMS; 507 sb[8].StatID = (uint)Stats.FrameMS;
389 sb[8].StatValue = m_frameMS / framesUpdated; 508 //sb[8].StatValue = m_frameMS / framesUpdated;
509 sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor;
390 510
391 sb[9].StatID = (uint)Stats.NetMS; 511 sb[9].StatID = (uint)Stats.NetMS;
392 sb[9].StatValue = m_netMS / framesUpdated; 512 //sb[9].StatValue = m_netMS / framesUpdated;
513 sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor;
393 514
394 sb[10].StatID = (uint)Stats.PhysicsMS; 515 sb[10].StatID = (uint)Stats.PhysicsMS;
395 sb[10].StatValue = m_physicsMS / framesUpdated; 516 //sb[10].StatValue = m_physicsMS / framesUpdated;
517 sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor;
396 518
397 sb[11].StatID = (uint)Stats.ImageMS ; 519 sb[11].StatID = (uint)Stats.ImageMS ;
398 sb[11].StatValue = m_imageMS / framesUpdated; 520 sb[11].StatValue = m_imageMS / framesUpdated;
399 521
400 sb[12].StatID = (uint)Stats.OtherMS; 522 sb[12].StatID = (uint)Stats.OtherMS;
401 sb[12].StatValue = m_otherMS / framesUpdated; 523 //sb[12].StatValue = m_otherMS / framesUpdated;
524 sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored / m_statisticsFPSfactor;
402 525
403 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 526 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
404 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 527 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
@@ -427,7 +550,31 @@ namespace OpenSim.Region.Framework.Scenes
427 sb[21].StatID = (uint)Stats.SimSpareMs; 550 sb[21].StatID = (uint)Stats.SimSpareMs;
428 sb[21].StatValue = m_spareMS / framesUpdated; 551 sb[21].StatValue = m_spareMS / framesUpdated;
429 552
430 for (int i = 0; i < 22; i++) 553 // Current ratio between the sum of physics and sim rate, and the
554 // minimum time to run a scene's frame
555 sb[22].StatID = (uint)Stats.FrameDilation;
556 sb[22].StatValue = frameDilation;
557
558 // Current number of users currently attemptint to login to region
559 sb[23].StatID = (uint)Stats.UsersLoggingIn;
560 sb[23].StatValue = m_usersLoggingIn;
561
562 // Total number of geometric primitives in the scene
563 sb[24].StatID = (uint)Stats.TotalGeoPrim;
564 sb[24].StatValue = m_numGeoPrim;
565
566 // Total number of mesh objects in the scene
567 sb[25].StatID = (uint)Stats.TotalMesh;
568 sb[25].StatValue = m_numMesh;
569
570 // Current number of threads that XEngine is using
571 sb[26].StatID = (uint)Stats.ThreadCount;
572 sb[26].StatValue = m_inUseThreads;
573
574 sb[27].StatID = (uint)Stats.ScriptMS;
575 sb[27].StatValue = (numFrames <= 0) ? 0 : ((float)m_scriptMS / numFrames);
576
577 for (int i = 0; i < m_statisticArraySize; i++)
431 { 578 {
432 lastReportedSimStats[i] = sb[i].StatValue; 579 lastReportedSimStats[i] = sb[i].StatValue;
433 } 580 }
@@ -472,6 +619,10 @@ namespace OpenSim.Region.Framework.Scenes
472 619
473 private void ResetValues() 620 private void ResetValues()
474 { 621 {
622 // Reset the number of frames that the physics library has
623 // processed since the last stats report
624 m_numberPhysicsFrames = 0;
625
475 m_timeDilation = 0; 626 m_timeDilation = 0;
476 m_fps = 0; 627 m_fps = 0;
477 m_pfps = 0; 628 m_pfps = 0;
@@ -488,10 +639,8 @@ namespace OpenSim.Region.Framework.Scenes
488 m_physicsMS = 0; 639 m_physicsMS = 0;
489 m_imageMS = 0; 640 m_imageMS = 0;
490 m_otherMS = 0; 641 m_otherMS = 0;
642 m_scriptMS = 0;
491 m_spareMS = 0; 643 m_spareMS = 0;
492
493//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
494//Ckrinke m_scriptMS = 0;
495 } 644 }
496 645
497 # region methods called from Scene 646 # region methods called from Scene
@@ -602,6 +751,37 @@ namespace OpenSim.Region.Framework.Scenes
602 m_otherMS += ms; 751 m_otherMS += ms;
603 } 752 }
604 753
754 public void AddScriptMS(int ms)
755 {
756 m_scriptMS += ms;
757 }
758
759 public void addPhysicsFrame(int frames)
760 {
761 // Add the number of physics frames to the correct total physics
762 // frames
763 m_numberPhysicsFrames += frames;
764 }
765
766 public void addFrameTimeMilliseconds(double total, double simulation,
767 double physics, double network)
768 {
769 // Save the frame times from the current frame into the appropriate
770 // arrays
771 m_totalFrameTimeMilliseconds[m_nextLocation] = total;
772 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
773 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
774 m_networkFrameTimeMilliseconds[m_nextLocation] = network;
775
776 // Update to the next location in the list
777 m_nextLocation++;
778
779 // Since the list will begin to overwrite the oldest frame values
780 // first, the next location needs to loop back to the beginning of the
781 // list whenever it reaches the end
782 m_nextLocation = m_nextLocation % m_numberFramesStored;
783 }
784
605 public void AddPendingDownloads(int count) 785 public void AddPendingDownloads(int count)
606 { 786 {
607 m_pendingDownloads += count; 787 m_pendingDownloads += count;
@@ -624,6 +804,31 @@ namespace OpenSim.Region.Framework.Scenes
624 AddunAckedBytes(unAckedBytes); 804 AddunAckedBytes(unAckedBytes);
625 } 805 }
626 806
807 public void UpdateUsersLoggingIn(bool isLoggingIn)
808 {
809 // Determine whether the user has started logging in or has completed
810 // logging into the region
811 if (isLoggingIn)
812 {
813 // The user is starting to login to the region so increment the
814 // number of users attempting to login to the region
815 m_usersLoggingIn++;
816 }
817 else
818 {
819 // The user has finished logging into the region so decrement the
820 // number of users logging into the region
821 m_usersLoggingIn--;
822 }
823 }
824
825 public void SetThreadCount(int inUseThreads)
826 {
827 // Save the new number of threads to our member variable to send to
828 // the extra stats collector
829 m_inUseThreads = inUseThreads;
830 }
831
627 #endregion 832 #endregion
628 833
629 public Dictionary<string, float> GetExtraSimStats() 834 public Dictionary<string, float> GetExtraSimStats()