diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 124 |
1 files changed, 76 insertions, 48 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 2addb5b..0d359b9 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; |
@@ -287,7 +288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
287 | 288 | ||
288 | private void statsHeartBeat(object sender, EventArgs e) | 289 | private void statsHeartBeat(object sender, EventArgs e) |
289 | { | 290 | { |
290 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 291 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; |
291 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 292 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
292 | 293 | ||
293 | // Know what's not thread safe in Mono... modifying timers. | 294 | // Know what's not thread safe in Mono... modifying timers. |
@@ -325,6 +326,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | physfps = 0; | 326 | physfps = 0; |
326 | 327 | ||
327 | #endregion | 328 | #endregion |
329 | float factor = 1 / m_statsUpdateFactor; | ||
330 | |||
331 | if (reportedFPS <= 0) | ||
332 | reportedFPS = 1; | ||
333 | |||
334 | float perframe = 1.0f / (float)reportedFPS; | ||
335 | |||
336 | float TotalFrameTime = m_frameMS * perframe; | ||
337 | |||
338 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
339 | |||
340 | float sparetime; | ||
341 | float sleeptime; | ||
342 | |||
343 | if (TotalFrameTime > targetframetime) | ||
344 | { | ||
345 | sparetime = 0; | ||
346 | sleeptime = 0; | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
351 | sparetime *= perframe; | ||
352 | if (sparetime < 0) | ||
353 | sparetime = 0; | ||
354 | else if (sparetime > TotalFrameTime) | ||
355 | sparetime = TotalFrameTime; | ||
356 | sleeptime = m_sleeptimeMS * perframe; | ||
357 | } | ||
328 | 358 | ||
329 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 359 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
330 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 360 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -336,25 +366,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
336 | // so that stat numbers are always consistent. | 366 | // so that stat numbers are always consistent. |
337 | CheckStatSanity(); | 367 | CheckStatSanity(); |
338 | 368 | ||
339 | //Our time dilation is 0.91 when we're running a full speed, | 369 | // other MS is actually simulation time |
340 | // therefore to make sure we get an appropriate range, | 370 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
341 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 371 | // m_imageMS m_netMS are not included in m_frameMS |
342 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
343 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
344 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
345 | |||
346 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
347 | // values to X-per-second values. | ||
348 | 372 | ||
349 | uint thisFrame = m_scene.Frame; | 373 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; |
350 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 374 | if (m_otherMS < 0) |
351 | m_lastUpdateFrame = thisFrame; | 375 | m_otherMS = 0; |
352 | 376 | ||
353 | // Avoid div-by-zero if somehow we've not updated any frames. | 377 | for (int i = 0; i < 23; i++) |
354 | if (framesUpdated == 0) | ||
355 | framesUpdated = 1; | ||
356 | |||
357 | for (int i = 0; i < 22; i++) | ||
358 | { | 378 | { |
359 | sb[i] = new SimStatsPacket.StatBlock(); | 379 | sb[i] = new SimStatsPacket.StatBlock(); |
360 | } | 380 | } |
@@ -384,19 +404,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
384 | sb[7].StatValue = m_activePrim; | 404 | sb[7].StatValue = m_activePrim; |
385 | 405 | ||
386 | sb[8].StatID = (uint)Stats.FrameMS; | 406 | sb[8].StatID = (uint)Stats.FrameMS; |
387 | sb[8].StatValue = m_frameMS / framesUpdated; | 407 | sb[8].StatValue = TotalFrameTime; |
388 | 408 | ||
389 | sb[9].StatID = (uint)Stats.NetMS; | 409 | sb[9].StatID = (uint)Stats.NetMS; |
390 | sb[9].StatValue = m_netMS / framesUpdated; | 410 | sb[9].StatValue = m_netMS * perframe; |
391 | 411 | ||
392 | sb[10].StatID = (uint)Stats.PhysicsMS; | 412 | sb[10].StatID = (uint)Stats.PhysicsMS; |
393 | sb[10].StatValue = m_physicsMS / framesUpdated; | 413 | sb[10].StatValue = m_physicsMS * perframe; |
394 | 414 | ||
395 | sb[11].StatID = (uint)Stats.ImageMS ; | 415 | sb[11].StatID = (uint)Stats.ImageMS ; |
396 | sb[11].StatValue = m_imageMS / framesUpdated; | 416 | sb[11].StatValue = m_imageMS * perframe; |
397 | 417 | ||
398 | sb[12].StatID = (uint)Stats.OtherMS; | 418 | sb[12].StatID = (uint)Stats.OtherMS; |
399 | sb[12].StatValue = m_otherMS / framesUpdated; | 419 | sb[12].StatValue = m_otherMS * perframe; |
400 | 420 | ||
401 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 421 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
402 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 422 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -408,7 +428,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
408 | sb[15].StatValue = m_unAckedBytes; | 428 | sb[15].StatValue = m_unAckedBytes; |
409 | 429 | ||
410 | sb[16].StatID = (uint)Stats.AgentMS; | 430 | sb[16].StatID = (uint)Stats.AgentMS; |
411 | sb[16].StatValue = m_agentMS / framesUpdated; | 431 | sb[16].StatValue = m_agentMS * perframe; |
412 | 432 | ||
413 | sb[17].StatID = (uint)Stats.PendingDownloads; | 433 | sb[17].StatID = (uint)Stats.PendingDownloads; |
414 | sb[17].StatValue = m_pendingDownloads; | 434 | sb[17].StatValue = m_pendingDownloads; |
@@ -423,7 +443,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
423 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 443 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
424 | 444 | ||
425 | sb[21].StatID = (uint)Stats.SimSpareMs; | 445 | sb[21].StatID = (uint)Stats.SimSpareMs; |
426 | sb[21].StatValue = m_spareMS / framesUpdated; | 446 | sb[21].StatValue = sparetime; |
447 | |||
448 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
449 | sb[22].StatValue = sleeptime; | ||
427 | 450 | ||
428 | for (int i = 0; i < 22; i++) | 451 | for (int i = 0; i < 22; i++) |
429 | { | 452 | { |
@@ -442,28 +465,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
442 | } | 465 | } |
443 | 466 | ||
444 | // Extra statistics that aren't currently sent to clients | 467 | // Extra statistics that aren't currently sent to clients |
445 | lock (m_lastReportedExtraSimStats) | 468 | if (m_scene.PhysicsScene != null) |
446 | { | 469 | { |
447 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 470 | lock (m_lastReportedExtraSimStats) |
448 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
449 | |||
450 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
451 | |||
452 | if (physicsStats != null) | ||
453 | { | 471 | { |
454 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 472 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
473 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
474 | |||
475 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
476 | |||
477 | if (physicsStats != null) | ||
455 | { | 478 | { |
456 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 479 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
457 | // Need to change things so that stats source can indicate whether they are per second or | 480 | { |
458 | // per frame. | 481 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
459 | if (tuple.Key.EndsWith("MS")) | 482 | // Need to change things so that stats source can indicate whether they are per second or |
460 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 483 | // per frame. |
461 | else | 484 | if (tuple.Key.EndsWith("MS")) |
462 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 485 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
486 | else | ||
487 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
488 | } | ||
463 | } | 489 | } |
464 | } | 490 | } |
465 | } | 491 | } |
466 | 492 | ||
493 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
467 | ResetValues(); | 494 | ResetValues(); |
468 | } | 495 | } |
469 | } | 496 | } |
@@ -486,7 +513,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
486 | m_physicsMS = 0; | 513 | m_physicsMS = 0; |
487 | m_imageMS = 0; | 514 | m_imageMS = 0; |
488 | m_otherMS = 0; | 515 | m_otherMS = 0; |
489 | m_spareMS = 0; | 516 | // m_spareMS = 0; |
517 | m_sleeptimeMS = 0; | ||
490 | 518 | ||
491 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 519 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
492 | //Ckrinke m_scriptMS = 0; | 520 | //Ckrinke m_scriptMS = 0; |
@@ -570,11 +598,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
570 | SlowFramesStat.Value++; | 598 | SlowFramesStat.Value++; |
571 | } | 599 | } |
572 | 600 | ||
573 | public void AddSpareMS(int ms) | ||
574 | { | ||
575 | m_spareMS += ms; | ||
576 | } | ||
577 | |||
578 | public void addNetMS(int ms) | 601 | public void addNetMS(int ms) |
579 | { | 602 | { |
580 | m_netMS += ms; | 603 | m_netMS += ms; |
@@ -600,6 +623,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | m_otherMS += ms; | 623 | m_otherMS += ms; |
601 | } | 624 | } |
602 | 625 | ||
626 | public void addSleepMS(int ms) | ||
627 | { | ||
628 | m_sleeptimeMS += ms; | ||
629 | } | ||
630 | |||
603 | public void AddPendingDownloads(int count) | 631 | public void AddPendingDownloads(int count) |
604 | { | 632 | { |
605 | m_pendingDownloads += count; | 633 | m_pendingDownloads += count; |