aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-04 23:07:25 +0100
committerUbitUmarov2015-09-04 23:07:25 +0100
commit2130984befaabda9b264c96e8db44594206818e3 (patch)
treeaa89bc2cac30c46725b087a1ab442f9634e09301 /OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
parentcomment a large debug message (diff)
downloadopensim-SC-2130984befaabda9b264c96e8db44594206818e3.zip
opensim-SC-2130984befaabda9b264c96e8db44594206818e3.tar.gz
opensim-SC-2130984befaabda9b264c96e8db44594206818e3.tar.bz2
opensim-SC-2130984befaabda9b264c96e8db44594206818e3.tar.xz
a few changes to stats. Array order coerent on users. give up on moses stats for now, since SimExtraStatsCollector cant reach SimStatsReport etc
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SimStatsReporter.cs170
1 files changed, 91 insertions, 79 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 0cf751c..b964317 100755
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -62,8 +62,11 @@ namespace OpenSim.Region.Framework.Scenes
62 private YourStatsAreWrong handlerStatsIncorrect; 62 private YourStatsAreWrong handlerStatsIncorrect;
63 63
64 // Determines the size of the array that is used to collect StatBlocks 64 // Determines the size of the array that is used to collect StatBlocks
65 // for sending to the SimStats and SimExtraStatsCollector 65 // for sending viewer compatible stats must be conform with sb array filling below
66 private const int m_statisticArraySize = 28; 66 private const int m_statisticViewerArraySize = 23;
67 // size of LastReportedSimFPS with extra stats.
68 private const int m_statisticExtraArraySize = m_statisticViewerArraySize +
69 (int)(Stats.SimExtraCountEnd - Stats.SimExtraCountStart);
67 70
68 /// <summary> 71 /// <summary>
69 /// These are the IDs of stats sent in the StatsPacket to the viewer. 72 /// These are the IDs of stats sent in the StatsPacket to the viewer.
@@ -74,6 +77,7 @@ namespace OpenSim.Region.Framework.Scenes
74 /// </remarks> 77 /// </remarks>
75 public enum Stats : uint 78 public enum Stats : uint
76 { 79 {
80// viewers defined IDs
77 TimeDilation = 0, 81 TimeDilation = 0,
78 SimFPS = 1, 82 SimFPS = 1,
79 PhysicsFPS = 2, 83 PhysicsFPS = 2,
@@ -90,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes
90 Agents = 13, 94 Agents = 13,
91 ChildAgents = 14, 95 ChildAgents = 14,
92 ActiveScripts = 15, 96 ActiveScripts = 15,
93 LSLScriptLinesPerSecond = 16, // viewers don't like this 97 LSLScriptLinesPerSecond = 16, // viewers don't like this anymore
94 InPacketsPerSecond = 17, 98 InPacketsPerSecond = 17,
95 OutPacketsPerSecond = 18, 99 OutPacketsPerSecond = 18,
96 PendingDownloads = 19, 100 PendingDownloads = 19,
@@ -116,11 +120,17 @@ namespace OpenSim.Region.Framework.Scenes
116 SimSkippedSillouet_PS = 39, 120 SimSkippedSillouet_PS = 39,
117 SimSkippedCharsPerC = 40, 121 SimSkippedCharsPerC = 40,
118 122
119 MOSESFrameDilation = 100, 123// extra stats IDs irrelevant, just far from viewer defined ones
120 MOSESUsersLoggingIn = 101, 124 SimExtraCountStart = 1000,
121 MOSESTotalGeoPrim = 102, 125
122 MOSESTotalMesh = 103, 126 internalLSLScriptLinesPerSecond = 1000,
123 MOSESThreadCount = 104 127 FrameDilation2 = 1001,
128 UsersLoggingIn = 1002,
129 TotalGeoPrim = 1003,
130 TotalMesh = 1004,
131 ThreadCount = 1005,
132
133 SimExtraCountEnd = 1006
124 } 134 }
125 135
126 /// <summary> 136 /// <summary>
@@ -175,11 +185,6 @@ namespace OpenSim.Region.Framework.Scenes
175 private uint m_lastUpdateFrame; 185 private uint m_lastUpdateFrame;
176 186
177 /// <summary> 187 /// <summary>
178 /// Our nominal fps target, as expected in fps stats when a sim is running normally.
179 /// </summary>
180 private float m_nominalReportedFps = 11;
181
182 /// <summary>
183 /// Parameter to adjust reported scene fps 188 /// Parameter to adjust reported scene fps
184 /// </summary> 189 /// </summary>
185 /// <remarks> 190 /// <remarks>
@@ -187,11 +192,11 @@ namespace OpenSim.Region.Framework.Scenes
187 /// However, we will still report an FPS that's closer to what people are used to seeing. A lower FPS might 192 /// However, we will still report an FPS that's closer to what people are used to seeing. A lower FPS might
188 /// affect clients and monitoring scripts/software. 193 /// affect clients and monitoring scripts/software.
189 /// </remarks> 194 /// </remarks>
190 private float m_reportedFpsCorrectionFactor = 5; 195 private float m_reportedFpsCorrectionFactor = 1.0f;
191 196
192 // saved last reported value so there is something available for llGetRegionFPS 197 // saved last reported value so there is something available for llGetRegionFPS
193 private float lastReportedSimFPS; 198 private float lastReportedSimFPS;
194 private float[] lastReportedSimStats = new float[23]; 199 private float[] lastReportedSimStats = new float[m_statisticExtraArraySize];
195 private float m_pfps; 200 private float m_pfps;
196 201
197 /// <summary> 202 /// <summary>
@@ -225,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
225 private int m_pendingDownloads; 230 private int m_pendingDownloads;
226 private int m_pendingUploads = 0; // FIXME: Not currently filled in 231 private int m_pendingUploads = 0; // FIXME: Not currently filled in
227 private int m_activeScripts; 232 private int m_activeScripts;
228// private int m_scriptLinesPerSecond; 233 private int m_scriptLinesPerSecond;
229 234
230 private int m_objectCapacity = 45000; 235 private int m_objectCapacity = 45000;
231 236
@@ -268,9 +273,7 @@ namespace OpenSim.Region.Framework.Scenes
268 public SimStatsReporter(Scene scene) 273 public SimStatsReporter(Scene scene)
269 { 274 {
270 m_scene = scene; 275 m_scene = scene;
271// m_reportedFpsCorrectionFactor = 5.0f; // needs to come from config 276
272 m_reportedFpsCorrectionFactor = 1.0f; // needs to come from config
273 m_nominalReportedFps *= m_reportedFpsCorrectionFactor;
274 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000.0f); 277 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000.0f);
275 ReportingRegion = scene.RegionInfo; 278 ReportingRegion = scene.RegionInfo;
276 279
@@ -336,10 +339,17 @@ namespace OpenSim.Region.Framework.Scenes
336 339
337 private void statsHeartBeat(object sender, EventArgs e) 340 private void statsHeartBeat(object sender, EventArgs e)
338 { 341 {
342 double totalSumFrameTime;
343 double simulationSumFrameTime;
344 double physicsSumFrameTime;
345 double networkSumFrameTime;
346 float frameDilation;
347 int currentFrame;
348
339 if (!m_scene.Active) 349 if (!m_scene.Active)
340 return; 350 return;
341 351
342 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; 352 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[m_statisticViewerArraySize];
343 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 353 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
344 354
345 // Know what's not thread safe in Mono... modifying timers. 355 // Know what's not thread safe in Mono... modifying timers.
@@ -360,52 +370,27 @@ namespace OpenSim.Region.Framework.Scenes
360 } 370 }
361 371
362#region various statistic googly moogly 372#region various statistic googly moogly
363 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 373 // factor to consider updates integration time
374 float updateFactor = 1.0f / m_statsUpdateFactor;
364 375
365 // save the reported value so there is something available for llGetRegionFPS 376 // the nominal frame time, corrected by reporting multiplier
366 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 377 float TargetFrameTime = 1000.0f * m_scene.MinFrameTime / m_reportedFpsCorrectionFactor;
367
368 // ORIGINAL code commented out until we have time to add our own
369 // statistics to the statistics window
370 float physfps = m_pfps;
371
372 //if (physfps > 600)
373 //physfps = physfps - (physfps - 600);
374
375 if (physfps < 0)
376 physfps = 0;
377
378#endregion
379 float factor = 1.0f / m_statsUpdateFactor;
380 378
379 // acumulated fps scaled by reporting multiplier
380 float reportedFPS = (m_fps * m_reportedFpsCorrectionFactor);
381 if (reportedFPS <= 0) 381 if (reportedFPS <= 0)
382 reportedFPS = 1; 382 reportedFPS = 1;
383
384 float perframe = 1.0f / (float)reportedFPS;
385 383
386 float TotalFrameTime = m_frameMS * perframe; 384 // factor to calculate per frame values
385 float perframefactor = 1.0f / (float)reportedFPS;
387 386
388 float targetframetime = 1000.0f / (float)m_nominalReportedFps; 387 // fps considering the integration time
388 reportedFPS = (int)(reportedFPS * updateFactor);
389 // save the reported value so there is something available for llGetRegionFPS
390 lastReportedSimFPS = reportedFPS;
389 391
390 float sparetime;
391 float sleeptime;
392
393 if (TotalFrameTime > targetframetime)
394 {
395 sparetime = 0;
396 sleeptime = 0;
397 }
398 else
399 {
400 sparetime = m_frameMS - m_physicsMS - m_agentMS;
401 sparetime *= perframe;
402 if (sparetime < 0)
403 sparetime = 0;
404 else if (sparetime > TotalFrameTime)
405 sparetime = TotalFrameTime;
406 sleeptime = m_sleeptimeMS * perframe;
407 }
408 392
393#endregion
409 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 394 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
410 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 395 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
411 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); 396 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
@@ -414,6 +399,26 @@ namespace OpenSim.Region.Framework.Scenes
414 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); 399 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
415 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); 400 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
416 401
402 float physfps = m_pfps;
403 if (physfps < 0)
404 physfps = 0;
405
406 float sparetime;
407 float sleeptime;
408
409 float TotalFrameTime = m_frameMS * perframefactor;
410 sleeptime = m_sleeptimeMS * perframefactor;
411
412 sparetime = m_frameMS - m_sleeptimeMS; // total time minus sleep
413 sparetime *= perframefactor; // average per frame
414 sparetime = TargetFrameTime - sparetime; // real spare
415 if (sparetime < 0)
416 sparetime = 0;
417 else if (sparetime > TotalFrameTime)
418 sparetime = TotalFrameTime;
419
420
421
417 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code 422 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code
418 // so that stat numbers are always consistent. 423 // so that stat numbers are always consistent.
419 CheckStatSanity(); 424 CheckStatSanity();
@@ -435,13 +440,13 @@ namespace OpenSim.Region.Framework.Scenes
435 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; 440 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ;
436 441
437 sb[1].StatID = (uint) Stats.SimFPS; 442 sb[1].StatID = (uint) Stats.SimFPS;
438 sb[1].StatValue = reportedFPS / m_statsUpdateFactor; 443 sb[1].StatValue = reportedFPS;
439 444
440 sb[2].StatID = (uint) Stats.PhysicsFPS; 445 sb[2].StatID = (uint) Stats.PhysicsFPS;
441 sb[2].StatValue = physfps / m_statsUpdateFactor; 446 sb[2].StatValue = physfps * updateFactor;
442 447
443 sb[3].StatID = (uint) Stats.AgentUpdates; 448 sb[3].StatID = (uint) Stats.AgentUpdates;
444 sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor); 449 sb[3].StatValue = m_agentUpdates * updateFactor;
445 450
446 sb[4].StatID = (uint) Stats.Agents; 451 sb[4].StatID = (uint) Stats.Agents;
447 sb[4].StatValue = m_rootAgents; 452 sb[4].StatValue = m_rootAgents;
@@ -459,28 +464,28 @@ namespace OpenSim.Region.Framework.Scenes
459 sb[8].StatValue = TotalFrameTime; 464 sb[8].StatValue = TotalFrameTime;
460 465
461 sb[9].StatID = (uint)Stats.NetMS; 466 sb[9].StatID = (uint)Stats.NetMS;
462 sb[9].StatValue = m_netMS * perframe; 467 sb[9].StatValue = m_netMS * perframefactor;
463 468
464 sb[10].StatID = (uint)Stats.PhysicsMS; 469 sb[10].StatID = (uint)Stats.PhysicsMS;
465 sb[10].StatValue = m_physicsMS * perframe; 470 sb[10].StatValue = m_physicsMS * perframefactor;
466 471
467 sb[11].StatID = (uint)Stats.ImageMS ; 472 sb[11].StatID = (uint)Stats.ImageMS ;
468 sb[11].StatValue = m_imageMS * perframe; 473 sb[11].StatValue = m_imageMS * perframefactor;
469 474
470 sb[12].StatID = (uint)Stats.OtherMS; 475 sb[12].StatID = (uint)Stats.OtherMS;
471 sb[12].StatValue = m_otherMS * perframe; 476 sb[12].StatValue = m_otherMS * perframefactor;
472 477
473 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 478 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
474 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 479 sb[13].StatValue = (m_inPacketsPerSecond * updateFactor);
475 480
476 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 481 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
477 sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor); 482 sb[14].StatValue = (m_outPacketsPerSecond * updateFactor);
478 483
479 sb[15].StatID = (uint)Stats.UnAckedBytes; 484 sb[15].StatID = (uint)Stats.UnAckedBytes;
480 sb[15].StatValue = m_unAckedBytes; 485 sb[15].StatValue = m_unAckedBytes;
481 486
482 sb[16].StatID = (uint)Stats.AgentMS; 487 sb[16].StatID = (uint)Stats.AgentMS;
483 sb[16].StatValue = m_agentMS * perframe; 488 sb[16].StatValue = m_agentMS * perframefactor;
484 489
485 sb[17].StatID = (uint)Stats.PendingDownloads; 490 sb[17].StatID = (uint)Stats.PendingDownloads;
486 sb[17].StatValue = m_pendingDownloads; 491 sb[17].StatValue = m_pendingDownloads;
@@ -491,11 +496,11 @@ namespace OpenSim.Region.Framework.Scenes
491 sb[19].StatID = (uint)Stats.ActiveScripts; 496 sb[19].StatID = (uint)Stats.ActiveScripts;
492 sb[19].StatValue = m_activeScripts; 497 sb[19].StatValue = m_activeScripts;
493 498
494 sb[20].StatID = (uint)Stats.SimSpareMs; 499 sb[20].StatID = (uint)Stats.SimSleepMs;
495 sb[20].StatValue = sparetime; 500 sb[20].StatValue = sleeptime;
496 501
497 sb[21].StatID = (uint)Stats.SimSleepMs; 502 sb[21].StatID = (uint)Stats.SimSpareMs;
498 sb[21].StatValue = sleeptime; 503 sb[21].StatValue = sparetime;
499 504
500 // this should came from phys engine 505 // this should came from phys engine
501 sb[22].StatID = (uint)Stats.SimPhysicsStepMs; 506 sb[22].StatID = (uint)Stats.SimPhysicsStepMs;
@@ -511,6 +516,14 @@ namespace OpenSim.Region.Framework.Scenes
511 ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity, 516 ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)m_objectCapacity,
512 rb, sb, m_scene.RegionInfo.originRegionID); 517 rb, sb, m_scene.RegionInfo.originRegionID);
513 518
519 // add extra stats for internal use
520 lastReportedSimStats[23] = m_scriptLinesPerSecond * updateFactor;
521 lastReportedSimStats[24] = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation;
522 lastReportedSimStats[24] = m_usersLoggingIn;
523 lastReportedSimStats[25] = m_numGeoPrim;
524 lastReportedSimStats[26] = m_numMesh;
525 lastReportedSimStats[27] = m_inUseThreads;
526
514 handlerSendStatResult = OnSendStatsResult; 527 handlerSendStatResult = OnSendStatsResult;
515 if (handlerSendStatResult != null) 528 if (handlerSendStatResult != null)
516 { 529 {
@@ -522,7 +535,7 @@ namespace OpenSim.Region.Framework.Scenes
522 { 535 {
523 lock (m_lastReportedExtraSimStats) 536 lock (m_lastReportedExtraSimStats)
524 { 537 {
525 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; 538 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates * updateFactor;
526 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; 539 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;
527 540
528 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); 541 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
@@ -535,9 +548,9 @@ namespace OpenSim.Region.Framework.Scenes
535 // Need to change things so that stats source can indicate whether they are per second or 548 // Need to change things so that stats source can indicate whether they are per second or
536 // per frame. 549 // per frame.
537 if (tuple.Key.EndsWith("MS")) 550 if (tuple.Key.EndsWith("MS"))
538 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; 551 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframefactor;
539 else 552 else
540 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; 553 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * updateFactor;
541 } 554 }
542 } 555 }
543 } 556 }
@@ -562,7 +575,7 @@ namespace OpenSim.Region.Framework.Scenes
562 //m_inPacketsPerSecond = 0; 575 //m_inPacketsPerSecond = 0;
563 //m_outPacketsPerSecond = 0; 576 //m_outPacketsPerSecond = 0;
564 m_unAckedBytes = 0; 577 m_unAckedBytes = 0;
565 // m_scriptLinesPerSecond = 0; 578 m_scriptLinesPerSecond = 0;
566 579
567 m_frameMS = 0; 580 m_frameMS = 0;
568 m_agentMS = 0; 581 m_agentMS = 0;
@@ -696,8 +709,7 @@ namespace OpenSim.Region.Framework.Scenes
696 709
697 public void addScriptLines(int count) 710 public void addScriptLines(int count)
698 { 711 {
699 // we need events not lines 712 m_scriptLinesPerSecond += count;
700// m_scriptLinesPerSecond += count;
701 } 713 }
702 714
703 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) 715 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes)