PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewerstats.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 862 lines | 617 code | 111 blank | 134 comment | 48 complexity | 655cc05ae929b1457dd8ccc9de6682f6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewerstats.cpp
  3. * @brief LLViewerStats class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llviewerstats.h"
  28. #include "llviewerthrottle.h"
  29. #include "message.h"
  30. #include "llfloaterreg.h"
  31. #include "llmemory.h"
  32. #include "lltimer.h"
  33. #include "llvfile.h"
  34. #include "llappviewer.h"
  35. #include "pipeline.h"
  36. #include "lltexturefetch.h"
  37. #include "llviewerobjectlist.h"
  38. #include "llviewertexturelist.h"
  39. #include "lltexlayer.h"
  40. #include "lltexlayerparams.h"
  41. #include "llsurface.h"
  42. #include "llvlmanager.h"
  43. #include "llagent.h"
  44. #include "llagentcamera.h"
  45. #include "llviewercontrol.h"
  46. #include "llversioninfo.h"
  47. #include "llfloatertools.h"
  48. #include "lldebugview.h"
  49. #include "llfasttimerview.h"
  50. #include "llviewerregion.h"
  51. #include "llvoavatar.h"
  52. #include "llvoavatarself.h"
  53. #include "llviewerwindow.h" // *TODO: remove, only used for width/height
  54. #include "llworld.h"
  55. #include "llfeaturemanager.h"
  56. #include "llviewernetwork.h"
  57. #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
  58. class StatAttributes
  59. {
  60. public:
  61. StatAttributes(const char* name,
  62. const BOOL enabled,
  63. const BOOL is_timer)
  64. : mName(name),
  65. mEnabled(enabled),
  66. mIsTimer(is_timer)
  67. {
  68. }
  69. std::string mName;
  70. BOOL mEnabled;
  71. BOOL mIsTimer;
  72. };
  73. const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] =
  74. {
  75. // ST_VERSION
  76. StatAttributes("Version", TRUE, FALSE),
  77. // ST_AVATAR_EDIT_SECONDS
  78. StatAttributes("Seconds in Edit Appearence", FALSE, TRUE),
  79. // ST_TOOLBOX_SECONDS
  80. StatAttributes("Seconds using Toolbox", FALSE, TRUE),
  81. // ST_CHAT_COUNT
  82. StatAttributes("Chat messages sent", FALSE, FALSE),
  83. // ST_IM_COUNT
  84. StatAttributes("IMs sent", FALSE, FALSE),
  85. // ST_FULLSCREEN_BOOL
  86. StatAttributes("Fullscreen mode", FALSE, FALSE),
  87. // ST_RELEASE_COUNT
  88. StatAttributes("Object release count", FALSE, FALSE),
  89. // ST_CREATE_COUNT
  90. StatAttributes("Object create count", FALSE, FALSE),
  91. // ST_REZ_COUNT
  92. StatAttributes("Object rez count", FALSE, FALSE),
  93. // ST_FPS_10_SECONDS
  94. StatAttributes("Seconds below 10 FPS", FALSE, TRUE),
  95. // ST_FPS_2_SECONDS
  96. StatAttributes("Seconds below 2 FPS", FALSE, TRUE),
  97. // ST_MOUSELOOK_SECONDS
  98. StatAttributes("Seconds in Mouselook", FALSE, TRUE),
  99. // ST_FLY_COUNT
  100. StatAttributes("Fly count", FALSE, FALSE),
  101. // ST_TELEPORT_COUNT
  102. StatAttributes("Teleport count", FALSE, FALSE),
  103. // ST_OBJECT_DELETE_COUNT
  104. StatAttributes("Objects deleted", FALSE, FALSE),
  105. // ST_SNAPSHOT_COUNT
  106. StatAttributes("Snapshots taken", FALSE, FALSE),
  107. // ST_UPLOAD_SOUND_COUNT
  108. StatAttributes("Sounds uploaded", FALSE, FALSE),
  109. // ST_UPLOAD_TEXTURE_COUNT
  110. StatAttributes("Textures uploaded", FALSE, FALSE),
  111. // ST_EDIT_TEXTURE_COUNT
  112. StatAttributes("Changes to textures on objects", FALSE, FALSE),
  113. // ST_KILLED_COUNT
  114. StatAttributes("Number of times killed", FALSE, FALSE),
  115. // ST_FRAMETIME_JITTER
  116. StatAttributes("Average delta between sucessive frame times", FALSE, FALSE),
  117. // ST_FRAMETIME_SLEW
  118. StatAttributes("Average delta between frame time and mean", FALSE, FALSE),
  119. // ST_INVENTORY_TOO_LONG
  120. StatAttributes("Inventory took too long to load", FALSE, FALSE),
  121. // ST_WEARABLES_TOO_LONG
  122. StatAttributes("Wearables took too long to load", FALSE, FALSE),
  123. // ST_LOGIN_SECONDS
  124. StatAttributes("Time between LoginRequest and LoginReply", FALSE, FALSE),
  125. // ST_LOGIN_TIMEOUT_COUNT
  126. StatAttributes("Number of login attempts that timed out", FALSE, FALSE),
  127. // ST_HAS_BAD_TIMER
  128. StatAttributes("Known bad timer if != 0.0", FALSE, FALSE),
  129. // ST_DOWNLOAD_FAILED
  130. StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE, FALSE),
  131. // ST_LSL_SAVE_COUNT
  132. StatAttributes("Number of times user has saved a script", FALSE, FALSE),
  133. // ST_UPLOAD_ANIM_COUNT
  134. StatAttributes("Animations uploaded", FALSE, FALSE),
  135. // ST_FPS_8_SECONDS
  136. StatAttributes("Seconds below 8 FPS", FALSE, TRUE),
  137. // ST_SIM_FPS_20_SECONDS
  138. StatAttributes("Seconds with sim FPS below 20", FALSE, TRUE),
  139. // ST_PHYS_FPS_20_SECONDS
  140. StatAttributes("Seconds with physics FPS below 20", FALSE, TRUE),
  141. // ST_LOSS_05_SECONDS
  142. StatAttributes("Seconds with packet loss > 5%", FALSE, TRUE),
  143. // ST_FPS_DROP_50_RATIO
  144. StatAttributes("Ratio of frames 2x longer than previous", FALSE, FALSE),
  145. // ST_ENABLE_VBO
  146. StatAttributes("Vertex Buffers Enabled", TRUE, FALSE),
  147. // ST_DELTA_BANDWIDTH
  148. StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE, FALSE),
  149. // ST_MAX_BANDWIDTH
  150. StatAttributes("Max bandwidth setting", FALSE, FALSE),
  151. // ST_LIGHTING_DETAIL
  152. StatAttributes("Lighting Detail", FALSE, FALSE),
  153. // ST_VISIBLE_AVATARS
  154. StatAttributes("Visible Avatars", FALSE, FALSE),
  155. // ST_SHADER_OJECTS
  156. StatAttributes("Object Shaders", FALSE, FALSE),
  157. // ST_SHADER_ENVIRONMENT
  158. StatAttributes("Environment Shaders", FALSE, FALSE),
  159. // ST_VISIBLE_DRAW_DIST
  160. StatAttributes("Draw Distance", FALSE, FALSE),
  161. // ST_VISIBLE_CHAT_BUBBLES
  162. StatAttributes("Chat Bubbles Enabled", FALSE, FALSE),
  163. // ST_SHADER_AVATAR
  164. StatAttributes("Avatar Shaders", FALSE, FALSE),
  165. // ST_FRAME_SECS
  166. StatAttributes("FRAME_SECS", FALSE, FALSE),
  167. // ST_UPDATE_SECS
  168. StatAttributes("UPDATE_SECS", FALSE, FALSE),
  169. // ST_NETWORK_SECS
  170. StatAttributes("NETWORK_SECS", FALSE, FALSE),
  171. // ST_IMAGE_SECS
  172. StatAttributes("IMAGE_SECS", FALSE, FALSE),
  173. // ST_REBUILD_SECS
  174. StatAttributes("REBUILD_SECS", FALSE, FALSE),
  175. // ST_RENDER_SECS
  176. StatAttributes("RENDER_SECS", FALSE, FALSE),
  177. // ST_CROSSING_AVG
  178. StatAttributes("CROSSING_AVG", FALSE, FALSE),
  179. // ST_CROSSING_MAX
  180. StatAttributes("CROSSING_MAX", FALSE, FALSE),
  181. // ST_LIBXUL_WIDGET_USED
  182. StatAttributes("LibXUL Widget used", FALSE, FALSE), // Unused
  183. // ST_WINDOW_WIDTH
  184. StatAttributes("Window width", FALSE, FALSE),
  185. // ST_WINDOW_HEIGHT
  186. StatAttributes("Window height", FALSE, FALSE),
  187. // ST_TEX_BAKES
  188. StatAttributes("Texture Bakes", FALSE, FALSE),
  189. // ST_TEX_REBAKES
  190. StatAttributes("Texture Rebakes", FALSE, FALSE)
  191. };
  192. LLViewerStats::LLViewerStats() :
  193. mKBitStat("kbitstat"),
  194. mLayersKBitStat("layerskbitstat"),
  195. mObjectKBitStat("objectkbitstat"),
  196. mAssetKBitStat("assetkbitstat"),
  197. mTextureKBitStat("texturekbitstat"),
  198. mVFSPendingOperations("vfspendingoperations"),
  199. mObjectsDrawnStat("objectsdrawnstat"),
  200. mObjectsCulledStat("objectsculledstat"),
  201. mObjectsTestedStat("objectstestedstat"),
  202. mObjectsComparedStat("objectscomparedstat"),
  203. mObjectsOccludedStat("objectsoccludedstat"),
  204. mFPSStat("fpsstat"),
  205. mPacketsInStat("packetsinstat"),
  206. mPacketsLostStat("packetsloststat"),
  207. mPacketsOutStat("packetsoutstat"),
  208. mPacketsLostPercentStat("packetslostpercentstat", 64),
  209. mTexturePacketsStat("texturepacketsstat"),
  210. mActualInKBitStat("actualinkbitstat"),
  211. mActualOutKBitStat("actualoutkbitstat"),
  212. mTrianglesDrawnStat("trianglesdrawnstat"),
  213. mSimTimeDilation("simtimedilation"),
  214. mSimFPS("simfps"),
  215. mSimPhysicsFPS("simphysicsfps"),
  216. mSimAgentUPS("simagentups"),
  217. mSimScriptEPS("simscripteps"),
  218. mSimFrameMsec("simframemsec"),
  219. mSimNetMsec("simnetmsec"),
  220. mSimSimOtherMsec("simsimothermsec"),
  221. mSimSimPhysicsMsec("simsimphysicsmsec"),
  222. mSimSimPhysicsStepMsec("simsimphysicsstepmsec"),
  223. mSimSimPhysicsShapeUpdateMsec("simsimphysicsshapeupdatemsec"),
  224. mSimSimPhysicsOtherMsec("simsimphysicsothermsec"),
  225. mSimAgentMsec("simagentmsec"),
  226. mSimImagesMsec("simimagesmsec"),
  227. mSimScriptMsec("simscriptmsec"),
  228. mSimSpareMsec("simsparemsec"),
  229. mSimSleepMsec("simsleepmsec"),
  230. mSimPumpIOMsec("simpumpiomsec"),
  231. mSimMainAgents("simmainagents"),
  232. mSimChildAgents("simchildagents"),
  233. mSimObjects("simobjects"),
  234. mSimActiveObjects("simactiveobjects"),
  235. mSimActiveScripts("simactivescripts"),
  236. mSimInPPS("siminpps"),
  237. mSimOutPPS("simoutpps"),
  238. mSimPendingDownloads("simpendingdownloads"),
  239. mSimPendingUploads("simpendinguploads"),
  240. mSimPendingLocalUploads("simpendinglocaluploads"),
  241. mSimTotalUnackedBytes("simtotalunackedbytes"),
  242. mPhysicsPinnedTasks("physicspinnedtasks"),
  243. mPhysicsLODTasks("physicslodtasks"),
  244. mPhysicsMemoryAllocated("physicsmemoryallocated"),
  245. mSimPingStat("simpingstat"),
  246. mNumImagesStat("numimagesstat", 32, TRUE),
  247. mNumRawImagesStat("numrawimagesstat", 32, TRUE),
  248. mGLTexMemStat("gltexmemstat", 32, TRUE),
  249. mGLBoundMemStat("glboundmemstat", 32, TRUE),
  250. mRawMemStat("rawmemstat", 32, TRUE),
  251. mFormattedMemStat("formattedmemstat", 32, TRUE),
  252. mNumObjectsStat("numobjectsstat"),
  253. mNumActiveObjectsStat("numactiveobjectsstat"),
  254. mNumNewObjectsStat("numnewobjectsstat"),
  255. mNumSizeCulledStat("numsizeculledstat"),
  256. mNumVisCulledStat("numvisculledstat"),
  257. mLastTimeDiff(0.0)
  258. {
  259. for (S32 i = 0; i < ST_COUNT; i++)
  260. {
  261. mStats[i] = 0.0;
  262. }
  263. if (LLTimer::knownBadTimer())
  264. {
  265. mStats[ST_HAS_BAD_TIMER] = 1.0;
  266. }
  267. mAgentPositionSnaps.reset();
  268. }
  269. LLViewerStats::~LLViewerStats()
  270. {
  271. }
  272. void LLViewerStats::resetStats()
  273. {
  274. LLViewerStats::getInstance()->mKBitStat.reset();
  275. LLViewerStats::getInstance()->mLayersKBitStat.reset();
  276. LLViewerStats::getInstance()->mObjectKBitStat.reset();
  277. LLViewerStats::getInstance()->mTextureKBitStat.reset();
  278. LLViewerStats::getInstance()->mVFSPendingOperations.reset();
  279. LLViewerStats::getInstance()->mAssetKBitStat.reset();
  280. LLViewerStats::getInstance()->mPacketsInStat.reset();
  281. LLViewerStats::getInstance()->mPacketsLostStat.reset();
  282. LLViewerStats::getInstance()->mPacketsOutStat.reset();
  283. LLViewerStats::getInstance()->mFPSStat.reset();
  284. LLViewerStats::getInstance()->mTexturePacketsStat.reset();
  285. LLViewerStats::getInstance()->mAgentPositionSnaps.reset();
  286. }
  287. F64 LLViewerStats::getStat(EStatType type) const
  288. {
  289. return mStats[type];
  290. }
  291. F64 LLViewerStats::setStat(EStatType type, F64 value)
  292. {
  293. mStats[type] = value;
  294. return mStats[type];
  295. }
  296. F64 LLViewerStats::incStat(EStatType type, F64 value)
  297. {
  298. mStats[type] += value;
  299. return mStats[type];
  300. }
  301. void LLViewerStats::updateFrameStats(const F64 time_diff)
  302. {
  303. if (mPacketsLostPercentStat.getCurrent() > 5.0)
  304. {
  305. incStat(LLViewerStats::ST_LOSS_05_SECONDS, time_diff);
  306. }
  307. if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f)
  308. {
  309. incStat(LLViewerStats::ST_SIM_FPS_20_SECONDS, time_diff);
  310. }
  311. if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f)
  312. {
  313. incStat(LLViewerStats::ST_PHYS_FPS_20_SECONDS, time_diff);
  314. }
  315. if (time_diff >= 0.5)
  316. {
  317. incStat(LLViewerStats::ST_FPS_2_SECONDS, time_diff);
  318. }
  319. if (time_diff >= 0.125)
  320. {
  321. incStat(LLViewerStats::ST_FPS_8_SECONDS, time_diff);
  322. }
  323. if (time_diff >= 0.1)
  324. {
  325. incStat(LLViewerStats::ST_FPS_10_SECONDS, time_diff);
  326. }
  327. if (gFrameCount && mLastTimeDiff > 0.0)
  328. {
  329. // new "stutter" meter
  330. setStat(LLViewerStats::ST_FPS_DROP_50_RATIO,
  331. (getStat(LLViewerStats::ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) +
  332. (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
  333. // old stats that were never really used
  334. setStat(LLViewerStats::ST_FRAMETIME_JITTER,
  335. (getStat(LLViewerStats::ST_FRAMETIME_JITTER) * (gFrameCount - 1) +
  336. fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
  337. F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
  338. setStat(LLViewerStats::ST_FRAMETIME_SLEW,
  339. (getStat(LLViewerStats::ST_FRAMETIME_SLEW) * (gFrameCount - 1) +
  340. fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);
  341. F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
  342. F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
  343. setStat(LLViewerStats::ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
  344. setStat(LLViewerStats::ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
  345. }
  346. mLastTimeDiff = time_diff;
  347. }
  348. void LLViewerStats::addToMessage(LLSD &body) const
  349. {
  350. LLSD &misc = body["misc"];
  351. for (S32 i = 0; i < ST_COUNT; i++)
  352. {
  353. if (STAT_INFO[i].mEnabled)
  354. {
  355. // TODO: send timer value so dataserver can normalize
  356. misc[STAT_INFO[i].mName] = mStats[i];
  357. llinfos << "STAT: " << STAT_INFO[i].mName << ": " << mStats[i]
  358. << llendl;
  359. }
  360. }
  361. body["AgentPositionSnaps"] = mAgentPositionSnaps.getData();
  362. llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev()
  363. << "; Count = " << mAgentPositionSnaps.getCount() << llendl;
  364. }
  365. // static
  366. // const std::string LLViewerStats::statTypeToText(EStatType type)
  367. // {
  368. // if (type >= 0 && type < ST_COUNT)
  369. // {
  370. // return STAT_INFO[type].mName;
  371. // }
  372. // else
  373. // {
  374. // return "Unknown statistic";
  375. // }
  376. // }
  377. // *NOTE:Mani The following methods used to exist in viewer.cpp
  378. // Moving them here, but not merging them into LLViewerStats yet.
  379. void reset_statistics()
  380. {
  381. if (LLSurface::sTextureUpdateTime)
  382. {
  383. LLSurface::sTexelsUpdated = 0;
  384. LLSurface::sTextureUpdateTime = 0.f;
  385. }
  386. }
  387. void output_statistics(void*)
  388. {
  389. llinfos << "Number of orphans: " << gObjectList.getOrphanCount() << llendl;
  390. llinfos << "Number of dead objects: " << gObjectList.mNumDeadObjects << llendl;
  391. llinfos << "Num images: " << gTextureList.getNumImages() << llendl;
  392. llinfos << "Texture usage: " << LLImageGL::sGlobalTextureMemoryInBytes << llendl;
  393. llinfos << "Texture working set: " << LLImageGL::sBoundTextureMemoryInBytes << llendl;
  394. llinfos << "Raw usage: " << LLImageRaw::sGlobalRawMemory << llendl;
  395. llinfos << "Formatted usage: " << LLImageFormatted::sGlobalFormattedMemory << llendl;
  396. llinfos << "Zombie Viewer Objects: " << LLViewerObject::getNumZombieObjects() << llendl;
  397. llinfos << "Number of lights: " << gPipeline.getLightCount() << llendl;
  398. llinfos << "Memory Usage:" << llendl;
  399. llinfos << "--------------------------------" << llendl;
  400. llinfos << "Pipeline:" << llendl;
  401. llinfos << llendl;
  402. #if LL_SMARTHEAP
  403. llinfos << "--------------------------------" << llendl;
  404. {
  405. llinfos << "sizeof(LLVOVolume) = " << sizeof(LLVOVolume) << llendl;
  406. U32 total_pool_size = 0;
  407. U32 total_used_size = 0;
  408. MEM_POOL_INFO pool_info;
  409. MEM_POOL_STATUS pool_status;
  410. U32 pool_num = 0;
  411. for(pool_status = MemPoolFirst( &pool_info, 1 );
  412. pool_status != MEM_POOL_END;
  413. pool_status = MemPoolNext( &pool_info, 1 ) )
  414. {
  415. llinfos << "Pool #" << pool_num << llendl;
  416. if( MEM_POOL_OK != pool_status )
  417. {
  418. llwarns << "Pool not ok" << llendl;
  419. continue;
  420. }
  421. llinfos << "Pool blockSizeFS " << pool_info.blockSizeFS
  422. << " pageSize " << pool_info.pageSize
  423. << llendl;
  424. U32 pool_count = MemPoolCount(pool_info.pool);
  425. llinfos << "Blocks " << pool_count << llendl;
  426. U32 pool_size = MemPoolSize( pool_info.pool );
  427. if( pool_size == MEM_ERROR_RET )
  428. {
  429. llinfos << "MemPoolSize() failed (" << pool_num << ")" << llendl;
  430. }
  431. else
  432. {
  433. llinfos << "MemPool Size " << pool_size / 1024 << "K" << llendl;
  434. }
  435. total_pool_size += pool_size;
  436. if( !MemPoolLock( pool_info.pool ) )
  437. {
  438. llinfos << "MemPoolLock failed (" << pool_num << ") " << llendl;
  439. continue;
  440. }
  441. U32 used_size = 0;
  442. MEM_POOL_ENTRY entry;
  443. entry.entry = NULL;
  444. while( MemPoolWalk( pool_info.pool, &entry ) == MEM_POOL_OK )
  445. {
  446. if( entry.isInUse )
  447. {
  448. used_size += entry.size;
  449. }
  450. }
  451. MemPoolUnlock( pool_info.pool );
  452. llinfos << "MemPool Used " << used_size/1024 << "K" << llendl;
  453. total_used_size += used_size;
  454. pool_num++;
  455. }
  456. llinfos << "Total Pool Size " << total_pool_size/1024 << "K" << llendl;
  457. llinfos << "Total Used Size " << total_used_size/1024 << "K" << llendl;
  458. }
  459. #endif
  460. llinfos << "--------------------------------" << llendl;
  461. llinfos << "Avatar Memory (partly overlaps with above stats):" << llendl;
  462. LLTexLayerStaticImageList::getInstance()->dumpByteCount();
  463. LLVOAvatarSelf::dumpScratchTextureByteCount();
  464. LLTexLayerSetBuffer::dumpTotalByteCount();
  465. LLVOAvatarSelf::dumpTotalLocalTextureByteCount();
  466. LLTexLayerParamAlpha::dumpCacheByteCount();
  467. LLVOAvatar::dumpBakedStatus();
  468. llinfos << llendl;
  469. llinfos << "Object counts:" << llendl;
  470. S32 i;
  471. S32 obj_counts[256];
  472. // S32 app_angles[256];
  473. for (i = 0; i < 256; i++)
  474. {
  475. obj_counts[i] = 0;
  476. }
  477. for (i = 0; i < gObjectList.getNumObjects(); i++)
  478. {
  479. LLViewerObject *objectp = gObjectList.getObject(i);
  480. if (objectp)
  481. {
  482. obj_counts[objectp->getPCode()]++;
  483. }
  484. }
  485. for (i = 0; i < 256; i++)
  486. {
  487. if (obj_counts[i])
  488. {
  489. llinfos << LLPrimitive::pCodeToString(i) << ":" << obj_counts[i] << llendl;
  490. }
  491. }
  492. }
  493. U32 gTotalLandIn = 0, gTotalLandOut = 0;
  494. U32 gTotalWaterIn = 0, gTotalWaterOut = 0;
  495. F32 gAveLandCompression = 0.f, gAveWaterCompression = 0.f;
  496. F32 gBestLandCompression = 1.f, gBestWaterCompression = 1.f;
  497. F32 gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f;
  498. U32 gTotalWorldBytes = 0, gTotalObjectBytes = 0, gTotalTextureBytes = 0, gSimPingCount = 0;
  499. U32 gObjectBits = 0;
  500. F32 gAvgSimPing = 0.f;
  501. U32 gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
  502. extern U32 gVisCompared;
  503. extern U32 gVisTested;
  504. std::map<S32,LLFrameTimer> gDebugTimers;
  505. std::map<S32,std::string> gDebugTimerLabel;
  506. void init_statistics()
  507. {
  508. // Label debug timers
  509. gDebugTimerLabel[0] = "Texture";
  510. }
  511. void update_statistics(U32 frame_count)
  512. {
  513. gTotalWorldBytes += gVLManager.getTotalBytes();
  514. gTotalObjectBytes += gObjectBits / 8;
  515. // make sure we have a valid time delta for this frame
  516. if (gFrameIntervalSeconds > 0.f)
  517. {
  518. if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
  519. {
  520. LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds);
  521. }
  522. else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
  523. {
  524. LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds);
  525. }
  526. else if (LLFloaterReg::instanceVisible("build"))
  527. {
  528. LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds);
  529. }
  530. }
  531. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
  532. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
  533. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
  534. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
  535. #if 0 // 1.9.2
  536. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_OBJECTS, (F64)gSavedSettings.getS32("VertexShaderLevelObject"));
  537. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_AVATAR, (F64)gSavedSettings.getBOOL("VertexShaderLevelAvatar"));
  538. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_ENVIRONMENT, (F64)gSavedSettings.getBOOL("VertexShaderLevelEnvironment"));
  539. #endif
  540. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame"));
  541. F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle");
  542. F64 network_secs = gDebugView->mFastTimerView->getTime("Network");
  543. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs);
  544. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_NETWORK_SECS, network_secs);
  545. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images"));
  546. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State"));
  547. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry"));
  548. LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
  549. if (cdp)
  550. {
  551. LLViewerStats::getInstance()->mSimPingStat.addValue(cdp->getPingDelay());
  552. gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
  553. gSimPingCount++;
  554. }
  555. else
  556. {
  557. LLViewerStats::getInstance()->mSimPingStat.addValue(10000);
  558. }
  559. LLViewerStats::getInstance()->mFPSStat.addValue(1);
  560. F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
  561. LLViewerStats::getInstance()->mLayersKBitStat.addValue(layer_bits/1024.f);
  562. LLViewerStats::getInstance()->mObjectKBitStat.addValue(gObjectBits/1024.f);
  563. LLViewerStats::getInstance()->mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
  564. LLViewerStats::getInstance()->mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
  565. gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
  566. if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
  567. {
  568. gDebugTimers[0].pause();
  569. }
  570. else
  571. {
  572. gDebugTimers[0].unpause();
  573. }
  574. {
  575. static F32 visible_avatar_frames = 0.f;
  576. static F32 avg_visible_avatars = 0;
  577. F32 visible_avatars = (F32)LLVOAvatar::sNumVisibleAvatars;
  578. if (visible_avatars > 0.f)
  579. {
  580. visible_avatar_frames = 1.f;
  581. avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames;
  582. }
  583. LLViewerStats::getInstance()->setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars);
  584. }
  585. LLWorld::getInstance()->updateNetStats();
  586. LLWorld::getInstance()->requestCacheMisses();
  587. // Reset all of these values.
  588. gVLManager.resetBitCounts();
  589. gObjectBits = 0;
  590. // gDecodedBits = 0;
  591. // Only update texture stats periodically so that they are less noisy
  592. {
  593. static const F32 texture_stats_freq = 10.f;
  594. static LLFrameTimer texture_stats_timer;
  595. if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
  596. {
  597. LLViewerStats::getInstance()->mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
  598. LLViewerStats::getInstance()->mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets);
  599. gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8;
  600. LLViewerTextureList::sTextureBits = 0;
  601. LLViewerTextureList::sTexturePackets = 0;
  602. texture_stats_timer.reset();
  603. }
  604. }
  605. }
  606. class ViewerStatsResponder : public LLHTTPClient::Responder
  607. {
  608. public:
  609. ViewerStatsResponder() { }
  610. void error(U32 statusNum, const std::string& reason)
  611. {
  612. llinfos << "ViewerStatsResponder::error " << statusNum << " "
  613. << reason << llendl;
  614. }
  615. void result(const LLSD& content)
  616. {
  617. llinfos << "ViewerStatsResponder::result" << llendl;
  618. }
  619. };
  620. /*
  621. * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats.
  622. *
  623. * There's also a compatibility shim for the old fixed-format sim
  624. * stats in newsim/llagentinfo.cpp:processViewerStats.
  625. *
  626. * If you move stats around here, make the corresponding changes in
  627. * those locations, too.
  628. */
  629. void send_stats()
  630. {
  631. // IW 9/23/02 I elected not to move this into LLViewerStats
  632. // because it depends on too many viewer.cpp globals.
  633. // Someday we may want to merge all our stats into a central place
  634. // but that day is not today.
  635. // Only send stats if the agent is connected to a region.
  636. if (!gAgent.getRegion())
  637. {
  638. return;
  639. }
  640. LLSD body;
  641. std::string url = gAgent.getRegion()->getCapability("ViewerStats");
  642. if (url.empty()) {
  643. llwarns << "Could not get ViewerStats capability" << llendl;
  644. return;
  645. }
  646. body["session_id"] = gAgentSessionID;
  647. LLSD &agent = body["agent"];
  648. time_t ltime;
  649. time(&ltime);
  650. F32 run_time = F32(LLFrameTimer::getElapsedSeconds());
  651. agent["start_time"] = S32(ltime - S32(run_time));
  652. // The first stat set must have a 0 run time if it doesn't actually
  653. // contain useful data in terms of FPS, etc. We use half the
  654. // SEND_STATS_PERIOD seconds as the point at which these statistics become
  655. // valid. Data warehouse uses a 0 value here to easily discard these
  656. // records with non-useful FPS values etc.
  657. if (run_time < (SEND_STATS_PERIOD / 2))
  658. {
  659. agent["run_time"] = 0.0f;
  660. }
  661. else
  662. {
  663. agent["run_time"] = run_time;
  664. }
  665. // send fps only for time app spends in foreground
  666. agent["fps"] = (F32)gForegroundFrameCount / gForegroundTime.getElapsedTimeF32();
  667. agent["version"] = LLVersionInfo::getChannelAndVersion();
  668. std::string language = LLUI::getLanguage();
  669. agent["language"] = language;
  670. agent["sim_fps"] = ((F32) gFrameCount - gSimFrames) /
  671. (F32) (gRenderStartTime.getElapsedTimeF32() - gSimLastTime);
  672. gSimLastTime = gRenderStartTime.getElapsedTimeF32();
  673. gSimFrames = (F32) gFrameCount;
  674. agent["agents_in_view"] = LLVOAvatar::sNumVisibleAvatars;
  675. agent["ping"] = gAvgSimPing;
  676. agent["meters_traveled"] = gAgent.getDistanceTraveled();
  677. agent["regions_visited"] = gAgent.getRegionsVisited();
  678. agent["mem_use"] = LLMemory::getCurrentRSS() / 1024.0;
  679. LLSD &system = body["system"];
  680. system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB();
  681. system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
  682. system["cpu"] = gSysCPU.getCPUString();
  683. unsigned char MACAddress[MAC_ADDRESS_BYTES];
  684. LLUUID::getNodeID(MACAddress);
  685. std::string macAddressString = llformat("%02x-%02x-%02x-%02x-%02x-%02x",
  686. MACAddress[0],MACAddress[1],MACAddress[2],
  687. MACAddress[3],MACAddress[4],MACAddress[5]);
  688. system["mac_address"] = macAddressString;
  689. system["serial_number"] = LLAppViewer::instance()->getSerialNumber();
  690. std::string gpu_desc = llformat(
  691. "%-6s Class %d ",
  692. gGLManager.mGLVendorShort.substr(0,6).c_str(),
  693. (S32)LLFeatureManager::getInstance()->getGPUClass())
  694. + LLFeatureManager::getInstance()->getGPUString();
  695. system["gpu"] = gpu_desc;
  696. system["gpu_class"] = (S32)LLFeatureManager::getInstance()->getGPUClass();
  697. system["gpu_vendor"] = gGLManager.mGLVendorShort;
  698. system["gpu_version"] = gGLManager.mDriverVersionVendorString;
  699. LLSD &download = body["downloads"];
  700. download["world_kbytes"] = gTotalWorldBytes / 1024.0;
  701. download["object_kbytes"] = gTotalObjectBytes / 1024.0;
  702. download["texture_kbytes"] = gTotalTextureBytes / 1024.0;
  703. download["mesh_kbytes"] = LLMeshRepository::sBytesReceived/1024.0;
  704. LLSD &in = body["stats"]["net"]["in"];
  705. in["kbytes"] = gMessageSystem->mTotalBytesIn / 1024.0;
  706. in["packets"] = (S32) gMessageSystem->mPacketsIn;
  707. in["compressed_packets"] = (S32) gMessageSystem->mCompressedPacketsIn;
  708. in["savings"] = (gMessageSystem->mUncompressedBytesIn -
  709. gMessageSystem->mCompressedBytesIn) / 1024.0;
  710. LLSD &out = body["stats"]["net"]["out"];
  711. out["kbytes"] = gMessageSystem->mTotalBytesOut / 1024.0;
  712. out["packets"] = (S32) gMessageSystem->mPacketsOut;
  713. out["compressed_packets"] = (S32) gMessageSystem->mCompressedPacketsOut;
  714. out["savings"] = (gMessageSystem->mUncompressedBytesOut -
  715. gMessageSystem->mCompressedBytesOut) / 1024.0;
  716. LLSD &fail = body["stats"]["failures"];
  717. fail["send_packet"] = (S32) gMessageSystem->mSendPacketFailureCount;
  718. fail["dropped"] = (S32) gMessageSystem->mDroppedPackets;
  719. fail["resent"] = (S32) gMessageSystem->mResentPackets;
  720. fail["failed_resends"] = (S32) gMessageSystem->mFailedResendPackets;
  721. fail["off_circuit"] = (S32) gMessageSystem->mOffCircuitPackets;
  722. fail["invalid"] = (S32) gMessageSystem->mInvalidOnCircuitPackets;
  723. // Misc stats, two strings and two ints
  724. // These are not expecticed to persist across multiple releases
  725. // Comment any changes with your name and the expected release revision
  726. // If the current revision is recent, ping the previous author before overriding
  727. LLSD &misc = body["stats"]["misc"];
  728. // Screen size so the UI team can figure out how big the widgets
  729. // appear and use a "typical" size for end user tests.
  730. S32 window_width = gViewerWindow->getWindowWidthRaw();
  731. S32 window_height = gViewerWindow->getWindowHeightRaw();
  732. S32 window_size = (window_width * window_height) / 1024;
  733. misc["string_1"] = llformat("%d", window_size);
  734. if (gDebugTimers.find(0) != gDebugTimers.end() && gFrameTimeSeconds > 0)
  735. {
  736. misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gDebugTimers[0].getElapsedTimeF32(), gFrameTimeSeconds);
  737. }
  738. // misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
  739. // misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21
  740. F32 unbaked_time = LLVOAvatar::sUnbakedTime * 1000.f / gFrameTimeSeconds;
  741. misc["int_1"] = LLSD::Integer(unbaked_time); // Steve: 1.22
  742. F32 grey_time = LLVOAvatar::sGreyTime * 1000.f / gFrameTimeSeconds;
  743. misc["int_2"] = LLSD::Integer(grey_time); // Steve: 1.22
  744. llinfos << "Misc Stats: int_1: " << misc["int_1"] << " int_2: " << misc["int_2"] << llendl;
  745. llinfos << "Misc Stats: string_1: " << misc["string_1"] << " string_2: " << misc["string_2"] << llendl;
  746. body["DisplayNamesEnabled"] = gSavedSettings.getBOOL("UseDisplayNames");
  747. body["DisplayNamesShowUsername"] = gSavedSettings.getBOOL("NameTagShowUsernames");
  748. body["MinimalSkin"] = false;
  749. LLViewerStats::getInstance()->addToMessage(body);
  750. LLHTTPClient::post(url, body, new ViewerStatsResponder());
  751. }