aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-04 23:07:53 +0100
committerJustin Clark-Casey (justincc)2012-06-04 23:07:53 +0100
commita7f4804f53f391d5d67bf3484733ab5e41bc34be (patch)
tree68b2a27289d6ddc1ed7eff07212d4a0c3749aaba /OpenSim/Region
parentFix build break whree accidentally did inv.Folders rather than inv.Folders.Co... (diff)
downloadopensim-SC-a7f4804f53f391d5d67bf3484733ab5e41bc34be.zip
opensim-SC-a7f4804f53f391d5d67bf3484733ab5e41bc34be.tar.gz
opensim-SC-a7f4804f53f391d5d67bf3484733ab5e41bc34be.tar.bz2
opensim-SC-a7f4804f53f391d5d67bf3484733ab5e41bc34be.tar.xz
Properly show per frame millisecond statistics per frame, not as amount of time taken per second.
This is to make these statistics actually match their names (and also be more accurate as number of frames can vary under heavy load) Currently using scene frames (11.23 every second) instead of physics frames (56.18 per second)
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs63
1 files changed, 41 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 87af311..11c321b 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -117,12 +117,17 @@ namespace OpenSim.Region.Framework.Scenes
117 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>(); 117 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
118 118
119 // Sending a stats update every 3 seconds- 119 // Sending a stats update every 3 seconds-
120 private int statsUpdatesEveryMS = 3000; 120 private int m_statsUpdatesEveryMS = 3000;
121 private float statsUpdateFactor = 0; 121 private float m_statsUpdateFactor = 0;
122 private float m_timeDilation = 0; 122 private float m_timeDilation = 0;
123 private int m_fps = 0; 123 private int m_fps = 0;
124 124
125 /// <summary> 125 /// <summary>
126 /// Number of the last frame on which we processed a stats udpate.
127 /// </summary>
128 private uint m_lastUpdateFrame;
129
130 /// <summary>
126 /// Our nominal fps target, as expected in fps stats when a sim is running normally. 131 /// Our nominal fps target, as expected in fps stats when a sim is running normally.
127 /// </summary> 132 /// </summary>
128 private float m_nominalReportedFps = 55; 133 private float m_nominalReportedFps = 55;
@@ -188,12 +193,12 @@ namespace OpenSim.Region.Framework.Scenes
188 { 193 {
189 m_scene = scene; 194 m_scene = scene;
190 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; 195 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
191 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 196 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
192 ReportingRegion = scene.RegionInfo; 197 ReportingRegion = scene.RegionInfo;
193 198
194 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 199 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
195 m_report.AutoReset = true; 200 m_report.AutoReset = true;
196 m_report.Interval = statsUpdatesEveryMS; 201 m_report.Interval = m_statsUpdatesEveryMS;
197 m_report.Elapsed += statsHeartBeat; 202 m_report.Elapsed += statsHeartBeat;
198 m_report.Enabled = true; 203 m_report.Enabled = true;
199 204
@@ -213,9 +218,9 @@ namespace OpenSim.Region.Framework.Scenes
213 /// <param name='ms'></param> 218 /// <param name='ms'></param>
214 public void SetUpdateMS(int ms) 219 public void SetUpdateMS(int ms)
215 { 220 {
216 statsUpdatesEveryMS = ms; 221 m_statsUpdatesEveryMS = ms;
217 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 222 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
218 m_report.Interval = statsUpdatesEveryMS; 223 m_report.Interval = m_statsUpdatesEveryMS;
219 } 224 }
220 225
221 private void statsHeartBeat(object sender, EventArgs e) 226 private void statsHeartBeat(object sender, EventArgs e)
@@ -247,7 +252,7 @@ namespace OpenSim.Region.Framework.Scenes
247 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 252 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
248 253
249 // save the reported value so there is something available for llGetRegionFPS 254 // save the reported value so there is something available for llGetRegionFPS
250 lastReportedSimFPS = reportedFPS / statsUpdateFactor; 255 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
251 256
252 float physfps = ((m_pfps / 1000)); 257 float physfps = ((m_pfps / 1000));
253 258
@@ -279,6 +284,14 @@ namespace OpenSim.Region.Framework.Scenes
279 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change 284 // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change
280 // values to X-per-second values. 285 // values to X-per-second values.
281 286
287 uint thisFrame = m_scene.Frame;
288 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame);
289 m_lastUpdateFrame = thisFrame;
290
291 // Avoid div-by-zero if somehow we've not updated any frames.
292 if (framesUpdated == 0)
293 framesUpdated = 1;
294
282 for (int i = 0; i < 21; i++) 295 for (int i = 0; i < 21; i++)
283 { 296 {
284 sb[i] = new SimStatsPacket.StatBlock(); 297 sb[i] = new SimStatsPacket.StatBlock();
@@ -288,13 +301,13 @@ namespace OpenSim.Region.Framework.Scenes
288 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 301 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
289 302
290 sb[1].StatID = (uint) Stats.SimFPS; 303 sb[1].StatID = (uint) Stats.SimFPS;
291 sb[1].StatValue = reportedFPS / statsUpdateFactor; 304 sb[1].StatValue = reportedFPS / m_statsUpdateFactor;
292 305
293 sb[2].StatID = (uint) Stats.PhysicsFPS; 306 sb[2].StatID = (uint) Stats.PhysicsFPS;
294 sb[2].StatValue = physfps / statsUpdateFactor; 307 sb[2].StatValue = physfps / m_statsUpdateFactor;
295 308
296 sb[3].StatID = (uint) Stats.AgentUpdates; 309 sb[3].StatID = (uint) Stats.AgentUpdates;
297 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 310 sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);
298 311
299 sb[4].StatID = (uint) Stats.Agents; 312 sb[4].StatID = (uint) Stats.Agents;
300 sb[4].StatValue = m_rootAgents; 313 sb[4].StatValue = m_rootAgents;
@@ -309,31 +322,31 @@ namespace OpenSim.Region.Framework.Scenes
309 sb[7].StatValue = m_activePrim; 322 sb[7].StatValue = m_activePrim;
310 323
311 sb[8].StatID = (uint)Stats.FrameMS; 324 sb[8].StatID = (uint)Stats.FrameMS;
312 sb[8].StatValue = m_frameMS / statsUpdateFactor; 325 sb[8].StatValue = m_frameMS / framesUpdated;
313 326
314 sb[9].StatID = (uint)Stats.NetMS; 327 sb[9].StatID = (uint)Stats.NetMS;
315 sb[9].StatValue = m_netMS / statsUpdateFactor; 328 sb[9].StatValue = m_netMS / framesUpdated;
316 329
317 sb[10].StatID = (uint)Stats.PhysicsMS; 330 sb[10].StatID = (uint)Stats.PhysicsMS;
318 sb[10].StatValue = m_physicsMS / statsUpdateFactor; 331 sb[10].StatValue = m_physicsMS / framesUpdated;
319 332
320 sb[11].StatID = (uint)Stats.ImageMS ; 333 sb[11].StatID = (uint)Stats.ImageMS ;
321 sb[11].StatValue = m_imageMS / statsUpdateFactor; 334 sb[11].StatValue = m_imageMS / framesUpdated;
322 335
323 sb[12].StatID = (uint)Stats.OtherMS; 336 sb[12].StatID = (uint)Stats.OtherMS;
324 sb[12].StatValue = m_otherMS / statsUpdateFactor; 337 sb[12].StatValue = m_otherMS / framesUpdated;
325 338
326 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 339 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
327 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); 340 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
328 341
329 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 342 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
330 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 343 sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);
331 344
332 sb[15].StatID = (uint)Stats.UnAckedBytes; 345 sb[15].StatID = (uint)Stats.UnAckedBytes;
333 sb[15].StatValue = m_unAckedBytes; 346 sb[15].StatValue = m_unAckedBytes;
334 347
335 sb[16].StatID = (uint)Stats.AgentMS; 348 sb[16].StatID = (uint)Stats.AgentMS;
336 sb[16].StatValue = m_agentMS / statsUpdateFactor; 349 sb[16].StatValue = m_agentMS / framesUpdated;
337 350
338 sb[17].StatID = (uint)Stats.PendingDownloads; 351 sb[17].StatID = (uint)Stats.PendingDownloads;
339 sb[17].StatValue = m_pendingDownloads; 352 sb[17].StatValue = m_pendingDownloads;
@@ -345,7 +358,7 @@ namespace OpenSim.Region.Framework.Scenes
345 sb[19].StatValue = m_activeScripts; 358 sb[19].StatValue = m_activeScripts;
346 359
347 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 360 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
348 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 361 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
349 362
350 for (int i = 0; i < 21; i++) 363 for (int i = 0; i < 21; i++)
351 { 364 {
@@ -366,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes
366 // Extra statistics that aren't currently sent to clients 379 // Extra statistics that aren't currently sent to clients
367 lock (m_lastReportedExtraSimStats) 380 lock (m_lastReportedExtraSimStats)
368 { 381 {
369 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / statsUpdateFactor; 382 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
370 383
371 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); 384 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
372 385
@@ -374,7 +387,13 @@ namespace OpenSim.Region.Framework.Scenes
374 { 387 {
375 foreach (KeyValuePair<string, float> tuple in physicsStats) 388 foreach (KeyValuePair<string, float> tuple in physicsStats)
376 { 389 {
377 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / statsUpdateFactor; 390 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
391 // Need to change things so that stats source can indicate whether they are per second or
392 // per frame.
393 if (tuple.Key.EndsWith("MS"))
394 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
395 else
396 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
378 } 397 }
379 } 398 }
380 } 399 }