aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs124
1 files changed, 76 insertions, 48 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 95f9caf..bf32251 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes
175 175
176 // saved last reported value so there is something available for llGetRegionFPS 176 // saved last reported value so there is something available for llGetRegionFPS
177 private float lastReportedSimFPS; 177 private float lastReportedSimFPS;
178 private float[] lastReportedSimStats = new float[22]; 178 private float[] lastReportedSimStats = new float[23];
179 private float m_pfps; 179 private float m_pfps;
180 180
181 /// <summary> 181 /// <summary>
@@ -189,12 +189,13 @@ namespace OpenSim.Region.Framework.Scenes
189 private int m_objectUpdates; 189 private int m_objectUpdates;
190 190
191 private int m_frameMS; 191 private int m_frameMS;
192 private int m_spareMS; 192
193 private int m_netMS; 193 private int m_netMS;
194 private int m_agentMS; 194 private int m_agentMS;
195 private int m_physicsMS; 195 private int m_physicsMS;
196 private int m_imageMS; 196 private int m_imageMS;
197 private int m_otherMS; 197 private int m_otherMS;
198 private int m_sleeptimeMS;
198 199
199//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 200//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//Ckrinke private int m_scriptMS = 0;
@@ -292,7 +293,7 @@ namespace OpenSim.Region.Framework.Scenes
292 if (!m_scene.Active) 293 if (!m_scene.Active)
293 return; 294 return;
294 295
295 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 296 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23];
296 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 297 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
297 298
298 // Know what's not thread safe in Mono... modifying timers. 299 // Know what's not thread safe in Mono... modifying timers.
@@ -330,6 +331,35 @@ namespace OpenSim.Region.Framework.Scenes
330 physfps = 0; 331 physfps = 0;
331 332
332#endregion 333#endregion
334 float factor = 1 / m_statsUpdateFactor;
335
336 if (reportedFPS <= 0)
337 reportedFPS = 1;
338
339 float perframe = 1.0f / (float)reportedFPS;
340
341 float TotalFrameTime = m_frameMS * perframe;
342
343 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
344
345 float sparetime;
346 float sleeptime;
347
348 if (TotalFrameTime > targetframetime)
349 {
350 sparetime = 0;
351 sleeptime = 0;
352 }
353 else
354 {
355 sparetime = m_frameMS - m_physicsMS - m_agentMS;
356 sparetime *= perframe;
357 if (sparetime < 0)
358 sparetime = 0;
359 else if (sparetime > TotalFrameTime)
360 sparetime = TotalFrameTime;
361 sleeptime = m_sleeptimeMS * perframe;
362 }
333 363
334 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 364 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
335 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 365 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
@@ -341,25 +371,15 @@ namespace OpenSim.Region.Framework.Scenes
341 // so that stat numbers are always consistent. 371 // so that stat numbers are always consistent.
342 CheckStatSanity(); 372 CheckStatSanity();
343 373
344 //Our time dilation is 0.91 when we're running a full speed, 374 // other MS is actually simulation time
345 // therefore to make sure we get an appropriate range, 375 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
346 // we have to factor in our error. (0.10f * statsUpdateFactor) 376 // m_imageMS m_netMS are not included in m_frameMS
347 // multiplies the fix for the error times the amount of times it'll occur a second
348 // / 10 divides the value by the number of times the sim heartbeat runs (10fps)
349 // Then we divide the whole amount by the amount of seconds pass in between stats updates.
350
351 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
352 // values to X-per-second values.
353 377
354 uint thisFrame = m_scene.Frame; 378 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS;
355 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; 379 if (m_otherMS < 0)
356 m_lastUpdateFrame = thisFrame; 380 m_otherMS = 0;
357 381
358 // Avoid div-by-zero if somehow we've not updated any frames. 382 for (int i = 0; i < 23; i++)
359 if (framesUpdated == 0)
360 framesUpdated = 1;
361
362 for (int i = 0; i < 22; i++)
363 { 383 {
364 sb[i] = new SimStatsPacket.StatBlock(); 384 sb[i] = new SimStatsPacket.StatBlock();
365 } 385 }
@@ -389,19 +409,19 @@ namespace OpenSim.Region.Framework.Scenes
389 sb[7].StatValue = m_activePrim; 409 sb[7].StatValue = m_activePrim;
390 410
391 sb[8].StatID = (uint)Stats.FrameMS; 411 sb[8].StatID = (uint)Stats.FrameMS;
392 sb[8].StatValue = m_frameMS / framesUpdated; 412 sb[8].StatValue = TotalFrameTime;
393 413
394 sb[9].StatID = (uint)Stats.NetMS; 414 sb[9].StatID = (uint)Stats.NetMS;
395 sb[9].StatValue = m_netMS / framesUpdated; 415 sb[9].StatValue = m_netMS * perframe;
396 416
397 sb[10].StatID = (uint)Stats.PhysicsMS; 417 sb[10].StatID = (uint)Stats.PhysicsMS;
398 sb[10].StatValue = m_physicsMS / framesUpdated; 418 sb[10].StatValue = m_physicsMS * perframe;
399 419
400 sb[11].StatID = (uint)Stats.ImageMS ; 420 sb[11].StatID = (uint)Stats.ImageMS ;
401 sb[11].StatValue = m_imageMS / framesUpdated; 421 sb[11].StatValue = m_imageMS * perframe;
402 422
403 sb[12].StatID = (uint)Stats.OtherMS; 423 sb[12].StatID = (uint)Stats.OtherMS;
404 sb[12].StatValue = m_otherMS / framesUpdated; 424 sb[12].StatValue = m_otherMS * perframe;
405 425
406 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 426 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
407 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 427 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
@@ -413,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes
413 sb[15].StatValue = m_unAckedBytes; 433 sb[15].StatValue = m_unAckedBytes;
414 434
415 sb[16].StatID = (uint)Stats.AgentMS; 435 sb[16].StatID = (uint)Stats.AgentMS;
416 sb[16].StatValue = m_agentMS / framesUpdated; 436 sb[16].StatValue = m_agentMS * perframe;
417 437
418 sb[17].StatID = (uint)Stats.PendingDownloads; 438 sb[17].StatID = (uint)Stats.PendingDownloads;
419 sb[17].StatValue = m_pendingDownloads; 439 sb[17].StatValue = m_pendingDownloads;
@@ -428,7 +448,10 @@ namespace OpenSim.Region.Framework.Scenes
428 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; 448 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
429 449
430 sb[21].StatID = (uint)Stats.SimSpareMs; 450 sb[21].StatID = (uint)Stats.SimSpareMs;
431 sb[21].StatValue = m_spareMS / framesUpdated; 451 sb[21].StatValue = sparetime;
452
453 sb[22].StatID = (uint)Stats.SimSleepMs;
454 sb[22].StatValue = sleeptime;
432 455
433 for (int i = 0; i < 22; i++) 456 for (int i = 0; i < 22; i++)
434 { 457 {
@@ -447,28 +470,32 @@ namespace OpenSim.Region.Framework.Scenes
447 } 470 }
448 471
449 // Extra statistics that aren't currently sent to clients 472 // Extra statistics that aren't currently sent to clients
450 lock (m_lastReportedExtraSimStats) 473 if (m_scene.PhysicsScene != null)
451 { 474 {
452 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; 475 lock (m_lastReportedExtraSimStats)
453 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;
454
455 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
456
457 if (physicsStats != null)
458 { 476 {
459 foreach (KeyValuePair<string, float> tuple in physicsStats) 477 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
478 m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value;
479
480 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
481
482 if (physicsStats != null)
460 { 483 {
461 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second 484 foreach (KeyValuePair<string, float> tuple in physicsStats)
462 // Need to change things so that stats source can indicate whether they are per second or 485 {
463 // per frame. 486 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
464 if (tuple.Key.EndsWith("MS")) 487 // Need to change things so that stats source can indicate whether they are per second or
465 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; 488 // per frame.
466 else 489 if (tuple.Key.EndsWith("MS"))
467 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; 490 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe;
491 else
492 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
493 }
468 } 494 }
469 } 495 }
470 } 496 }
471 497
498// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor;
472 ResetValues(); 499 ResetValues();
473 } 500 }
474 } 501 }
@@ -491,7 +518,8 @@ namespace OpenSim.Region.Framework.Scenes
491 m_physicsMS = 0; 518 m_physicsMS = 0;
492 m_imageMS = 0; 519 m_imageMS = 0;
493 m_otherMS = 0; 520 m_otherMS = 0;
494 m_spareMS = 0; 521// m_spareMS = 0;
522 m_sleeptimeMS = 0;
495 523
496//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 524//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
497//Ckrinke m_scriptMS = 0; 525//Ckrinke m_scriptMS = 0;
@@ -575,11 +603,6 @@ namespace OpenSim.Region.Framework.Scenes
575 SlowFramesStat.Value++; 603 SlowFramesStat.Value++;
576 } 604 }
577 605
578 public void AddSpareMS(int ms)
579 {
580 m_spareMS += ms;
581 }
582
583 public void addNetMS(int ms) 606 public void addNetMS(int ms)
584 { 607 {
585 m_netMS += ms; 608 m_netMS += ms;
@@ -605,6 +628,11 @@ namespace OpenSim.Region.Framework.Scenes
605 m_otherMS += ms; 628 m_otherMS += ms;
606 } 629 }
607 630
631 public void addSleepMS(int ms)
632 {
633 m_sleeptimeMS += ms;
634 }
635
608 public void AddPendingDownloads(int count) 636 public void AddPendingDownloads(int count)
609 { 637 {
610 m_pendingDownloads += count; 638 m_pendingDownloads += count;