From 407d227e25e292d37767bbf0406a0bd6846a2509 Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Mon, 16 Jul 2012 17:27:52 -0500 Subject: MAINT-1270 Fix for some flexi prims becoming flat at some LoDs --- indra/newview/llflexibleobject.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 06aac5f529..22c265cb8a 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -364,7 +364,7 @@ void LLVolumeImplFlexible::doIdleUpdate() if (visible) { if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1) && - mVO->getPixelArea() > 256.f) + pixel_area > 256.f) { U32 id; @@ -416,10 +416,11 @@ void LLVolumeImplFlexible::doFlexibleUpdate() LLPath *path = &volume->getPath(); if ((mSimulateRes == 0 || !mInitialized) && mVO->mDrawable->isVisible()) { - //mVO->markForUpdate(TRUE); + BOOL force_update = mSimulateRes == 0 ? TRUE : FALSE; + doIdleUpdate(); - if (mSimulateRes == 0) + if (!force_update || !gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE)) { return; // we did not get updated or initialized, proceeding without can be dangerous } -- cgit v1.2.3 From 891af8055acc66364e7da009c74a6b6a91ea4663 Mon Sep 17 00:00:00 2001 From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com> Date: Tue, 17 Jul 2012 13:52:08 -0700 Subject: MAINT-1276: Add ability to paste LSL tooltips into scripts. Reviewed by Kelly --- indra/llui/lltexteditor.cpp | 80 +++++++++++++++++----- indra/llui/lltexteditor.h | 6 +- indra/llui/lltooltip.cpp | 18 +++++ indra/llui/lltooltip.h | 4 ++ .../skins/default/xui/en/panel_script_ed.xml | 1 + 5 files changed, 90 insertions(+), 19 deletions(-) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 9720dded6c..0ba17c36db 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -237,7 +237,8 @@ LLTextEditor::Params::Params() show_line_numbers("show_line_numbers", false), default_color("default_color"), commit_on_focus_lost("commit_on_focus_lost", false), - show_context_menu("show_context_menu") + show_context_menu("show_context_menu"), + enable_tooltip_paste("enable_tooltip_paste") { addSynonym(prevalidate_callback, "text_type"); } @@ -256,7 +257,8 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : mTabsToNextField(p.ignore_tab), mPrevalidateFunc(p.prevalidate_callback()), mContextMenu(NULL), - mShowContextMenu(p.show_context_menu) + mShowContextMenu(p.show_context_menu), + mEnableTooltipPaste(p.enable_tooltip_paste) { mSourceID.generate(); @@ -1409,6 +1411,23 @@ void LLTextEditor::pasteHelper(bool is_primary) // Clean up string (replace tabs and remove characters that our fonts don't support). LLWString clean_string(paste); + cleanStringForPaste(clean_string); + + // Insert the new text into the existing text. + + //paste text with linebreaks. + pasteTextWithLinebreaks(clean_string); + + deselect(); + + onKeyStroke(); + mParseOnTheFly = TRUE; +} + + +// Clean up string (replace tabs and remove characters that our fonts don't support). +void LLTextEditor::cleanStringForPaste(LLWString & clean_string) +{ LLWStringUtil::replaceTabsWithSpaces(clean_string, SPACES_PER_TAB); if( mAllowEmbeddedItems ) { @@ -1427,10 +1446,11 @@ void LLTextEditor::pasteHelper(bool is_primary) } } } +} - // Insert the new text into the existing text. - //paste text with linebreaks. +void LLTextEditor::pasteTextWithLinebreaks(LLWString & clean_string) +{ std::basic_string<llwchar>::size_type start = 0; std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start); @@ -1449,15 +1469,8 @@ void LLTextEditor::pasteHelper(bool is_primary) std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); - - deselect(); - - onKeyStroke(); - mParseOnTheFly = TRUE; } - - // copy selection to primary void LLTextEditor::copyPrimary() { @@ -1678,19 +1691,50 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) { return FALSE; } - + if (mReadOnly && mScroller) { handled = (mScroller && mScroller->handleKeyHere( key, mask )) || handleSelectionKey(key, mask) || handleControlKey(key, mask); + } + else + { + if (mEnableTooltipPaste && + LLToolTipMgr::instance().toolTipVisible() && + KEY_TAB == key) + { // Paste the first line of a tooltip into the editor + std::string message; + LLToolTipMgr::instance().getToolTipMessage(message); + LLWString tool_tip_text(utf8str_to_wstring(message)); + + if (tool_tip_text.size() > 0) + { + // Delete any selected characters (the tooltip text replaces them) + if(hasSelection()) + { + deleteSelection(TRUE); + } + + std::basic_string<llwchar>::size_type pos = tool_tip_text.find('\n',0); + if (pos != -1) + { // Extract the first line of the tooltip + tool_tip_text = std::basic_string<llwchar>(tool_tip_text, 0, pos); + } + + // Add the text + cleanStringForPaste(tool_tip_text); + pasteTextWithLinebreaks(tool_tip_text); + handled = TRUE; + } + } + else + { // Normal key handling + handled = handleNavigationKey( key, mask ) + || handleSelectionKey(key, mask) + || handleControlKey(key, mask) + || handleSpecialKey(key, mask); } - else - { - handled = handleNavigationKey( key, mask ) - || handleSelectionKey(key, mask) - || handleControlKey(key, mask) - || handleSpecialKey(key, mask); } if( handled ) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 40821ae9fb..e60fe03e58 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -64,7 +64,8 @@ public: ignore_tab, show_line_numbers, commit_on_focus_lost, - show_context_menu; + show_context_menu, + enable_tooltip_paste; //colors Optional<LLUIColor> default_color; @@ -288,6 +289,8 @@ private: // Methods // void pasteHelper(bool is_primary); + void cleanStringForPaste(LLWString & clean_string); + void pasteTextWithLinebreaks(LLWString & clean_string); void drawLineNumbers(); @@ -321,6 +324,7 @@ private: BOOL mAllowEmbeddedItems; bool mShowContextMenu; bool mParseOnTheFly; + bool mEnableTooltipPaste; LLUUID mSourceID; diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index f737d48abf..7f1566d64a 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -390,6 +390,15 @@ bool LLToolTip::hasClickCallback() return mHasClickCallback; } +void LLToolTip::getToolTipMessage(std::string & message) +{ + if (mTextBox) + { + message = mTextBox->getText(); + } +} + + // // LLToolTipMgr @@ -594,5 +603,14 @@ void LLToolTipMgr::updateToolTipVisibility() } +// Return the current tooltip text +void LLToolTipMgr::getToolTipMessage(std::string & message) +{ + if (toolTipVisible()) + { + mToolTip->getToolTipMessage(message); + } +} + // EOF diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index d71a944c3d..fad127fc4c 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -105,6 +105,8 @@ public: LLToolTip(const Params& p); void initFromParams(const LLToolTip::Params& params); + void getToolTipMessage(std::string & message); + private: class LLTextBox* mTextBox; class LLButton* mInfoButton; @@ -142,6 +144,8 @@ public: LLRect getMouseNearRect(); void updateToolTipVisibility(); + void getToolTipMessage(std::string & message); + private: void createToolTip(const LLToolTip::Params& params); diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml index f6a8af0973..765b07ed8b 100644 --- a/indra/newview/skins/default/xui/en/panel_script_ed.xml +++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml @@ -158,6 +158,7 @@ text_readonly_color="DkGray" width="487" show_line_numbers="true" + enable_tooltip_paste="true" word_wrap="true"> Loading... </text_editor> -- cgit v1.2.3 From cfc5236e643618822e66bfc77dc912036bcb57cb Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Wed, 18 Jul 2012 15:49:47 -0500 Subject: MAINT-628 Fix for seams in high res snapshots when lighting and shadows is enabled. --- indra/llrender/llrendertarget.cpp | 34 ++++++------- indra/llrender/llrendertarget.h | 5 +- .../shaders/class1/deferred/fxaaF.glsl | 1 - indra/newview/llviewerwindow.cpp | 55 +++++++++++++++++++--- indra/newview/pipeline.cpp | 29 ++++++------ indra/newview/pipeline.h | 8 +++- 6 files changed, 90 insertions(+), 42 deletions(-) diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index cc5c232380..cd1c532243 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -51,11 +51,13 @@ void check_framebuffer_status() } bool LLRenderTarget::sUseFBO = false; +U32 LLRenderTarget::sCurFBO = 0; LLRenderTarget::LLRenderTarget() : mResX(0), mResY(0), mFBO(0), + mPreviousFBO(0), mDepth(0), mStencil(0), mUseDepth(false), @@ -107,6 +109,9 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt) bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples) { + resx = llmin(resx, (U32) 4096); + resy = llmin(resy, (U32) 4096); + stop_glerror(); release(); stop_glerror(); @@ -146,7 +151,7 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), mDepth, 0); stop_glerror(); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); } stop_glerror(); @@ -224,7 +229,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) check_framebuffer_status(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); } mTex.push_back(tex); @@ -313,7 +318,7 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) check_framebuffer_status(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); target.mUseDepth = true; } @@ -376,9 +381,13 @@ void LLRenderTarget::bindTarget() { if (mFBO) { + mPreviousFBO = sCurFBO; + stop_glerror(); glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + sCurFBO = mFBO; + stop_glerror(); if (gGLManager.mHasDrawBuffers) { //setup multiple render targets @@ -404,16 +413,6 @@ void LLRenderTarget::bindTarget() sBoundTarget = this; } -// static -void LLRenderTarget::unbindTarget() -{ - if (gGLManager.mHasFramebufferObject) - { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - } - sBoundTarget = NULL; -} - void LLRenderTarget::clear(U32 mask_in) { U32 mask = GL_COLOR_BUFFER_BIT; @@ -479,7 +478,8 @@ void LLRenderTarget::flush(bool fetch_depth) else { stop_glerror(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, mPreviousFBO); + sCurFBO = mPreviousFBO; stop_glerror(); } } @@ -509,7 +509,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, stop_glerror(); glCopyTexSubImage2D(LLTexUnit::getInternalType(mUsage), 0, srcX0, srcY0, dstX0, dstY0, dstX1, dstY1); stop_glerror(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); stop_glerror(); } else @@ -526,7 +526,7 @@ void LLRenderTarget::copyContents(LLRenderTarget& source, S32 srcX0, S32 srcY0, stop_glerror(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); stop_glerror(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); stop_glerror(); } } @@ -552,7 +552,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 stop_glerror(); glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); stop_glerror(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); stop_glerror(); } } diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index e1a51304f1..cf15f66d31 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -63,6 +63,7 @@ public: //whether or not to use FBO implementation static bool sUseFBO; static U32 sBytesAllocated; + static U32 sCurFBO; LLRenderTarget(); ~LLRenderTarget(); @@ -96,9 +97,6 @@ public: //applies appropriate viewport void bindTarget(); - //unbind target for rendering - static void unbindTarget(); - //clear render targer, clears depth buffer if present, //uses scissor rect if in copy-to-texture mode void clear(U32 mask = 0xFFFFFFFF); @@ -148,6 +146,7 @@ protected: std::vector<U32> mTex; std::vector<U32> mInternalFormat; U32 mFBO; + U32 mPreviousFBO; U32 mDepth; bool mStencil; bool mUseDepth; diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl index e02a7b405b..2cef8f2a5d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl @@ -2093,7 +2093,6 @@ uniform sampler2D diffuseMap; uniform vec2 rcp_screen_res; uniform vec4 rcp_frame_opt; uniform vec4 rcp_frame_opt2; -uniform vec2 screen_res; VARYING vec2 vary_fragcoord; VARYING vec2 vary_tc; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 862d53c613..25013eb08c 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4225,14 +4225,48 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei image_height = llmin(image_height, window_height); } + S32 original_width = 0; + S32 original_height = 0; + bool reset_deferred = false; + + LLRenderTarget scratch_space; + F32 scale_factor = 1.0f ; if (!keep_window_aspect || (image_width > window_width) || (image_height > window_height)) { - // if image cropping or need to enlarge the scene, compute a scale_factor - F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; - snapshot_width = (S32)(ratio * image_width) ; - snapshot_height = (S32)(ratio * image_height) ; - scale_factor = llmax(1.0f, 1.0f / ratio) ; + if ((image_width > window_width || image_height > window_height) && LLPipeline::sRenderDeferred && !show_ui) + { + if (scratch_space.allocate(image_width, image_height, GL_RGBA, true, true)) + { + original_width = gPipeline.mDeferredScreen.getWidth(); + original_height = gPipeline.mDeferredScreen.getHeight(); + + if (gPipeline.allocateScreenBuffer(image_width, image_height)) + { + window_width = image_width; + window_height = image_height; + snapshot_width = image_width; + snapshot_height = image_height; + reset_deferred = true; + mWorldViewRectRaw.set(0, image_height, image_width, 0); + scratch_space.bindTarget(); + } + else + { + scratch_space.release(); + gPipeline.allocateScreenBuffer(original_width, original_height); + } + } + } + + if (!reset_deferred) + { + // if image cropping or need to enlarge the scene, compute a scale_factor + F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; + snapshot_width = (S32)(ratio * image_width) ; + snapshot_height = (S32)(ratio * image_height) ; + scale_factor = llmax(1.0f, 1.0f / ratio) ; + } } if (show_ui && scale_factor > 1.f) @@ -4421,11 +4455,20 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei gPipeline.resetDrawOrders(); } + if (reset_deferred) + { + mWorldViewRectRaw = window_rect; + scratch_space.flush(); + scratch_space.release(); + gPipeline.allocateScreenBuffer(original_width, original_height); + + } + if (high_res) { send_agent_resume(); } - + return ret; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5417df2da1..55064f3278 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -774,7 +774,7 @@ void LLPipeline::allocatePhysicsBuffer() } } -void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) +bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { refreshCachedSettings(); U32 samples = RenderFSAASamples; @@ -784,8 +784,13 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) // - if not multisampled, shrink resolution and try again (favor X resolution over Y) // Make sure to call "releaseScreenBuffers" after each failure to cleanup the partially loaded state + bool ret = true; + if (!allocateScreenBuffer(resX, resY, samples)) { + //failed to allocate at requested specification, return false + ret = false; + releaseScreenBuffers(); //reduce number of samples while (samples > 0) @@ -793,7 +798,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) samples /= 2; if (allocateScreenBuffer(resX, resY, samples)) { //success - return; + return ret; } releaseScreenBuffers(); } @@ -806,20 +811,22 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) resY /= 2; if (allocateScreenBuffer(resX, resY, samples)) { - return; + return ret; } releaseScreenBuffers(); resX /= 2; if (allocateScreenBuffer(resX, resY, samples)) { - return; + return ret; } releaseScreenBuffers(); } llwarns << "Unable to allocate screen buffer at any resolution!" << llendl; } + + return ret; } @@ -864,7 +871,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (!mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) { - if (!mFXAABuffer.allocate(nhpo2(resX), nhpo2(resY), GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; } else { @@ -898,7 +905,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) } } - U32 width = nhpo2(U32(resX*scale))/2; + U32 width = resX*scale; U32 height = width; if (shadow_detail > 1) @@ -6701,11 +6708,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) gGlowProgram.unbind(); - if (LLRenderTarget::sUseFBO) + /*if (LLRenderTarget::sUseFBO) { LLFastTimer ftm(FTM_RENDER_BLOOM_FBO); glBindFramebuffer(GL_FRAMEBUFFER, 0); - } + }*/ gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; @@ -7581,10 +7588,6 @@ void LLPipeline::renderDeferredLighting() gGL.popMatrix(); stop_glerror(); - //copy depth and stencil from deferred screen - //mScreen.copyContents(mDeferredScreen, 0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight(), - // 0, 0, mScreen.getWidth(), mScreen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); - mScreen.bindTarget(); // clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky glClearColor(0,0,0,0); @@ -8355,8 +8358,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) } last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate; - LLRenderTarget::unbindTarget(); - LLPipeline::sReflectionRender = FALSE; if (!LLRenderTarget::sUseFBO) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index ecf6a5d262..d16d7d1169 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -119,8 +119,14 @@ public: void createGLBuffers(); void createLUTBuffers(); - void allocateScreenBuffer(U32 resX, U32 resY); + //allocate the largest screen buffer possible up to resX, resY + //returns true if full size buffer allocated, false if some other size is allocated + bool allocateScreenBuffer(U32 resX, U32 resY); + + //attempt to allocate screen buffers at resX, resY + //returns true if allocation successful, false otherwise bool allocateScreenBuffer(U32 resX, U32 resY, U32 samples); + void allocatePhysicsBuffer(); void resetVertexBuffers(LLDrawable* drawable); -- cgit v1.2.3 From 4a5ad357930f0bede4d84b9810978e9d0c5d268b Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Fri, 20 Jul 2012 11:42:15 -0500 Subject: MAINT-570 Remove unused memory tracking system LLMemType --- indra/llcharacter/llmotioncontroller.cpp | 3 - indra/llcommon/CMakeLists.txt | 2 - indra/llcommon/llallocator.cpp | 33 --- indra/llcommon/llallocator.h | 6 - indra/llcommon/llmemory.h | 1 - indra/llcommon/llmemtype.cpp | 232 --------------------- indra/llcommon/llmemtype.h | 242 ---------------------- indra/llimage/llimage.cpp | 85 +------- indra/llimage/llimage.h | 6 +- indra/llimage/llimagej2c.cpp | 4 - indra/llinventory/llinventory.h | 4 - indra/llmath/llvolume.cpp | 288 -------------------------- indra/llmath/llvolume.h | 11 - indra/llmath/llvolumemgr.cpp | 3 - indra/llmessage/llbuffer.cpp | 24 --- indra/llmessage/llbufferstream.cpp | 9 - indra/llmessage/llcachename.cpp | 4 - indra/llmessage/lliohttpserver.cpp | 7 - indra/llmessage/lliosocket.cpp | 16 -- indra/llmessage/llpumpio.cpp | 21 -- indra/llmessage/llsdrpcclient.cpp | 10 - indra/llmessage/llsdrpcserver.cpp | 8 - indra/llmessage/llurlrequest.cpp | 20 -- indra/llmessage/message.cpp | 3 - indra/llprimitive/llprimitive.cpp | 4 - indra/llprimitive/llprimtexturelist.cpp | 2 - indra/llrender/llgl.cpp | 2 - indra/llrender/llvertexbuffer.cpp | 27 --- indra/llwindow/llwindowwin32.cpp | 3 - indra/newview/CMakeLists.txt | 2 - indra/newview/llappviewer.cpp | 6 - indra/newview/llappviewerwin32.cpp | 3 - indra/newview/lldebugview.cpp | 9 - indra/newview/lldrawable.cpp | 6 - indra/newview/lldrawable.h | 2 - indra/newview/llface.cpp | 8 - indra/newview/llfloaterbulkpermission.cpp | 2 - indra/newview/llinventoryfunctions.cpp | 1 - indra/newview/llinventorypanel.cpp | 2 - indra/newview/llmemoryview.cpp | 333 ------------------------------ indra/newview/llmemoryview.h | 62 ------ indra/newview/llpanelmaininventory.cpp | 3 - indra/newview/llpolymesh.cpp | 2 - indra/newview/llspatialpartition.cpp | 34 --- indra/newview/llstartup.cpp | 2 - indra/newview/llsurface.cpp | 1 - indra/newview/llviewerdisplay.cpp | 15 -- indra/newview/llviewermessage.cpp | 4 - indra/newview/llviewerobject.cpp | 19 -- indra/newview/llviewerobject.h | 2 - indra/newview/llviewerobjectlist.cpp | 9 - indra/newview/llviewerparceloverlay.cpp | 1 - indra/newview/llviewerpartsim.cpp | 26 +-- indra/newview/llviewerpartsim.h | 2 +- indra/newview/llviewerpartsource.cpp | 22 -- indra/newview/llviewerregion.cpp | 1 - indra/newview/llviewertexture.cpp | 1 - indra/newview/llviewertexturelist.cpp | 1 - indra/newview/llvoavatar.cpp | 28 --- indra/newview/llvoavatarself.cpp | 6 - indra/newview/llvograss.cpp | 1 - indra/newview/llvopartgroup.cpp | 1 - indra/newview/llvovolume.cpp | 1 - indra/newview/llworld.cpp | 2 - indra/newview/pipeline.cpp | 56 ----- indra/test/llbuffer_tut.cpp | 1 - 66 files changed, 4 insertions(+), 1753 deletions(-) delete mode 100644 indra/llcommon/llmemtype.cpp delete mode 100644 indra/llcommon/llmemtype.h delete mode 100644 indra/newview/llmemoryview.cpp delete mode 100644 indra/newview/llmemoryview.h diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 4f6351709e..829dda9993 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -29,8 +29,6 @@ //----------------------------------------------------------------------------- #include "linden_common.h" -#include "llmemtype.h" - #include "llmotioncontroller.h" #include "llkeyframemotion.h" #include "llmath.h" @@ -335,7 +333,6 @@ void LLMotionController::removeMotionInstance(LLMotion* motionp) //----------------------------------------------------------------------------- LLMotion* LLMotionController::createMotion( const LLUUID &id ) { - LLMemType mt(LLMemType::MTYPE_ANIMATION); // do we have an instance of this motion for this character? LLMotion *motion = findMotion(id); diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index dd7b8c6eb8..346ea360f1 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -71,7 +71,6 @@ set(llcommon_SOURCE_FILES llmd5.cpp llmemory.cpp llmemorystream.cpp - llmemtype.cpp llmetrics.cpp llmetricperformancetester.cpp llmortician.cpp @@ -195,7 +194,6 @@ set(llcommon_HEADER_FILES llmd5.h llmemory.h llmemorystream.h - llmemtype.h llmetrics.h llmetricperformancetester.h llmortician.h diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp index 6f6abefc67..bc8c2d6023 100644 --- a/indra/llcommon/llallocator.cpp +++ b/indra/llcommon/llallocator.cpp @@ -35,28 +35,6 @@ DECLARE_bool(heap_profile_use_stack_trace); //DECLARE_double(tcmalloc_release_rate); -// static -void LLAllocator::pushMemType(S32 type) -{ - if(isProfiling()) - { - PushMemType(type); - } -} - -// static -S32 LLAllocator::popMemType() -{ - if (isProfiling()) - { - return PopMemType(); - } - else - { - return -1; - } -} - void LLAllocator::setProfilingEnabled(bool should_enable) { // NULL disables dumping to disk @@ -94,17 +72,6 @@ std::string LLAllocator::getRawProfile() // stub implementations for when tcmalloc is disabled // -// static -void LLAllocator::pushMemType(S32 type) -{ -} - -// static -S32 LLAllocator::popMemType() -{ - return -1; -} - void LLAllocator::setProfilingEnabled(bool should_enable) { } diff --git a/indra/llcommon/llallocator.h b/indra/llcommon/llallocator.h index a91dd57d14..d26ad73c5b 100644 --- a/indra/llcommon/llallocator.h +++ b/indra/llcommon/llallocator.h @@ -29,16 +29,10 @@ #include <string> -#include "llmemtype.h" #include "llallocator_heap_profile.h" class LL_COMMON_API LLAllocator { friend class LLMemoryView; - friend class LLMemType; - -private: - static void pushMemType(S32 type); - static S32 popMemType(); public: void setProfilingEnabled(bool should_enable); diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index bbbdaa6497..a5a7b15a45 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -26,7 +26,6 @@ #ifndef LLMEMORY_H #define LLMEMORY_H -#include "llmemtype.h" #if LL_DEBUG inline void* ll_aligned_malloc( size_t size, int align ) { diff --git a/indra/llcommon/llmemtype.cpp b/indra/llcommon/llmemtype.cpp deleted file mode 100644 index 6290a7158f..0000000000 --- a/indra/llcommon/llmemtype.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @file llmemtype.cpp - * @brief Simple memory allocation/deallocation tracking stuff here - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llmemtype.h" -#include "llallocator.h" - -std::vector<char const *> LLMemType::DeclareMemType::mNameList; - -LLMemType::DeclareMemType LLMemType::MTYPE_INIT("Init"); -LLMemType::DeclareMemType LLMemType::MTYPE_STARTUP("Startup"); -LLMemType::DeclareMemType LLMemType::MTYPE_MAIN("Main"); -LLMemType::DeclareMemType LLMemType::MTYPE_FRAME("Frame"); - -LLMemType::DeclareMemType LLMemType::MTYPE_GATHER_INPUT("GatherInput"); -LLMemType::DeclareMemType LLMemType::MTYPE_JOY_KEY("JoyKey"); - -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE("Idle"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_PUMP("IdlePump"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_NETWORK("IdleNetwork"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_REGIONS("IdleUpdateRegions"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_VIEWER_REGION("IdleUpdateViewerRegion"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_SURFACE("IdleUpdateSurface"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY("IdleUpdateParcelOverlay"); -LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_AUDIO("IdleAudio"); - -LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING("CacheProcessPending"); -LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS("CacheProcessPendingAsks"); -LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES("CacheProcessPendingReplies"); - -LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_CHECK_ALL("MessageCheckAll"); -LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_PROCESS_ACKS("MessageProcessAcks"); - -LLMemType::DeclareMemType LLMemType::MTYPE_RENDER("Render"); -LLMemType::DeclareMemType LLMemType::MTYPE_SLEEP("Sleep"); - -LLMemType::DeclareMemType LLMemType::MTYPE_NETWORK("Network"); -LLMemType::DeclareMemType LLMemType::MTYPE_PHYSICS("Physics"); -LLMemType::DeclareMemType LLMemType::MTYPE_INTERESTLIST("InterestList"); - -LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEBASE("ImageBase"); -LLMemType::DeclareMemType LLMemType::MTYPE_IMAGERAW("ImageRaw"); -LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEFORMATTED("ImageFormatted"); - -LLMemType::DeclareMemType LLMemType::MTYPE_APPFMTIMAGE("AppFmtImage"); -LLMemType::DeclareMemType LLMemType::MTYPE_APPRAWIMAGE("AppRawImage"); -LLMemType::DeclareMemType LLMemType::MTYPE_APPAUXRAWIMAGE("AppAuxRawImage"); - -LLMemType::DeclareMemType LLMemType::MTYPE_DRAWABLE("Drawable"); - -LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT("Object"); -LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE("ObjectProcessUpdate"); -LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE_CORE("ObjectProcessUpdateCore"); - -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY("Display"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE("DisplayUpdate"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA("DisplayUpdateCam"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_GEOM("DisplayUpdateGeom"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SWAP("DisplaySwap"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_HUD("DisplayUpdateHud"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_GEN_REFLECTION("DisplayGenRefl"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE("DisplayImageUpdate"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_STATE_SORT("DisplayStateSort"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SKY("DisplaySky"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_GEOM("DisplayRenderGeom"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_FLUSH("DisplayRenderFlush"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_UI("DisplayRenderUI"); -LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_ATTACHMENTS("DisplayRenderAttach"); - -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DATA("VertexData"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CONSTRUCTOR("VertexConstr"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTRUCTOR("VertexDestr"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_VERTICES("VertexCreateVerts"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_INDICES("VertexCreateIndices"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_BUFFER("VertexDestroyBuff"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_INDICES("VertexDestroyIndices"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_VERTS("VertexUpdateVerts"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_INDICES("VertexUpdateIndices"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER("VertexAllocateBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_RESIZE_BUFFER("VertexResizeBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER("VertexMapBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES("VertexMapBufferVerts"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES("VertexMapBufferIndices"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UNMAP_BUFFER("VertexUnmapBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_STRIDE("VertexSetStride"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_BUFFER("VertexSetBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER("VertexSetupVertBuff"); -LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CLEANUP_CLASS("VertexCleanupClass"); - -LLMemType::DeclareMemType LLMemType::MTYPE_SPACE_PARTITION("SpacePartition"); - -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE("Pipeline"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_INIT("PipelineInit"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS("PipelineCreateBuffs"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RESTORE_GL("PipelineRestroGL"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS("PipelineUnloadShaders"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL("PipelineLightingDetail"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE("PipelineGetPoolType"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_POOL("PipelineAddPool"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE("PipelineAllocDrawable"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_OBJECT("PipelineAddObj"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS("PipelineCreateObjs"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_MOVE("PipelineUpdateMove"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_GEOM("PipelineUpdateGeom"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_VISIBLE("PipelineMarkVisible"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_MOVED("PipelineMarkMoved"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_SHIFT("PipelineMarkShift"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS("PipelineShiftObjs"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_TEXTURED("PipelineMarkTextured"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_REBUILD("PipelineMarkRebuild"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_CULL("PipelineUpdateCull"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_STATE_SORT("PipelineStateSort"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_POST_SORT("PipelinePostSort"); - -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS("PipelineHudEls"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HL("PipelineRenderHL"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM("PipelineRenderGeom"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED("PipelineRenderGeomDef"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF("PipelineRenderGeomPostDef"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW("PipelineRenderGeomShadow"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_SELECT("PipelineRenderSelect"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_REBUILD_POOLS("PipelineRebuildPools"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP("PipelineQuickLookup"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS("PipelineRenderObjs"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR("PipelineGenImpostors"); -LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_BLOOM("PipelineRenderBloom"); - -LLMemType::DeclareMemType LLMemType::MTYPE_UPKEEP_POOLS("UpkeepPools"); - -LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR("Avatar"); -LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR_MESH("AvatarMesh"); -LLMemType::DeclareMemType LLMemType::MTYPE_PARTICLES("Particles"); -LLMemType::DeclareMemType LLMemType::MTYPE_REGIONS("Regions"); - -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY("Inventory"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DRAW("InventoryDraw"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_BUILD_NEW_VIEWS("InventoryBuildNewViews"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DO_FOLDER("InventoryDoFolder"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_POST_BUILD("InventoryPostBuild"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_FROM_XML("InventoryFromXML"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_CREATE_NEW_ITEM("InventoryCreateNewItem"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_INIT("InventoryViewInit"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_SHOW("InventoryViewShow"); -LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE("InventoryViewToggle"); - -LLMemType::DeclareMemType LLMemType::MTYPE_ANIMATION("Animation"); -LLMemType::DeclareMemType LLMemType::MTYPE_VOLUME("Volume"); -LLMemType::DeclareMemType LLMemType::MTYPE_PRIMITIVE("Primitive"); - -LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT("Script"); -LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_RUN("ScriptRun"); -LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_BYTECODE("ScriptByteCode"); - -LLMemType::DeclareMemType LLMemType::MTYPE_IO_PUMP("IoPump"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_TCP("IoTCP"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient"); -LLMemType::DeclareMemType LLMemType::MTYPE_IO_URL_REQUEST("IOUrlRequest"); - -LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit"); - -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP1("Temp1"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP2("Temp2"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP3("Temp3"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP4("Temp4"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP5("Temp5"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP6("Temp6"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP7("Temp7"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP8("Temp8"); -LLMemType::DeclareMemType LLMemType::MTYPE_TEMP9("Temp9"); - -LLMemType::DeclareMemType LLMemType::MTYPE_OTHER("Other"); - - -LLMemType::DeclareMemType::DeclareMemType(char const * st) -{ - mID = (S32)mNameList.size(); - mName = st; - - mNameList.push_back(mName); -} - -LLMemType::DeclareMemType::~DeclareMemType() -{ -} - -LLMemType::LLMemType(LLMemType::DeclareMemType& dt) -{ - mTypeIndex = dt.mID; - LLAllocator::pushMemType(dt.mID); -} - -LLMemType::~LLMemType() -{ - LLAllocator::popMemType(); -} - -char const * LLMemType::getNameFromID(S32 id) -{ - if (id < 0 || id >= (S32)DeclareMemType::mNameList.size()) - { - return "INVALID"; - } - - return DeclareMemType::mNameList[id]; -} - -//-------------------------------------------------------------------------------------------------- diff --git a/indra/llcommon/llmemtype.h b/indra/llcommon/llmemtype.h deleted file mode 100644 index 4945dbaf60..0000000000 --- a/indra/llcommon/llmemtype.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * @file llmemtype.h - * @brief Runtime memory usage debugging utilities. - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_MEMTYPE_H -#define LL_MEMTYPE_H - -//---------------------------------------------------------------------------- -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -#include "linden_common.h" -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// WARNING: Never commit with MEM_TRACK_MEM == 1 -//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -#define MEM_TRACK_MEM (0 && LL_WINDOWS) - -#include <vector> - -#define MEM_TYPE_NEW(T) - -class LL_COMMON_API LLMemType -{ -public: - - // class we'll initialize all instances of as - // static members of MemType. Then use - // to construct any new mem type. - class LL_COMMON_API DeclareMemType - { - public: - DeclareMemType(char const * st); - ~DeclareMemType(); - - S32 mID; - char const * mName; - - // array so we can map an index ID to Name - static std::vector<char const *> mNameList; - }; - - LLMemType(DeclareMemType& dt); - ~LLMemType(); - - static char const * getNameFromID(S32 id); - - static DeclareMemType MTYPE_INIT; - static DeclareMemType MTYPE_STARTUP; - static DeclareMemType MTYPE_MAIN; - static DeclareMemType MTYPE_FRAME; - - static DeclareMemType MTYPE_GATHER_INPUT; - static DeclareMemType MTYPE_JOY_KEY; - - static DeclareMemType MTYPE_IDLE; - static DeclareMemType MTYPE_IDLE_PUMP; - static DeclareMemType MTYPE_IDLE_NETWORK; - static DeclareMemType MTYPE_IDLE_UPDATE_REGIONS; - static DeclareMemType MTYPE_IDLE_UPDATE_VIEWER_REGION; - static DeclareMemType MTYPE_IDLE_UPDATE_SURFACE; - static DeclareMemType MTYPE_IDLE_UPDATE_PARCEL_OVERLAY; - static DeclareMemType MTYPE_IDLE_AUDIO; - - static DeclareMemType MTYPE_CACHE_PROCESS_PENDING; - static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_ASKS; - static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_REPLIES; - - static DeclareMemType MTYPE_MESSAGE_CHECK_ALL; - static DeclareMemType MTYPE_MESSAGE_PROCESS_ACKS; - - static DeclareMemType MTYPE_RENDER; - static DeclareMemType MTYPE_SLEEP; - - static DeclareMemType MTYPE_NETWORK; - static DeclareMemType MTYPE_PHYSICS; - static DeclareMemType MTYPE_INTERESTLIST; - - static DeclareMemType MTYPE_IMAGEBASE; - static DeclareMemType MTYPE_IMAGERAW; - static DeclareMemType MTYPE_IMAGEFORMATTED; - - static DeclareMemType MTYPE_APPFMTIMAGE; - static DeclareMemType MTYPE_APPRAWIMAGE; - static DeclareMemType MTYPE_APPAUXRAWIMAGE; - - static DeclareMemType MTYPE_DRAWABLE; - - static DeclareMemType MTYPE_OBJECT; - static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE; - static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE_CORE; - - static DeclareMemType MTYPE_DISPLAY; - static DeclareMemType MTYPE_DISPLAY_UPDATE; - static DeclareMemType MTYPE_DISPLAY_UPDATE_CAMERA; - static DeclareMemType MTYPE_DISPLAY_UPDATE_GEOM; - static DeclareMemType MTYPE_DISPLAY_SWAP; - static DeclareMemType MTYPE_DISPLAY_UPDATE_HUD; - static DeclareMemType MTYPE_DISPLAY_GEN_REFLECTION; - static DeclareMemType MTYPE_DISPLAY_IMAGE_UPDATE; - static DeclareMemType MTYPE_DISPLAY_STATE_SORT; - static DeclareMemType MTYPE_DISPLAY_SKY; - static DeclareMemType MTYPE_DISPLAY_RENDER_GEOM; - static DeclareMemType MTYPE_DISPLAY_RENDER_FLUSH; - static DeclareMemType MTYPE_DISPLAY_RENDER_UI; - static DeclareMemType MTYPE_DISPLAY_RENDER_ATTACHMENTS; - - static DeclareMemType MTYPE_VERTEX_DATA; - static DeclareMemType MTYPE_VERTEX_CONSTRUCTOR; - static DeclareMemType MTYPE_VERTEX_DESTRUCTOR; - static DeclareMemType MTYPE_VERTEX_CREATE_VERTICES; - static DeclareMemType MTYPE_VERTEX_CREATE_INDICES; - static DeclareMemType MTYPE_VERTEX_DESTROY_BUFFER; - static DeclareMemType MTYPE_VERTEX_DESTROY_INDICES; - static DeclareMemType MTYPE_VERTEX_UPDATE_VERTS; - static DeclareMemType MTYPE_VERTEX_UPDATE_INDICES; - static DeclareMemType MTYPE_VERTEX_ALLOCATE_BUFFER; - static DeclareMemType MTYPE_VERTEX_RESIZE_BUFFER; - static DeclareMemType MTYPE_VERTEX_MAP_BUFFER; - static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_VERTICES; - static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_INDICES; - static DeclareMemType MTYPE_VERTEX_UNMAP_BUFFER; - static DeclareMemType MTYPE_VERTEX_SET_STRIDE; - static DeclareMemType MTYPE_VERTEX_SET_BUFFER; - static DeclareMemType MTYPE_VERTEX_SETUP_VERTEX_BUFFER; - static DeclareMemType MTYPE_VERTEX_CLEANUP_CLASS; - - static DeclareMemType MTYPE_SPACE_PARTITION; - - static DeclareMemType MTYPE_PIPELINE; - static DeclareMemType MTYPE_PIPELINE_INIT; - static DeclareMemType MTYPE_PIPELINE_CREATE_BUFFERS; - static DeclareMemType MTYPE_PIPELINE_RESTORE_GL; - static DeclareMemType MTYPE_PIPELINE_UNLOAD_SHADERS; - static DeclareMemType MTYPE_PIPELINE_LIGHTING_DETAIL; - static DeclareMemType MTYPE_PIPELINE_GET_POOL_TYPE; - static DeclareMemType MTYPE_PIPELINE_ADD_POOL; - static DeclareMemType MTYPE_PIPELINE_ALLOCATE_DRAWABLE; - static DeclareMemType MTYPE_PIPELINE_ADD_OBJECT; - static DeclareMemType MTYPE_PIPELINE_CREATE_OBJECTS; - static DeclareMemType MTYPE_PIPELINE_UPDATE_MOVE; - static DeclareMemType MTYPE_PIPELINE_UPDATE_GEOM; - static DeclareMemType MTYPE_PIPELINE_MARK_VISIBLE; - static DeclareMemType MTYPE_PIPELINE_MARK_MOVED; - static DeclareMemType MTYPE_PIPELINE_MARK_SHIFT; - static DeclareMemType MTYPE_PIPELINE_SHIFT_OBJECTS; - static DeclareMemType MTYPE_PIPELINE_MARK_TEXTURED; - static DeclareMemType MTYPE_PIPELINE_MARK_REBUILD; - static DeclareMemType MTYPE_PIPELINE_UPDATE_CULL; - static DeclareMemType MTYPE_PIPELINE_STATE_SORT; - static DeclareMemType MTYPE_PIPELINE_POST_SORT; - - static DeclareMemType MTYPE_PIPELINE_RENDER_HUD_ELS; - static DeclareMemType MTYPE_PIPELINE_RENDER_HL; - static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM; - static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED; - static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_POST_DEF; - static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_SHADOW; - static DeclareMemType MTYPE_PIPELINE_RENDER_SELECT; - static DeclareMemType MTYPE_PIPELINE_REBUILD_POOLS; - static DeclareMemType MTYPE_PIPELINE_QUICK_LOOKUP; - static DeclareMemType MTYPE_PIPELINE_RENDER_OBJECTS; - static DeclareMemType MTYPE_PIPELINE_GENERATE_IMPOSTOR; - static DeclareMemType MTYPE_PIPELINE_RENDER_BLOOM; - - static DeclareMemType MTYPE_UPKEEP_POOLS; - - static DeclareMemType MTYPE_AVATAR; - static DeclareMemType MTYPE_AVATAR_MESH; - static DeclareMemType MTYPE_PARTICLES; - static DeclareMemType MTYPE_REGIONS; - - static DeclareMemType MTYPE_INVENTORY; - static DeclareMemType MTYPE_INVENTORY_DRAW; - static DeclareMemType MTYPE_INVENTORY_BUILD_NEW_VIEWS; - static DeclareMemType MTYPE_INVENTORY_DO_FOLDER; - static DeclareMemType MTYPE_INVENTORY_POST_BUILD; - static DeclareMemType MTYPE_INVENTORY_FROM_XML; - static DeclareMemType MTYPE_INVENTORY_CREATE_NEW_ITEM; - static DeclareMemType MTYPE_INVENTORY_VIEW_INIT; - static DeclareMemType MTYPE_INVENTORY_VIEW_SHOW; - static DeclareMemType MTYPE_INVENTORY_VIEW_TOGGLE; - - static DeclareMemType MTYPE_ANIMATION; - static DeclareMemType MTYPE_VOLUME; - static DeclareMemType MTYPE_PRIMITIVE; - - static DeclareMemType MTYPE_SCRIPT; - static DeclareMemType MTYPE_SCRIPT_RUN; - static DeclareMemType MTYPE_SCRIPT_BYTECODE; - - static DeclareMemType MTYPE_IO_PUMP; - static DeclareMemType MTYPE_IO_TCP; - static DeclareMemType MTYPE_IO_BUFFER; - static DeclareMemType MTYPE_IO_HTTP_SERVER; - static DeclareMemType MTYPE_IO_SD_SERVER; - static DeclareMemType MTYPE_IO_SD_CLIENT; - static DeclareMemType MTYPE_IO_URL_REQUEST; - - static DeclareMemType MTYPE_DIRECTX_INIT; - - static DeclareMemType MTYPE_TEMP1; - static DeclareMemType MTYPE_TEMP2; - static DeclareMemType MTYPE_TEMP3; - static DeclareMemType MTYPE_TEMP4; - static DeclareMemType MTYPE_TEMP5; - static DeclareMemType MTYPE_TEMP6; - static DeclareMemType MTYPE_TEMP7; - static DeclareMemType MTYPE_TEMP8; - static DeclareMemType MTYPE_TEMP9; - - static DeclareMemType MTYPE_OTHER; // Special; used by display code - - S32 mTypeIndex; -}; - -//---------------------------------------------------------------------------- - -#endif - diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 6775b005f4..eb9ff4d5a0 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -30,7 +30,6 @@ #include "llmath.h" #include "v4coloru.h" -#include "llmemtype.h" #include "llimagebmp.h" #include "llimagetga.h" @@ -96,8 +95,7 @@ LLImageBase::LLImageBase() mHeight(0), mComponents(0), mBadBufferAllocation(false), - mAllowOverSize(false), - mMemType(LLMemType::MTYPE_IMAGEBASE) + mAllowOverSize(false) { } @@ -167,8 +165,6 @@ void LLImageBase::deleteData() // virtual U8* LLImageBase::allocateData(S32 size) { - LLMemType mt1(mMemType); - if (size < 0) { size = mWidth * mHeight * mComponents; @@ -213,7 +209,6 @@ U8* LLImageBase::allocateData(S32 size) // virtual U8* LLImageBase::reallocateData(S32 size) { - LLMemType mt1(mMemType); U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!new_datap) { @@ -279,14 +274,12 @@ S32 LLImageRaw::sRawImageCount = 0; LLImageRaw::LLImageRaw() : LLImageBase() { - mMemType = LLMemType::MTYPE_IMAGERAW; ++sRawImageCount; } LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components) : LLImageBase() { - mMemType = LLMemType::MTYPE_IMAGERAW; //llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE ); allocateDataSize(width, height, components); ++sRawImageCount; @@ -295,7 +288,6 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components) LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components) : LLImageBase() { - mMemType = LLMemType::MTYPE_IMAGERAW; if(allocateDataSize(width, height, components)) { memcpy(getData(), data, width*height*components); @@ -370,29 +362,6 @@ BOOL LLImageRaw::resize(U16 width, U16 height, S8 components) return TRUE; } -#if 0 -U8 * LLImageRaw::getSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height) const -{ - LLMemType mt1(mMemType); - U8 *data = new U8[width*height*getComponents()]; - - // Should do some simple bounds checking - if (!data) - { - llerrs << "Out of memory in LLImageRaw::getSubImage" << llendl; - return NULL; - } - - U32 i; - for (i = y_pos; i < y_pos+height; i++) - { - memcpy(data + i*width*getComponents(), /* Flawfinder: ignore */ - getData() + ((y_pos + i)*getWidth() + x_pos)*getComponents(), getComponents()*width); - } - return data; -} -#endif - BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height, const U8 *data, U32 stride, BOOL reverse_y) { @@ -457,7 +426,6 @@ void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a) // Reverses the order of the rows in the image void LLImageRaw::verticalFlip() { - LLMemType mt1(mMemType); S32 row_bytes = getWidth() * getComponents(); llassert(row_bytes > 0); std::vector<U8> line_buffer(row_bytes); @@ -590,7 +558,6 @@ void LLImageRaw::composite( LLImageRaw* src ) // Src and dst can be any size. Src has 4 components. Dst has 3 components. void LLImageRaw::compositeScaled4onto3(LLImageRaw* src) { - LLMemType mt1(mMemType); llinfos << "compositeScaled4onto3" << llendl; LLImageRaw* dst = this; // Just for clarity. @@ -832,7 +799,6 @@ void LLImageRaw::copyUnscaled3onto4( LLImageRaw* src ) // Src and dst can be any size. Src and dst have same number of components. void LLImageRaw::copyScaled( LLImageRaw* src ) { - LLMemType mt1(mMemType); LLImageRaw* dst = this; // Just for clarity. llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) ); @@ -861,57 +827,9 @@ void LLImageRaw::copyScaled( LLImageRaw* src ) } } -#if 0 -//scale down image by not blending a pixel with its neighbors. -BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height) -{ - LLMemType mt1(mMemType); - - S8 c = getComponents() ; - llassert((1 == c) || (3 == c) || (4 == c) ); - - S32 old_width = getWidth(); - S32 old_height = getHeight(); - - S32 new_data_size = old_width * new_height * c ; - llassert_always(new_data_size > 0); - - F32 ratio_x = (F32)old_width / new_width ; - F32 ratio_y = (F32)old_height / new_height ; - if( ratio_x < 1.0f || ratio_y < 1.0f ) - { - return TRUE; // Nothing to do. - } - ratio_x -= 1.0f ; - ratio_y -= 1.0f ; - - U8* new_data = allocateMemory(new_data_size) ; - llassert_always(new_data != NULL) ; - - U8* old_data = getData() ; - S32 i, j, k, s, t; - for(i = 0, s = 0, t = 0 ; i < new_height ; i++) - { - for(j = 0 ; j < new_width ; j++) - { - for(k = 0 ; k < c ; k++) - { - new_data[s++] = old_data[t++] ; - } - t += (S32)(ratio_x * c + 0.1f) ; - } - t += (S32)(ratio_y * old_width * c + 0.1f) ; - } - - setDataAndSize(new_data, new_width, new_height, c) ; - - return TRUE ; -} -#endif BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) { - LLMemType mt1(mMemType); llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) ); S32 old_width = getWidth(); @@ -1341,7 +1259,6 @@ LLImageFormatted::LLImageFormatted(S8 codec) mDiscardLevel(-1), mLevels(0) { - mMemType = LLMemType::MTYPE_IMAGEFORMATTED; } // virtual diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 46e6d1a901..d4b2fc2589 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -30,7 +30,6 @@ #include "lluuid.h" #include "llstring.h" #include "llthread.h" -#include "llmemtype.h" const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 const S32 MAX_IMAGE_MIP = 11; // 2048x2048 @@ -176,8 +175,6 @@ private: bool mAllowOverSize ; static LLPrivateMemoryPool* sPrivatePoolp ; -public: - LLMemType::DeclareMemType& mMemType; // debug }; // Raw representation of an image (used for textures, and other uncompressed formats @@ -211,8 +208,7 @@ public: void contractToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE, BOOL scale_image = TRUE); void biasedScaleToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE); BOOL scale( S32 new_width, S32 new_height, BOOL scale_image = TRUE ); - //BOOL scaleDownWithoutBlending( S32 new_width, S32 new_height) ; - + // Fill the buffer with a constant color void fill( const LLColor4U& color ); diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 452aad25cb..5412f98ee5 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -26,7 +26,6 @@ #include "lldir.h" #include "llimagej2c.h" -#include "llmemtype.h" #include "lltimer.h" #include "llmath.h" #include "llmemory.h" @@ -161,7 +160,6 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) { LLTimer elapsed; - LLMemType mt1(mMemType); BOOL res = TRUE; @@ -227,7 +225,6 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) { LLTimer elapsed; - LLMemType mt1(mMemType); resetLastError(); BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); if (!mLastError.empty()) @@ -404,7 +401,6 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename) BOOL LLImageJ2C::validate(U8 *data, U32 file_size) { - LLMemType mt1(mMemType); resetLastError(); diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index a5cfe59bda..4dda41d325 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -30,7 +30,6 @@ #include "lldarray.h" #include "llfoldertype.h" #include "llinventorytype.h" -#include "llmemtype.h" #include "llpermissions.h" #include "llrefcount.h" #include "llsaleinfo.h" @@ -54,7 +53,6 @@ public: // Initialization //-------------------------------------------------------------------- public: - MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY); LLInventoryObject(); LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid, @@ -129,7 +127,6 @@ public: // Initialization //-------------------------------------------------------------------- public: - MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY); LLInventoryItem(const LLUUID& uuid, const LLUUID& parent_uuid, const LLPermissions& permissions, @@ -242,7 +239,6 @@ public: // Initialization //-------------------------------------------------------------------- public: - MEM_TYPE_NEW(LLMemType::MTYPE_INVENTORY); LLInventoryCategory(const LLUUID& uuid, const LLUUID& parent_uuid, LLFolderType::EType preferred_type, const std::string& name); diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 06ac0aa1f6..6e57142230 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -35,7 +35,6 @@ #include <cmath> #include "llerror.h" -#include "llmemtype.h" #include "llvolumemgr.h" #include "v2math.h" @@ -389,8 +388,6 @@ public: LLProfile::Face* LLProfile::addCap(S16 faceID) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - Face *face = vector_append(mFaces, 1); face->mIndex = 0; @@ -403,8 +400,6 @@ LLProfile::Face* LLProfile::addCap(S16 faceID) LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BOOL flat) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - Face *face = vector_append(mFaces, 1); face->mIndex = i; @@ -420,7 +415,6 @@ LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BO //static S32 LLProfile::getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 offset, F32 bevel, F32 ang_scale, S32 split) { // this is basically LLProfile::genNGon stripped down to only the operations that influence the number of points - LLMemType m1(LLMemType::MTYPE_VOLUME); S32 np = 0; // Generate an n-sided "circular" path. @@ -486,8 +480,6 @@ S32 LLProfile::getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 of // filleted and chamfered corners void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F32 bevel, F32 ang_scale, S32 split) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - // Generate an n-sided "circular" path. // 0 is (1,0), and we go counter-clockwise along a circular path from there. const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; @@ -741,8 +733,6 @@ LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F3 S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split, BOOL is_sculpted, S32 sculpt_size) { // this is basically LLProfile::generate stripped down to only operations that influence the number of points - LLMemType m1(LLMemType::MTYPE_VOLUME); - if (detail < MIN_LOD) { detail = MIN_LOD; @@ -853,8 +843,6 @@ S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 de BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split, BOOL is_sculpted, S32 sculpt_size) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - if ((!mDirty) && (!is_sculpted)) { return FALSE; @@ -1127,8 +1115,6 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai BOOL LLProfileParams::importFile(LLFILE *fp) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ // *NOTE: changing the size or type of these buffers will require @@ -1204,8 +1190,6 @@ BOOL LLProfileParams::exportFile(LLFILE *fp) const BOOL LLProfileParams::importLegacyStream(std::istream& input_stream) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ // *NOTE: changing the size or type of these buffers will require @@ -1297,7 +1281,6 @@ bool LLProfileParams::fromLLSD(LLSD& sd) void LLProfileParams::copyParams(const LLProfileParams ¶ms) { - LLMemType m1(LLMemType::MTYPE_VOLUME); setCurveType(params.getCurveType()); setBegin(params.getBegin()); setEnd(params.getEnd()); @@ -1514,8 +1497,6 @@ const LLVector2 LLPathParams::getEndScale() const S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail) { // this is basically LLPath::generate stripped down to only the operations that influence the number of points - LLMemType m1(LLMemType::MTYPE_VOLUME); - if (detail < MIN_LOD) { detail = MIN_LOD; @@ -1565,8 +1546,6 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail) BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, BOOL is_sculpted, S32 sculpt_size) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - if ((!mDirty) && (!is_sculpted)) { return FALSE; @@ -1694,8 +1673,6 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split, BOOL is_sculpted, S32 sculpt_size) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - mOpen = TRUE; // Draw end caps if (getPathLength() == 0) { @@ -1717,8 +1694,6 @@ BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split, BOOL LLPathParams::importFile(LLFILE *fp) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ // *NOTE: changing the size or type of these buffers will require @@ -1863,8 +1838,6 @@ BOOL LLPathParams::exportFile(LLFILE *fp) const BOOL LLPathParams::importLegacyStream(std::istream& input_stream) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ // *NOTE: changing the size or type of these buffers will require @@ -2072,8 +2045,6 @@ S32 LLVolume::sNumMeshPoints = 0; LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL generate_single_face, const BOOL is_unique) : mParams(params) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - mUnique = is_unique; mFaceMask = 0x0; mDetail = detail; @@ -2145,7 +2116,6 @@ LLVolume::~LLVolume() BOOL LLVolume::generate() { - LLMemType m1(LLMemType::MTYPE_VOLUME); llassert_always(mProfilep); //Added 10.03.05 Dave Parks @@ -2741,8 +2711,6 @@ S32 LLVolume::getNumFaces() const void LLVolume::createVolumeFaces() { - LLMemType m1(LLMemType::MTYPE_VOLUME); - if (mGenerateSingleFace) { // do nothing @@ -2914,8 +2882,6 @@ F32 LLVolume::sculptGetSurfaceArea() // create placeholder shape void LLVolume::sculptGeneratePlaceholder() { - LLMemType m1(LLMemType::MTYPE_VOLUME); - S32 sizeS = mPathp->mPath.size(); S32 sizeT = mProfilep->mProfile.size(); @@ -2952,9 +2918,6 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; BOOL reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR - - LLMemType m1(LLMemType::MTYPE_VOLUME); - S32 sizeS = mPathp->mPath.size(); S32 sizeT = mProfilep->mProfile.size(); @@ -3103,7 +3066,6 @@ void sculpt_calc_mesh_resolution(U16 width, U16 height, U8 type, F32 detail, S32 // sculpt replaces generate() for sculpted surfaces void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level) { - LLMemType m1(LLMemType::MTYPE_VOLUME); U8 sculpt_type = mParams.getSculptType(); BOOL data_is_empty = FALSE; @@ -3240,7 +3202,6 @@ bool LLVolumeParams::operator<(const LLVolumeParams ¶ms) const void LLVolumeParams::copyParams(const LLVolumeParams ¶ms) { - LLMemType m1(LLMemType::MTYPE_VOLUME); mProfileParams.copyParams(params.mProfileParams); mPathParams.copyParams(params.mPathParams); mSculptID = params.getSculptID(); @@ -3612,8 +3573,6 @@ bool LLVolumeParams::validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 h S32 *LLVolume::getTriangleIndices(U32 &num_indices) const { - LLMemType m1(LLMemType::MTYPE_VOLUME); - S32 expected_num_triangle_indices = getNumTriangleIndices(); if (expected_num_triangle_indices > MAX_VOLUME_TRIANGLE_INDICES) { @@ -4341,8 +4300,6 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, const LLMatrix3& norm_mat_in, S32 face_mask) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - LLMatrix4a mat; mat.loadu(mat_in); @@ -4804,241 +4761,8 @@ BOOL equalTriangle(const S32 *a, const S32 *b) return FALSE; } -BOOL LLVolume::cleanupTriangleData( const S32 num_input_vertices, - const std::vector<Point>& input_vertices, - const S32 num_input_triangles, - S32 *input_triangles, - S32 &num_output_vertices, - LLVector3 **output_vertices, - S32 &num_output_triangles, - S32 **output_triangles) -{ - LLMemType m1(LLMemType::MTYPE_VOLUME); - - /* Testing: avoid any cleanup - static BOOL skip_cleanup = TRUE; - if ( skip_cleanup ) - { - num_output_vertices = num_input_vertices; - num_output_triangles = num_input_triangles; - - *output_vertices = new LLVector3[num_input_vertices]; - for (S32 index = 0; index < num_input_vertices; index++) - { - (*output_vertices)[index] = input_vertices[index].mPos; - } - - *output_triangles = new S32[num_input_triangles*3]; - memcpy(*output_triangles, input_triangles, 3*num_input_triangles*sizeof(S32)); // Flawfinder: ignore - return TRUE; - } - */ - - // Here's how we do this: - // Create a structure which contains the original vertex index and the - // LLVector3 data. - // "Sort" the data by the vectors - // Create an array the size of the old vertex list, with a mapping of - // old indices to new indices. - // Go through triangles, shift so the lowest index is first - // Sort triangles by first index - // Remove duplicate triangles - // Allocate and pack new triangle data. - - //LLTimer cleanupTimer; - //llinfos << "In vertices: " << num_input_vertices << llendl; - //llinfos << "In triangles: " << num_input_triangles << llendl; - - S32 i; - typedef std::multiset<LLVertexIndexPair*, lessVertex> vertex_set_t; - vertex_set_t vertex_list; - - LLVertexIndexPair *pairp = NULL; - for (i = 0; i < num_input_vertices; i++) - { - LLVertexIndexPair *new_pairp = new LLVertexIndexPair(input_vertices[i].mPos, i); - vertex_list.insert(new_pairp); - } - - // Generate the vertex mapping and the list of vertices without - // duplicates. This will crash if there are no vertices. - llassert(num_input_vertices > 0); // check for no vertices! - S32 *vertex_mapping = new S32[num_input_vertices]; - LLVector3 *new_vertices = new LLVector3[num_input_vertices]; - LLVertexIndexPair *prev_pairp = NULL; - - S32 new_num_vertices; - - new_num_vertices = 0; - for (vertex_set_t::iterator iter = vertex_list.begin(), - end = vertex_list.end(); - iter != end; iter++) - { - pairp = *iter; - if (!prev_pairp || ((pairp->mVertex - prev_pairp->mVertex).magVecSquared() >= VERTEX_SLOP_SQRD)) - { - new_vertices[new_num_vertices] = pairp->mVertex; - //llinfos << "Added vertex " << new_num_vertices << " : " << pairp->mVertex << llendl; - new_num_vertices++; - // Update the previous - prev_pairp = pairp; - } - else - { - //llinfos << "Removed duplicate vertex " << pairp->mVertex << ", distance magVecSquared() is " << (pairp->mVertex - prev_pairp->mVertex).magVecSquared() << llendl; - } - vertex_mapping[pairp->mIndex] = new_num_vertices - 1; - } - - // Iterate through triangles and remove degenerates, re-ordering vertices - // along the way. - S32 *new_triangles = new S32[num_input_triangles * 3]; - S32 new_num_triangles = 0; - - for (i = 0; i < num_input_triangles; i++) - { - S32 v1 = i*3; - S32 v2 = v1 + 1; - S32 v3 = v1 + 2; - - //llinfos << "Checking triangle " << input_triangles[v1] << ":" << input_triangles[v2] << ":" << input_triangles[v3] << llendl; - input_triangles[v1] = vertex_mapping[input_triangles[v1]]; - input_triangles[v2] = vertex_mapping[input_triangles[v2]]; - input_triangles[v3] = vertex_mapping[input_triangles[v3]]; - - if ((input_triangles[v1] == input_triangles[v2]) - || (input_triangles[v1] == input_triangles[v3]) - || (input_triangles[v2] == input_triangles[v3])) - { - //llinfos << "Removing degenerate triangle " << input_triangles[v1] << ":" << input_triangles[v2] << ":" << input_triangles[v3] << llendl; - // Degenerate triangle, skip - continue; - } - - if (input_triangles[v1] < input_triangles[v2]) - { - if (input_triangles[v1] < input_triangles[v3]) - { - // (0 < 1) && (0 < 2) - new_triangles[new_num_triangles*3] = input_triangles[v1]; - new_triangles[new_num_triangles*3+1] = input_triangles[v2]; - new_triangles[new_num_triangles*3+2] = input_triangles[v3]; - } - else - { - // (0 < 1) && (2 < 0) - new_triangles[new_num_triangles*3] = input_triangles[v3]; - new_triangles[new_num_triangles*3+1] = input_triangles[v1]; - new_triangles[new_num_triangles*3+2] = input_triangles[v2]; - } - } - else if (input_triangles[v2] < input_triangles[v3]) - { - // (1 < 0) && (1 < 2) - new_triangles[new_num_triangles*3] = input_triangles[v2]; - new_triangles[new_num_triangles*3+1] = input_triangles[v3]; - new_triangles[new_num_triangles*3+2] = input_triangles[v1]; - } - else - { - // (1 < 0) && (2 < 1) - new_triangles[new_num_triangles*3] = input_triangles[v3]; - new_triangles[new_num_triangles*3+1] = input_triangles[v1]; - new_triangles[new_num_triangles*3+2] = input_triangles[v2]; - } - new_num_triangles++; - } - - if (new_num_triangles == 0) - { - llwarns << "Created volume object with 0 faces." << llendl; - delete[] new_triangles; - delete[] vertex_mapping; - delete[] new_vertices; - return FALSE; - } - - typedef std::set<S32*, lessTriangle> triangle_set_t; - triangle_set_t triangle_list; - - for (i = 0; i < new_num_triangles; i++) - { - triangle_list.insert(&new_triangles[i*3]); - } - - // Sort through the triangle list, and delete duplicates - - S32 *prevp = NULL; - S32 *curp = NULL; - - S32 *sorted_tris = new S32[new_num_triangles*3]; - S32 cur_tri = 0; - for (triangle_set_t::iterator iter = triangle_list.begin(), - end = triangle_list.end(); - iter != end; iter++) - { - curp = *iter; - if (!prevp || !equalTriangle(prevp, curp)) - { - //llinfos << "Added triangle " << *curp << ":" << *(curp+1) << ":" << *(curp+2) << llendl; - sorted_tris[cur_tri*3] = *curp; - sorted_tris[cur_tri*3+1] = *(curp+1); - sorted_tris[cur_tri*3+2] = *(curp+2); - cur_tri++; - prevp = curp; - } - else - { - //llinfos << "Skipped triangle " << *curp << ":" << *(curp+1) << ":" << *(curp+2) << llendl; - } - } - - *output_vertices = new LLVector3[new_num_vertices]; - num_output_vertices = new_num_vertices; - for (i = 0; i < new_num_vertices; i++) - { - (*output_vertices)[i] = new_vertices[i]; - } - - *output_triangles = new S32[cur_tri*3]; - num_output_triangles = cur_tri; - memcpy(*output_triangles, sorted_tris, 3*cur_tri*sizeof(S32)); /* Flawfinder: ignore */ - - /* - llinfos << "Out vertices: " << num_output_vertices << llendl; - llinfos << "Out triangles: " << num_output_triangles << llendl; - for (i = 0; i < num_output_vertices; i++) - { - llinfos << i << ":" << (*output_vertices)[i] << llendl; - } - for (i = 0; i < num_output_triangles; i++) - { - llinfos << i << ":" << (*output_triangles)[i*3] << ":" << (*output_triangles)[i*3+1] << ":" << (*output_triangles)[i*3+2] << llendl; - } - */ - - //llinfos << "Out vertices: " << num_output_vertices << llendl; - //llinfos << "Out triangles: " << num_output_triangles << llendl; - delete[] vertex_mapping; - vertex_mapping = NULL; - delete[] new_vertices; - new_vertices = NULL; - delete[] new_triangles; - new_triangles = NULL; - delete[] sorted_tris; - sorted_tris = NULL; - triangle_list.clear(); - std::for_each(vertex_list.begin(), vertex_list.end(), DeletePointer()); - vertex_list.clear(); - - return TRUE; -} - - BOOL LLVolumeParams::importFile(LLFILE *fp) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - //llinfos << "importing volume" << llendl; const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ @@ -5093,8 +4817,6 @@ BOOL LLVolumeParams::exportFile(LLFILE *fp) const BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - //llinfos << "importing volume" << llendl; const S32 BUFSIZE = 16384; // *NOTE: changing the size or type of this buffer will require @@ -5134,8 +4856,6 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream) BOOL LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const { - LLMemType m1(LLMemType::MTYPE_VOLUME); - output_stream <<"\tshape 0\n"; output_stream <<"\t{\n"; mPathParams.exportLegacyStream(output_stream); @@ -6351,8 +6071,6 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0, BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - const std::vector<LLVolume::Point>& mesh = volume->getMesh(); const std::vector<LLVector3>& profile = volume->getProfile().mProfile; S32 max_s = volume->getProfile().getTotal(); @@ -6503,8 +6221,6 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK) && ((volume->getParams().getPathParams().getBegin()==0.0f)&& @@ -6891,8 +6607,6 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) void LLVolumeFace::createBinormals() { - LLMemType m1(LLMemType::MTYPE_VOLUME); - if (!mBinormals) { allocateBinormals(mNumVertices); @@ -7159,8 +6873,6 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) { - LLMemType m1(LLMemType::MTYPE_VOLUME); - BOOL flat = mTypeMask & FLAT_MASK; U8 sculpt_type = volume->getParams().getSculptType(); diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 2e6f9e2f71..c845556557 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -1023,17 +1023,6 @@ public: LLVector3* normal = NULL, LLVector3* bi_normal = NULL); - // The following cleans up vertices and triangles, - // getting rid of degenerate triangles and duplicate vertices, - // and allocates new arrays with the clean data. - static BOOL cleanupTriangleData( const S32 num_input_vertices, - const std::vector<Point> &input_vertices, - const S32 num_input_triangles, - S32 *input_triangles, - S32 &num_output_vertices, - LLVector3 **output_vertices, - S32 &num_output_triangles, - S32 **output_triangles); LLFaceID generateFaceMask(); BOOL isFaceMaskValid(LLFaceID face_mask); diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp index c60b750088..9083273ee5 100644 --- a/indra/llmath/llvolumemgr.cpp +++ b/indra/llmath/llvolumemgr.cpp @@ -26,7 +26,6 @@ #include "linden_common.h" #include "llvolumemgr.h" -#include "llmemtype.h" #include "llvolume.h" @@ -182,7 +181,6 @@ void LLVolumeMgr::insertGroup(LLVolumeLODGroup* volgroup) // protected LLVolumeLODGroup* LLVolumeMgr::createNewGroup(const LLVolumeParams& volume_params) { - LLMemType m1(LLMemType::MTYPE_VOLUME); LLVolumeLODGroup* volgroup = new LLVolumeLODGroup(volume_params); insertGroup(volgroup); return volgroup; @@ -297,7 +295,6 @@ LLVolume* LLVolumeLODGroup::refLOD(const S32 detail) mRefs++; if (mVolumeLODs[detail].isNull()) { - LLMemType m1(LLMemType::MTYPE_VOLUME); mVolumeLODs[detail] = new LLVolume(mVolumeParams, mDetailScales[detail]); } mLODRefs[detail]++; diff --git a/indra/llmessage/llbuffer.cpp b/indra/llmessage/llbuffer.cpp index 250cace6e9..01da20f060 100644 --- a/indra/llmessage/llbuffer.cpp +++ b/indra/llmessage/llbuffer.cpp @@ -30,7 +30,6 @@ #include "llbuffer.h" #include "llmath.h" -#include "llmemtype.h" #include "llstl.h" #include "llthread.h" @@ -44,7 +43,6 @@ LLSegment::LLSegment() : mData(NULL), mSize(0) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } LLSegment::LLSegment(S32 channel, U8* data, S32 data_len) : @@ -52,12 +50,10 @@ LLSegment::LLSegment(S32 channel, U8* data, S32 data_len) : mData(data), mSize(data_len) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } LLSegment::~LLSegment() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } bool LLSegment::isOnChannel(S32 channel) const @@ -104,7 +100,6 @@ LLHeapBuffer::LLHeapBuffer() : mNextFree(NULL), mReclaimedBytes(0) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); const S32 DEFAULT_HEAP_BUFFER_SIZE = 16384; allocate(DEFAULT_HEAP_BUFFER_SIZE); } @@ -115,7 +110,6 @@ LLHeapBuffer::LLHeapBuffer(S32 size) : mNextFree(NULL), mReclaimedBytes(0) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); allocate(size); } @@ -125,7 +119,6 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) : mNextFree(NULL), mReclaimedBytes(0) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); if((len > 0) && src) { allocate(len); @@ -139,7 +132,6 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) : // virtual LLHeapBuffer::~LLHeapBuffer() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); delete[] mBuffer; mBuffer = NULL; mSize = 0; @@ -157,7 +149,6 @@ bool LLHeapBuffer::createSegment( S32 size, LLSegment& segment) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); // get actual size of the segment. S32 actual_size = llmin(size, (mSize - S32(mNextFree - mBuffer))); @@ -212,7 +203,6 @@ bool LLHeapBuffer::containsSegment(const LLSegment& segment) const void LLHeapBuffer::allocate(S32 size) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); mReclaimedBytes = 0; mBuffer = new U8[size]; if(mBuffer) @@ -230,12 +220,10 @@ LLBufferArray::LLBufferArray() : mNextBaseChannel(0), mMutexp(NULL) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } LLBufferArray::~LLBufferArray() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); std::for_each(mBuffers.begin(), mBuffers.end(), DeletePointer()); delete mMutexp; @@ -314,7 +302,6 @@ bool LLBufferArray::append(S32 channel, const U8* src, S32 len) { LLMutexLock lock(mMutexp) ; - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); std::vector<LLSegment> segments; if(copyIntoBuffers(channel, src, len, segments)) { @@ -329,7 +316,6 @@ bool LLBufferArray::prepend(S32 channel, const U8* src, S32 len) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); std::vector<LLSegment> segments; if(copyIntoBuffers(channel, src, len, segments)) { @@ -345,7 +331,6 @@ bool LLBufferArray::insertAfter( const U8* src, S32 len) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); std::vector<LLSegment> segments; LLMutexLock lock(mMutexp) ; @@ -366,7 +351,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::splitAfter(U8* address) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); segment_iterator_t end = mSegments.end(); segment_iterator_t it = getSegment(address); if(it == end) @@ -414,7 +398,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::constructSegmentAfter( LLSegment& segment) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); segment_iterator_t rv = mSegments.begin(); segment_iterator_t end = mSegments.end(); if(!address) @@ -578,7 +561,6 @@ U8* LLBufferArray::readAfter( U8* dest, S32& len) const { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); U8* rv = start; if(!dest || len <= 0) { @@ -642,7 +624,6 @@ U8* LLBufferArray::seek( S32 delta) const { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); const_segment_iterator_t it; const_segment_iterator_t end = mSegments.end(); U8* rv = start; @@ -786,8 +767,6 @@ U8* LLBufferArray::seek( //test use only bool LLBufferArray::takeContents(LLBufferArray& source) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); - LLMutexLock lock(mMutexp); source.lock(); @@ -813,7 +792,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::makeSegment( S32 len) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); // start at the end of the buffers, because it is the most likely // to have free space. LLSegment segment; @@ -852,7 +830,6 @@ LLBufferArray::segment_iterator_t LLBufferArray::makeSegment( bool LLBufferArray::eraseSegment(const segment_iterator_t& erase_iter) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); // Find out which buffer contains the segment, and if it is found, // ask it to reclaim the memory. @@ -885,7 +862,6 @@ bool LLBufferArray::copyIntoBuffers( std::vector<LLSegment>& segments) { ASSERT_LLBUFFERARRAY_MUTEX_LOCKED - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); if(!src || !len) return false; S32 copied = 0; LLSegment segment; diff --git a/indra/llmessage/llbufferstream.cpp b/indra/llmessage/llbufferstream.cpp index 8d8ad05ad5..a51a48edc3 100644 --- a/indra/llmessage/llbufferstream.cpp +++ b/indra/llmessage/llbufferstream.cpp @@ -30,7 +30,6 @@ #include "llbufferstream.h" #include "llbuffer.h" -#include "llmemtype.h" #include "llthread.h" static const S32 DEFAULT_OUTPUT_SEGMENT_SIZE = 1024 * 4; @@ -44,19 +43,16 @@ LLBufferStreamBuf::LLBufferStreamBuf( mChannels(channels), mBuffer(buffer) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } LLBufferStreamBuf::~LLBufferStreamBuf() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); sync(); } // virtual int LLBufferStreamBuf::underflow() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); //lldebugs << "LLBufferStreamBuf::underflow()" << llendl; if(!mBuffer) { @@ -129,7 +125,6 @@ int LLBufferStreamBuf::underflow() // virtual int LLBufferStreamBuf::overflow(int c) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); if(!mBuffer) { return EOF; @@ -169,7 +164,6 @@ int LLBufferStreamBuf::overflow(int c) // virtual int LLBufferStreamBuf::sync() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); int return_value = -1; if(!mBuffer) { @@ -251,7 +245,6 @@ streampos LLBufferStreamBuf::seekoff( std::ios::openmode which) #endif { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); if(!mBuffer || ((way == std::ios::beg) && (off < 0)) || ((way == std::ios::end) && (off > 0))) @@ -343,10 +336,8 @@ LLBufferStream::LLBufferStream( std::iostream(&mStreamBuf), mStreamBuf(channels, buffer) { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } LLBufferStream::~LLBufferStream() { - LLMemType m1(LLMemType::MTYPE_IO_BUFFER); } diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 479efabb5f..8f4af1984c 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -36,7 +36,6 @@ #include "llsdserialize.h" #include "lluuid.h" #include "message.h" -#include "llmemtype.h" #include <boost/regex.hpp> @@ -663,7 +662,6 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, ol void LLCacheName::processPending() { - LLMemType mt_pp(LLMemType::MTYPE_CACHE_PROCESS_PENDING); const F32 SECS_BETWEEN_PROCESS = 0.1f; if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS)) { @@ -769,7 +767,6 @@ std::string LLCacheName::getDefaultLastName() void LLCacheName::Impl::processPendingAsks() { - LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS); sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); mAskNameQueue.clear(); @@ -778,7 +775,6 @@ void LLCacheName::Impl::processPendingAsks() void LLCacheName::Impl::processPendingReplies() { - LLMemType mt_ppr(LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES); // First call all the callbacks, because they might send messages. for(ReplyQueue::iterator it = mReplyQueue.begin(); it != mReplyQueue.end(); ++it) { diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 987f386aa3..127a2caabe 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -37,7 +37,6 @@ #include "lliopipe.h" #include "lliosocket.h" #include "llioutil.h" -#include "llmemtype.h" #include "llmemorystream.h" #include "llpumpio.h" #include "llsd.h" @@ -443,7 +442,6 @@ LLIOPipe::EStatus LLHTTPResponseHeader::process_impl( { LLFastTimer t(FTM_PROCESS_HTTP_HEADER); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); if(eos) { PUMP_DEBUG; @@ -587,13 +585,11 @@ LLHTTPResponder::LLHTTPResponder(const LLHTTPNode& tree, const LLSD& ctx) : mContentLength(0), mRootNode(tree) { - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); } // virtual LLHTTPResponder::~LLHTTPResponder() { - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); //lldebugs << "destroying LLHTTPResponder" << llendl; } @@ -603,7 +599,6 @@ bool LLHTTPResponder::readHeaderLine( U8* dest, S32& len) { - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); --len; U8* last = buffer->readAfter(channels.in(), mLastRead, dest, len); dest[len] = '\0'; @@ -628,7 +623,6 @@ void LLHTTPResponder::markBad( const LLChannelDescriptors& channels, buffer_ptr_t buffer) { - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); mState = STATE_SHORT_CIRCUIT; LLBufferStream out(channels, buffer.get()); out << HTTP_VERSION_STR << " 400 Bad Request\r\n\r\n<html>\n" @@ -648,7 +642,6 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl( { LLFastTimer t(FTM_PROCESS_HTTP_RESPONDER); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER); LLIOPipe::EStatus status = STATUS_OK; // parsing headers diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index d5b4d45821..0287026659 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -33,7 +33,6 @@ #include "llbuffer.h" #include "llhost.h" -#include "llmemtype.h" #include "llpumpio.h" // @@ -100,7 +99,6 @@ void ll_debug_socket(const char* msg, apr_socket_t* apr_sock) // static LLSocket::ptr_t LLSocket::create(apr_pool_t* pool, EType type, U16 port) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); LLSocket::ptr_t rv; apr_socket_t* socket = NULL; apr_pool_t* new_pool = NULL; @@ -198,7 +196,6 @@ LLSocket::ptr_t LLSocket::create(apr_pool_t* pool, EType type, U16 port) // static LLSocket::ptr_t LLSocket::create(apr_socket_t* socket, apr_pool_t* pool) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); LLSocket::ptr_t rv; if(!socket) { @@ -240,12 +237,10 @@ LLSocket::LLSocket(apr_socket_t* socket, apr_pool_t* pool) : mPort(PORT_INVALID) { ll_debug_socket("Constructing wholely formed socket", mSocket); - LLMemType m1(LLMemType::MTYPE_IO_TCP); } LLSocket::~LLSocket() { - LLMemType m1(LLMemType::MTYPE_IO_TCP); // *FIX: clean up memory we are holding. if(mSocket) { @@ -265,7 +260,6 @@ LLSocket::~LLSocket() void LLSocket::setBlocking(S32 timeout) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); // set up the socket options ll_apr_warn_status(apr_socket_timeout_set(mSocket, timeout)); ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 0)); @@ -276,7 +270,6 @@ void LLSocket::setBlocking(S32 timeout) void LLSocket::setNonBlocking() { - LLMemType m1(LLMemType::MTYPE_IO_TCP); // set up the socket options ll_apr_warn_status(apr_socket_timeout_set(mSocket, 0)); ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 1)); @@ -293,12 +286,10 @@ LLIOSocketReader::LLIOSocketReader(LLSocket::ptr_t socket) : mSource(socket), mInitialized(false) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); } LLIOSocketReader::~LLIOSocketReader() { - LLMemType m1(LLMemType::MTYPE_IO_TCP); //lldebugs << "Destroying LLIOSocketReader" << llendl; } @@ -314,7 +305,6 @@ LLIOPipe::EStatus LLIOSocketReader::process_impl( { LLFastTimer t(FTM_PROCESS_SOCKET_READER); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_TCP); if(!mSource) return STATUS_PRECONDITION_NOT_MET; if(!mInitialized) { @@ -396,12 +386,10 @@ LLIOSocketWriter::LLIOSocketWriter(LLSocket::ptr_t socket) : mLastWritten(NULL), mInitialized(false) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); } LLIOSocketWriter::~LLIOSocketWriter() { - LLMemType m1(LLMemType::MTYPE_IO_TCP); //lldebugs << "Destroying LLIOSocketWriter" << llendl; } @@ -416,7 +404,6 @@ LLIOPipe::EStatus LLIOSocketWriter::process_impl( { LLFastTimer t(FTM_PROCESS_SOCKET_WRITER); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_TCP); if(!mDestination) return STATUS_PRECONDITION_NOT_MET; if(!mInitialized) { @@ -550,12 +537,10 @@ LLIOServerSocket::LLIOServerSocket( mInitialized(false), mResponseTimeout(DEFAULT_CHAIN_EXPIRY_SECS) { - LLMemType m1(LLMemType::MTYPE_IO_TCP); } LLIOServerSocket::~LLIOServerSocket() { - LLMemType m1(LLMemType::MTYPE_IO_TCP); //lldebugs << "Destroying LLIOServerSocket" << llendl; } @@ -575,7 +560,6 @@ LLIOPipe::EStatus LLIOServerSocket::process_impl( { LLFastTimer t(FTM_PROCESS_SERVER_SOCKET); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_TCP); if(!pump) { llwarns << "Need a pump for server socket." << llendl; diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp index f3ef4f2684..97db666e6b 100644 --- a/indra/llmessage/llpumpio.cpp +++ b/indra/llmessage/llpumpio.cpp @@ -34,7 +34,6 @@ #include "apr_poll.h" #include "llapr.h" -#include "llmemtype.h" #include "llstl.h" #include "llstat.h" @@ -153,7 +152,6 @@ struct ll_delete_apr_pollset_fd_client_data typedef std::pair<LLIOPipe::ptr_t, apr_pollfd_t> pipe_conditional_t; void operator()(const pipe_conditional_t& conditional) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); S32* client_id = (S32*)conditional.second.client_data; delete client_id; } @@ -177,19 +175,16 @@ LLPumpIO::LLPumpIO(apr_pool_t* pool) : { mCurrentChain = mRunningChains.end(); - LLMemType m1(LLMemType::MTYPE_IO_PUMP); initialize(pool); } LLPumpIO::~LLPumpIO() { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); cleanup(); } bool LLPumpIO::prime(apr_pool_t* pool) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); cleanup(); initialize(pool); return ((pool == NULL) ? false : true); @@ -197,7 +192,6 @@ bool LLPumpIO::prime(apr_pool_t* pool) bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(chain.empty()) return false; #if LL_THREADS_APR @@ -233,7 +227,6 @@ bool LLPumpIO::addChain( LLSD context, F32 timeout) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); // remember that if the caller is providing a full link // description, we need to have that description matched to a @@ -311,7 +304,6 @@ static std::string events_2_string(apr_int16_t events) bool LLPumpIO::setConditional(LLIOPipe* pipe, const apr_pollfd_t* poll) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(!pipe) return false; ll_debug_poll_fd("Set conditional", poll); @@ -423,7 +415,6 @@ bool LLPumpIO::sleepChain(F64 seconds) bool LLPumpIO::copyCurrentLinkInfo(links_t& links) const { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(mRunningChains.end() == mCurrentChain) { return false; @@ -454,7 +445,6 @@ LLPumpIO::current_chain_t LLPumpIO::removeRunningChain(LLPumpIO::current_chain_t //timeout is in microseconds void LLPumpIO::pump(const S32& poll_timeout) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLFastTimer t1(FTM_PUMP_IO); //llinfos << "LLPumpIO::pump()" << llendl; @@ -747,7 +737,6 @@ void LLPumpIO::pump(const S32& poll_timeout) bool LLPumpIO::respond(LLIOPipe* pipe) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(NULL == pipe) return false; #if LL_THREADS_APR @@ -766,7 +755,6 @@ bool LLPumpIO::respond( LLIOPipe::buffer_ptr_t data, LLSD context) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); // if the caller is providing a full link description, we need to // have that description matched to a particular buffer. if(!data) return false; @@ -789,7 +777,6 @@ static LLFastTimer::DeclareTimer FTM_PUMP_CALLBACK_CHAIN("Chain"); void LLPumpIO::callback() { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); //llinfos << "LLPumpIO::callback()" << llendl; if(true) { @@ -840,7 +827,6 @@ void LLPumpIO::control(LLPumpIO::EControl op) void LLPumpIO::initialize(apr_pool_t* pool) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(!pool) return; #if LL_THREADS_APR // SJB: Windows defaults to NESTED and OSX defaults to UNNESTED, so use UNNESTED explicitly. @@ -852,7 +838,6 @@ void LLPumpIO::initialize(apr_pool_t* pool) void LLPumpIO::cleanup() { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); #if LL_THREADS_APR if(mChainsMutex) apr_thread_mutex_destroy(mChainsMutex); if(mCallbackMutex) apr_thread_mutex_destroy(mCallbackMutex); @@ -875,7 +860,6 @@ void LLPumpIO::cleanup() void LLPumpIO::rebuildPollset() { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); // lldebugs << "LLPumpIO::rebuildPollset()" << llendl; if(mPollset) { @@ -928,7 +912,6 @@ void LLPumpIO::rebuildPollset() void LLPumpIO::processChain(LLChainInfo& chain) { PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLIOPipe::EStatus status = LLIOPipe::STATUS_OK; links_t::iterator it = chain.mHead; links_t::iterator end = chain.mChainLinks.end(); @@ -1130,7 +1113,6 @@ bool LLPumpIO::handleChainError( LLChainInfo& chain, LLIOPipe::EStatus error) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); links_t::reverse_iterator rit; if(chain.mHead == chain.mChainLinks.end()) { @@ -1194,13 +1176,11 @@ LLPumpIO::LLChainInfo::LLChainInfo() : mEOS(false), mHasCurlRequest(false) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); mTimer.setTimerExpirySec(DEFAULT_CHAIN_EXPIRY_SECS); } void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(timeout > 0.0f) { mTimer.start(); @@ -1215,7 +1195,6 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout) void LLPumpIO::LLChainInfo::adjustTimeoutSeconds(F32 delta) { - LLMemType m1(LLMemType::MTYPE_IO_PUMP); if(mTimer.getStarted()) { F64 expiry = mTimer.expiresAt(); diff --git a/indra/llmessage/llsdrpcclient.cpp b/indra/llmessage/llsdrpcclient.cpp index 91fd070f07..fcda0e81a3 100644 --- a/indra/llmessage/llsdrpcclient.cpp +++ b/indra/llmessage/llsdrpcclient.cpp @@ -31,7 +31,6 @@ #include "llbufferstream.h" #include "llfiltersd2xmlrpc.h" -#include "llmemtype.h" #include "llpumpio.h" #include "llsd.h" #include "llsdserialize.h" @@ -50,18 +49,15 @@ LLSDRPCResponse::LLSDRPCResponse() : mIsError(false), mIsFault(false) { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); } // virtual LLSDRPCResponse::~LLSDRPCResponse() { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); } bool LLSDRPCResponse::extractResponse(const LLSD& sd) { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); bool rv = true; if(sd.has(LLSDRPC_RESPONSE_NAME)) { @@ -94,7 +90,6 @@ LLIOPipe::EStatus LLSDRPCResponse::process_impl( { LLFastTimer t(FTM_SDRPC_RESPONSE); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); if(mIsError) { error(pump); @@ -119,13 +114,11 @@ LLSDRPCClient::LLSDRPCClient() : mState(STATE_NONE), mQueue(EPBQ_PROCESS) { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); } // virtual LLSDRPCClient::~LLSDRPCClient() { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); } bool LLSDRPCClient::call( @@ -135,7 +128,6 @@ bool LLSDRPCClient::call( LLSDRPCResponse* response, EPassBackQueue queue) { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); //llinfos << "RPC: " << uri << "." << method << "(" << *parameter << ")" // << llendl; if(method.empty() || !response) @@ -162,7 +154,6 @@ bool LLSDRPCClient::call( LLSDRPCResponse* response, EPassBackQueue queue) { - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); //llinfos << "RPC: " << uri << "." << method << "(" << parameter << ")" // << llendl; if(method.empty() || parameter.empty() || !response) @@ -193,7 +184,6 @@ LLIOPipe::EStatus LLSDRPCClient::process_impl( { LLFastTimer t(FTM_PROCESS_SDRPC_CLIENT); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT); if((STATE_NONE == mState) || (!pump)) { // You should have called the call() method already. diff --git a/indra/llmessage/llsdrpcserver.cpp b/indra/llmessage/llsdrpcserver.cpp index 9f776aca72..f26ee52f71 100644 --- a/indra/llmessage/llsdrpcserver.cpp +++ b/indra/llmessage/llsdrpcserver.cpp @@ -31,7 +31,6 @@ #include "llbuffer.h" #include "llbufferstream.h" -#include "llmemtype.h" #include "llpumpio.h" #include "llsdserialize.h" #include "llstl.h" @@ -58,12 +57,10 @@ LLSDRPCServer::LLSDRPCServer() : mPump(NULL), mLock(0) { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); } LLSDRPCServer::~LLSDRPCServer() { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); std::for_each( mMethods.begin(), mMethods.end(), @@ -109,7 +106,6 @@ LLIOPipe::EStatus LLSDRPCServer::process_impl( { LLFastTimer t(FTM_PROCESS_SDRPC_SERVER); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); // lldebugs << "LLSDRPCServer::process_impl" << llendl; // Once we have all the data, We need to read the sd on // the the in channel, and respond on the out channel @@ -253,7 +249,6 @@ ESDRPCSStatus LLSDRPCServer::callMethod( const LLChannelDescriptors& channels, LLBufferArray* response) { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); // Try to find the method in the method table. ESDRPCSStatus rv = ESDRPCS_DONE; method_map_t::iterator it = mMethods.find(method); @@ -292,7 +287,6 @@ ESDRPCSStatus LLSDRPCServer::callbackMethod( const LLChannelDescriptors& channels, LLBufferArray* response) { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); // Try to find the method in the callback method table. ESDRPCSStatus rv = ESDRPCS_DONE; method_map_t::iterator it = mCallbackMethods.find(method); @@ -320,7 +314,6 @@ void LLSDRPCServer::buildFault( S32 code, const std::string& msg) { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); LLBufferStream ostr(channels, data); ostr << FAULT_PART_1 << code << FAULT_PART_2 << msg << FAULT_PART_3; llinfos << "LLSDRPCServer::buildFault: " << code << ", " << msg << llendl; @@ -332,7 +325,6 @@ void LLSDRPCServer::buildResponse( LLBufferArray* data, const LLSD& response) { - LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER); LLBufferStream ostr(channels, data); ostr << RESPONSE_PART_1; LLSDSerialize::toNotation(response, ostr); diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index a16f5c7bf0..8d96ad73ca 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -34,7 +34,6 @@ #include <openssl/ssl.h> #include "llcurl.h" #include "llioutil.h" -#include "llmemtype.h" #include "llproxy.h" #include "llpumpio.h" #include "llsd.h" @@ -81,7 +80,6 @@ LLURLRequestDetail::LLURLRequestDetail() : mIsBodyLimitSet(false), mSSLVerifyCallback(NULL) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mCurlRequest = new LLCurlEasyRequest(); if(!mCurlRequest->isValid()) //failed. @@ -93,7 +91,6 @@ LLURLRequestDetail::LLURLRequestDetail() : LLURLRequestDetail::~LLURLRequestDetail() { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); delete mCurlRequest; mLastRead = NULL; } @@ -156,7 +153,6 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action) LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action) : mAction(action) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); initialize(); } @@ -165,21 +161,18 @@ LLURLRequest::LLURLRequest( const std::string& url) : mAction(action) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); initialize(); setURL(url); } LLURLRequest::~LLURLRequest() { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); delete mDetail; mDetail = NULL ; } void LLURLRequest::setURL(const std::string& url) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mDetail->mURL = url; } @@ -190,7 +183,6 @@ std::string LLURLRequest::getURL() const void LLURLRequest::addHeader(const char* header) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mDetail->mCurlRequest->slist_append(header); } @@ -202,7 +194,6 @@ void LLURLRequest::setBodyLimit(U32 size) void LLURLRequest::setCallback(LLURLRequestComplete* callback) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mCompletionCallback = callback; mDetail->mCurlRequest->setHeaderCallback(&headerCallback, (void*)callback); } @@ -267,8 +258,6 @@ LLIOPipe::EStatus LLURLRequest::handleError( LLIOPipe::EStatus status, LLPumpIO* pump) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); - if(!isValid()) { return STATUS_EXPIRED ; @@ -300,7 +289,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl( { LLFastTimer t(FTM_PROCESS_URL_REQUEST); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); //llinfos << "LLURLRequest::process_impl()" << llendl; if (!buffer) return STATUS_ERROR; @@ -456,7 +444,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl( void LLURLRequest::initialize() { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mState = STATE_INITIALIZED; mDetail = new LLURLRequestDetail; @@ -477,7 +464,6 @@ bool LLURLRequest::configure() { LLFastTimer t(FTM_URL_REQUEST_CONFIGURE); - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); bool rv = false; S32 bytes = mDetail->mResponseBuffer->countAfter( mDetail->mChannels.in(), @@ -557,7 +543,6 @@ size_t LLURLRequest::downCallback( size_t nmemb, void* user) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLURLRequest* req = (LLURLRequest*)user; if(STATE_WAITING_FOR_RESPONSE == req->mState) { @@ -593,7 +578,6 @@ size_t LLURLRequest::upCallback( size_t nmemb, void* user) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLURLRequest* req = (LLURLRequest*)user; S32 bytes = llmin( (S32)(size * nmemb), @@ -691,7 +675,6 @@ LLIOPipe::EStatus LLContextURLExtractor::process_impl( { LLFastTimer t(FTM_PROCESS_URL_EXTRACTOR); PUMP_DEBUG; - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); // The destination host is in the context. if(context.isUndefined() || !mRequest) { @@ -719,13 +702,11 @@ LLIOPipe::EStatus LLContextURLExtractor::process_impl( LLURLRequestComplete::LLURLRequestComplete() : mRequestStatus(LLIOPipe::STATUS_ERROR) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); } // virtual LLURLRequestComplete::~LLURLRequestComplete() { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); } //virtual @@ -764,7 +745,6 @@ void LLURLRequestComplete::noResponse() void LLURLRequestComplete::responseStatus(LLIOPipe::EStatus status) { - LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); mRequestStatus = status; } diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 6a425cfe98..ae95087377 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -80,7 +80,6 @@ #include "v3math.h" #include "v4math.h" #include "lltransfertargetvfile.h" -#include "llmemtype.h" // Constants //const char* MESSAGE_LOG_FILENAME = "message.log"; @@ -793,7 +792,6 @@ S32 LLMessageSystem::getReceiveBytes() const void LLMessageSystem::processAcks() { - LLMemType mt_pa(LLMemType::MTYPE_MESSAGE_PROCESS_ACKS); F64 mt_sec = getMessageTimeSeconds(); { gTransferManager.updateTransfers(); @@ -4020,7 +4018,6 @@ void LLMessageSystem::setTimeDecodesSpamThreshold( F32 seconds ) // TODO: babbage: move gServicePump in to LLMessageSystem? bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump) { - LLMemType mt_cam(LLMemType::MTYPE_MESSAGE_CHECK_ALL); if(checkMessages(frame_count)) { return true; diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 30532247ac..9572378b46 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -27,7 +27,6 @@ #include "linden_common.h" #include "material_codes.h" -#include "llmemtype.h" #include "llerror.h" #include "message.h" #include "llprimitive.h" @@ -188,7 +187,6 @@ void LLPrimitive::clearTextureList() // static LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); LLPrimitive *retval = new LLPrimitive(); if (retval) @@ -206,7 +204,6 @@ LLPrimitive *LLPrimitive::createPrimitive(LLPCode p_code) //=============================================================== void LLPrimitive::init_primitive(LLPCode p_code) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); clearTextureList(); mPrimitiveCode = p_code; } @@ -698,7 +695,6 @@ S32 face_index_from_id(LLFaceID face_ID, const std::vector<LLProfile::Face>& fac BOOL LLPrimitive::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume) { - LLMemType m1(LLMemType::MTYPE_VOLUME); LLVolume *volumep; if (unique_volume) { diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 36e04df7b7..7ef87ed382 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -28,7 +28,6 @@ #include "llprimtexturelist.h" #include "lltextureentry.h" -#include "llmemtype.h" // static //int (TMyClass::*pt2Member)(float, char, char) = NULL; // C++ @@ -367,7 +366,6 @@ S32 LLPrimTextureList::size() const // sets the size of the mEntryList container void LLPrimTextureList::setSize(S32 new_size) { - LLMemType m1(LLMemType::MTYPE_PRIMITIVE); if (new_size < 0) { new_size = 0; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 0b56b3889c..9e4857b6bc 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -44,7 +44,6 @@ #include "llmath.h" #include "m4math.h" #include "llstring.h" -#include "llmemtype.h" #include "llstacktrace.h" #include "llglheaders.h" @@ -2323,7 +2322,6 @@ void LLGLNamePool::release(GLuint name) //static void LLGLNamePool::upkeepPools() { - LLMemType mt(LLMemType::MTYPE_UPKEEP_POOLS); for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter) { LLGLNamePool & pool = *iter; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index fd106ab79b..a2ab95e756 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -31,7 +31,6 @@ #include "llvertexbuffer.h" // #include "llrender.h" #include "llglheaders.h" -#include "llmemtype.h" #include "llrender.h" #include "llvector4a.h" #include "llshadermgr.h" @@ -856,7 +855,6 @@ void LLVertexBuffer::unbind() //static void LLVertexBuffer::cleanupClass() { - LLMemType mt2(LLMemType::MTYPE_VERTEX_CLEANUP_CLASS); unbind(); sStreamIBOPool.cleanup(); @@ -937,8 +935,6 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : mMappable(false), mFence(NULL) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR); - mMappable = (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping); //zero out offsets @@ -998,7 +994,6 @@ S32 LLVertexBuffer::getSize() const //virtual LLVertexBuffer::~LLVertexBuffer() { - LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTRUCTOR); destroyGLBuffer(); destroyGLIndices(); @@ -1118,8 +1113,6 @@ void LLVertexBuffer::releaseIndices() void LLVertexBuffer::createGLBuffer(U32 size) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_VERTICES); - if (mGLBuffer) { destroyGLBuffer(); @@ -1149,8 +1142,6 @@ void LLVertexBuffer::createGLBuffer(U32 size) void LLVertexBuffer::createGLIndices(U32 size) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_INDICES); - if (mGLIndices) { destroyGLIndices(); @@ -1185,7 +1176,6 @@ void LLVertexBuffer::createGLIndices(U32 size) void LLVertexBuffer::destroyGLBuffer() { - LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_BUFFER); if (mGLBuffer) { if (mMappedDataUsingVBOs) @@ -1206,7 +1196,6 @@ void LLVertexBuffer::destroyGLBuffer() void LLVertexBuffer::destroyGLIndices() { - LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_INDICES); if (mGLIndices) { if (mMappedIndexDataUsingVBOs) @@ -1227,8 +1216,6 @@ void LLVertexBuffer::destroyGLIndices() void LLVertexBuffer::updateNumVerts(S32 nverts) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_VERTS); - llassert(nverts >= 0); if (nverts > 65536) @@ -1251,8 +1238,6 @@ void LLVertexBuffer::updateNumVerts(S32 nverts) void LLVertexBuffer::updateNumIndices(S32 nindices) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_INDICES); - llassert(nindices >= 0); U32 needed_size = sizeof(U16) * nindices; @@ -1269,8 +1254,6 @@ void LLVertexBuffer::updateNumIndices(S32 nindices) void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER); - stop_glerror(); if (nverts < 0 || nindices < 0 || @@ -1421,8 +1404,6 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) llassert(newnverts >= 0); llassert(newnindices >= 0); - LLMemType mt2(LLMemType::MTYPE_VERTEX_RESIZE_BUFFER); - updateNumVerts(newnverts); updateNumIndices(newnindices); @@ -1470,7 +1451,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map"); volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) { bindGLBuffer(true); - LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER); if (mFinal) { llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl; @@ -1519,7 +1499,6 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (!mVertexLocked) { - LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES); mVertexLocked = true; sMappedCount++; stop_glerror(); @@ -1650,7 +1629,6 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map"); volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER); bindGLIndices(true); if (mFinal) { @@ -1697,8 +1675,6 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (!mIndexLocked) { - LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES); - mIndexLocked = true; sMappedCount++; stop_glerror(); @@ -1821,7 +1797,6 @@ static LLFastTimer::DeclareTimer FTM_IBO_FLUSH_RANGE("Flush IBO Range"); void LLVertexBuffer::unmapBuffer() { - LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER); if (!useVBOs()) { return; //nothing to unmap @@ -2175,7 +2150,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { flush(); - LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER); //set up pointers if the data mask is different ... bool setup = (sLastMask != data_mask); @@ -2317,7 +2291,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask) // virtual (default) void LLVertexBuffer::setupVertexBuffer(U32 data_mask) { - LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER); stop_glerror(); volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 6f0d90be06..b337b1fc2a 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -58,7 +58,6 @@ #include <dinput.h> #include <Dbt.h.> -#include "llmemtype.h" // culled from winuser.h #ifndef WM_MOUSEWHEEL /* Added to be compatible with later SDK's */ const S32 WM_MOUSEWHEEL = 0x020A; @@ -1767,8 +1766,6 @@ void LLWindowWin32::gatherInput() MSG msg; int msg_count = 0; - LLMemType m1(LLMemType::MTYPE_GATHER_INPUT); - while ((msg_count < MAX_MESSAGE_PER_UPDATE) && PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { mCallbacks->handlePingWatchdog(this, "Main:TranslateGatherInput"); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 0a267cbad0..1d595d3eb1 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -319,7 +319,6 @@ set(viewer_SOURCE_FILES llmarketplacenotifications.cpp llmediactrl.cpp llmediadataclient.cpp - llmemoryview.cpp llmeshrepository.cpp llmimetypes.cpp llmorphview.cpp @@ -877,7 +876,6 @@ set(viewer_HEADER_FILES llmarketplacenotifications.h llmediactrl.h llmediadataclient.h - llmemoryview.h llmeshrepository.h llmimetypes.h llmorphview.h diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 062551a3e8..ba2150e277 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1183,7 +1183,6 @@ static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update"); bool LLAppViewer::mainLoop() { - LLMemType mt1(LLMemType::MTYPE_MAIN); mMainloopTimeout = new LLWatchdogTimeout(); //------------------------------------------- @@ -1283,7 +1282,6 @@ bool LLAppViewer::mainLoop() && (gHeadlessClient || !gViewerWindow->getShowProgress()) && !gFocusMgr.focusLocked()) { - LLMemType mjk(LLMemType::MTYPE_JOY_KEY); joystick->scanJoystick(); gKeyboard->scanKeyboard(); } @@ -1297,7 +1295,6 @@ bool LLAppViewer::mainLoop() if (gAres != NULL && gAres->isInitialized()) { - LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP); pingMainloopTimeout("Main:ServicePump"); LLFastTimer t4(FTM_PUMP); { @@ -1347,7 +1344,6 @@ bool LLAppViewer::mainLoop() // Sleep and run background threads { - LLMemType mt_sleep(LLMemType::MTYPE_SLEEP); LLFastTimer t2(FTM_SLEEP); // yield some time to the os based on command line option @@ -4110,7 +4106,6 @@ static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager"); /////////////////////////////////////////////////////// void LLAppViewer::idle() { - LLMemType mt_idle(LLMemType::MTYPE_IDLE); pingMainloopTimeout("Main:Idle"); // Update frame timers @@ -4705,7 +4700,6 @@ static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit" void LLAppViewer::idleNetwork() { - LLMemType mt_in(LLMemType::MTYPE_IDLE_NETWORK); pingMainloopTimeout("idleNetwork"); gObjectList.mNumNewObjects = 0; diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index bad60a9757..2be090af0a 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -32,7 +32,6 @@ #include "llappviewerwin32.h" -#include "llmemtype.h" #include "llwindowwin32.h" // *FIX: for setting gIconResource. #include "llgl.h" @@ -117,8 +116,6 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, #endif // _DEBUG #endif // INCLUDE_VLD - LLMemType mt1(LLMemType::MTYPE_STARTUP); - const S32 MAX_HEAPS = 255; DWORD heap_enable_lfh_error[MAX_HEAPS]; S32 num_heaps = 0; diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp index 29b1d23d7d..aeecf054b8 100644 --- a/indra/newview/lldebugview.cpp +++ b/indra/newview/lldebugview.cpp @@ -30,7 +30,6 @@ // library includes #include "llfasttimerview.h" -#include "llmemoryview.h" #include "llconsole.h" #include "lltextureview.h" #include "llresmgr.h" @@ -38,7 +37,6 @@ #include "llviewercontrol.h" #include "llviewerwindow.h" #include "llappviewer.h" -#include "llmemoryview.h" #include "llsceneview.h" #include "llviewertexture.h" #include "llfloaterreg.h" @@ -103,13 +101,6 @@ void LLDebugView::init() r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f)); - LLMemoryView::Params mp; - mp.name("memory"); - mp.rect(r); - mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT); - mp.visible(false); - mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp); - addChild(mMemoryView); r.set(150, rect.getHeight() - 50, 820, 100); LLTextureView::Params tvp; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 4eda2b92b3..46ec1abec1 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -256,8 +256,6 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { - LLMemType mt(LLMemType::MTYPE_DRAWABLE); - LLFace *face = new LLFace(this, mVObjp); if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl; @@ -280,8 +278,6 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) { - LLMemType mt(LLMemType::MTYPE_DRAWABLE); - LLFace *face; face = new LLFace(this, mVObjp); @@ -763,8 +759,6 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) void LLDrawable::updateTexture() { - LLMemType mt(LLMemType::MTYPE_DRAWABLE); - if (isDead()) { llwarns << "Dead drawable updating texture!" << llendl; diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index bb0d0d1805..c20040e759 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -38,7 +38,6 @@ #include "llvector4a.h" #include "llquaternion.h" #include "xform.h" -#include "llmemtype.h" #include "lldarray.h" #include "llviewerobject.h" #include "llrect.h" @@ -76,7 +75,6 @@ public: static void initClass(); LLDrawable() { init(); } - MEM_TYPE_NEW(LLMemType::MTYPE_DRAWABLE); void markDead(); // Mark this drawable as dead BOOL isDead() const { return isState(DEAD); } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 4b107ae151..829e326ec9 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -263,8 +263,6 @@ void LLFace::setPool(LLFacePool* pool) void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep) { - LLMemType mt1(LLMemType::MTYPE_DRAWABLE); - if (!new_pool) { llerrs << "Setting pool to null!" << llendl; @@ -429,8 +427,6 @@ U16 LLFace::getGeometryAvatar( LLStrider<F32> &vertex_weights, LLStrider<LLVector4> &clothing_weights) { - LLMemType mt1(LLMemType::MTYPE_DRAWABLE); - if (mVertexBuffer.notNull()) { mVertexBuffer->getVertexStrider (vertices, mGeomIndex, mGeomCount); @@ -446,8 +442,6 @@ U16 LLFace::getGeometryAvatar( U16 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &normals, LLStrider<LLVector2> &tex_coords, LLStrider<U16> &indicesp) { - LLMemType mt1(LLMemType::MTYPE_DRAWABLE); - if (mVertexBuffer.notNull()) { mVertexBuffer->getVertexStrider(vertices, mGeomIndex, mGeomCount); @@ -757,8 +751,6 @@ bool less_than_max_mag(const LLVector4a& vec) BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, const LLMatrix4& mat_vert_in, const LLMatrix3& mat_normal_in, BOOL global_volume) { - LLMemType mt1(LLMemType::MTYPE_DRAWABLE); - //get bounding box if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED)) { diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp index 90f40628a8..39b6e465f3 100644 --- a/indra/newview/llfloaterbulkpermission.cpp +++ b/indra/newview/llfloaterbulkpermission.cpp @@ -336,8 +336,6 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, LLInve void LLFloaterBulkPermission::updateInventory(LLViewerObject* object, LLViewerInventoryItem* item, U8 key, bool is_new) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - // This slices the object into what we're concerned about on the viewer. // The simulator will take the permissions and transfer ownership. LLPointer<LLViewerInventoryItem> task_item = diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index e98d3f88a6..68732024de 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -959,7 +959,6 @@ void LLSaveFolderState::setApply(BOOL apply) void LLSaveFolderState::doFolder(LLFolderViewFolder* folder) { - LLMemType mt(LLMemType::MTYPE_INVENTORY_DO_FOLDER); LLInvFVBridge* bridge = (LLInvFVBridge*)folder->getListener(); if(!bridge) return; diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 05c81957c6..c6df207552 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -191,8 +191,6 @@ void LLInventoryPanel::buildFolderView(const LLInventoryPanel::Params& params) void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) { - LLMemType mt(LLMemType::MTYPE_INVENTORY_POST_BUILD); - mCommitCallbackRegistrar.pushScope(); // registered as a widget; need to push callback scope ourselves buildFolderView(params); diff --git a/indra/newview/llmemoryview.cpp b/indra/newview/llmemoryview.cpp deleted file mode 100644 index c0a323d6cb..0000000000 --- a/indra/newview/llmemoryview.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/** - * @file llmemoryview.cpp - * @brief LLMemoryView class implementation - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llmemoryview.h" - -#include "llappviewer.h" -#include "llallocator_heap_profile.h" -#include "llgl.h" // LLGLSUIDefault -#include "llviewerwindow.h" -#include "llviewercontrol.h" - -#include <sstream> -#include <boost/algorithm/string/split.hpp> - -#include "llmemory.h" - -LLMemoryView::LLMemoryView(const LLMemoryView::Params& p) -: LLView(p), - mPaused(FALSE), - //mDelay(120), - mAlloc(NULL) -{ -} - -LLMemoryView::~LLMemoryView() -{ -} - -BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask) -{ - if (mask & MASK_SHIFT) - { - } - else if (mask & MASK_CONTROL) - { - } - else - { - mPaused = !mPaused; - } - return TRUE; -} - -BOOL LLMemoryView::handleMouseUp(S32 x, S32 y, MASK mask) -{ - return TRUE; -} - - -BOOL LLMemoryView::handleHover(S32 x, S32 y, MASK mask) -{ - return FALSE; -} - -void LLMemoryView::refreshProfile() -{ - /* - LLAllocator & alloc = LLAppViewer::instance()->getAllocator(); - if(alloc.isProfiling()) { - std::string profile_text = alloc.getRawProfile(); - - boost::algorithm::split(mLines, profile_text, boost::bind(std::equal_to<llwchar>(), '\n', _1)); - } else { - mLines.clear(); - } - */ - if (mAlloc == NULL) { - mAlloc = &LLAppViewer::instance()->getAllocator(); - } - - mLines.clear(); - - if(mAlloc->isProfiling()) - { - const LLAllocatorHeapProfile &prof = mAlloc->getProfile(); - for(size_t i = 0; i < prof.mLines.size(); ++i) - { - std::stringstream ss; - ss << "Unfreed Mem: " << (prof.mLines[i].mLiveSize >> 20) << " M Trace: "; - for(size_t k = 0; k < prof.mLines[i].mTrace.size(); ++k) - { - ss << LLMemType::getNameFromID(prof.mLines[i].mTrace[k]) << " "; - } - mLines.push_back(utf8string_to_wstring(ss.str())); - } - } -} - -void LLMemoryView::draw() -{ - const S32 UPDATE_INTERVAL = 60; - const S32 MARGIN_AMT = 10; - static S32 curUpdate = UPDATE_INTERVAL; - static LLUIColor s_console_color = LLUIColorTable::instance().getColor("ConsoleBackground", LLColor4U::black); - - // setup update interval - if (curUpdate >= UPDATE_INTERVAL) - { - refreshProfile(); - curUpdate = 0; - } - curUpdate++; - - // setup window properly - S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f); - S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.9f); - setRect(LLRect().setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height)); - - // setup window color - F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f); - LLColor4 color = s_console_color; - color.mV[VALPHA] *= console_opacity; - - LLGLSUIDefault gls_ui; - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d(0, height, width, 0, color); - - LLFontGL * font = LLFontGL::getFontSansSerifSmall(); - - // draw remaining lines - F32 y_pos = 0.f; - F32 y_off = 0.f; - - F32 line_height = font->getLineHeight(); - S32 target_width = width - 2 * MARGIN_AMT; - - // cut off lines on bottom - U32 max_lines = U32((height - 2 * line_height) / line_height); - y_pos = height - MARGIN_AMT - line_height; - y_off = 0.f; - -#if !MEM_TRACK_MEM - std::vector<LLWString>::const_iterator end = mLines.end(); - if(mLines.size() > max_lines) { - end = mLines.begin() + max_lines; - } - for (std::vector<LLWString>::const_iterator i = mLines.begin(); i != end; ++i) - { - font->render(*i, 0, MARGIN_AMT, y_pos - y_off, - LLColor4::white, - LLFontGL::LEFT, - LLFontGL::BASELINE, - LLFontGL::NORMAL, - LLFontGL::DROP_SHADOW, - S32_MAX, - target_width - ); - y_off += line_height; - } - -#else - LLMemTracker::getInstance()->preDraw(mPaused) ; - - { - F32 x_pos = MARGIN_AMT ; - U32 lines = 0 ; - const char* str = LLMemTracker::getInstance()->getNextLine() ; - while(str != NULL) - { - lines++ ; - font->renderUTF8(str, 0, x_pos, y_pos - y_off, - LLColor4::white, - LLFontGL::LEFT, - LLFontGL::BASELINE, - LLFontGL::NORMAL, - LLFontGL::DROP_SHADOW, - S32_MAX, - target_width, - NULL, FALSE); - - str = LLMemTracker::getInstance()->getNextLine() ; - y_off += line_height; - - if(lines >= max_lines) - { - lines = 0 ; - x_pos += 512.f ; - if(x_pos + 512.f > target_width) - { - break ; - } - - y_pos = height - MARGIN_AMT - line_height; - y_off = 0.f; - } - } - } - - LLMemTracker::getInstance()->postDraw() ; -#endif - -#if MEM_TRACK_TYPE - - S32 left, top, right, bottom; - S32 x, y; - - S32 margin = 10; - S32 texth = LLFontGL::getFontMonospace()->getLineHeight(); - - S32 xleft = margin; - S32 ytop = height - margin; - S32 labelwidth = 0; - S32 maxmaxbytes = 1; - - // Make sure all timers are accounted for - // Set 'MT_OTHER' to unaccounted ticks last frame - { - S32 display_memtypes[LLMemType::MTYPE_NUM_TYPES]; - for (S32 i=0; i < LLMemType::MTYPE_NUM_TYPES; i++) - { - display_memtypes[i] = 0; - } - for (S32 i=0; i < MTV_DISPLAY_NUM; i++) - { - S32 tidx = mtv_display_table[i].memtype; - display_memtypes[tidx]++; - } - LLMemType::sMemCount[LLMemType::MTYPE_OTHER] = 0; - LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] = 0; - for (S32 tidx = 0; tidx < LLMemType::MTYPE_NUM_TYPES; tidx++) - { - if (display_memtypes[tidx] == 0) - { - LLMemType::sMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMemCount[tidx]; - LLMemType::sMaxMemCount[LLMemType::MTYPE_OTHER] += LLMemType::sMaxMemCount[tidx]; - } - } - } - - // Labels - { - y = ytop; - S32 peak = 0; - for (S32 i=0; i<MTV_DISPLAY_NUM; i++) - { - x = xleft; - - int tidx = mtv_display_table[i].memtype; - S32 bytes = LLMemType::sMemCount[tidx]; - S32 maxbytes = LLMemType::sMaxMemCount[tidx]; - maxmaxbytes = llmax(maxbytes, maxmaxbytes); - peak += maxbytes; - S32 mbytes = bytes >> 20; - - tdesc = llformat("%s [%4d MB] in %06d NEWS",mtv_display_table[i].desc,mbytes, LLMemType::sNewCount[tidx]); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - - y -= (texth + 2); - - S32 textw = LLFontGL::getFontMonospace()->getWidth(tdesc); - if (textw > labelwidth) - labelwidth = textw; - } - - S32 num_avatars = 0; - S32 num_motions = 0; - S32 num_loading_motions = 0; - S32 num_loaded_motions = 0; - S32 num_active_motions = 0; - S32 num_deprecated_motions = 0; - for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) - { - num_avatars++; - (*iter)->getMotionController().incMotionCounts(num_motions, num_loading_motions, num_loaded_motions, num_active_motions, num_deprecated_motions); - } - - x = xleft; - tdesc = llformat("Total Bytes: %d MB Overhead: %d KB Avs %d Motions:%d Loading:%d Loaded:%d Active:%d Dep:%d", - LLMemType::sTotalMem >> 20, LLMemType::sOverheadMem >> 10, - num_avatars, num_motions, num_loading_motions, num_loaded_motions, num_active_motions, num_deprecated_motions); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - } - - // Bars - y = ytop; - labelwidth += 8; - S32 barw = width - labelwidth - xleft - margin; - for (S32 i=0; i<MTV_DISPLAY_NUM; i++) - { - x = xleft + labelwidth; - - int tidx = mtv_display_table[i].memtype; - S32 bytes = LLMemType::sMemCount[tidx]; - F32 frac = (F32)bytes / (F32)maxmaxbytes; - S32 w = (S32)(frac * (F32)barw); - left = x; right = x + w; - top = y; bottom = y - texth; - gl_rect_2d(left, top, right, bottom, *mtv_display_table[i].color); - - S32 maxbytes = LLMemType::sMaxMemCount[tidx]; - F32 frac2 = (F32)maxbytes / (F32)maxmaxbytes; - S32 w2 = (S32)(frac2 * (F32)barw); - left = x + w + 1; right = x + w2; - top = y; bottom = y - texth; - LLColor4 tcolor = *mtv_display_table[i].color; - tcolor.setAlpha(.5f); - gl_rect_2d(left, top, right, bottom, tcolor); - - y -= (texth + 2); - } - - dumpData(); - -#endif - - LLView::draw(); -} diff --git a/indra/newview/llmemoryview.h b/indra/newview/llmemoryview.h deleted file mode 100644 index dc4849a9c4..0000000000 --- a/indra/newview/llmemoryview.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file llmemoryview.h - * @brief LLMemoryView class definition - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLMEMORYVIEW_H -#define LL_LLMEMORYVIEW_H - -#include "llview.h" - -class LLAllocator; - -class LLMemoryView : public LLView -{ -public: - struct Params : public LLInitParam::Block<Params, LLView::Params> - { - Params() - { - changeDefault(mouse_opaque, true); - changeDefault(visible, false); - } - }; - LLMemoryView(const LLMemoryView::Params&); - virtual ~LLMemoryView(); - - virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); - virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual void draw(); - - void refreshProfile(); - -private: - std::vector<LLWString> mLines; - LLAllocator* mAlloc; - BOOL mPaused ; - -}; - -#endif diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 9f3273da2d..28cfb5b282 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -105,7 +105,6 @@ LLPanelMainInventory::LLPanelMainInventory(const LLPanel::Params& p) mMenuAdd(NULL), mNeedUploadCost(true) { - LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_INIT); // Menu Callbacks (non contex menus) mCommitCallbackRegistrar.add("Inventory.DoToSelected", boost::bind(&LLPanelMainInventory::doToSelected, this, _2)); mCommitCallbackRegistrar.add("Inventory.CloseAllFolders", boost::bind(&LLPanelMainInventory::closeAllFolders, this)); @@ -604,7 +603,6 @@ void LLPanelMainInventory::setFilterTextFromFilter() void LLPanelMainInventory::toggleFindOptions() { - LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE); LLFloater *floater = getFinder(); if (!floater) { @@ -726,7 +724,6 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() void LLFloaterInventoryFinder::draw() { - LLMemType mt(LLMemType::MTYPE_INVENTORY_DRAW); U64 filter = 0xffffffffffffffffULL; BOOL filtered_by_all_types = TRUE; diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp index 3baa1eccc8..82879cf657 100644 --- a/indra/newview/llpolymesh.cpp +++ b/indra/newview/llpolymesh.cpp @@ -749,8 +749,6 @@ const LLVector2 &LLPolyMeshSharedData::getUVs(U32 index) //----------------------------------------------------------------------------- LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_mesh) { - LLMemType mt(LLMemType::MTYPE_AVATAR_MESH); - llassert(shared_data); mSharedData = shared_data; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index d70b04361f..ab60acdcc9 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -376,7 +376,6 @@ LLSpatialGroup::~LLSpatialGroup() } } - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); clearDrawMap(); clearAtlasList() ; } @@ -614,8 +613,6 @@ void LLSpatialGroup::validateDrawMap() BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - drawablep->updateSpatialExtents(); OctreeNode* parent = mOctreeNode->getOctParent(); @@ -637,7 +634,6 @@ BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate) BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_octree) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); if (!from_octree) { mOctreeNode->insert(drawablep); @@ -663,7 +659,6 @@ BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_oc void LLSpatialGroup::rebuildGeom() { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); if (!isDead()) { mSpatialPartition->rebuildGeom(this); @@ -875,7 +870,6 @@ LLSpatialGroup* LLSpatialGroup::getParent() BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); unbound(); if (mOctreeNode && !from_octree) { @@ -912,7 +906,6 @@ BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) void LLSpatialGroup::shift(const LLVector4a &offset) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); LLVector4a t = mOctreeNode->getCenter(); t.add(offset); mOctreeNode->setCenter(t); @@ -967,8 +960,6 @@ void LLSpatialGroup::setState(U32 state) void LLSpatialGroup::setState(U32 state, S32 mode) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - llassert(state <= LLSpatialGroup::STATE_MASK); if (mode > STATE_MODE_SINGLE) @@ -1025,8 +1016,6 @@ void LLSpatialGroup::clearState(U32 state, S32 mode) { llassert(state <= LLSpatialGroup::STATE_MASK); - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - if (mode > STATE_MODE_SINGLE) { if (mode == STATE_MODE_DIFF) @@ -1083,8 +1072,6 @@ public: void LLSpatialGroup::setOcclusionState(U32 state, S32 mode) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - if (mode > STATE_MODE_SINGLE) { if (mode == STATE_MODE_DIFF) @@ -1149,8 +1136,6 @@ public: void LLSpatialGroup::clearOcclusionState(U32 state, S32 mode) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - if (mode > STATE_MODE_SINGLE) { if (mode == STATE_MODE_DIFF) @@ -1200,7 +1185,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : mCurUpdatingTexture (NULL) { sNodeCount++; - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); mViewAngle.splat(0.f); mLastUpdateViewAngle.splat(-1.f); @@ -1386,7 +1370,6 @@ BOOL LLSpatialGroup::changeLOD() void LLSpatialGroup::handleInsertion(const TreeNode* node, LLDrawable* drawablep) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); addObject(drawablep, FALSE, TRUE); unbound(); setState(OBJECT_DIRTY); @@ -1394,14 +1377,12 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLDrawable* drawablep void LLSpatialGroup::handleRemoval(const TreeNode* node, LLDrawable* drawable) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); removeObject(drawable, TRUE); setState(OBJECT_DIRTY); } void LLSpatialGroup::handleDestruction(const TreeNode* node) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); setState(DEAD); for (element_iter i = getDataBegin(); i != getDataEnd(); ++i) @@ -1443,7 +1424,6 @@ void LLSpatialGroup::handleStateChange(const TreeNode* node) void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); if (child->getListenerCount() == 0) { new LLSpatialGroup(child, mSpatialPartition); @@ -1789,7 +1769,6 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera) LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage) : mRenderByGroup(render_by_group), mBridge(NULL) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); mOcclusionEnabled = TRUE; mDrawableType = 0; mPartitionType = LLViewerRegion::PARTITION_NONE; @@ -1813,8 +1792,6 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 LLSpatialPartition::~LLSpatialPartition() { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - delete mOctree; mOctree = NULL; } @@ -1822,8 +1799,6 @@ LLSpatialPartition::~LLSpatialPartition() LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - drawablep->updateSpatialExtents(); //keep drawable from being garbage collected @@ -1845,8 +1820,6 @@ LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible) BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - if (!curp->removeObject(drawablep)) { OCT_ERRS << "Failed to remove drawable from octree!" << llendl; @@ -1863,8 +1836,6 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp) void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - // sanity check submitted by open source user bushing Spatula // who was seeing crashing here. (See VWR-424 reported by Bunny Mayne) if (!drawablep) @@ -1921,7 +1892,6 @@ public: void LLSpatialPartition::shift(const LLVector4a &offset) { //shift octree node bounding boxes by offset - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); LLSpatialShift shifter(offset); shifter.traverse(mOctree); } @@ -2335,7 +2305,6 @@ public: void LLSpatialPartition::restoreGL() { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); } void LLSpatialPartition::resetVertexBuffers() @@ -2378,7 +2347,6 @@ BOOL LLSpatialPartition::visibleObjectsInFrustum(LLCamera& camera) S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); #if LL_OCTREE_PARANOIA_CHECK ((LLSpatialGroup*)mOctree->getListener(0))->checkStates(); #endif @@ -4436,8 +4404,6 @@ void LLSpatialPartition::renderDebug() sCurMaxTexPriority = 0.f; } - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); - LLGLDisable cullface(GL_CULL_FACE); LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6b0fc26db7..9efb4e6eec 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -311,8 +311,6 @@ void update_texture_fetch() // true when all initialization done. bool idle_startup() { - LLMemType mt1(LLMemType::MTYPE_STARTUP); - const F32 PRECACHING_DELAY = gSavedSettings.getF32("PrecachingDelay"); static LLTimer timeout; static S32 timeout_count = 0; diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 230e871b49..84fa53bb37 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -634,7 +634,6 @@ void LLSurface::updatePatchVisibilities(LLAgent &agent) BOOL LLSurface::idleUpdate(F32 max_update_time) { - LLMemType mt_ius(LLMemType::MTYPE_IDLE_UPDATE_SURFACE); if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_TERRAIN)) { return FALSE; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 0ad2a6eb9b..09d2a54470 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -168,7 +168,6 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Update Camera"); void display_update_camera() { LLFastTimer t(FTM_UPDATE_CAMERA); - LLMemType mt_uc(LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA); // TODO: cut draw distance down if customizing avatar? // TODO: cut draw distance on per-parcel basis? @@ -230,7 +229,6 @@ static LLFastTimer::DeclareTimer FTM_TELEPORT_DISPLAY("Teleport Display"); // Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { - LLMemType mt_render(LLMemType::MTYPE_RENDER); LLFastTimer t(FTM_RENDER); if (gWindowResized) @@ -571,7 +569,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (!gDisconnected) { - LLMemType mt_du(LLMemType::MTYPE_DISPLAY_UPDATE); LLAppViewer::instance()->pingMainloopTimeout("Display:Update"); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { //don't draw hud objects in this frame @@ -593,7 +590,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) // *TODO: merge these two methods { LLFastTimer t(FTM_HUD_UPDATE); - LLMemType mt_uh(LLMemType::MTYPE_DISPLAY_UPDATE_HUD); LLHUDManager::getInstance()->updateEffects(); LLHUDObject::updateAll(); stop_glerror(); @@ -601,7 +597,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM); - LLMemType mt_ug(LLMemType::MTYPE_DISPLAY_UPDATE_GEOM); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); @@ -662,8 +657,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); { - LLMemType mt_ds(LLMemType::MTYPE_DISPLAY_SWAP); - if (gResizeScreenTexture) { gResizeScreenTexture = FALSE; @@ -722,7 +715,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) //if (!for_snapshot) { - LLMemType mt_gw(LLMemType::MTYPE_DISPLAY_GEN_REFLECTION); LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); gPipeline.generateHighlight(*LLViewerCamera::getInstance()); @@ -742,7 +734,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); { - LLMemType mt_iu(LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE); LLFastTimer t(FTM_IMAGE_UPDATE); { @@ -786,7 +777,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort"); { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - LLMemType mt_ss(LLMemType::MTYPE_DISPLAY_STATE_SORT); gPipeline.stateSort(*LLViewerCamera::getInstance(), result); stop_glerror(); @@ -808,7 +798,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLPipeline::sUseOcclusion = occlusion; { - LLMemType mt_ds(LLMemType::MTYPE_DISPLAY_SKY); LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LLFastTimer t(FTM_UPDATE_SKY); gSky.updateSky(); @@ -897,7 +886,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) && !gRestoreGL) { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - LLMemType mt_rg(LLMemType::MTYPE_DISPLAY_RENDER_GEOM); if (gSavedSettings.getBOOL("RenderDepthPrePass") && LLGLSLShader::sNoFixedFunction) { @@ -958,7 +946,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (to_texture) { - LLMemType mt_rf(LLMemType::MTYPE_DISPLAY_RENDER_FLUSH); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.mDeferredScreen.flush(); @@ -1025,7 +1012,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) void render_hud_attachments() { - LLMemType mt_ra(LLMemType::MTYPE_DISPLAY_RENDER_ATTACHMENTS); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.matrixMode(LLRender::MM_MODELVIEW); @@ -1215,7 +1201,6 @@ static LLFastTimer::DeclareTimer FTM_SWAP("Swap"); void render_ui(F32 zoom_factor, int subfield) { - LLMemType mt_ru(LLMemType::MTYPE_DISPLAY_RENDER_UI); LLGLState::checkStates(); glh::matrix4f saved_view = glh_get_current_modelview(); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d790fbc31d..76e18b1812 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4228,7 +4228,6 @@ extern U32 gObjectBits; void process_object_update(LLMessageSystem *mesgsys, void **user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); // Update the data counters if (mesgsys->getReceiveCompressedSize()) { @@ -4245,7 +4244,6 @@ void process_object_update(LLMessageSystem *mesgsys, void **user_data) void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); // Update the data counters if (mesgsys->getReceiveCompressedSize()) { @@ -4262,7 +4260,6 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); // Update the data counters if (mesgsys->getReceiveCompressedSize()) { @@ -4280,7 +4277,6 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data) void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); if (mesgsys->getReceiveCompressedSize()) { gObjectBits += mesgsys->getReceiveCompressedSize() * 8; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index b52c9d0d4b..ebe84482dd 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -873,7 +873,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, const EObjectUpdateType update_type, LLDataPacker *dp) { - LLMemType mt(LLMemType::MTYPE_OBJECT); U32 retval = 0x0; // If region is removed from the list it is also deleted. @@ -2332,8 +2331,6 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) BOOL LLViewerObject::setData(const U8 *datap, const U32 data_size) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - delete [] mData; if (datap) @@ -2375,8 +2372,6 @@ void LLViewerObject::doUpdateInventory( U8 key, bool is_new) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - LLViewerInventoryItem* old_item = NULL; if(TASK_INVENTORY_ITEM_KEY == key) { @@ -2460,8 +2455,6 @@ void LLViewerObject::saveScript( BOOL active, bool is_new) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - /* * XXXPAM Investigate not making this copy. Seems unecessary, but I'm unsure about the * interaction with doUpdateInventory() called below. @@ -2537,8 +2530,6 @@ void LLViewerObject::dirtyInventory() void LLViewerObject::registerInventoryListener(LLVOInventoryListener* listener, void* user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - LLInventoryCallbackInfo* info = new LLInventoryCallbackInfo; info->mListener = listener; info->mInventoryData = user_data; @@ -2636,8 +2627,6 @@ S32 LLFilenameAndTask::sCount = 0; // static void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - LLUUID task_id; msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_TaskID, task_id); LLViewerObject* object = gObjectList.findObject(task_id); @@ -2724,8 +2713,6 @@ void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code, LLExtS void LLViewerObject::loadTaskInvFile(const std::string& filename) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - std::string filename_and_local_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, filename); llifstream ifs(filename_and_local_path); if(ifs.good()) @@ -2822,8 +2809,6 @@ void LLViewerObject::updateInventory( U8 key, bool is_new) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - std::list<LLUUID>::iterator begin = mPendingInventoryItemsIDs.begin(); std::list<LLUUID>::iterator end = mPendingInventoryItemsIDs.end(); @@ -3847,8 +3832,6 @@ std::string LLViewerObject::getMediaURL() const void LLViewerObject::setMediaURL(const std::string& media_url) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - if (!mMedia) { mMedia = new LLViewerObjectMedia; @@ -3898,8 +3881,6 @@ BOOL LLViewerObject::setMaterial(const U8 material) void LLViewerObject::setNumTEs(const U8 num_tes) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - U32 i; if (num_tes != getNumTEs()) { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 19ea06ed20..e649c89c15 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -34,7 +34,6 @@ #include "llhudicon.h" #include "llinventory.h" #include "llrefcount.h" -#include "llmemtype.h" #include "llprimitive.h" #include "lluuid.h" #include "llvoinventorylistener.h" @@ -128,7 +127,6 @@ public: typedef const child_list_t const_child_list_t; LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp, BOOL is_global = FALSE); - MEM_TYPE_NEW(LLMemType::MTYPE_OBJECT); virtual void markDead(); // Mark this object as dead, and clean up its references BOOL isDead() const {return mDead;} diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 37a9675278..3f3df0824a 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -230,7 +230,6 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp, LLDataPacker* dpp, BOOL just_created) { - LLMemType mt(LLMemType::MTYPE_OBJECT_PROCESS_UPDATE_CORE); LLMessageSystem* msg = gMessageSystem; // ignore returned flags @@ -283,7 +282,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, const EObjectUpdateType update_type, bool cached, bool compressed) { - LLMemType mt(LLMemType::MTYPE_OBJECT_PROCESS_UPDATE); LLFastTimer t(FTM_PROCESS_OBJECTS); LLVector3d camera_global = gAgentCamera.getCameraPositionGlobal(); @@ -883,8 +881,6 @@ private: void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { - LLMemType mt(LLMemType::MTYPE_OBJECT); - // Update globals LLViewerObject::setVelocityInterpolate( gSavedSettings.getBOOL("VelocityInterpolate") ); LLViewerObject::setPingInterpolate( gSavedSettings.getBOOL("PingInterpolate") ); @@ -1196,7 +1192,6 @@ void LLViewerObjectList::clearDebugText() void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) { - LLMemType mt(LLMemType::MTYPE_OBJECT); if (mDeadObjects.find(objectp->mID) != mDeadObjects.end()) { llinfos << "Object " << objectp->mID << " already on dead list!" << llendl; @@ -1424,7 +1419,6 @@ void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp) void LLViewerObjectList::updateActive(LLViewerObject *objectp) { - LLMemType mt(LLMemType::MTYPE_OBJECT); if (objectp->isDead()) { return; // We don't update dead objects! @@ -1903,7 +1897,6 @@ void LLViewerObjectList::resetObjectBeacons() LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp) { - LLMemType mt(LLMemType::MTYPE_OBJECT); LLUUID fullid; fullid.generate(); @@ -1929,7 +1922,6 @@ static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object"); LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRegion *regionp, const LLUUID &uuid, const U32 local_id, const LLHost &sender) { - LLMemType mt(LLMemType::MTYPE_OBJECT); LLFastTimer t(FTM_CREATE_OBJECT); LLUUID fullid; @@ -1994,7 +1986,6 @@ S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port) { - LLMemType mt(LLMemType::MTYPE_OBJECT); #ifdef ORPHAN_SPAM llinfos << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl; #endif diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index a0cf2fc803..a1c12c5cd6 100644 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -828,7 +828,6 @@ void LLViewerParcelOverlay::updateGL() void LLViewerParcelOverlay::idleUpdate(bool force_update) { - LLMemType mt_iup(LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY); if (gGLManager.mIsDisabled) { return; diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 345023dbfa..6bd9f66b9c 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -79,7 +79,6 @@ LLViewerPart::LLViewerPart() : mVPCallback(NULL), mImagep(NULL) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mPartSourcep = NULL; ++LLViewerPartSim::sParticleCount2 ; @@ -87,7 +86,6 @@ LLViewerPart::LLViewerPart() : LLViewerPart::~LLViewerPart() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mPartSourcep = NULL; --LLViewerPartSim::sParticleCount2 ; @@ -95,7 +93,6 @@ LLViewerPart::~LLViewerPart() void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerTexture *imagep, LLVPCallback cb) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mPartID = LLViewerPart::sNextPartID; LLViewerPart::sNextPartID++; mFlags = 0x00f; @@ -120,7 +117,6 @@ void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerTexture * LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 box_side, bool hud) : mHud(hud) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mVOPartGroupp = NULL; mUniformParticles = TRUE; @@ -177,7 +173,6 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 ¢er_agent, const F32 bo LLViewerPartGroup::~LLViewerPartGroup() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); cleanup(); S32 count = (S32) mParticles.size(); @@ -192,7 +187,6 @@ LLViewerPartGroup::~LLViewerPartGroup() void LLViewerPartGroup::cleanup() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (mVOPartGroupp) { if (!mVOPartGroupp->isDead()) @@ -205,7 +199,6 @@ void LLViewerPartGroup::cleanup() BOOL LLViewerPartGroup::posInGroup(const LLVector3 &pos, const F32 desired_size) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if ((pos.mV[VX] < mMinObjPos.mV[VX]) || (pos.mV[VY] < mMinObjPos.mV[VY]) || (pos.mV[VZ] < mMinObjPos.mV[VZ])) @@ -233,8 +226,6 @@ BOOL LLViewerPartGroup::posInGroup(const LLVector3 &pos, const F32 desired_size) BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); - if (part->mFlags & LLPartData::LL_PART_HUD && !mHud) { return FALSE; @@ -261,7 +252,6 @@ BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) void LLViewerPartGroup::updateParticles(const F32 lastdt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 dt; LLVector3 gravity(0.f, 0.f, GRAVITY); @@ -429,7 +419,6 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) void LLViewerPartGroup::shift(const LLVector3 &offset) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mCenterAgent += offset; mMinObjPos += offset; mMaxObjPos += offset; @@ -442,8 +431,6 @@ void LLViewerPartGroup::shift(const LLVector3 &offset) void LLViewerPartGroup::removeParticlesByID(const U32 source_id) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); - for (S32 i = 0; i < (S32)mParticles.size(); i++) { if(mParticles[i]->mPartSourcep->getID() == source_id) @@ -475,7 +462,6 @@ void LLViewerPartSim::checkParticleCount(U32 size) LLViewerPartSim::LLViewerPartSim() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); sMaxParticleCount = llmin(gSavedSettings.getS32("RenderMaxPartCount"), LL_MAX_PARTICLE_COUNT); static U32 id_seed = 0; mID = ++id_seed; @@ -484,7 +470,6 @@ LLViewerPartSim::LLViewerPartSim() void LLViewerPartSim::destroyClass() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); S32 i; S32 count; @@ -500,9 +485,9 @@ void LLViewerPartSim::destroyClass() mViewerPartSources.clear(); } +//static BOOL LLViewerPartSim::shouldAddPart() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (sParticleCount > PART_THROTTLE_THRESHOLD*sMaxParticleCount) { @@ -525,7 +510,6 @@ BOOL LLViewerPartSim::shouldAddPart() void LLViewerPartSim::addPart(LLViewerPart* part) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (sParticleCount < MAX_PART_COUNT) { put(part); @@ -541,7 +525,6 @@ void LLViewerPartSim::addPart(LLViewerPart* part) LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); const F32 MAX_MAG = 1000000.f*1000000.f; // 1 million LLViewerPartGroup *return_group = NULL ; if (part->mPosAgent.magVecSquared() > MAX_MAG || !part->mPosAgent.isFinite()) @@ -599,7 +582,6 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part) LLViewerPartGroup *LLViewerPartSim::createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size, bool hud) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); //find a box that has a center position divisible by PART_SIM_BOX_SIDE that encompasses //pos_agent LLViewerPartGroup *groupp = new LLViewerPartGroup(pos_agent, desired_size, hud); @@ -632,8 +614,6 @@ static LLFastTimer::DeclareTimer FTM_SIMULATE_PARTICLES("Simulate Particles"); void LLViewerPartSim::updateSimulation() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); - static LLFrameTimer update_timer; const F32 dt = llmin(update_timer.getElapsedTimeAndResetF32(), 0.1f); @@ -800,7 +780,6 @@ void LLViewerPartSim::updatePartBurstRate() void LLViewerPartSim::addPartSource(LLPointer<LLViewerPartSource> sourcep) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!sourcep) { llwarns << "Null part source!" << llendl; @@ -817,7 +796,6 @@ void LLViewerPartSim::removeLastCreatedSource() void LLViewerPartSim::cleanupRegion(LLViewerRegion *regionp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); for (group_list_t::iterator i = mViewerPartGroups.begin(); i != mViewerPartGroups.end(); ) { group_list_t::iterator iter = i++; @@ -832,7 +810,6 @@ void LLViewerPartSim::cleanupRegion(LLViewerRegion *regionp) void LLViewerPartSim::clearParticlesByID(const U32 system_id) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); for (group_list_t::iterator g = mViewerPartGroups.begin(); g != mViewerPartGroups.end(); ++g) { (*g)->removeParticlesByID(system_id); @@ -850,7 +827,6 @@ void LLViewerPartSim::clearParticlesByID(const U32 system_id) void LLViewerPartSim::clearParticlesByOwnerID(const LLUUID& task_id) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); for (source_list_t::iterator iter = mViewerPartSources.begin(); iter != mViewerPartSources.end(); ++iter) { if ((*iter)->getOwnerUUID() == task_id) diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h index c9959c63ec..c91fcf0691 100644 --- a/indra/newview/llviewerpartsim.h +++ b/indra/newview/llviewerpartsim.h @@ -142,7 +142,7 @@ public: void cleanupRegion(LLViewerRegion *regionp); - BOOL shouldAddPart(); // Just decides whether this particle should be added or not (for particle count capping) + static BOOL shouldAddPart(); // Just decides whether this particle should be added or not (for particle count capping) F32 maxRate() // Return maximum particle generation rate { if (sParticleCount >= MAX_PART_COUNT) diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index 4af92e79ff..b311f659fb 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -90,7 +90,6 @@ void LLViewerPartSource::setStart() LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) : LLViewerPartSource(LL_PART_SOURCE_SCRIPT) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); llassert(source_objp); mSourceObjectp = source_objp; mPosAgent = mSourceObjectp->getPositionAgent(); @@ -102,7 +101,6 @@ LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) void LLViewerPartSourceScript::setDead() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mIsDead = TRUE; mSourceObjectp = NULL; mTargetObjectp = NULL; @@ -113,7 +111,6 @@ void LLViewerPartSourceScript::update(const F32 dt) if( mIsSuspended ) return; - LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 old_update_time = mLastUpdateTime; mLastUpdateTime += dt; @@ -394,7 +391,6 @@ void LLViewerPartSourceScript::update(const F32 dt) // static LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, const S32 block_num) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!pssp) { if (LLPartSysData::isNullPS(block_num)) @@ -436,7 +432,6 @@ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewer LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewerObject *source_objp, LLPointer<LLViewerPartSourceScript> pssp, LLDataPacker &dp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!pssp) { LLPointer<LLViewerPartSourceScript> new_pssp = new LLViewerPartSourceScript(source_objp); @@ -470,8 +465,6 @@ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewer /* static */ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::createPSS(LLViewerObject *source_objp, const LLPartSysData& particle_parameters) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); - LLPointer<LLViewerPartSourceScript> new_pssp = new LLViewerPartSourceScript(source_objp); new_pssp->mPartSysData = particle_parameters; @@ -487,13 +480,11 @@ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::createPSS(LLViewer void LLViewerPartSourceScript::setImage(LLViewerTexture *imagep) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mImagep = imagep; } void LLViewerPartSourceScript::setTargetObject(LLViewerObject *objp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mTargetObjectp = objp; } @@ -509,7 +500,6 @@ LLViewerPartSourceSpiral::LLViewerPartSourceSpiral(const LLVector3 &pos) : void LLViewerPartSourceSpiral::setDead() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mIsDead = TRUE; mSourceObjectp = NULL; } @@ -517,7 +507,6 @@ void LLViewerPartSourceSpiral::setDead() void LLViewerPartSourceSpiral::updatePart(LLViewerPart &part, const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 frac = part.mLastUpdateTime/part.mMaxAge; LLVector3 center_pos; @@ -542,7 +531,6 @@ void LLViewerPartSourceSpiral::updatePart(LLViewerPart &part, const F32 dt) void LLViewerPartSourceSpiral::update(const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); @@ -588,7 +576,6 @@ void LLViewerPartSourceSpiral::update(const F32 dt) void LLViewerPartSourceSpiral::setSourceObject(LLViewerObject *objp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mSourceObjectp = objp; } @@ -612,7 +599,6 @@ LLViewerPartSourceBeam::~LLViewerPartSourceBeam() void LLViewerPartSourceBeam::setDead() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mIsDead = TRUE; mSourceObjectp = NULL; mTargetObjectp = NULL; @@ -626,7 +612,6 @@ void LLViewerPartSourceBeam::setColor(const LLColor4 &color) void LLViewerPartSourceBeam::updatePart(LLViewerPart &part, const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 frac = part.mLastUpdateTime/part.mMaxAge; LLViewerPartSource *ps = (LLViewerPartSource*)part.mPartSourcep; @@ -671,7 +656,6 @@ void LLViewerPartSourceBeam::updatePart(LLViewerPart &part, const F32 dt) void LLViewerPartSourceBeam::update(const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); const F32 RATE = 0.025f; mLastUpdateTime += dt; @@ -743,13 +727,11 @@ void LLViewerPartSourceBeam::update(const F32 dt) void LLViewerPartSourceBeam::setSourceObject(LLViewerObject* objp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mSourceObjectp = objp; } void LLViewerPartSourceBeam::setTargetObject(LLViewerObject* objp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mTargetObjectp = objp; } @@ -764,7 +746,6 @@ LLViewerPartSourceChat::LLViewerPartSourceChat(const LLVector3 &pos) : void LLViewerPartSourceChat::setDead() { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mIsDead = TRUE; mSourceObjectp = NULL; } @@ -772,7 +753,6 @@ void LLViewerPartSourceChat::setDead() void LLViewerPartSourceChat::updatePart(LLViewerPart &part, const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 frac = part.mLastUpdateTime/part.mMaxAge; LLVector3 center_pos; @@ -797,7 +777,6 @@ void LLViewerPartSourceChat::updatePart(LLViewerPart &part, const F32 dt) void LLViewerPartSourceChat::update(const F32 dt) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); @@ -853,7 +832,6 @@ void LLViewerPartSourceChat::update(const F32 dt) void LLViewerPartSourceChat::setSourceObject(LLViewerObject *objp) { - LLMemType mt(LLMemType::MTYPE_PARTICLES); mSourceObjectp = objp; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e4108e2cd1..17ea58a3b7 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -695,7 +695,6 @@ void LLViewerRegion::dirtyHeights() BOOL LLViewerRegion::idleUpdate(F32 max_update_time) { - LLMemType mt_ivr(LLMemType::MTYPE_IDLE_UPDATE_VIEWER_REGION); // did_update returns TRUE if we did at least one significant update BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index e1eb54bd24..6562ae6e82 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -39,7 +39,6 @@ #include "llimagebmp.h" #include "llimagej2c.h" #include "llimagetga.h" -#include "llmemtype.h" #include "llstl.h" #include "llvfile.h" #include "llvfs.h" diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 9a6c0569a9..4ffc12df2d 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1282,7 +1282,6 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d { static LLCachedControl<bool> log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ; - LLMemType mt1(LLMemType::MTYPE_APPFMTIMAGE); LLFastTimer t(FTM_PROCESS_IMAGES); // Receives image packet, copy into image object, diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5b373b7cc9..674a63aaf1 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -695,7 +695,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mLastRezzedStatus(-1) { - LLMemType mt(LLMemType::MTYPE_AVATAR); //VTResume(); // VTune // mVoiceVisualizer is created by the hud effects manager and uses the HUD Effects pipeline @@ -1739,8 +1738,6 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector //----------------------------------------------------------------------------- BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - //------------------------------------------------------------------------- // parse the file //------------------------------------------------------------------------- @@ -1782,8 +1779,6 @@ BOOL LLVOAvatar::parseSkeletonFile(const std::string& filename) //----------------------------------------------------------------------------- BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 &volume_num, S32 &joint_num) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - LLViewerJoint* joint = NULL; if (info->mIsJoint) @@ -1849,8 +1844,6 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent //----------------------------------------------------------------------------- BOOL LLVOAvatar::buildSkeleton(const LLVOAvatarSkeletonInfo *info) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - //------------------------------------------------------------------------- // allocate joints //------------------------------------------------------------------------- @@ -1921,8 +1914,6 @@ void LLVOAvatar::startDefaultMotions() //----------------------------------------------------------------------------- void LLVOAvatar::buildCharacter() { - LLMemType mt(LLMemType::MTYPE_AVATAR); - //------------------------------------------------------------------------- // remove all references to our existing skeleton // so we can rebuild it @@ -2072,8 +2063,6 @@ void LLVOAvatar::buildCharacter() //----------------------------------------------------------------------------- void LLVOAvatar::releaseMeshData() { - LLMemType mt(LLMemType::MTYPE_AVATAR); - if (sInstances.size() < AVATAR_RELEASE_THRESHOLD || mIsDummy) { return; @@ -2128,7 +2117,6 @@ void LLVOAvatar::releaseMeshData() void LLVOAvatar::restoreMeshData() { llassert(!isSelf()); - LLMemType mt(LLMemType::MTYPE_AVATAR); //llinfos << "Restoring" << llendl; mMeshValid = TRUE; @@ -2344,8 +2332,6 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys, U32 block_num, const EObjectUpdateType update_type, LLDataPacker *dp) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - LLVector3 old_vel = getVelocity(); const BOOL has_name = !getNVPair("FirstName"); @@ -2425,7 +2411,6 @@ void LLVOAvatar::dumpAnimationState() //------------------------------------------------------------------------ void LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) { - LLMemType mt(LLMemType::MTYPE_AVATAR); LLFastTimer t(FTM_AVATAR_UPDATE); if (isDead()) @@ -3463,8 +3448,6 @@ bool LLVOAvatar::isVisuallyMuted() const //------------------------------------------------------------------------ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - // clear debug text mDebugText.clear(); if (LLVOAvatar::sShowAnimationDebug) @@ -4793,8 +4776,6 @@ const LLUUID& LLVOAvatar::getStepSound() const //----------------------------------------------------------------------------- void LLVOAvatar::processAnimationStateChanges() { - LLMemType mt(LLMemType::MTYPE_AVATAR); - if ( isAnyAnimationSignaled(AGENT_WALK_ANIMS, NUM_AGENT_WALK_ANIMS) ) { startMotion(ANIM_AGENT_WALK_ADJUST); @@ -4885,8 +4866,6 @@ void LLVOAvatar::processAnimationStateChanges() //----------------------------------------------------------------------------- BOOL LLVOAvatar::processSingleAnimationStateChange( const LLUUID& anim_id, BOOL start ) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - BOOL result = FALSE; if ( start ) // start animation @@ -5021,8 +5000,6 @@ LLUUID LLVOAvatar::remapMotionID(const LLUUID& id) //----------------------------------------------------------------------------- BOOL LLVOAvatar::startMotion(const LLUUID& id, F32 time_offset) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - lldebugs << "motion requested " << id.asString() << " " << gAnimLibrary.animationName(id) << llendl; LLUUID remap_id = remapMotionID(id); @@ -5851,8 +5828,6 @@ BOOL LLVOAvatar::isActive() const //----------------------------------------------------------------------------- void LLVOAvatar::setPixelAreaAndAngle(LLAgent &agent) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - if (mDrawable.isNull()) { return; @@ -7297,8 +7272,6 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) return; } - LLMemType mt(LLMemType::MTYPE_AVATAR); - BOOL is_first_appearance_message = !mFirstAppearanceMessageReceived; mFirstAppearanceMessageReceived = TRUE; @@ -7499,7 +7472,6 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture if (!userdata) return; //llinfos << "onBakedTextureMasksLoaded: " << src_vi->getID() << llendl; - const LLMemType mt(LLMemType::MTYPE_AVATAR); const LLUUID id = src_vi->getID(); LLTextureMaskData* maskData = (LLTextureMaskData*) userdata; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 4ca915a7ef..2fc47efe3e 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -257,8 +257,6 @@ BOOL LLVOAvatarSelf::loadAvatarSelf() BOOL LLVOAvatarSelf::buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - // add special-purpose "screen" joint mScreenp = new LLViewerJoint("mScreen", NULL); // for now, put screen at origin, as it is only used during special @@ -652,8 +650,6 @@ BOOL LLVOAvatarSelf::loadLayersets() // virtual BOOL LLVOAvatarSelf::updateCharacter(LLAgent &agent) { - LLMemType mt(LLMemType::MTYPE_AVATAR); - // update screen joint size if (mScreenp) { @@ -1008,8 +1004,6 @@ void LLVOAvatarSelf::idleUpdateTractorBeam() // virtual void LLVOAvatarSelf::restoreMeshData() { - LLMemType mt(LLMemType::MTYPE_AVATAR); - //llinfos << "Restoring" << llendl; mMeshValid = TRUE; updateJointLODs(); diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 566c33c0af..4dca87652d 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -675,7 +675,6 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_GRASS_VB("Grass VB"); void LLGrassPartition::getGeometry(LLSpatialGroup* group) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); LLFastTimer ftm(FTM_REBUILD_GRASS_VB); std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater()); diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index e4f9915e93..fa34a6f1f5 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -599,7 +599,6 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_PARTICLE_GEOM("Particle Geom"); void LLParticlePartition::getGeometry(LLSpatialGroup* group) { - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); LLFastTimer ftm(FTM_REBUILD_PARTICLE_GEOM); std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater()); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c46ccd8ad5..c2318f9cf4 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3941,7 +3941,6 @@ static LLFastTimer::DeclareTimer FTM_REGISTER_FACE("Register Face"); void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type) { LLFastTimer t(FTM_REGISTER_FACE); - LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); if (facep->getViewerObject()->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects) { diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 78ee3e4fd9..a13a0ccaf0 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -138,7 +138,6 @@ void LLWorld::destroyClass() LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) { - LLMemType mt(LLMemType::MTYPE_REGIONS); llinfos << "Add region with handle: " << region_handle << " on host " << host << llendl; LLViewerRegion *regionp = getRegionFromHandle(region_handle); if (regionp) @@ -644,7 +643,6 @@ void LLWorld::updateVisibilities() void LLWorld::updateRegions(F32 max_update_time) { - LLMemType mt_ur(LLMemType::MTYPE_IDLE_UPDATE_REGIONS); LLTimer update_timer; BOOL did_one = FALSE; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 55064f3278..a8050e3163 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -35,7 +35,6 @@ #include "llviewercontrol.h" #include "llfasttimer.h" #include "llfontgl.h" -#include "llmemtype.h" #include "llnamevalue.h" #include "llpointer.h" #include "llprimitive.h" @@ -461,8 +460,6 @@ void LLPipeline::connectRefreshCachedSettingsSafe(const std::string name) void LLPipeline::init() { - LLMemType mt(LLMemType::MTYPE_PIPELINE_INIT); - refreshCachedSettings(); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); @@ -1131,7 +1128,6 @@ void LLPipeline::releaseScreenBuffers() void LLPipeline::createGLBuffers() { stop_glerror(); - LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS); assertInitialized(); updateRenderDeferred(); @@ -1268,7 +1264,6 @@ void LLPipeline::createLUTBuffers() void LLPipeline::restoreGL() { - LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_RESTORE_GL); assertInitialized(); if (mVertexShadersEnabled) @@ -1330,7 +1325,6 @@ BOOL LLPipeline::canUseAntiAliasing() const void LLPipeline::unloadShaders() { - LLMemType mt_us(LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS); LLViewerShaderMgr::instance()->unloadShaders(); mVertexShadersLoaded = 0; @@ -1362,7 +1356,6 @@ S32 LLPipeline::getMaxLightingDetail() const S32 LLPipeline::setLightingDetail(S32 level) { - LLMemType mt_ld(LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL); refreshCachedSettings(); if (level < 0) @@ -1524,7 +1517,6 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) LLDrawPool *LLPipeline::getPool(const U32 type, LLViewerTexture *tex0) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); LLDrawPool *poolp = findPool(type, tex0); if (poolp) { @@ -1541,7 +1533,6 @@ LLDrawPool *LLPipeline::getPool(const U32 type, LLViewerTexture *tex0) // static LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); U32 type = getPoolTypeFromTE(te, imagep); return gPipeline.getPool(type, imagep); } @@ -1549,8 +1540,6 @@ LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* //static U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) { - LLMemType mt_gpt(LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE); - if (!te || !imagep) { return 0; @@ -1579,7 +1568,6 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima void LLPipeline::addPool(LLDrawPool *new_poolp) { - LLMemType mt_a(LLMemType::MTYPE_PIPELINE_ADD_POOL); assertInitialized(); mPools.insert(new_poolp); addToQuickLookup( new_poolp ); @@ -1587,7 +1575,6 @@ void LLPipeline::addPool(LLDrawPool *new_poolp) void LLPipeline::allocDrawable(LLViewerObject *vobj) { - LLMemType mt_ad(LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE); LLDrawable *drawable = new LLDrawable(); vobj->mDrawable = drawable; @@ -1686,8 +1673,6 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable) U32 LLPipeline::addObject(LLViewerObject *vobj) { - LLMemType mt_ao(LLMemType::MTYPE_PIPELINE_ADD_OBJECT); - if (RenderDelayCreation) { mCreateQ.push_back(vobj); @@ -1703,7 +1688,6 @@ U32 LLPipeline::addObject(LLViewerObject *vobj) void LLPipeline::createObjects(F32 max_dtime) { LLFastTimer ftm(FTM_PIPELINE_CREATE); - LLMemType mt(LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS); LLTimer update_timer; @@ -1889,7 +1873,6 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move"); void LLPipeline::updateMove() { LLFastTimer t(FTM_UPDATE_MOVE); - LLMemType mt_um(LLMemType::MTYPE_PIPELINE_UPDATE_MOVE); if (FreezeTime) { @@ -2242,7 +2225,6 @@ static LLFastTimer::DeclareTimer FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep) { LLFastTimer t(FTM_CULL); - LLMemType mt_uc(LLMemType::MTYPE_PIPELINE_UPDATE_CULL); grabReferences(result); @@ -2566,7 +2548,6 @@ void LLPipeline::rebuildPriorityGroups() { LLFastTimer t(FTM_REBUILD_PRIORITY_GROUPS); LLTimer update_timer; - LLMemType mt(LLMemType::MTYPE_PIPELINE); assertInitialized(); gMeshRepo.notifyLoadedMeshes(); @@ -2637,7 +2618,6 @@ void LLPipeline::rebuildGroups() void LLPipeline::updateGeom(F32 max_dtime) { LLTimer update_timer; - LLMemType mt(LLMemType::MTYPE_PIPELINE_UPDATE_GEOM); LLPointer<LLDrawable> drawablep; LLFastTimer t(FTM_GEO_UPDATE); @@ -2731,8 +2711,6 @@ void LLPipeline::updateGeom(F32 max_dtime) void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE); - if(drawablep && !drawablep->isDead()) { if (drawablep->isSpatialBridge()) @@ -2770,8 +2748,6 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) { - LLMemType mt_mm(LLMemType::MTYPE_PIPELINE_MARK_MOVED); - if (!drawablep) { //llerrs << "Sending null drawable to moved list!" << llendl; @@ -2816,8 +2792,6 @@ void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) void LLPipeline::markShift(LLDrawable *drawablep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_SHIFT); - if (!drawablep || drawablep->isDead()) { return; @@ -2843,8 +2817,6 @@ static LLFastTimer::DeclareTimer FTM_SHIFT_HUD("Shift HUD"); void LLPipeline::shiftObjects(const LLVector3 &offset) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS); - assertInitialized(); glClear(GL_DEPTH_BUFFER_BIT); @@ -2898,8 +2870,6 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) void LLPipeline::markTextured(LLDrawable *drawablep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_TEXTURED); - if (drawablep && !drawablep->isDead() && assertInitialized()) { mRetexturedList.insert(drawablep); @@ -2950,8 +2920,6 @@ void LLPipeline::markMeshDirty(LLSpatialGroup* group) void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); - if (group && !group->isDead() && group->mSpatialPartition) { if (group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_HUD) @@ -2991,8 +2959,6 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority) void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_REBUILD); - if (drawablep && !drawablep->isDead() && assertInitialized()) { if (!drawablep->isState(LLDrawable::BUILT)) @@ -3039,7 +3005,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } LLFastTimer ftm(FTM_STATESORT); - LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); //LLVertexBuffer::unbind(); @@ -3140,7 +3105,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); if (group->changeLOD()) { for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) @@ -3159,7 +3123,6 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); if (bridge->getSpatialGroup()->changeLOD()) { bool force_update = false; @@ -3169,8 +3132,6 @@ void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); - if (!drawablep || drawablep->isDead() || !hasRenderType(drawablep->getRenderType())) @@ -3461,7 +3422,6 @@ void renderSoundHighlights(LLDrawable* drawablep) void LLPipeline::postSort(LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_POST_SORT); LLFastTimer ftm(FTM_STATESORT_POSTSORT); assertInitialized(); @@ -3713,7 +3673,6 @@ void LLPipeline::postSort(LLCamera& camera) void render_hud_elements() { - LLMemType mt_rhe(LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS); LLFastTimer t(FTM_RENDER_UI); gPipeline.disableLights(); @@ -3768,8 +3727,6 @@ void render_hud_elements() void LLPipeline::renderHighlights() { - LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_HL); - assertInitialized(); // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD) @@ -3933,7 +3890,6 @@ U32 LLPipeline::sCurRenderPoolType = 0 ; void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_GEOM); LLFastTimer t(FTM_RENDER_GEOMETRY); assertInitialized(); @@ -4185,7 +4141,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); - LLMemType mt_rgd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED); LLFastTimer t(FTM_RENDER_GEOMETRY); LLFastTimer t2(FTM_DEFERRED_POOLS); @@ -4282,7 +4237,6 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) void LLPipeline::renderGeomPostDeferred(LLCamera& camera) { - LLMemType mt_rgpd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF); LLFastTimer t(FTM_POST_DEFERRED_POOLS); U32 cur_type = 0; @@ -4378,7 +4332,6 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) void LLPipeline::renderGeomShadow(LLCamera& camera) { - LLMemType mt_rgs(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW); U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -4532,8 +4485,6 @@ void LLPipeline::renderPhysicsDisplay() void LLPipeline::renderDebug() { - LLMemType mt(LLMemType::MTYPE_PIPELINE); - assertInitialized(); gGL.color4f(1,1,1,1); @@ -4859,7 +4810,6 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_POOLS("Rebuild Pools"); void LLPipeline::rebuildPools() { LLFastTimer t(FTM_REBUILD_POOLS); - LLMemType mt(LLMemType::MTYPE_PIPELINE_REBUILD_POOLS); assertInitialized(); @@ -4899,8 +4849,6 @@ void LLPipeline::rebuildPools() void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) { - LLMemType mt(LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP); - assertInitialized(); switch( new_poolp->getType() ) @@ -5066,7 +5014,6 @@ void LLPipeline::removePool( LLDrawPool* poolp ) void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) { assertInitialized(); - LLMemType mt(LLMemType::MTYPE_PIPELINE); switch( poolp->getType() ) { case LLDrawPool::POOL_SIMPLE: @@ -6483,7 +6430,6 @@ void LLPipeline::doResetVertexBuffers() void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture) { - LLMemType mt_ro(LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS); assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -6556,7 +6502,6 @@ static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom"); void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) { - LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM); if (!(gPipeline.canUseVertexShaders() && sRenderGlow)) { @@ -9615,7 +9560,6 @@ static LLFastTimer::DeclareTimer FTM_IMPOSTOR_RESIZE("Impostor Resize"); void LLPipeline::generateImpostor(LLVOAvatar* avatar) { - LLMemType mt_gi(LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); diff --git a/indra/test/llbuffer_tut.cpp b/indra/test/llbuffer_tut.cpp index dc1a5cdd3d..a25fdebb7f 100644 --- a/indra/test/llbuffer_tut.cpp +++ b/indra/test/llbuffer_tut.cpp @@ -31,7 +31,6 @@ #include "lltut.h" #include "llbuffer.h" #include "llerror.h" -#include "llmemtype.h" namespace tut -- cgit v1.2.3 From bfd1c0370fe9f7a2372365f890bf88cf00c52f77 Mon Sep 17 00:00:00 2001 From: Kelly Washington <kelly@lindenlab.com> Date: Fri, 20 Jul 2012 13:28:04 -0700 Subject: MAINT-570 Remove unused memory tracking system LLMemType follow up to fix test compiles. --- indra/llimage/tests/llimageworker_test.cpp | 3 +-- indra/llkdu/tests/llimagej2ckdu_test.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 08476fb72c..e255d65b43 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -49,8 +49,7 @@ mWidth(0), mHeight(0), mComponents(0), mBadBufferAllocation(false), -mAllowOverSize(false), -mMemType(LLMemType::MTYPE_IMAGEBASE) +mAllowOverSize(false) { } LLImageBase::~LLImageBase() {} diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index beee99a522..87e2227ca7 100644 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -58,8 +58,7 @@ mWidth(0), mHeight(0), mComponents(0), mBadBufferAllocation(false), -mAllowOverSize(false), -mMemType(LLMemType::MTYPE_IMAGEBASE) +mAllowOverSize(false) { } LLImageBase::~LLImageBase() { } U8* LLImageBase::allocateData(S32 ) { return NULL; } -- cgit v1.2.3 From 93b2e05c2f8380408df39ad4e1ed4248b623d3b9 Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Wed, 25 Jul 2012 13:48:28 -0500 Subject: MAINT-611 Differentiate between mobile and not mobile NVIDIA GPUs in the gpu table. --- indra/newview/gpu_table.txt | 86 ++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 28 deletions(-) diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt index 777d54a5c3..4ea139617d 100644 --- a/indra/newview/gpu_table.txt +++ b/indra/newview/gpu_table.txt @@ -312,35 +312,65 @@ NVIDIA G 315 .*NVIDIA .*315(M)?.* 2 1 NVIDIA G 320M .*NVIDIA .*320(M)?.* 2 1 NVIDIA G 405 .*NVIDIA .*405(M)?.* 1 1 NVIDIA G 410M .*NVIDIA .*410(M)?.* 1 1 -NVIDIA GT 120M .*NVIDIA .*GT *120(M)?.* 2 1 + + +NVIDIA GT 120M .*NVIDIA .*GT *120M.* 2 1 +NVIDIA GT 130M .*NVIDIA .*GT *130M.* 2 1 +NVIDIA GT 140M .*NVIDIA .*GT *140M.* 2 1 +NVIDIA GT 150M .*NVIDIA .*GT *150M.* 2 1 +NVIDIA GT 160M .*NVIDIA .*GT *160M.* 2 1 +NVIDIA GT 220M .*NVIDIA .*GT *220M.* 2 1 +NVIDIA GT 230M .*NVIDIA .*GT *230M.* 2 1 +NVIDIA GT 240M .*NVIDIA .*GT *240M.* 2 1 +NVIDIA GT 250M .*NVIDIA .*GT *250M.* 2 1 +NVIDIA GT 260M .*NVIDIA .*GT *260M.* 2 1 +NVIDIA GT 320M .*NVIDIA .*GT *320M.* 2 1 +NVIDIA GT 325M .*NVIDIA .*GT *325M.* 0 1 +NVIDIA GT 330M .*NVIDIA .*GT *330M.* 3 1 +NVIDIA GT 335M .*NVIDIA .*GT *335M.* 1 1 +NVIDIA GT 340M .*NVIDIA .*GT *340M.* 2 1 +NVIDIA GT 415M .*NVIDIA .*GT *415M.* 2 1 +NVIDIA GT 420M .*NVIDIA .*GT *420M.* 2 1 +NVIDIA GT 425M .*NVIDIA .*GT *425M.* 3 1 +NVIDIA GT 430M .*NVIDIA .*GT *430M.* 3 1 +NVIDIA GT 435M .*NVIDIA .*GT *435M.* 3 1 +NVIDIA GT 440M .*NVIDIA .*GT *440M.* 3 1 +NVIDIA GT 445M .*NVIDIA .*GT *445M.* 3 1 +NVIDIA GT 450M .*NVIDIA .*GT *450M.* 3 1 +NVIDIA GT 520M .*NVIDIA .*GT *52.M.* 3 1 +NVIDIA GT 530M .*NVIDIA .*GT *530M.* 3 1 +NVIDIA GT 540M .*NVIDIA .*GT *54.M.* 3 1 +NVIDIA GT 550M .*NVIDIA .*GT *550M.* 3 1 +NVIDIA GT 555M .*NVIDIA .*GT *555M.* 3 1 NVIDIA GT 120 .*NVIDIA .*GT.*120 2 1 -NVIDIA GT 130M .*NVIDIA .*GT *130(M)?.* 2 1 -NVIDIA GT 140M .*NVIDIA .*GT *140(M)?.* 2 1 -NVIDIA GT 150M .*NVIDIA .*GT(S)? *150(M)?.* 2 1 -NVIDIA GT 160M .*NVIDIA .*GT *160(M)?.* 2 1 -NVIDIA GT 220M .*NVIDIA .*GT *220(M)?.* 2 1 -NVIDIA GT 230M .*NVIDIA .*GT *230(M)?.* 2 1 -NVIDIA GT 240M .*NVIDIA .*GT *240(M)?.* 2 1 -NVIDIA GT 250M .*NVIDIA .*GT *250(M)?.* 2 1 -NVIDIA GT 260M .*NVIDIA .*GT *260(M)?.* 2 1 -NVIDIA GT 320M .*NVIDIA .*GT *320(M)?.* 2 1 -NVIDIA GT 325M .*NVIDIA .*GT *325(M)?.* 0 1 -NVIDIA GT 330M .*NVIDIA .*GT *330(M)?.* 3 1 -NVIDIA GT 335M .*NVIDIA .*GT *335(M)?.* 1 1 -NVIDIA GT 340M .*NVIDIA .*GT *340(M)?.* 2 1 -NVIDIA GT 415M .*NVIDIA .*GT *415(M)?.* 2 1 -NVIDIA GT 420M .*NVIDIA .*GT *420(M)?.* 2 1 -NVIDIA GT 425M .*NVIDIA .*GT *425(M)?.* 3 1 -NVIDIA GT 430M .*NVIDIA .*GT *430(M)?.* 3 1 -NVIDIA GT 435M .*NVIDIA .*GT *435(M)?.* 3 1 -NVIDIA GT 440M .*NVIDIA .*GT *440(M)?.* 3 1 -NVIDIA GT 445M .*NVIDIA .*GT *445(M)?.* 3 1 -NVIDIA GT 450M .*NVIDIA .*GT *450(M)?.* 3 1 -NVIDIA GT 520M .*NVIDIA .*GT *52.(M)?.* 3 1 -NVIDIA GT 530M .*NVIDIA .*GT *530(M)?.* 3 1 -NVIDIA GT 540M .*NVIDIA .*GT *54.(M)?.* 3 1 -NVIDIA GT 550M .*NVIDIA .*GT *550(M)?.* 3 1 -NVIDIA GT 555M .*NVIDIA .*GT *555(M)?.* 3 1 +NVIDIA GT 130 .*NVIDIA .*GT *130.* 2 1 +NVIDIA GT 140 .*NVIDIA .*GT *140.* 2 1 +NVIDIA GT 150 .*NVIDIA .*GT *150.* 2 1 +NVIDIA GT 160 .*NVIDIA .*GT *160.* 2 1 +NVIDIA GT 220 .*NVIDIA .*GT *220.* 2 1 +NVIDIA GT 230 .*NVIDIA .*GT *230.* 2 1 +NVIDIA GT 240 .*NVIDIA .*GT *240.* 2 1 +NVIDIA GT 250 .*NVIDIA .*GT *250.* 2 1 +NVIDIA GT 260 .*NVIDIA .*GT *260.* 2 1 +NVIDIA GT 320 .*NVIDIA .*GT *320.* 2 1 +NVIDIA GT 325 .*NVIDIA .*GT *325.* 0 1 +NVIDIA GT 330 .*NVIDIA .*GT *330.* 3 1 +NVIDIA GT 335 .*NVIDIA .*GT *335.* 1 1 +NVIDIA GT 340 .*NVIDIA .*GT *340.* 2 1 +NVIDIA GT 415 .*NVIDIA .*GT *415.* 2 1 +NVIDIA GT 420 .*NVIDIA .*GT *420.* 2 1 +NVIDIA GT 425 .*NVIDIA .*GT *425.* 3 1 +NVIDIA GT 430 .*NVIDIA .*GT *430.* 3 1 +NVIDIA GT 435 .*NVIDIA .*GT *435.* 3 1 +NVIDIA GT 440 .*NVIDIA .*GT *440.* 3 1 +NVIDIA GT 445 .*NVIDIA .*GT *445.* 3 1 +NVIDIA GT 450 .*NVIDIA .*GT *450.* 3 1 +NVIDIA GT 520 .*NVIDIA .*GT *52..* 3 1 +NVIDIA GT 530 .*NVIDIA .*GT *530.* 3 1 +NVIDIA GT 540 .*NVIDIA .*GT *54..* 3 1 +NVIDIA GT 550 .*NVIDIA .*GT *550.* 3 1 +NVIDIA GT 555 .*NVIDIA .*GT *555.* 3 1 +NVIDIA GTS 150 .*NVIDIA .*GTS*150(M)?.* 2 1 NVIDIA GTS 160M .*NVIDIA .*GT(S)? *160(M)?.* 2 1 NVIDIA GTS 240 .*NVIDIA .*GTS *24.* 3 1 NVIDIA GTS 250 .*NVIDIA .*GTS *25.* 3 1 -- cgit v1.2.3 From 49879c254cfc58b34a003d34be102c3e51eb0037 Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Wed, 25 Jul 2012 14:46:23 -0500 Subject: MAINT-615 Fix for texture animation freezing under certain situations. --- indra/newview/lldrawpoolavatar.cpp | 3 +++ indra/newview/llvovolume.cpp | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 730ad1a364..59161d063e 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1272,6 +1272,9 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* face->setGeomIndex(0); face->setIndicesIndex(0); + //rigged faces do not batch textures + face->setTextureIndex(255); + if (buffer.isNull() || buffer->getTypeMask() != data_mask || !buffer->isWriteable()) { //make a new buffer if (sShaderLevel > 0) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index c2318f9cf4..59166df9f6 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4867,11 +4867,19 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: facep->setTextureIndex(cur_tex); texture_list.push_back(tex); - //if (can_batch_texture(facep)) - { + if (can_batch_texture(facep)) + { //populate texture_list with any textures that can be batched + //move i to the next unbatchable face while (i != faces.end()) { facep = *i; + + if (!can_batch_texture(facep)) + { //face is bump mapped or has an animated texture matrix -- can't + //batch more than 1 texture at a time + break; + } + if (facep->getTexture() != tex) { if (distance_sort) @@ -4897,12 +4905,6 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std:: cur_tex++; } - if (!can_batch_texture(facep)) - { //face is bump mapped or has an animated texture matrix -- can't - //batch more than 1 texture at a time - break; - } - if (cur_tex >= texture_index_channels) { //cut batches when index channels are depleted break; -- cgit v1.2.3 From 7e6ccbc01df82b87df0e1defe872e1667978dfa3 Mon Sep 17 00:00:00 2001 From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com> Date: Wed, 25 Jul 2012 15:46:15 -0700 Subject: MAINT-1042: Blocking asset avatar prevents future uploads. Reviewed by Kelly. --- indra/newview/llworld.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index a13a0ccaf0..09d17b3701 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1192,7 +1192,7 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector<LLVector3d>* positi { LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; - if (!pVOAvatar->isDead() && !pVOAvatar->isSelf()) + if (!pVOAvatar->isDead() && !pVOAvatar->isSelf() && !pVOAvatar->mIsDummy) { LLVector3d pos_global = pVOAvatar->getPositionGlobal(); LLUUID uuid = pVOAvatar->getID(); -- cgit v1.2.3 From 64fc52d85ea04a860e0f1670bbbf67efea977513 Mon Sep 17 00:00:00 2001 From: callum <none@none> Date: Fri, 27 Jul 2012 13:35:00 -0700 Subject: MAINT-1056 FIX Microsoft SkyDrive is not compatible with Second Life Reviewed by YP --- autobuild.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index ba57d09f86..bfb4b5eae4 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1618,9 +1618,9 @@ <key>archive</key> <map> <key>hash</key> - <string>dde928cb24d22a267004a8c17669ba65</string> + <string>8aedfdcf670348c18a9991ae1b384a61</string> <key>url</key> - <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/226426/arch/Linux/installer/google_perftools-1.7-linux-20110412.tar.bz2</string> + <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/262672/arch/Linux/installer/gperftools-2.0-linux-20120727.tar.bz2</string> </map> <key>name</key> <string>linux</string> @@ -1630,9 +1630,9 @@ <key>archive</key> <map> <key>hash</key> - <string>8308f7bd68bb7083655753b7abe7225f</string> + <string>f62841804acb91e1309603a84f3f0ce8</string> <key>url</key> - <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/226287/arch/CYGWIN/installer/google_perftools-1.7-windows-20110411.tar.bz2</string> + <string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-google-perftools/rev/262672/arch/CYGWIN/installer/gperftools-2.0-windows-20120727.tar.bz2</string> </map> <key>name</key> <string>windows</string> -- cgit v1.2.3 From 267c01d4c8724adcfa9a9603d24e13cce037f89f Mon Sep 17 00:00:00 2001 From: Dave Parks <davep@lindenlab.com> Date: Mon, 30 Jul 2012 12:20:16 -0500 Subject: MAINT-570 Fix for linux build. --- indra/newview/llappviewerlinux.cpp | 3 --- indra/newview/llappviewermacosx.cpp | 4 ---- 2 files changed, 7 deletions(-) diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 48d02dfeaa..a19ad1eceb 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -31,7 +31,6 @@ #include "llcommandlineparser.h" #include "lldiriterator.h" -#include "llmemtype.h" #include "llurldispatcher.h" // SLURL from other app instance #include "llviewernetwork.h" #include "llviewercontrol.h" @@ -71,8 +70,6 @@ static void exceptionTerminateHandler() int main( int argc, char **argv ) { - LLMemType mt1(LLMemType::MTYPE_STARTUP); - #if LL_SOLARIS && defined(__sparc) asm ("ta\t6"); // NOTE: Make sure memory alignment is enforced on SPARC #endif diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index c2916717bd..4d340cafa9 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -33,8 +33,6 @@ #include "llappviewermacosx.h" #include "llcommandlineparser.h" -#include "llmemtype.h" - #include "llviewernetwork.h" #include "llviewercontrol.h" #include "llmd5.h" @@ -67,8 +65,6 @@ namespace int main( int argc, char **argv ) { - LLMemType mt1(LLMemType::MTYPE_STARTUP); - #if LL_SOLARIS && defined(__sparc) asm ("ta\t6"); // NOTE: Make sure memory alignment is enforced on SPARC #endif -- cgit v1.2.3 From 0ccecbe966a1a19b7625efba304ef3071b2265cb Mon Sep 17 00:00:00 2001 From: "simon@Simon-PC.lindenlab.com" <simon@Simon-PC.lindenlab.com> Date: Mon, 30 Jul 2012 15:11:00 -0700 Subject: Fix linux build crankiness --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a8050e3163..777db06a3f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -902,7 +902,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) } } - U32 width = resX*scale; + U32 width = (U32)(resX*scale); U32 height = width; if (shadow_detail > 1) -- cgit v1.2.3 From 62379fd7628afa5ce1b104ff66b26821ce740c29 Mon Sep 17 00:00:00 2001 From: Kelly Washington <kelly@lindenlab.com> Date: Tue, 31 Jul 2012 10:37:50 -0700 Subject: MAINT-1305 llDialog tooltip typo --- indra/newview/skins/default/xui/en/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 866ea296c3..1d5163e725 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -1446,7 +1446,7 @@ integer llScriptDanger(vector pos) Returns TRUE if pos is over public land, sandbox land, land that doesn't allow everyone to edit and build, or land that doesn't allow outside scripts </string> <string name="LSLTipText_llDialog" translate="false"> -llDialog(key avatar, string message, list buttons, integer chat_channel +llDialog(key avatar, string message, list buttons, integer chat_channel) Shows a dialog box on the avatar's screen with a message and up to 12 buttons. If a button is pressed, the avatar says the text of the button label on chat_channel. </string> -- cgit v1.2.3 From 22b1223ea7d68b27304cdd713f8e8b491b654060 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" <vir@lindenlab.com> Date: Thu, 2 Aug 2012 11:45:38 -0400 Subject: MAINT-515 FIX, CHOP-100 FIX - technically we are avoiding these issues rather than fixing them; changing llcommon to be statically linked avoids the symbol issues with llcommon.dll --- indra/cmake/LLAddBuildTest.cmake | 9 +++++++++ indra/cmake/LLCommon.cmake | 2 +- indra/llcommon/llstat.cpp | 19 ++++++++++++------- indra/llcommon/llstat.h | 6 +++--- 4 files changed, 25 insertions(+), 11 deletions(-) mode change 100644 => 100755 indra/cmake/LLAddBuildTest.cmake diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake old mode 100644 new mode 100755 index 08feab6e36..03ce46781c --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -201,6 +201,15 @@ FUNCTION(LL_ADD_INTEGRATION_TEST endif(TEST_DEBUG) ADD_EXECUTABLE(INTEGRATION_TEST_${testname} ${source_files}) SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}") + if (WINDOWS) + set_target_properties(INTEGRATION_TEST_${testname} + PROPERTIES + LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS /INCLUDE:__tcmalloc" + LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO" + LINK_FLAGS_RELEASE "" + ) + endif(WINDOWS) + if(STANDALONE) SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname} PROPERTIES COMPILE_FLAGS -I"${TUT_INCLUDE_DIR}") endif(STANDALONE) diff --git a/indra/cmake/LLCommon.cmake b/indra/cmake/LLCommon.cmake index 17e211cb99..d4694ad37a 100644 --- a/indra/cmake/LLCommon.cmake +++ b/indra/cmake/LLCommon.cmake @@ -24,7 +24,7 @@ endif (LINUX) add_definitions(${TCMALLOC_FLAG}) -set(LLCOMMON_LINK_SHARED ON CACHE BOOL "Build the llcommon target as a shared library.") +set(LLCOMMON_LINK_SHARED OFF CACHE BOOL "Build the llcommon target as a shared library.") if(LLCOMMON_LINK_SHARED) add_definitions(-DLL_COMMON_LINK_SHARED=1) endif(LLCOMMON_LINK_SHARED) diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 057257057f..b82d52797e 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -40,7 +40,6 @@ S32 LLPerfBlock::sStatsFlags = LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS; // Control what is being recorded LLPerfBlock::stat_map_t LLPerfBlock::sStatMap; // Map full path string to LLStatTime objects, tracks all active objects std::string LLPerfBlock::sCurrentStatPath = ""; // Something like "/total_time/physics/physics step" -LLStat::stat_map_t LLStat::sStatList; //------------------------------------------------------------------------ // Live config file to trigger stats logging @@ -771,13 +770,19 @@ void LLStat::init() if (!mName.empty()) { - stat_map_t::iterator iter = sStatList.find(mName); - if (iter != sStatList.end()) + stat_map_t::iterator iter = getStatList().find(mName); + if (iter != getStatList().end()) llwarns << "LLStat with duplicate name: " << mName << llendl; - sStatList.insert(std::make_pair(mName, this)); + getStatList().insert(std::make_pair(mName, this)); } } +LLStat::stat_map_t& LLStat::getStatList() +{ + static LLStat::stat_map_t stat_list; + return stat_list; +} + LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) : mUseFrameTimer(use_frame_timer), mNumBins(num_bins) @@ -803,10 +808,10 @@ LLStat::~LLStat() if (!mName.empty()) { // handle multiple entries with the same name - stat_map_t::iterator iter = sStatList.find(mName); - while (iter != sStatList.end() && iter->second != this) + stat_map_t::iterator iter = getStatList().find(mName); + while (iter != getStatList().end() && iter->second != this) ++iter; - sStatList.erase(iter); + getStatList().erase(iter); } } diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index b877432e86..1a8404cc07 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -263,9 +263,9 @@ class LL_COMMON_API LLStat { private: typedef std::multimap<std::string, LLStat*> stat_map_t; - static stat_map_t sStatList; void init(); + static stat_map_t& getStatList(); public: LLStat(U32 num_bins = 32, BOOL use_frame_timer = FALSE); @@ -342,8 +342,8 @@ public: static LLStat* getStat(const std::string& name) { // return the first stat that matches 'name' - stat_map_t::iterator iter = sStatList.find(name); - if (iter != sStatList.end()) + stat_map_t::iterator iter = getStatList().find(name); + if (iter != getStatList().end()) return iter->second; else return NULL; -- cgit v1.2.3 From 3bead10a488a27335a4ed09feac5ae1927479d02 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Mon, 6 Aug 2012 17:25:53 +0300 Subject: MAINT-73 FIXED Hide Stand/Stop flying panel after pressing Ctrl-Shift-U --- indra/newview/llviewermenu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 01a54509ef..9aa4cfa494 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3940,6 +3940,7 @@ class LLViewToggleUI : public view_listener_t if (option == 0) // OK { gViewerWindow->setUIVisibility(!gViewerWindow->getUIVisibility()); + LLPanelStandStopFlying::getInstance()->setVisible(gViewerWindow->getUIVisibility()); } } }; -- cgit v1.2.3 From 80171c8d2c5641e61362b5012c9b7adca9caf9de Mon Sep 17 00:00:00 2001 From: maxim_productengine <none@none> Date: Thu, 5 Jul 2012 15:32:14 +0300 Subject: MAINT-436 FIXED Set focus to line editor if it exists in alert toast --- indra/newview/lltoastalertpanel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp index 8fef2ed6d1..3f75f8da5e 100644 --- a/indra/newview/lltoastalertpanel.cpp +++ b/indra/newview/lltoastalertpanel.cpp @@ -357,6 +357,7 @@ LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal if (mLineEditor) { mLineEditor->selectAll(); + mLineEditor->setFocus(TRUE); } if(mDefaultOption >= 0) { -- cgit v1.2.3 From 5d32e23a11f272a2cdf8b6aac106534b6814ea98 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 12 Jul 2012 22:35:51 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages improved update logging API and output format --- indra/newview/app_settings/logcontrol.xml | 20 +++- indra/newview/llappviewer.cpp | 8 -- indra/newview/llviewerobjectlist.cpp | 37 ++++-- indra/newview/llviewerregion.cpp | 6 +- indra/newview/llviewerstatsrecorder.cpp | 188 +++++++++++++++++------------- indra/newview/llviewerstatsrecorder.h | 37 +++--- 6 files changed, 174 insertions(+), 122 deletions(-) diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 64122bbb6c..8636ba1090 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -48,6 +48,24 @@ --> </array> </map> - </array> + <map> + <key>level</key> + <string>NONE</string> + <key>functions</key> + <array> + </array> + <key>classes</key> + <array> + <string>LLViewerStatsRecorder</string> + </array> + <key>files</key> + <array> + </array> + <key>tags</key> + <array> + + </array> + </map> + </array> </map> </llsd> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ed04b5bf38..c02bc882ea 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -719,10 +719,6 @@ bool LLAppViewer::init() mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling")); -#if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::initClass(); -#endif - // *NOTE:Mani - LLCurl::initClass is not thread safe. // Called before threads are created. LLCurl::initClass(gSavedSettings.getF32("CurlRequestTimeOut"), @@ -1894,10 +1890,6 @@ bool LLAppViewer::cleanup() LLMetricPerformanceTesterBasic::cleanClass() ; -#if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::cleanupClass(); -#endif - llinfos << "Cleaning up Media and Textures" << llendflush; //Note: diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 54ccfb9aae..b010ac9aa7 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -334,6 +334,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, U64 region_handle; mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle); + LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle); if (!regionp) @@ -345,9 +346,9 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, U8 compressed_dpbuffer[2048]; LLDataPackerBinaryBuffer compressed_dp(compressed_dpbuffer, 2048); LLDataPacker *cached_dpp = NULL; - + LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance(); #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->beginObjectUpdateEvents(regionp); + recorder.beginObjectUpdateEvents(1.f); #endif for (i = 0; i < num_objects; i++) @@ -355,6 +356,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, // timer is unused? LLTimer update_timer; BOOL justCreated = FALSE; + S32 msg_size = 0; if (cached) { @@ -362,6 +364,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, U32 crc; mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, id, i); mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_CRC, crc, i); + msg_size += sizeof(U32) * 2; // Lookup data packer and add this id to cache miss lists if necessary. U8 cache_miss_type = LLViewerRegion::CACHE_MISS_TYPE_NONE; @@ -377,9 +380,9 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, else { // Cache Miss. - #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordCacheMissEvent(id, update_type, cache_miss_type); - #endif +#if LL_RECORD_VIEWER_STATS + recorder.recordCacheMissEvent(id, update_type, cache_miss_type, msg_size); +#endif continue; // no data packer, skip this object } @@ -391,10 +394,12 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, S32 compressed_length; compressed_dp.reset(); + U32 flags = 0; if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only? { mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i); + msg_size += sizeof(U32); } // I don't think we ever use this flag from the server. DK 2010/12/09 @@ -402,6 +407,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { //llinfos << "TEST: flags & FLAGS_ZLIB_COMPRESSED" << llendl; compressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data); + msg_size += compressed_length; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compbuffer, 0, i); uncompressed_length = 2048; uncompress(compressed_dpbuffer, (unsigned long *)&uncompressed_length, @@ -411,6 +417,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, else { uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data); + msg_size += uncompressed_length; mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i); compressed_dp.assignBuffer(compressed_dpbuffer, uncompressed_length); } @@ -439,6 +446,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, else if (update_type != OUT_FULL) // !compressed, !OUT_FULL ==> OUT_FULL_CACHED only? { mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i); + msg_size += sizeof(U32); + getUUIDFromLocal(fullid, local_id, gMessageSystem->getSenderIP(), @@ -453,6 +462,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_FullID, fullid, i); mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i); + msg_size += sizeof(LLUUID); + msg_size += sizeof(U32); // llinfos << "Full Update, obj " << local_id << ", global ID" << fullid << "from " << mesgsys->getSender() << llendl; } objectp = findObject(fullid); @@ -499,7 +510,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { // llinfos << "terse update for an unknown object (compressed):" << fullid << llendl; #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type); + recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); #endif continue; } @@ -513,12 +524,14 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { //llinfos << "terse update for an unknown object:" << fullid << llendl; #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type); + recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); #endif continue; } mesgsys->getU8Fast(_PREHASH_ObjectData, _PREHASH_PCode, pcode, i); + msg_size += sizeof(U8); + } #ifdef IGNORE_DEAD if (mDeadObjects.find(fullid) != mDeadObjects.end()) @@ -526,7 +539,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, mNumDeadObjectUpdates++; //llinfos << "update for a dead object:" << fullid << llendl; #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type); + recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); #endif continue; } @@ -537,7 +550,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { llinfos << "createObject failure for object: " << fullid << llendl; #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordObjectUpdateFailure(local_id, update_type); + recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); #endif continue; } @@ -566,7 +579,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, bCached = true; #if LL_RECORD_VIEWER_STATS LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp); - LLViewerStatsRecorder::instance()->recordCacheFullUpdate(local_id, update_type, result, objectp); + recorder.recordCacheFullUpdate(local_id, update_type, result, objectp, msg_size); #else objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp); #endif @@ -586,14 +599,14 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, processUpdateCore(objectp, user_data, i, update_type, NULL, justCreated); } #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->recordObjectUpdateEvent(local_id, update_type, objectp); + recorder.recordObjectUpdateEvent(local_id, update_type, objectp, msg_size); #endif objectp->setLastUpdateType(update_type); objectp->setLastUpdateCached(bCached); } #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->endObjectUpdateEvents(); + recorder.endObjectUpdateEvents(); #endif LLVOAvatar::cullAvatarsByPixelArea(); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e3cb985ddb..0e2927cea4 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1318,9 +1318,9 @@ void LLViewerRegion::requestCacheMisses() mCacheDirty = TRUE ; // llinfos << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << llendl; #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance()->beginObjectUpdateEvents(this); - LLViewerStatsRecorder::instance()->recordRequestCacheMissesEvent(full_count + crc_count); - LLViewerStatsRecorder::instance()->endObjectUpdateEvents(); + LLViewerStatsRecorder::instance().beginObjectUpdateEvents(1.f); + LLViewerStatsRecorder::instance().recordRequestCacheMissesEvent(full_count + crc_count); + LLViewerStatsRecorder::instance().endObjectUpdateEvents(); #endif } diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp index e9d21b4848..cfb446fe45 100644 --- a/indra/newview/llviewerstatsrecorder.cpp +++ b/indra/newview/llviewerstatsrecorder.cpp @@ -45,9 +45,10 @@ LLViewerStatsRecorder* LLViewerStatsRecorder::sInstance = NULL; LLViewerStatsRecorder::LLViewerStatsRecorder() : mObjectCacheFile(NULL), mTimer(), - mRegionp(NULL), - mStartTime(0.f), - mProcessingTime(0.f) + mStartTime(0.0), + mProcessingStartTime(0.0), + mProcessingTotalTime(0.0), + mLastSnapshotTime(0.0) { if (NULL != sInstance) { @@ -61,112 +62,114 @@ LLViewerStatsRecorder::~LLViewerStatsRecorder() { if (mObjectCacheFile != NULL) { + // last chance snapshot + takeSnapshot(); LLFile::close(mObjectCacheFile); mObjectCacheFile = NULL; } } -// static -void LLViewerStatsRecorder::initClass() -{ - sInstance = new LLViewerStatsRecorder(); -} - -// static -void LLViewerStatsRecorder::cleanupClass() -{ - delete sInstance; - sInstance = NULL; -} - - -void LLViewerStatsRecorder::initStatsRecorder(LLViewerRegion *regionp) +void LLViewerStatsRecorder::beginObjectUpdateEvents(F32 interval) { + mSnapshotInterval = interval; if (mObjectCacheFile == NULL) { - mStartTime = LLTimer::getTotalTime(); + mStartTime = LLTimer::getTotalSeconds(); mObjectCacheFile = LLFile::fopen(STATS_FILE_NAME, "wb"); if (mObjectCacheFile) { // Write column headers std::ostringstream data_msg; - data_msg << "EventTime, " - << "ProcessingTime, " - << "CacheHits, " - << "CacheFullMisses, " - << "CacheCrcMisses, " - << "FullUpdates, " - << "TerseUpdates, " - << "CacheMissRequests, " - << "CacheMissResponses, " - << "CacheUpdateDupes, " - << "CacheUpdateChanges, " - << "CacheUpdateAdds, " - << "CacheUpdateReplacements, " - << "UpdateFailures" + data_msg << "EventTime(ms), " + << "Processing Time(ms), " + << "Cache Hits, " + << "Cache Full Misses, " + << "Cache Crc Misses, " + << "Full Updates, " + << "Terse Updates, " + << "Cache Miss Requests, " + << "Cache Miss Responses, " + << "Cache Update Dupes, " + << "Cache Update Changes, " + << "Cache Update Adds, " + << "Cache Update Replacements, " + << "Update Failures, " + << "Cache Hits bps, " + << "Cache Full Misses bps, " + << "Cache Crc Misses bps, " + << "Full Updates bps, " + << "Terse Updates bps, " + << "Cache Miss Responses bps, " << "\n"; fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); } } -} - -void LLViewerStatsRecorder::beginObjectUpdateEvents(LLViewerRegion *regionp) -{ - initStatsRecorder(regionp); - mRegionp = regionp; - mProcessingTime = LLTimer::getTotalTime(); - clearStats(); + mProcessingStartTime = LLTimer::getTotalSeconds(); } void LLViewerStatsRecorder::clearStats() { mObjectCacheHitCount = 0; + mObjectCacheHitSize = 0; mObjectCacheMissFullCount = 0; + mObjectCacheMissFullSize = 0; mObjectCacheMissCrcCount = 0; + mObjectCacheMissCrcSize = 0; mObjectFullUpdates = 0; + mObjectFullUpdatesSize = 0; mObjectTerseUpdates = 0; + mObjectTerseUpdatesSize = 0; mObjectCacheMissRequests = 0; mObjectCacheMissResponses = 0; + mObjectCacheMissResponsesSize = 0; mObjectCacheUpdateDupes = 0; mObjectCacheUpdateChanges = 0; mObjectCacheUpdateAdds = 0; mObjectCacheUpdateReplacements = 0; mObjectUpdateFailures = 0; + mObjectUpdateFailuresSize = 0; } -void LLViewerStatsRecorder::recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type) +void LLViewerStatsRecorder::recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type, S32 msg_size) { mObjectUpdateFailures++; + mObjectUpdateFailuresSize += msg_size; } -void LLViewerStatsRecorder::recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type) +void LLViewerStatsRecorder::recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type, S32 msg_size) { if (LLViewerRegion::CACHE_MISS_TYPE_FULL == cache_miss_type) { mObjectCacheMissFullCount++; + mObjectCacheMissFullSize += msg_size; } else { mObjectCacheMissCrcCount++; + mObjectCacheMissCrcSize += msg_size; } } -void LLViewerStatsRecorder::recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp) +void LLViewerStatsRecorder::recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp, S32 msg_size) { switch (update_type) { case OUT_FULL: mObjectFullUpdates++; + mObjectFullUpdatesSize += msg_size; break; case OUT_TERSE_IMPROVED: mObjectTerseUpdates++; + mObjectTerseUpdatesSize += msg_size; break; case OUT_FULL_COMPRESSED: mObjectCacheMissResponses++; + mObjectCacheMissResponsesSize += msg_size; break; case OUT_FULL_CACHED: mObjectCacheHitCount++; + mObjectCacheHitSize += msg_size; break; default: llwarns << "Unknown update_type" << llendl; @@ -174,7 +177,7 @@ void LLViewerStatsRecorder::recordObjectUpdateEvent(U32 local_id, const EObjectU }; } -void LLViewerStatsRecorder::recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp) +void LLViewerStatsRecorder::recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp, S32 msg_size) { switch (update_result) { @@ -203,53 +206,72 @@ void LLViewerStatsRecorder::recordRequestCacheMissesEvent(S32 count) void LLViewerStatsRecorder::endObjectUpdateEvents() { - llinfos << "ILX: " - << mObjectCacheHitCount << " hits, " - << mObjectCacheMissFullCount << " full misses, " - << mObjectCacheMissCrcCount << " crc misses, " - << mObjectFullUpdates << " full updates, " - << mObjectTerseUpdates << " terse updates, " - << mObjectCacheMissRequests << " cache miss requests, " - << mObjectCacheMissResponses << " cache miss responses, " - << mObjectCacheUpdateDupes << " cache update dupes, " - << mObjectCacheUpdateChanges << " cache update changes, " - << mObjectCacheUpdateAdds << " cache update adds, " - << mObjectCacheUpdateReplacements << " cache update replacements, " - << mObjectUpdateFailures << " update failures" - << llendl; + mProcessingTotalTime += LLTimer::getTotalSeconds() - mProcessingStartTime; + takeSnapshot(); +} - S32 total_objects = mObjectCacheHitCount + mObjectCacheMissCrcCount + mObjectCacheMissFullCount + mObjectFullUpdates + mObjectTerseUpdates + mObjectCacheMissRequests + mObjectCacheMissResponses + mObjectCacheUpdateDupes + mObjectCacheUpdateChanges + mObjectCacheUpdateAdds + mObjectCacheUpdateReplacements + mObjectUpdateFailures; - if (mObjectCacheFile != NULL && - total_objects > 0) +void LLViewerStatsRecorder::takeSnapshot() +{ + F64 delta_time = LLTimer::getTotalSeconds() - mLastSnapshotTime; + if ( delta_time > mSnapshotInterval) { - std::ostringstream data_msg; - F32 processing32 = (F32) ((LLTimer::getTotalTime() - mProcessingTime) / 1000.0); + mLastSnapshotTime = LLTimer::getTotalSeconds(); + llinfos << "ILX: " + << mObjectCacheHitCount << " hits, " + << mObjectCacheMissFullCount << " full misses, " + << mObjectCacheMissCrcCount << " crc misses, " + << mObjectFullUpdates << " full updates, " + << mObjectTerseUpdates << " terse updates, " + << mObjectCacheMissRequests << " cache miss requests, " + << mObjectCacheMissResponses << " cache miss responses, " + << mObjectCacheUpdateDupes << " cache update dupes, " + << mObjectCacheUpdateChanges << " cache update changes, " + << mObjectCacheUpdateAdds << " cache update adds, " + << mObjectCacheUpdateReplacements << " cache update replacements, " + << mObjectUpdateFailures << " update failures" + << llendl; - data_msg << getTimeSinceStart() - << ", " << processing32 - << ", " << mObjectCacheHitCount - << ", " << mObjectCacheMissFullCount - << ", " << mObjectCacheMissCrcCount - << ", " << mObjectFullUpdates - << ", " << mObjectTerseUpdates - << ", " << mObjectCacheMissRequests - << ", " << mObjectCacheMissResponses - << ", " << mObjectCacheUpdateDupes - << ", " << mObjectCacheUpdateChanges - << ", " << mObjectCacheUpdateAdds - << ", " << mObjectCacheUpdateReplacements - << ", " << mObjectUpdateFailures - << "\n"; + S32 total_objects = mObjectCacheHitCount + mObjectCacheMissCrcCount + mObjectCacheMissFullCount + mObjectFullUpdates + mObjectTerseUpdates + mObjectCacheMissRequests + mObjectCacheMissResponses + mObjectCacheUpdateDupes + mObjectCacheUpdateChanges + mObjectCacheUpdateAdds + mObjectCacheUpdateReplacements + mObjectUpdateFailures; + if (mObjectCacheFile != NULL && + total_objects > 0) + { + std::ostringstream data_msg; - fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); - } + F32 processing32 = (F32) mProcessingTotalTime; + mProcessingTotalTime = 0.0; - clearStats(); + data_msg << getTimeSinceStart() + << ", " << processing32 + << ", " << mObjectCacheHitCount + << ", " << mObjectCacheMissFullCount + << ", " << mObjectCacheMissCrcCount + << ", " << mObjectFullUpdates + << ", " << mObjectTerseUpdates + << ", " << mObjectCacheMissRequests + << ", " << mObjectCacheMissResponses + << ", " << mObjectCacheUpdateDupes + << ", " << mObjectCacheUpdateChanges + << ", " << mObjectCacheUpdateAdds + << ", " << mObjectCacheUpdateReplacements + << ", " << mObjectUpdateFailures + << ", " << (mObjectCacheHitSize * 8 / delta_time) + << ", " << (mObjectCacheMissFullSize * 8 / delta_time) + << ", " << (mObjectCacheMissCrcSize * 8 / delta_time) + << ", " << (mObjectFullUpdatesSize * 8 / delta_time) + << ", " << (mObjectTerseUpdatesSize * 8 / delta_time) + << ", " << (mObjectCacheMissResponsesSize * 8 / delta_time) + << "\n"; + + fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); + } + + clearStats(); + } } F32 LLViewerStatsRecorder::getTimeSinceStart() { - return (F32) ((LLTimer::getTotalTime() - mStartTime) / 1000.0); + return (F32) (LLTimer::getTotalSeconds() - mStartTime); } #endif diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h index 612ac380f7..09530b13eb 100644 --- a/indra/newview/llviewerstatsrecorder.h +++ b/indra/newview/llviewerstatsrecorder.h @@ -32,7 +32,7 @@ // for analysis. // This is normally 0. Set to 1 to enable viewer stats recording -#define LL_RECORD_VIEWER_STATS 0 +#define LL_RECORD_VIEWER_STATS 1 #if LL_RECORD_VIEWER_STATS @@ -41,52 +41,59 @@ #include "llviewerregion.h" class LLMutex; -class LLViewerRegion; class LLViewerObject; -class LLViewerStatsRecorder +class LLViewerStatsRecorder : public LLSingleton<LLViewerStatsRecorder> { public: + LOG_CLASS(LLViewerStatsRecorder); LLViewerStatsRecorder(); ~LLViewerStatsRecorder(); - static void initClass(); - static void cleanupClass(); - static LLViewerStatsRecorder* instance() {return sInstance; } + void beginObjectUpdateEvents(F32 interval); - void initStatsRecorder(LLViewerRegion *regionp); - - void beginObjectUpdateEvents(LLViewerRegion *regionp); - void recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type); - void recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type); - void recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp); - void recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp); + void recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type, S32 msg_size); + void recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type, S32 msg_size); + void recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp, S32 msg_size); + void recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp, S32 msg_size); void recordRequestCacheMissesEvent(S32 count); + void endObjectUpdateEvents(); F32 getTimeSinceStart(); private: + void takeSnapshot(); + static LLViewerStatsRecorder* sInstance; LLFILE * mObjectCacheFile; // File to write data into LLFrameTimer mTimer; - LLViewerRegion* mRegionp; F64 mStartTime; - F64 mProcessingTime; + F64 mProcessingStartTime; + F64 mProcessingTotalTime; + F64 mSnapshotInterval; + F64 mLastSnapshotTime; S32 mObjectCacheHitCount; + S32 mObjectCacheHitSize; S32 mObjectCacheMissFullCount; + S32 mObjectCacheMissFullSize; S32 mObjectCacheMissCrcCount; + S32 mObjectCacheMissCrcSize; S32 mObjectFullUpdates; + S32 mObjectFullUpdatesSize; S32 mObjectTerseUpdates; + S32 mObjectTerseUpdatesSize; S32 mObjectCacheMissRequests; S32 mObjectCacheMissResponses; + S32 mObjectCacheMissResponsesSize; S32 mObjectCacheUpdateDupes; S32 mObjectCacheUpdateChanges; S32 mObjectCacheUpdateAdds; S32 mObjectCacheUpdateReplacements; S32 mObjectUpdateFailures; + S32 mObjectUpdateFailuresSize; void clearStats(); -- cgit v1.2.3 From 5564fcb271d993b1b8a98fae7f832f47f1236fd4 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 16 Jul 2012 19:15:46 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages clean up of llstats stuff --- indra/llcommon/llfasttimer_class.cpp | 46 +- indra/llcommon/llfasttimer_class.h | 18 - indra/llcommon/llstat.cpp | 713 +----------------------------- indra/llcommon/llstat.h | 222 ---------- indra/llmessage/llcircuit.cpp | 2 - indra/llmessage/llcircuit.h | 3 - indra/llmessage/lliohttpserver.cpp | 13 +- indra/llmessage/llmessagetemplate.h | 2 +- indra/llmessage/llpumpio.cpp | 3 +- indra/newview/app_settings/logcontrol.xml | 18 - indra/newview/llfasttimerview.cpp | 12 - indra/newview/llfasttimerview.h | 1 - indra/newview/lltexturefetch.cpp | 9 + indra/newview/llviewerobjectlist.cpp | 37 +- indra/newview/llviewerregion.cpp | 7 +- indra/newview/llviewerstats.cpp | 89 ++-- indra/newview/llviewerstats.h | 3 +- indra/newview/llviewerstatsrecorder.cpp | 179 ++++---- indra/newview/llviewerstatsrecorder.h | 67 ++- 19 files changed, 230 insertions(+), 1214 deletions(-) diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp index 463f558c2c..449074dbfe 100644 --- a/indra/llcommon/llfasttimer_class.cpp +++ b/indra/llcommon/llfasttimer_class.cpp @@ -73,9 +73,6 @@ U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution #endif std::vector<LLFastTimer::FrameState>* LLFastTimer::sTimerInfos = NULL; -U64 LLFastTimer::sTimerCycles = 0; -U32 LLFastTimer::sTimerCalls = 0; - // FIXME: move these declarations to the relevant modules @@ -425,8 +422,8 @@ void LLFastTimer::NamedTimer::buildHierarchy() { // since ancestors have already been visited, reparenting won't affect tree traversal //step up tree, bringing our descendants with us - //llinfos << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << - // " to child of " << timerp->getParent()->getParent()->getName() << llendl; + LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << + " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); timerp->getFrameState().mMoveUpTree = false; @@ -507,12 +504,12 @@ void LLFastTimer::NamedTimer::resetFrame() static S32 call_count = 0; if (call_count % 100 == 0) { - llinfos << "countsPerSecond (32 bit): " << countsPerSecond() << llendl; - llinfos << "get_clock_count (64 bit): " << get_clock_count() << llendl; - llinfos << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << llendl; - llinfos << "getCPUClockCount32() " << getCPUClockCount32() << llendl; - llinfos << "getCPUClockCount64() " << getCPUClockCount64() << llendl; - llinfos << "elapsed sec " << ((F64)getCPUClockCount64())/((F64)LLProcessorInfo().getCPUFrequency()*1000000.0) << llendl; + LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL; + LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << llendl; + LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; + LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64())/((F64)LLProcessorInfo().getCPUFrequency()*1000000.0) << LL_ENDL; } call_count++; @@ -566,26 +563,21 @@ void LLFastTimer::NamedTimer::resetFrame() DeclareTimer::updateCachedPointers(); // reset for next frame + for (instance_iter it = beginInstances(); it != endInstances(); ++it) { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - NamedTimer& timer = *it; + NamedTimer& timer = *it; - FrameState& info = timer.getFrameState(); - info.mSelfTimeCounter = 0; - info.mCalls = 0; - info.mLastCaller = NULL; - info.mMoveUpTree = false; - // update parent pointer in timer state struct - if (timer.mParent) - { - info.mParent = &timer.mParent->getFrameState(); - } + FrameState& info = timer.getFrameState(); + info.mSelfTimeCounter = 0; + info.mCalls = 0; + info.mLastCaller = NULL; + info.mMoveUpTree = false; + // update parent pointer in timer state struct + if (timer.mParent) + { + info.mParent = &timer.mParent->getFrameState(); } } - - //sTimerCycles = 0; - //sTimerCalls = 0; } //static diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index f481e968a6..8a12aa1372 100644 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -30,7 +30,6 @@ #include "llinstancetracker.h" #define FAST_TIMER_ON 1 -#define TIME_FAST_TIMERS 0 #define DEBUG_FAST_TIMER_THREADS 1 class LLMutex; @@ -157,9 +156,6 @@ public: LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) : mFrameState(timer.mFrameState) { -#if TIME_FAST_TIMERS - U64 timer_start = getCPUClockCount64(); -#endif #if FAST_TIMER_ON LLFastTimer::FrameState* frame_state = mFrameState; mStartTime = getCPUClockCount32(); @@ -175,10 +171,6 @@ public: cur_timer_data->mFrameState = frame_state; cur_timer_data->mChildTime = 0; #endif -#if TIME_FAST_TIMERS - U64 timer_end = getCPUClockCount64(); - sTimerCycles += timer_end - timer_start; -#endif #if DEBUG_FAST_TIMER_THREADS #if !LL_RELEASE assert_main_thread(); @@ -188,9 +180,6 @@ public: LL_FORCE_INLINE ~LLFastTimer() { -#if TIME_FAST_TIMERS - U64 timer_start = getCPUClockCount64(); -#endif #if FAST_TIMER_ON LLFastTimer::FrameState* frame_state = mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; @@ -206,11 +195,6 @@ public: mLastTimerData.mChildTime += total_time; LLFastTimer::sCurTimerData = mLastTimerData; -#endif -#if TIME_FAST_TIMERS - U64 timer_end = getCPUClockCount64(); - sTimerCycles += timer_end - timer_start; - sTimerCalls++; #endif } @@ -222,8 +206,6 @@ public: static std::string sLogName; static bool sPauseHistory; static bool sResetHistory; - static U64 sTimerCycles; - static U32 sTimerCalls; typedef std::vector<FrameState> info_list_t; static info_list_t& getFrameStateList(); diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 057257057f..5cf5ae3c12 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -37,715 +37,8 @@ // statics -S32 LLPerfBlock::sStatsFlags = LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS; // Control what is being recorded -LLPerfBlock::stat_map_t LLPerfBlock::sStatMap; // Map full path string to LLStatTime objects, tracks all active objects -std::string LLPerfBlock::sCurrentStatPath = ""; // Something like "/total_time/physics/physics step" LLStat::stat_map_t LLStat::sStatList; - //------------------------------------------------------------------------ -// Live config file to trigger stats logging -static const char STATS_CONFIG_FILE_NAME[] = "/dev/shm/simperf/simperf_proc_config.llsd"; -static const F32 STATS_CONFIG_REFRESH_RATE = 5.0; // seconds - -class LLStatsConfigFile : public LLLiveFile -{ -public: - LLStatsConfigFile() - : LLLiveFile(filename(), STATS_CONFIG_REFRESH_RATE), - mChanged(false), mStatsp(NULL) { } - - static std::string filename(); - -protected: - /* virtual */ bool loadFile(); - -public: - void init(LLPerfStats* statsp); - static LLStatsConfigFile& instance(); - // return the singleton stats config file - - bool mChanged; - -protected: - LLPerfStats* mStatsp; -}; - -std::string LLStatsConfigFile::filename() -{ - return STATS_CONFIG_FILE_NAME; -} - -void LLStatsConfigFile::init(LLPerfStats* statsp) -{ - mStatsp = statsp; -} - -LLStatsConfigFile& LLStatsConfigFile::instance() -{ - static LLStatsConfigFile the_file; - return the_file; -} - - -/* virtual */ -// Load and parse the stats configuration file -bool LLStatsConfigFile::loadFile() -{ - if (!mStatsp) - { - llwarns << "Tries to load performance configure file without initializing LPerfStats" << llendl; - return false; - } - mChanged = true; - - LLSD stats_config; - { - llifstream file(filename().c_str()); - if (file.is_open()) - { - LLSDSerialize::fromXML(stats_config, file); - if (stats_config.isUndefined()) - { - llinfos << "Performance statistics configuration file ill-formed, not recording statistics" << llendl; - mStatsp->setReportPerformanceDuration( 0.f ); - return false; - } - } - else - { // File went away, turn off stats if it was on - if ( mStatsp->frameStatsIsRunning() ) - { - llinfos << "Performance statistics configuration file deleted, not recording statistics" << llendl; - mStatsp->setReportPerformanceDuration( 0.f ); - } - return true; - } - } - - F32 duration = 0.f; - F32 interval = 0.f; - S32 flags = LLPerfBlock::LLSTATS_BASIC_STATS; - - const char * w = "duration"; - if (stats_config.has(w)) - { - duration = (F32)stats_config[w].asReal(); - } - w = "interval"; - if (stats_config.has(w)) - { - interval = (F32)stats_config[w].asReal(); - } - w = "flags"; - if (stats_config.has(w)) - { - flags = (S32)stats_config[w].asInteger(); - if (flags == LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS && - duration > 0) - { // No flags passed in, but have a duration, so reset to basic stats - flags = LLPerfBlock::LLSTATS_BASIC_STATS; - } - } - - mStatsp->setReportPerformanceDuration( duration, flags ); - mStatsp->setReportPerformanceInterval( interval ); - - if ( duration > 0 ) - { - if ( interval == 0.f ) - { - llinfos << "Recording performance stats every frame for " << duration << " sec" << llendl; - } - else - { - llinfos << "Recording performance stats every " << interval << " seconds for " << duration << " seconds" << llendl; - } - } - else - { - llinfos << "Performance stats recording turned off" << llendl; - } - return true; -} - - -//------------------------------------------------------------------------ - -LLPerfStats::LLPerfStats(const std::string& process_name, S32 process_pid) : - mFrameStatsFileFailure(FALSE), - mSkipFirstFrameStats(FALSE), - mProcessName(process_name), - mProcessPID(process_pid), - mReportPerformanceStatInterval(1.f), - mReportPerformanceStatEnd(0.0) -{ } - -LLPerfStats::~LLPerfStats() -{ - LLPerfBlock::clearDynamicStats(); - mFrameStatsFile.close(); -} - -void LLPerfStats::init() -{ - // Initialize the stats config file instance. - (void) LLStatsConfigFile::instance().init(this); - (void) LLStatsConfigFile::instance().checkAndReload(); -} - -// Open file for statistics -void LLPerfStats::openPerfStatsFile() -{ - if ( !mFrameStatsFile - && !mFrameStatsFileFailure ) - { - std::string stats_file = llformat("/dev/shm/simperf/%s_proc.%d.llsd", mProcessName.c_str(), mProcessPID); - mFrameStatsFile.close(); - mFrameStatsFile.clear(); - mFrameStatsFile.open(stats_file, llofstream::out); - if ( mFrameStatsFile.fail() ) - { - llinfos << "Error opening statistics log file " << stats_file << llendl; - mFrameStatsFileFailure = TRUE; - } - else - { - LLSD process_info = LLSD::emptyMap(); - process_info["name"] = mProcessName; - process_info["pid"] = (LLSD::Integer) mProcessPID; - process_info["stat_rate"] = (LLSD::Integer) mReportPerformanceStatInterval; - // Add process-specific info. - addProcessHeaderInfo(process_info); - - mFrameStatsFile << LLSDNotationStreamer(process_info) << std::endl; - } - } -} - -// Dump out performance metrics over some time interval -void LLPerfStats::dumpIntervalPerformanceStats() -{ - // Ensure output file is OK - openPerfStatsFile(); - - if ( mFrameStatsFile ) - { - LLSD stats = LLSD::emptyMap(); - - LLStatAccum::TimeScale scale; - if ( getReportPerformanceInterval() == 0.f ) - { - scale = LLStatAccum::SCALE_PER_FRAME; - } - else if ( getReportPerformanceInterval() < 0.5f ) - { - scale = LLStatAccum::SCALE_100MS; - } - else - { - scale = LLStatAccum::SCALE_SECOND; - } - - // Write LLSD into log - stats["utc_time"] = (LLSD::String) LLError::utcTime(); - stats["timestamp"] = U64_to_str((totalTime() / 1000) + (gUTCOffset * 1000)); // milliseconds since epoch - stats["frame_number"] = (LLSD::Integer) LLFrameTimer::getFrameCount(); - - // Add process-specific frame info. - addProcessFrameInfo(stats, scale); - LLPerfBlock::addStatsToLLSDandReset( stats, scale ); - - mFrameStatsFile << LLSDNotationStreamer(stats) << std::endl; - } -} - -// Set length of performance stat recording. -// If turning stats on, caller must provide flags -void LLPerfStats::setReportPerformanceDuration( F32 seconds, S32 flags /* = LLSTATS_NO_OPTIONAL_STATS */ ) -{ - if ( seconds <= 0.f ) - { - mReportPerformanceStatEnd = 0.0; - LLPerfBlock::setStatsFlags(LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS); // Make sure all recording is off - mFrameStatsFile.close(); - LLPerfBlock::clearDynamicStats(); - } - else - { - mReportPerformanceStatEnd = LLFrameTimer::getElapsedSeconds() + ((F64) seconds); - // Clear failure flag to try and create the log file once - mFrameStatsFileFailure = FALSE; - mSkipFirstFrameStats = TRUE; // Skip the first report (at the end of this frame) - LLPerfBlock::setStatsFlags(flags); - } -} - -void LLPerfStats::updatePerFrameStats() -{ - (void) LLStatsConfigFile::instance().checkAndReload(); - static LLFrameTimer performance_stats_timer; - if ( frameStatsIsRunning() ) - { - if ( mReportPerformanceStatInterval == 0 ) - { // Record info every frame - if ( mSkipFirstFrameStats ) - { // Skip the first time - was started this frame - mSkipFirstFrameStats = FALSE; - } - else - { - dumpIntervalPerformanceStats(); - } - } - else - { - performance_stats_timer.setTimerExpirySec( getReportPerformanceInterval() ); - if (performance_stats_timer.checkExpirationAndReset( mReportPerformanceStatInterval )) - { - dumpIntervalPerformanceStats(); - } - } - - if ( LLFrameTimer::getElapsedSeconds() > mReportPerformanceStatEnd ) - { // Reached end of time, clear it to stop reporting - setReportPerformanceDuration(0.f); // Don't set mReportPerformanceStatEnd directly - llinfos << "Recording performance stats completed" << llendl; - } - } -} - - -//------------------------------------------------------------------------ - -U64 LLStatAccum::sScaleTimes[NUM_SCALES] = -{ - USEC_PER_SEC / 10, // 100 millisec - USEC_PER_SEC * 1, // seconds - USEC_PER_SEC * 60, // minutes -#if ENABLE_LONG_TIME_STATS - // enable these when more time scales are desired - USEC_PER_SEC * 60*60, // hours - USEC_PER_SEC * 24*60*60, // days - USEC_PER_SEC * 7*24*60*60, // weeks -#endif -}; - - - -LLStatAccum::LLStatAccum(bool useFrameTimer) - : mUseFrameTimer(useFrameTimer), - mRunning(FALSE), - mLastTime(0), - mLastSampleValue(0.0), - mLastSampleValid(FALSE) -{ -} - -LLStatAccum::~LLStatAccum() -{ -} - - - -void LLStatAccum::reset(U64 when) -{ - mRunning = TRUE; - mLastTime = when; - - for (int i = 0; i < NUM_SCALES; ++i) - { - mBuckets[i].accum = 0.0; - mBuckets[i].endTime = when + sScaleTimes[i]; - mBuckets[i].lastValid = false; - } -} - -void LLStatAccum::sum(F64 value) -{ - sum(value, getCurrentUsecs()); -} - -void LLStatAccum::sum(F64 value, U64 when) -{ - if (!mRunning) - { - reset(when); - return; - } - if (when < mLastTime) - { - // This happens a LOT on some dual core systems. - lldebugs << "LLStatAccum::sum clock has gone backwards from " - << mLastTime << " to " << when << ", resetting" << llendl; - - reset(when); - return; - } - - // how long is this value for - U64 timeSpan = when - mLastTime; - - for (int i = 0; i < NUM_SCALES; ++i) - { - Bucket& bucket = mBuckets[i]; - - if (when < bucket.endTime) - { - bucket.accum += value; - } - else - { - U64 timeScale = sScaleTimes[i]; - - U64 timeLeft = when - bucket.endTime; - // how much time is left after filling this bucket - - if (timeLeft < timeScale) - { - F64 valueLeft = value * timeLeft / timeSpan; - - bucket.lastValid = true; - bucket.lastAccum = bucket.accum + (value - valueLeft); - bucket.accum = valueLeft; - bucket.endTime += timeScale; - } - else - { - U64 timeTail = timeLeft % timeScale; - - bucket.lastValid = true; - bucket.lastAccum = value * timeScale / timeSpan; - bucket.accum = value * timeTail / timeSpan; - bucket.endTime += (timeLeft - timeTail) + timeScale; - } - } - } - - mLastTime = when; -} - - -F32 LLStatAccum::meanValue(TimeScale scale) const -{ - if (!mRunning) - { - return 0.0; - } - if ( scale == SCALE_PER_FRAME ) - { // Per-frame not supported here - scale = SCALE_100MS; - } - - if (scale < 0 || scale >= NUM_SCALES) - { - llwarns << "llStatAccum::meanValue called for unsupported scale: " - << scale << llendl; - return 0.0; - } - - const Bucket& bucket = mBuckets[scale]; - - F64 value = bucket.accum; - U64 timeLeft = bucket.endTime - mLastTime; - U64 scaleTime = sScaleTimes[scale]; - - if (bucket.lastValid) - { - value += bucket.lastAccum * timeLeft / scaleTime; - } - else if (timeLeft < scaleTime) - { - value *= scaleTime / (scaleTime - timeLeft); - } - else - { - value = 0.0; - } - - return (F32)(value / scaleTime); -} - - -U64 LLStatAccum::getCurrentUsecs() const -{ - if (mUseFrameTimer) - { - return LLFrameTimer::getTotalTime(); - } - else - { - return totalTime(); - } -} - - -// ------------------------------------------------------------------------ - -LLStatRate::LLStatRate(bool use_frame_timer) - : LLStatAccum(use_frame_timer) -{ -} - -void LLStatRate::count(U32 value) -{ - sum((F64)value * sScaleTimes[SCALE_SECOND]); -} - - -void LLStatRate::mark() - { - // Effectively the same as count(1), but sets mLastSampleValue - U64 when = getCurrentUsecs(); - - if ( mRunning - && (when > mLastTime) ) - { // Set mLastSampleValue to the time from the last mark() - F64 duration = ((F64)(when - mLastTime)) / sScaleTimes[SCALE_SECOND]; - if ( duration > 0.0 ) - { - mLastSampleValue = 1.0 / duration; - } - else - { - mLastSampleValue = 0.0; - } - } - - sum( (F64) sScaleTimes[SCALE_SECOND], when); - } - - -// ------------------------------------------------------------------------ - - -LLStatMeasure::LLStatMeasure(bool use_frame_timer) - : LLStatAccum(use_frame_timer) -{ -} - -void LLStatMeasure::sample(F64 value) -{ - U64 when = getCurrentUsecs(); - - if (mLastSampleValid) - { - F64 avgValue = (value + mLastSampleValue) / 2.0; - F64 interval = (F64)(when - mLastTime); - - sum(avgValue * interval, when); - } - else - { - reset(when); - } - - mLastSampleValid = TRUE; - mLastSampleValue = value; -} - - -// ------------------------------------------------------------------------ - -LLStatTime::LLStatTime(const std::string & key) - : LLStatAccum(false), - mFrameNumber(LLFrameTimer::getFrameCount()), - mTotalTimeInFrame(0), - mKey(key) -#if LL_DEBUG - , mRunning(FALSE) -#endif -{ -} - -void LLStatTime::start() -{ - // Reset frame accumluation if the frame number has changed - U32 frame_number = LLFrameTimer::getFrameCount(); - if ( frame_number != mFrameNumber ) - { - mFrameNumber = frame_number; - mTotalTimeInFrame = 0; - } - - sum(0.0); - -#if LL_DEBUG - // Shouldn't be running already - llassert( !mRunning ); - mRunning = TRUE; -#endif -} - -void LLStatTime::stop() -{ - U64 end_time = getCurrentUsecs(); - U64 duration = end_time - mLastTime; - sum(F64(duration), end_time); - //llinfos << "mTotalTimeInFrame incremented from " << mTotalTimeInFrame << " to " << (mTotalTimeInFrame + duration) << llendl; - mTotalTimeInFrame += duration; - -#if LL_DEBUG - mRunning = FALSE; -#endif -} - -/* virtual */ F32 LLStatTime::meanValue(TimeScale scale) const -{ - if ( LLStatAccum::SCALE_PER_FRAME == scale ) - { - return (F32)mTotalTimeInFrame; - } - else - { - return LLStatAccum::meanValue(scale); - } -} - - -// ------------------------------------------------------------------------ - - -// Use this constructor for pre-defined LLStatTime objects -LLPerfBlock::LLPerfBlock(LLStatTime* stat ) : mPredefinedStat(stat), mDynamicStat(NULL) -{ - if (mPredefinedStat) - { - // If dynamic stats are turned on, this will create a separate entry in the stat map. - initDynamicStat(mPredefinedStat->mKey); - - // Start predefined stats. These stats are not part of the stat map. - mPredefinedStat->start(); - } -} - -// Use this constructor for normal, optional LLPerfBlock time slices -LLPerfBlock::LLPerfBlock( const char* key ) : mPredefinedStat(NULL), mDynamicStat(NULL) -{ - if ((sStatsFlags & LLSTATS_BASIC_STATS) == 0) - { // These are off unless the base set is enabled - return; - } - - initDynamicStat(key); -} - - -// Use this constructor for dynamically created LLPerfBlock time slices -// that are only enabled by specific control flags -LLPerfBlock::LLPerfBlock( const char* key1, const char* key2, S32 flags ) : mPredefinedStat(NULL), mDynamicStat(NULL) -{ - if ((sStatsFlags & flags) == 0) - { - return; - } - - if (NULL == key2 || strlen(key2) == 0) - { - initDynamicStat(key1); - } - else - { - std::ostringstream key; - key << key1 << "_" << key2; - initDynamicStat(key.str()); - } -} - -// Set up the result data map if dynamic stats are enabled -void LLPerfBlock::initDynamicStat(const std::string& key) -{ - // Early exit if dynamic stats aren't enabled. - if (sStatsFlags == LLSTATS_NO_OPTIONAL_STATS) - return; - - mLastPath = sCurrentStatPath; // Save and restore current path - sCurrentStatPath += "/" + key; // Add key to current path - - // See if the LLStatTime object already exists - stat_map_t::iterator iter = sStatMap.find(sCurrentStatPath); - if ( iter == sStatMap.end() ) - { - // StatEntry object doesn't exist, so create it - mDynamicStat = new StatEntry( key ); - sStatMap[ sCurrentStatPath ] = mDynamicStat; // Set the entry for this path - } - else - { - // Found this path in the map, use the object there - mDynamicStat = (*iter).second; // Get StatEntry for the current path - } - - if (mDynamicStat) - { - mDynamicStat->mStat.start(); - mDynamicStat->mCount++; - } - else - { - llwarns << "Initialized NULL dynamic stat at '" << sCurrentStatPath << "'" << llendl; - sCurrentStatPath = mLastPath; - } -} - - -// Destructor does the time accounting -LLPerfBlock::~LLPerfBlock() -{ - if (mPredefinedStat) mPredefinedStat->stop(); - if (mDynamicStat) - { - mDynamicStat->mStat.stop(); - sCurrentStatPath = mLastPath; // Restore the path in case sStatsEnabled changed during this block - } -} - - -// Clear the map of any dynamic stats. Static routine -void LLPerfBlock::clearDynamicStats() -{ - std::for_each(sStatMap.begin(), sStatMap.end(), DeletePairedPointer()); - sStatMap.clear(); -} - -// static - Extract the stat info into LLSD -void LLPerfBlock::addStatsToLLSDandReset( LLSD & stats, - LLStatAccum::TimeScale scale ) -{ - // If we aren't in per-frame scale, we need to go from second to microsecond. - U32 scale_adjustment = 1; - if (LLStatAccum::SCALE_PER_FRAME != scale) - { - scale_adjustment = USEC_PER_SEC; - } - stat_map_t::iterator iter = sStatMap.begin(); - for ( ; iter != sStatMap.end(); ++iter ) - { // Put the entry into LLSD "/full/path/to/stat/" = microsecond total time - const std::string & stats_full_path = (*iter).first; - - StatEntry * stat = (*iter).second; - if (stat) - { - if (stat->mCount > 0) - { - stats[stats_full_path] = LLSD::emptyMap(); - stats[stats_full_path]["us"] = (LLSD::Integer) (scale_adjustment * stat->mStat.meanValue(scale)); - if (stat->mCount > 1) - { - stats[stats_full_path]["count"] = (LLSD::Integer) stat->mCount; - } - stat->mCount = 0; - } - } - else - { // Shouldn't have a NULL pointer in the map. - llwarns << "Unexpected NULL dynamic stat at '" << stats_full_path << "'" << llendl; - } - } -} - - -// ------------------------------------------------------------------------ - LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; @@ -786,9 +79,9 @@ LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) } LLStat::LLStat(std::string name, U32 num_bins, BOOL use_frame_timer) - : mUseFrameTimer(use_frame_timer), - mNumBins(num_bins), - mName(name) +: mUseFrameTimer(use_frame_timer), + mNumBins(num_bins), + mName(name) { init(); } diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index b877432e86..7718d40ffb 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -36,228 +36,6 @@ class LLSD; -// Set this if longer stats are needed -#define ENABLE_LONG_TIME_STATS 0 - -// -// Accumulates statistics for an arbitrary length of time. -// Does this by maintaining a chain of accumulators, each one -// accumulation the results of the parent. Can scale to arbitrary -// amounts of time with very low memory cost. -// - -class LL_COMMON_API LLStatAccum -{ -protected: - LLStatAccum(bool use_frame_timer); - virtual ~LLStatAccum(); - -public: - enum TimeScale { - SCALE_100MS, - SCALE_SECOND, - SCALE_MINUTE, -#if ENABLE_LONG_TIME_STATS - SCALE_HOUR, - SCALE_DAY, - SCALE_WEEK, -#endif - NUM_SCALES, // Use to size storage arrays - SCALE_PER_FRAME // For latest frame information - should be after NUM_SCALES since this doesn't go into the time buckets - }; - - static U64 sScaleTimes[NUM_SCALES]; - - virtual F32 meanValue(TimeScale scale) const; - // see the subclasses for the specific meaning of value - - F32 meanValueOverLast100ms() const { return meanValue(SCALE_100MS); } - F32 meanValueOverLastSecond() const { return meanValue(SCALE_SECOND); } - F32 meanValueOverLastMinute() const { return meanValue(SCALE_MINUTE); } - - void reset(U64 when); - - void sum(F64 value); - void sum(F64 value, U64 when); - - U64 getCurrentUsecs() const; - // Get current microseconds based on timer type - - BOOL mUseFrameTimer; - BOOL mRunning; - - U64 mLastTime; - - struct Bucket - { - Bucket() : - accum(0.0), - endTime(0), - lastValid(false), - lastAccum(0.0) - {} - - F64 accum; - U64 endTime; - - bool lastValid; - F64 lastAccum; - }; - - Bucket mBuckets[NUM_SCALES]; - - BOOL mLastSampleValid; - F64 mLastSampleValue; -}; - -class LL_COMMON_API LLStatMeasure : public LLStatAccum - // gathers statistics about things that are measured - // ex.: tempature, time dilation -{ -public: - LLStatMeasure(bool use_frame_timer = true); - - void sample(F64); - void sample(S32 v) { sample((F64)v); } - void sample(U32 v) { sample((F64)v); } - void sample(S64 v) { sample((F64)v); } - void sample(U64 v) { sample((F64)v); } -}; - - -class LL_COMMON_API LLStatRate : public LLStatAccum - // gathers statistics about things that can be counted over time - // ex.: LSL instructions executed, messages sent, simulator frames completed - // renders it in terms of rate of thing per second -{ -public: - LLStatRate(bool use_frame_timer = true); - - void count(U32); - // used to note that n items have occured - - void mark(); - // used for counting the rate thorugh a point in the code -}; - - -class LL_COMMON_API LLStatTime : public LLStatAccum - // gathers statistics about time spent in a block of code - // measure average duration per second in the block -{ -public: - LLStatTime( const std::string & key = "undefined" ); - - U32 mFrameNumber; // Current frame number - U64 mTotalTimeInFrame; // Total time (microseconds) accumulated during the last frame - - void setKey( const std::string & key ) { mKey = key; }; - - virtual F32 meanValue(TimeScale scale) const; - -private: - void start(); // Start and stop measuring time block - void stop(); - - std::string mKey; // Tag representing this time block - -#if LL_DEBUG - BOOL mRunning; // TRUE if start() has been called -#endif - - friend class LLPerfBlock; -}; - -// ---------------------------------------------------------------------------- - - -// Use this class on the stack to record statistics about an area of code -class LL_COMMON_API LLPerfBlock -{ -public: - struct StatEntry - { - StatEntry(const std::string& key) : mStat(LLStatTime(key)), mCount(0) {} - LLStatTime mStat; - U32 mCount; - }; - typedef std::map<std::string, StatEntry*> stat_map_t; - - // Use this constructor for pre-defined LLStatTime objects - LLPerfBlock(LLStatTime* stat); - - // Use this constructor for normal, optional LLPerfBlock time slices - LLPerfBlock( const char* key ); - - // Use this constructor for dynamically created LLPerfBlock time slices - // that are only enabled by specific control flags - LLPerfBlock( const char* key1, const char* key2, S32 flags = LLSTATS_BASIC_STATS ); - - ~LLPerfBlock(); - - enum - { // Stats bitfield flags - LLSTATS_NO_OPTIONAL_STATS = 0x00, // No optional stats gathering, just pre-defined LLStatTime objects - LLSTATS_BASIC_STATS = 0x01, // Gather basic optional runtime stats - LLSTATS_SCRIPT_FUNCTIONS = 0x02, // Include LSL function calls - }; - static void setStatsFlags( S32 flags ) { sStatsFlags = flags; }; - static S32 getStatsFlags() { return sStatsFlags; }; - - static void clearDynamicStats(); // Reset maps to clear out dynamic objects - static void addStatsToLLSDandReset( LLSD & stats, // Get current information and clear time bin - LLStatAccum::TimeScale scale ); - -private: - // Initialize dynamically created LLStatTime objects - void initDynamicStat(const std::string& key); - - std::string mLastPath; // Save sCurrentStatPath when this is called - LLStatTime * mPredefinedStat; // LLStatTime object to get data - StatEntry * mDynamicStat; // StatEntryobject to get data - - static S32 sStatsFlags; // Control what is being recorded - static stat_map_t sStatMap; // Map full path string to LLStatTime objects - static std::string sCurrentStatPath; // Something like "frame/physics/physics step" -}; - -// ---------------------------------------------------------------------------- - -class LL_COMMON_API LLPerfStats -{ -public: - LLPerfStats(const std::string& process_name = "unknown", S32 process_pid = 0); - virtual ~LLPerfStats(); - - virtual void init(); // Reset and start all stat timers - virtual void updatePerFrameStats(); - // Override these function to add process-specific information to the performance log header and per-frame logging. - virtual void addProcessHeaderInfo(LLSD& info) { /* not implemented */ } - virtual void addProcessFrameInfo(LLSD& info, LLStatAccum::TimeScale scale) { /* not implemented */ } - - // High-resolution frame stats - BOOL frameStatsIsRunning() { return (mReportPerformanceStatEnd > 0.); }; - F32 getReportPerformanceInterval() const { return mReportPerformanceStatInterval; }; - void setReportPerformanceInterval( F32 interval ) { mReportPerformanceStatInterval = interval; }; - void setReportPerformanceDuration( F32 seconds, S32 flags = LLPerfBlock::LLSTATS_NO_OPTIONAL_STATS ); - void setProcessName(const std::string& process_name) { mProcessName = process_name; } - void setProcessPID(S32 process_pid) { mProcessPID = process_pid; } - -protected: - void openPerfStatsFile(); // Open file for high resolution metrics logging - void dumpIntervalPerformanceStats(); - - llofstream mFrameStatsFile; // File for per-frame stats - BOOL mFrameStatsFileFailure; // Flag to prevent repeat opening attempts - BOOL mSkipFirstFrameStats; // Flag to skip one (partial) frame report - std::string mProcessName; - S32 mProcessPID; - -private: - F32 mReportPerformanceStatInterval; // Seconds between performance stats - F64 mReportPerformanceStatEnd; // End time (seconds) for performance stats -}; - // ---------------------------------------------------------------------------- class LL_COMMON_API LLStat { diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index e0410906fb..0c2d4b823d 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -679,7 +679,6 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) setPacketInID((id + 1) % LL_MAX_OUT_PACKET_ID); mLastPacketGap = 0; - mOutOfOrderRate.count(0); return; } @@ -775,7 +774,6 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) } } - mOutOfOrderRate.count(gap); mLastPacketGap = gap; } diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h index d1c400c6a2..c46fd56acc 100644 --- a/indra/llmessage/llcircuit.h +++ b/indra/llmessage/llcircuit.h @@ -126,8 +126,6 @@ public: S32 getUnackedPacketCount() const { return mUnackedPacketCount; } S32 getUnackedPacketBytes() const { return mUnackedPacketBytes; } F64 getNextPingSendTime() const { return mNextPingSendTime; } - F32 getOutOfOrderRate(LLStatAccum::TimeScale scale = LLStatAccum::SCALE_MINUTE) - { return mOutOfOrderRate.meanValue(scale); } U32 getLastPacketGap() const { return mLastPacketGap; } LLHost getHost() const { return mHost; } F64 getLastPacketInTime() const { return mLastPacketInTime; } @@ -275,7 +273,6 @@ protected: LLTimer mExistenceTimer; // initialized when circuit created, used to track bandwidth numbers S32 mCurrentResendCount; // Number of resent packets since last spam - LLStatRate mOutOfOrderRate; // Rate of out of order packets coming in. U32 mLastPacketGap; // Gap in sequence number of last packet. const F32 mHeartbeatInterval; diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 987f386aa3..74eaf9f025 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -141,6 +141,11 @@ private: }; static LLFastTimer::DeclareTimer FTM_PROCESS_HTTP_PIPE("HTTP Pipe"); +static LLFastTimer::DeclareTimer FTM_PROCESS_HTTP_GET("HTTP Get"); +static LLFastTimer::DeclareTimer FTM_PROCESS_HTTP_PUT("HTTP Put"); +static LLFastTimer::DeclareTimer FTM_PROCESS_HTTP_POST("HTTP Post"); +static LLFastTimer::DeclareTimer FTM_PROCESS_HTTP_DELETE("HTTP Delete"); + LLIOPipe::EStatus LLHTTPPipe::process_impl( const LLChannelDescriptors& channels, buffer_ptr_t& buffer, @@ -177,12 +182,12 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl( std::string verb = context[CONTEXT_REQUEST][CONTEXT_VERB]; if(verb == HTTP_VERB_GET) { - LLPerfBlock getblock("http_get"); + LLFastTimer _(FTM_PROCESS_HTTP_GET); mNode.get(LLHTTPNode::ResponsePtr(mResponse), context); } else if(verb == HTTP_VERB_PUT) { - LLPerfBlock putblock("http_put"); + LLFastTimer _(FTM_PROCESS_HTTP_PUT); LLSD input; if (mNode.getContentType() == LLHTTPNode::CONTENT_TYPE_LLSD) { @@ -198,7 +203,7 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl( } else if(verb == HTTP_VERB_POST) { - LLPerfBlock postblock("http_post"); + LLFastTimer _(FTM_PROCESS_HTTP_POST); LLSD input; if (mNode.getContentType() == LLHTTPNode::CONTENT_TYPE_LLSD) { @@ -214,7 +219,7 @@ LLIOPipe::EStatus LLHTTPPipe::process_impl( } else if(verb == HTTP_VERB_DELETE) { - LLPerfBlock delblock("http_delete"); + LLFastTimer _(FTM_PROCESS_HTTP_DELETE); mNode.del(LLHTTPNode::ResponsePtr(mResponse), context); } else if(verb == HTTP_VERB_OPTIONS) diff --git a/indra/llmessage/llmessagetemplate.h b/indra/llmessage/llmessagetemplate.h index 16d825d33b..a2024166ee 100644 --- a/indra/llmessage/llmessagetemplate.h +++ b/indra/llmessage/llmessagetemplate.h @@ -263,6 +263,7 @@ enum EMsgDeprecation MD_DEPRECATED }; + class LLMessageTemplate { public: @@ -364,7 +365,6 @@ public: { if (mHandlerFunc) { - LLPerfBlock msg_cb_time("msg_cb", mName); mHandlerFunc(msgsystem, mUserData); return TRUE; } diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp index f3ef4f2684..fcb77a23a9 100644 --- a/indra/llmessage/llpumpio.cpp +++ b/indra/llmessage/llpumpio.cpp @@ -441,6 +441,7 @@ void LLPumpIO::pump() } static LLFastTimer::DeclareTimer FTM_PUMP_IO("Pump IO"); +static LLFastTimer::DeclareTimer FTM_PUMP_POLL("Pump Poll"); LLPumpIO::current_chain_t LLPumpIO::removeRunningChain(LLPumpIO::current_chain_t& run_chain) { @@ -536,7 +537,7 @@ void LLPumpIO::pump(const S32& poll_timeout) S32 count = 0; S32 client_id = 0; { - LLPerfBlock polltime("pump_poll"); + LLFastTimer _(FTM_PUMP_POLL); apr_pollset_poll(mPollset, poll_timeout, &count, &poll_fd); } PUMP_DEBUG; diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 8636ba1090..92a241857e 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -48,24 +48,6 @@ --> </array> </map> - <map> - <key>level</key> - <string>NONE</string> - <key>functions</key> - <array> - </array> - <key>classes</key> - <array> - <string>LLViewerStatsRecorder</string> - </array> - <key>files</key> - <array> - </array> - <key>tags</key> - <array> - - </array> - </map> </array> </map> </llsd> diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 9664aa7dbe..c032d5d049 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -95,7 +95,6 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mHoverBarIndex = -1; FTV_NUM_TIMERS = LLFastTimer::NamedTimer::instanceCount(); mPrintStats = -1; - mAverageCyclesPerTimer = 0; } void LLFastTimerView::onPause() @@ -379,12 +378,6 @@ void LLFastTimerView::draw() S32 xleft = margin; S32 ytop = margin; - mAverageCyclesPerTimer = LLFastTimer::sTimerCalls == 0 - ? 0 - : llround(lerp((F32)mAverageCyclesPerTimer, (F32)(LLFastTimer::sTimerCycles / (U64)LLFastTimer::sTimerCalls), 0.1f)); - LLFastTimer::sTimerCycles = 0; - LLFastTimer::sTimerCalls = 0; - // Draw some help { @@ -392,10 +385,6 @@ void LLFastTimerView::draw() y = height - ytop; texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); -#if TIME_FAST_TIMERS - tdesc = llformat("Cycles per timer call: %d", mAverageCyclesPerTimer); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); -#else char modedesc[][32] = { "2 x Average ", "Max ", @@ -419,7 +408,6 @@ void LLFastTimerView::draw() LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); -#endif y -= (texth + 2); } diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index a349e7ad4c..1fda91f173 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -90,7 +90,6 @@ private: S32 mHoverBarIndex; LLFrameTimer mHighlightTimer; S32 mPrintStats; - S32 mAverageCyclesPerTimer; LLRect mGraphRect; }; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 7e6dfbc9d9..143db79eb5 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -50,6 +50,7 @@ #include "llviewertexture.h" #include "llviewerregion.h" #include "llviewerstats.h" +#include "llviewerstatsrecorder.h" #include "llviewerassetstats.h" #include "llworld.h" #include "llsdutil.h" @@ -1703,6 +1704,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels, LL_DEBUGS("Texture") << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL; if (data_size > 0) { + LLViewerStatsRecorder::instance().textureFetch(data_size); // *TODO: set the formatted image data here directly to avoid the copy mBuffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size); buffer->readAfter(channels.in(), NULL, mBuffer, data_size); @@ -1736,6 +1738,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels, mLoaded = TRUE; setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority); + LLViewerStatsRecorder::instance().log(0.2f); return data_size ; } @@ -2639,6 +2642,9 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8 return false; } + LLViewerStatsRecorder::instance().textureFetch(data_size); + LLViewerStatsRecorder::instance().log(0.1f); + worker->lockWorkMutex(); // Copy header data into image object @@ -2685,6 +2691,9 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1 return false; } + LLViewerStatsRecorder::instance().textureFetch(data_size); + LLViewerStatsRecorder::instance().log(0.1f); + worker->lockWorkMutex(); res = worker->insertPacket(packet_num, data, data_size); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index b010ac9aa7..5a23b55fa7 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -347,9 +347,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, LLDataPackerBinaryBuffer compressed_dp(compressed_dpbuffer, 2048); LLDataPacker *cached_dpp = NULL; LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance(); -#if LL_RECORD_VIEWER_STATS - recorder.beginObjectUpdateEvents(1.f); -#endif for (i = 0; i < num_objects; i++) { @@ -380,9 +377,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, else { // Cache Miss. -#if LL_RECORD_VIEWER_STATS - recorder.recordCacheMissEvent(id, update_type, cache_miss_type, msg_size); -#endif + recorder.cacheMissEvent(id, update_type, cache_miss_type, msg_size); continue; // no data packer, skip this object } @@ -509,9 +504,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, if (update_type == OUT_TERSE_IMPROVED) { // llinfos << "terse update for an unknown object (compressed):" << fullid << llendl; - #if LL_RECORD_VIEWER_STATS - recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); - #endif + recorder.objectUpdateFailure(local_id, update_type, msg_size); continue; } } @@ -523,9 +516,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, if (update_type != OUT_FULL) { //llinfos << "terse update for an unknown object:" << fullid << llendl; - #if LL_RECORD_VIEWER_STATS - recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); - #endif + recorder.objectUpdateFailure(local_id, update_type, msg_size); continue; } @@ -538,9 +529,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, { mNumDeadObjectUpdates++; //llinfos << "update for a dead object:" << fullid << llendl; - #if LL_RECORD_VIEWER_STATS - recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); - #endif + recorder.objectUpdateFailure(local_id, update_type, msg_size); continue; } #endif @@ -549,9 +538,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, if (!objectp) { llinfos << "createObject failure for object: " << fullid << llendl; - #if LL_RECORD_VIEWER_STATS - recorder.recordObjectUpdateFailure(local_id, update_type, msg_size); - #endif + recorder.objectUpdateFailure(local_id, update_type, msg_size); continue; } justCreated = TRUE; @@ -577,12 +564,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only? { bCached = true; - #if LL_RECORD_VIEWER_STATS LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp); - recorder.recordCacheFullUpdate(local_id, update_type, result, objectp, msg_size); - #else - objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp); - #endif + recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size); } } else if (cached) // Cache hit only? @@ -598,16 +581,12 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, } processUpdateCore(objectp, user_data, i, update_type, NULL, justCreated); } - #if LL_RECORD_VIEWER_STATS - recorder.recordObjectUpdateEvent(local_id, update_type, objectp, msg_size); - #endif + recorder.objectUpdateEvent(local_id, update_type, objectp, msg_size); objectp->setLastUpdateType(update_type); objectp->setLastUpdateCached(bCached); } -#if LL_RECORD_VIEWER_STATS - recorder.endObjectUpdateEvents(); -#endif + recorder.log(0.2f); LLVOAvatar::cullAvatarsByPixelArea(); } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 0e2927cea4..44377b1f3e 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1317,11 +1317,8 @@ void LLViewerRegion::requestCacheMisses() mCacheDirty = TRUE ; // llinfos << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << llendl; - #if LL_RECORD_VIEWER_STATS - LLViewerStatsRecorder::instance().beginObjectUpdateEvents(1.f); - LLViewerStatsRecorder::instance().recordRequestCacheMissesEvent(full_count + crc_count); - LLViewerStatsRecorder::instance().endObjectUpdateEvents(); - #endif + LLViewerStatsRecorder::instance().requestCacheMissesEvent(full_count + crc_count); + LLViewerStatsRecorder::instance().log(0.2f); } void LLViewerRegion::dumpCache() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 497e95c5e3..c1ccfe3faa 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -323,55 +323,55 @@ void LLViewerStats::updateFrameStats(const F64 time_diff) { if (mPacketsLostPercentStat.getCurrent() > 5.0) { - incStat(LLViewerStats::ST_LOSS_05_SECONDS, time_diff); + incStat(ST_LOSS_05_SECONDS, time_diff); } if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f) { - incStat(LLViewerStats::ST_SIM_FPS_20_SECONDS, time_diff); + incStat(ST_SIM_FPS_20_SECONDS, time_diff); } if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f) { - incStat(LLViewerStats::ST_PHYS_FPS_20_SECONDS, time_diff); + incStat(ST_PHYS_FPS_20_SECONDS, time_diff); } if (time_diff >= 0.5) { - incStat(LLViewerStats::ST_FPS_2_SECONDS, time_diff); + incStat(ST_FPS_2_SECONDS, time_diff); } if (time_diff >= 0.125) { - incStat(LLViewerStats::ST_FPS_8_SECONDS, time_diff); + incStat(ST_FPS_8_SECONDS, time_diff); } if (time_diff >= 0.1) { - incStat(LLViewerStats::ST_FPS_10_SECONDS, time_diff); + incStat(ST_FPS_10_SECONDS, time_diff); } if (gFrameCount && mLastTimeDiff > 0.0) { // new "stutter" meter - setStat(LLViewerStats::ST_FPS_DROP_50_RATIO, - (getStat(LLViewerStats::ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + + setStat(ST_FPS_DROP_50_RATIO, + (getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount); // old stats that were never really used - setStat(LLViewerStats::ST_FRAMETIME_JITTER, - (getStat(LLViewerStats::ST_FRAMETIME_JITTER) * (gFrameCount - 1) + + setStat(ST_FRAMETIME_JITTER, + (getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount); F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount; - setStat(LLViewerStats::ST_FRAMETIME_SLEW, - (getStat(LLViewerStats::ST_FRAMETIME_SLEW) * (gFrameCount - 1) + + setStat(ST_FRAMETIME_SLEW, + (getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + fabs(average_frametime - time_diff) / average_frametime) / gFrameCount); F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth; - setStat(LLViewerStats::ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); + setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); - setStat(LLViewerStats::ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); + setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); } @@ -399,19 +399,6 @@ void LLViewerStats::addToMessage(LLSD &body) const << "; Count = " << mAgentPositionSnaps.getCount() << llendl; } -// static -// const std::string LLViewerStats::statTypeToText(EStatType type) -// { -// if (type >= 0 && type < ST_COUNT) -// { -// return STAT_INFO[type].mName; -// } -// else -// { -// return "Unknown statistic"; -// } -// } - // *NOTE:Mani The following methods used to exist in viewer.cpp // Moving them here, but not merging them into LLViewerStats yet. void reset_statistics() @@ -579,6 +566,8 @@ void update_statistics(U32 frame_count) gTotalWorldBytes += gVLManager.getTotalBytes(); gTotalObjectBytes += gObjectBits / 8; + LLViewerStats& stats = LLViewerStats::instance(); + // make sure we have a valid time delta for this frame if (gFrameIntervalSeconds > 0.f) { @@ -595,42 +584,42 @@ void update_statistics(U32 frame_count) LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds); } } - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); + stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); + stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); + stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); + stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); #if 0 // 1.9.2 - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_OBJECTS, (F64)gSavedSettings.getS32("VertexShaderLevelObject")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_AVATAR, (F64)gSavedSettings.getBOOL("VertexShaderLevelAvatar")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_SHADER_ENVIRONMENT, (F64)gSavedSettings.getBOOL("VertexShaderLevelEnvironment")); + stats.setStat(LLViewerStats::ST_SHADER_OBJECTS, (F64)gSavedSettings.getS32("VertexShaderLevelObject")); + stats.setStat(LLViewerStats::ST_SHADER_AVATAR, (F64)gSavedSettings.getBOOL("VertexShaderLevelAvatar")); + stats.setStat(LLViewerStats::ST_SHADER_ENVIRONMENT, (F64)gSavedSettings.getBOOL("VertexShaderLevelEnvironment")); #endif - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); + stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle"); F64 network_secs = gDebugView->mFastTimerView->getTime("Network"); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_NETWORK_SECS, network_secs); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State")); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry")); + stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs); + stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs); + stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images")); + stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State")); + stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry")); LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { - LLViewerStats::getInstance()->mSimPingStat.addValue(cdp->getPingDelay()); + stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { - LLViewerStats::getInstance()->mSimPingStat.addValue(10000); + stats.mSimPingStat.addValue(10000); } - LLViewerStats::getInstance()->mFPSStat.addValue(1); + stats.mFPSStat.addValue(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - LLViewerStats::getInstance()->mLayersKBitStat.addValue(layer_bits/1024.f); - LLViewerStats::getInstance()->mObjectKBitStat.addValue(gObjectBits/1024.f); - LLViewerStats::getInstance()->mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); - LLViewerStats::getInstance()->mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); + stats.mLayersKBitStat.addValue(layer_bits/1024.f); + stats.mObjectKBitStat.addValue(gObjectBits/1024.f); + stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); + stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) @@ -651,7 +640,7 @@ void update_statistics(U32 frame_count) visible_avatar_frames = 1.f; avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames; } - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars); + stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars); } LLWorld::getInstance()->updateNetStats(); LLWorld::getInstance()->requestCacheMisses(); @@ -667,8 +656,8 @@ void update_statistics(U32 frame_count) static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - LLViewerStats::getInstance()->mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); - LLViewerStats::getInstance()->mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); + stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); + stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8; LLViewerTextureList::sTextureBits = 0; LLViewerTextureList::sTexturePackets = 0; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 750d963f69..9a2a33fa7b 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -112,8 +112,7 @@ public: void resetStats(); public: - // If you change this, please also add a corresponding text label - // in statTypeToText in llviewerstats.cpp + // If you change this, please also add a corresponding text label in llviewerstats.cpp enum EStatType { ST_VERSION = 0, diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp index cfb446fe45..91e485d01b 100644 --- a/indra/newview/llviewerstatsrecorder.cpp +++ b/indra/newview/llviewerstatsrecorder.cpp @@ -27,7 +27,6 @@ #include "llviewerprecompiledheaders.h" #include "llviewerstatsrecorder.h" -#if LL_RECORD_VIEWER_STATS #include "llfile.h" #include "llviewerregion.h" @@ -46,8 +45,6 @@ LLViewerStatsRecorder::LLViewerStatsRecorder() : mObjectCacheFile(NULL), mTimer(), mStartTime(0.0), - mProcessingStartTime(0.0), - mProcessingTotalTime(0.0), mLastSnapshotTime(0.0) { if (NULL != sInstance) @@ -63,50 +60,12 @@ LLViewerStatsRecorder::~LLViewerStatsRecorder() if (mObjectCacheFile != NULL) { // last chance snapshot - takeSnapshot(); + writeToLog(0.f); LLFile::close(mObjectCacheFile); mObjectCacheFile = NULL; } } -void LLViewerStatsRecorder::beginObjectUpdateEvents(F32 interval) -{ - mSnapshotInterval = interval; - if (mObjectCacheFile == NULL) - { - mStartTime = LLTimer::getTotalSeconds(); - mObjectCacheFile = LLFile::fopen(STATS_FILE_NAME, "wb"); - if (mObjectCacheFile) - { // Write column headers - std::ostringstream data_msg; - data_msg << "EventTime(ms), " - << "Processing Time(ms), " - << "Cache Hits, " - << "Cache Full Misses, " - << "Cache Crc Misses, " - << "Full Updates, " - << "Terse Updates, " - << "Cache Miss Requests, " - << "Cache Miss Responses, " - << "Cache Update Dupes, " - << "Cache Update Changes, " - << "Cache Update Adds, " - << "Cache Update Replacements, " - << "Update Failures, " - << "Cache Hits bps, " - << "Cache Full Misses bps, " - << "Cache Crc Misses bps, " - << "Full Updates bps, " - << "Terse Updates bps, " - << "Cache Miss Responses bps, " - << "\n"; - - fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); - } - } - mProcessingStartTime = LLTimer::getTotalSeconds(); -} - void LLViewerStatsRecorder::clearStats() { mObjectCacheHitCount = 0; @@ -128,6 +87,7 @@ void LLViewerStatsRecorder::clearStats() mObjectCacheUpdateReplacements = 0; mObjectUpdateFailures = 0; mObjectUpdateFailuresSize = 0; + mTextureFetchSize = 0; } @@ -204,69 +164,93 @@ void LLViewerStatsRecorder::recordRequestCacheMissesEvent(S32 count) mObjectCacheMissRequests += count; } -void LLViewerStatsRecorder::endObjectUpdateEvents() -{ - mProcessingTotalTime += LLTimer::getTotalSeconds() - mProcessingStartTime; - takeSnapshot(); -} - -void LLViewerStatsRecorder::takeSnapshot() +void LLViewerStatsRecorder::writeToLog( F32 interval ) { F64 delta_time = LLTimer::getTotalSeconds() - mLastSnapshotTime; - if ( delta_time > mSnapshotInterval) - { - mLastSnapshotTime = LLTimer::getTotalSeconds(); - llinfos << "ILX: " - << mObjectCacheHitCount << " hits, " - << mObjectCacheMissFullCount << " full misses, " - << mObjectCacheMissCrcCount << " crc misses, " - << mObjectFullUpdates << " full updates, " - << mObjectTerseUpdates << " terse updates, " - << mObjectCacheMissRequests << " cache miss requests, " - << mObjectCacheMissResponses << " cache miss responses, " - << mObjectCacheUpdateDupes << " cache update dupes, " - << mObjectCacheUpdateChanges << " cache update changes, " - << mObjectCacheUpdateAdds << " cache update adds, " - << mObjectCacheUpdateReplacements << " cache update replacements, " - << mObjectUpdateFailures << " update failures" - << llendl; + S32 total_objects = mObjectCacheHitCount + mObjectCacheMissCrcCount + mObjectCacheMissFullCount + mObjectFullUpdates + mObjectTerseUpdates + mObjectCacheMissRequests + mObjectCacheMissResponses + mObjectCacheUpdateDupes + mObjectCacheUpdateChanges + mObjectCacheUpdateAdds + mObjectCacheUpdateReplacements + mObjectUpdateFailures; - S32 total_objects = mObjectCacheHitCount + mObjectCacheMissCrcCount + mObjectCacheMissFullCount + mObjectFullUpdates + mObjectTerseUpdates + mObjectCacheMissRequests + mObjectCacheMissResponses + mObjectCacheUpdateDupes + mObjectCacheUpdateChanges + mObjectCacheUpdateAdds + mObjectCacheUpdateReplacements + mObjectUpdateFailures; - if (mObjectCacheFile != NULL && - total_objects > 0) - { - std::ostringstream data_msg; + if ( delta_time < interval || total_objects == 0) return; - F32 processing32 = (F32) mProcessingTotalTime; - mProcessingTotalTime = 0.0; + mLastSnapshotTime = LLTimer::getTotalSeconds(); + lldebugs << "ILX: " + << mObjectCacheHitCount << " hits, " + << mObjectCacheMissFullCount << " full misses, " + << mObjectCacheMissCrcCount << " crc misses, " + << mObjectFullUpdates << " full updates, " + << mObjectTerseUpdates << " terse updates, " + << mObjectCacheMissRequests << " cache miss requests, " + << mObjectCacheMissResponses << " cache miss responses, " + << mObjectCacheUpdateDupes << " cache update dupes, " + << mObjectCacheUpdateChanges << " cache update changes, " + << mObjectCacheUpdateAdds << " cache update adds, " + << mObjectCacheUpdateReplacements << " cache update replacements, " + << mObjectUpdateFailures << " update failures" + << llendl; - data_msg << getTimeSinceStart() - << ", " << processing32 - << ", " << mObjectCacheHitCount - << ", " << mObjectCacheMissFullCount - << ", " << mObjectCacheMissCrcCount - << ", " << mObjectFullUpdates - << ", " << mObjectTerseUpdates - << ", " << mObjectCacheMissRequests - << ", " << mObjectCacheMissResponses - << ", " << mObjectCacheUpdateDupes - << ", " << mObjectCacheUpdateChanges - << ", " << mObjectCacheUpdateAdds - << ", " << mObjectCacheUpdateReplacements - << ", " << mObjectUpdateFailures - << ", " << (mObjectCacheHitSize * 8 / delta_time) - << ", " << (mObjectCacheMissFullSize * 8 / delta_time) - << ", " << (mObjectCacheMissCrcSize * 8 / delta_time) - << ", " << (mObjectFullUpdatesSize * 8 / delta_time) - << ", " << (mObjectTerseUpdatesSize * 8 / delta_time) - << ", " << (mObjectCacheMissResponsesSize * 8 / delta_time) + if (mObjectCacheFile == NULL) + { + mStartTime = LLTimer::getTotalSeconds(); + mObjectCacheFile = LLFile::fopen(STATS_FILE_NAME, "wb"); + if (mObjectCacheFile) + { // Write column headers + std::ostringstream data_msg; + data_msg << "EventTime(ms)\t" + << "Cache Hits\t" + << "Cache Full Misses\t" + << "Cache Crc Misses\t" + << "Full Updates\t" + << "Terse Updates\t" + << "Cache Miss Requests\t" + << "Cache Miss Responses\t" + << "Cache Update Dupes\t" + << "Cache Update Changes\t" + << "Cache Update Adds\t" + << "Cache Update Replacements\t" + << "Update Failures\t" + << "Cache Hits bps\t" + << "Cache Full Misses bps\t" + << "Cache Crc Misses bps\t" + << "Full Updates bps\t" + << "Terse Updates bps\t" + << "Cache Miss Responses bps\t" + << "Texture Fetch bps\t" << "\n"; fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); } - - clearStats(); + else + { + llwarns << "Couldn't open " << STATS_FILE_NAME << " for logging." << llendl; + return; + } } + + std::ostringstream data_msg; + + data_msg << getTimeSinceStart() + << "\t " << mObjectCacheHitCount + << "\t" << mObjectCacheMissFullCount + << "\t" << mObjectCacheMissCrcCount + << "\t" << mObjectFullUpdates + << "\t" << mObjectTerseUpdates + << "\t" << mObjectCacheMissRequests + << "\t" << mObjectCacheMissResponses + << "\t" << mObjectCacheUpdateDupes + << "\t" << mObjectCacheUpdateChanges + << "\t" << mObjectCacheUpdateAdds + << "\t" << mObjectCacheUpdateReplacements + << "\t" << mObjectUpdateFailures + << "\t" << (mObjectCacheHitSize * 8 / delta_time) + << "\t" << (mObjectCacheMissFullSize * 8 / delta_time) + << "\t" << (mObjectCacheMissCrcSize * 8 / delta_time) + << "\t" << (mObjectFullUpdatesSize * 8 / delta_time) + << "\t" << (mObjectTerseUpdatesSize * 8 / delta_time) + << "\t" << (mObjectCacheMissResponsesSize * 8 / delta_time) + << "\t" << (mTextureFetchSize * 8 / delta_time) + << "\n"; + + fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ); + clearStats(); } F32 LLViewerStatsRecorder::getTimeSinceStart() @@ -274,7 +258,10 @@ F32 LLViewerStatsRecorder::getTimeSinceStart() return (F32) (LLTimer::getTotalSeconds() - mStartTime); } -#endif +void LLViewerStatsRecorder::recordTextureFetch( S32 msg_size ) +{ + mTextureFetchSize += msg_size; +} diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h index 09530b13eb..ce6dd63ec5 100644 --- a/indra/newview/llviewerstatsrecorder.h +++ b/indra/newview/llviewerstatsrecorder.h @@ -35,7 +35,6 @@ #define LL_RECORD_VIEWER_STATS 1 -#if LL_RECORD_VIEWER_STATS #include "llframetimer.h" #include "llviewerobject.h" #include "llviewerregion.h" @@ -50,29 +49,71 @@ class LLViewerStatsRecorder : public LLSingleton<LLViewerStatsRecorder> LLViewerStatsRecorder(); ~LLViewerStatsRecorder(); - void beginObjectUpdateEvents(F32 interval); + void objectUpdateFailure(U32 local_id, const EObjectUpdateType update_type, S32 msg_size) + { +#if LL_RECORD_VIEWER_STATS + recordObjectUpdateFailure(local_id, update_type, msg_size); +#endif + } + + void cacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type, S32 msg_size) + { +#if LL_RECORD_VIEWER_STATS + recordCacheMissEvent(local_id, update_type, cache_miss_type, msg_size); +#endif + } + + void objectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp, S32 msg_size) + { +#if LL_RECORD_VIEWER_STATS + recordObjectUpdateEvent(local_id, update_type, objectp, msg_size); +#endif + } + void cacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp, S32 msg_size) + { +#if LL_RECORD_VIEWER_STATS + recordCacheFullUpdate(local_id, update_type, update_result, objectp, msg_size); +#endif + } + + void requestCacheMissesEvent(S32 count) + { +#if LL_RECORD_VIEWER_STATS + recordRequestCacheMissesEvent(count); +#endif + } + + void textureFetch(S32 msg_size) + { +#if LL_RECORD_VIEWER_STATS + recordTextureFetch(msg_size); +#endif + } + + void log(F32 interval) + { +#if LL_RECORD_VIEWER_STATS + writeToLog(interval); +#endif + } + + F32 getTimeSinceStart(); + +private: void recordObjectUpdateFailure(U32 local_id, const EObjectUpdateType update_type, S32 msg_size); void recordCacheMissEvent(U32 local_id, const EObjectUpdateType update_type, U8 cache_miss_type, S32 msg_size); void recordObjectUpdateEvent(U32 local_id, const EObjectUpdateType update_type, LLViewerObject * objectp, S32 msg_size); void recordCacheFullUpdate(U32 local_id, const EObjectUpdateType update_type, LLViewerRegion::eCacheUpdateResult update_result, LLViewerObject* objectp, S32 msg_size); void recordRequestCacheMissesEvent(S32 count); - - void endObjectUpdateEvents(); - - F32 getTimeSinceStart(); - -private: - void takeSnapshot(); + void recordTextureFetch(S32 msg_size); + void writeToLog(F32 interval); static LLViewerStatsRecorder* sInstance; LLFILE * mObjectCacheFile; // File to write data into LLFrameTimer mTimer; F64 mStartTime; - F64 mProcessingStartTime; - F64 mProcessingTotalTime; - F64 mSnapshotInterval; F64 mLastSnapshotTime; S32 mObjectCacheHitCount; @@ -94,11 +135,11 @@ private: S32 mObjectCacheUpdateReplacements; S32 mObjectUpdateFailures; S32 mObjectUpdateFailuresSize; + S32 mTextureFetchSize; void clearStats(); }; -#endif // LL_RECORD_VIEWER_STATS #endif // LLVIEWERSTATSRECORDER_H -- cgit v1.2.3 From df7d6c90758eef95f2c8c004611add495b8a5eee Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 18 Jul 2012 12:37:52 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages continued clean up of llstats stuff --- indra/newview/llappviewer.cpp | 6 +- indra/newview/llstartup.cpp | 2 +- indra/newview/llsurface.cpp | 2 - indra/newview/llsurface.h | 3 - indra/newview/lltexturefetch.cpp | 8 +- indra/newview/llviewermenu.cpp | 17 --- indra/newview/llviewerstats.cpp | 194 ++++------------------------------ indra/newview/llviewerstats.h | 157 +++++++++++++-------------- indra/newview/llviewertexturelist.cpp | 8 -- indra/newview/llviewerwindow.cpp | 20 ++-- indra/newview/llvlcomposition.cpp | 2 - 11 files changed, 108 insertions(+), 311 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c02bc882ea..161cc418dd 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -785,9 +785,6 @@ bool LLAppViewer::init() ////////////////////////////////////////////////////////////////////////////// // *FIX: The following code isn't grouped into functions yet. - // Statistics / debug timer initialization - init_statistics(); - // // Various introspection concerning the libs we're using - particularly // the libs involved in getting to a full login screen. @@ -4208,7 +4205,6 @@ void LLAppViewer::idle() // of SEND_STATS_PERIOD so that the initial stats report will // be sent immediately. static LLFrameStatsTimer viewer_stats_timer(SEND_STATS_PERIOD); - reset_statistics(); // Update session stats every large chunk of time // *FIX: (???) SAMANTHA @@ -4268,7 +4264,7 @@ void LLAppViewer::idle() idle_afk_check(); // Update statistics for this frame - update_statistics(gFrameCount); + update_statistics(); } //////////////////////////////////////// diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6b0fc26db7..77d0932fc0 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1394,7 +1394,7 @@ bool idle_startup() display_startup(); //reset statistics - LLViewerStats::getInstance()->resetStats(); + LLViewerStats::instance().resetStats(); display_startup(); // diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index 66df7dae3e..3bd2d4cabc 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -61,8 +61,6 @@ LLColor4U MAX_WATER_COLOR(0, 48, 96, 240); S32 LLSurface::sTextureSize = 256; -S32 LLSurface::sTexelsUpdated = 0; -F32 LLSurface::sTextureUpdateTime = 0.f; // ---------------- LLSurface:: Public Members --------------- diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index a4ef4fe2de..eb120f142d 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -168,9 +168,6 @@ public: F32 mDetailTextureScale; // Number of times to repeat detail texture across this surface - static F32 sTextureUpdateTime; - static S32 sTexelsUpdated; - protected: void createSTexture(); void createWaterTexture(); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 143db79eb5..001060f4de 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3242,7 +3242,7 @@ void LLTextureFetchDebugger::startDebug() } //collect statistics - mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32() - mTotalFetchingTime; + mTotalFetchingTime = gTextureTimer.getElapsedTimeF32() - mTotalFetchingTime; std::set<LLUUID> fetched_textures; S32 size = mFetchingHistory.size(); @@ -3324,7 +3324,7 @@ void LLTextureFetchDebugger::stopDebug() //unlock the fetcher mFetcher->lockFetcher(false); mFreezeHistory = FALSE; - mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32(); //reset + mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset } //called in the main thread and when the fetching queue is empty @@ -3637,7 +3637,7 @@ bool LLTextureFetchDebugger::update() case REFETCH_VIS_CACHE: if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) { - mRefetchVisCacheTime = gDebugTimers[0].getElapsedTimeF32() - mTotalFetchingTime; + mRefetchVisCacheTime = gTextureTimer.getElapsedTimeF32() - mTotalFetchingTime; mState = IDLE; mFetcher->lockFetcher(true); } @@ -3645,7 +3645,7 @@ bool LLTextureFetchDebugger::update() case REFETCH_VIS_HTTP: if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) { - mRefetchVisHTTPTime = gDebugTimers[0].getElapsedTimeF32() - mTotalFetchingTime; + mRefetchVisHTTPTime = gTextureTimer.getElapsedTimeF32() - mTotalFetchingTime; mState = IDLE; mFetcher->lockFetcher(true); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 34e916fec0..75b4815ba7 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1314,22 +1314,6 @@ class LLAdvancedPrintAgentInfo : public view_listener_t } }; - - -//////////////////////////////// -// PRINT TEXTURE MEMORY STATS // -//////////////////////////////// - - -class LLAdvancedPrintTextureMemoryStats : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - output_statistics(NULL); - return true; - } -}; - ////////////////// // DEBUG CLICKS // ////////////////// @@ -8280,7 +8264,6 @@ void initialize_menus() commit.add("Advanced.DumpFocusHolder", boost::bind(&handle_dump_focus) ); view_listener_t::addMenu(new LLAdvancedPrintSelectedObjectInfo(), "Advanced.PrintSelectedObjectInfo"); view_listener_t::addMenu(new LLAdvancedPrintAgentInfo(), "Advanced.PrintAgentInfo"); - view_listener_t::addMenu(new LLAdvancedPrintTextureMemoryStats(), "Advanced.PrintTextureMemoryStats"); view_listener_t::addMenu(new LLAdvancedToggleDebugClicks(), "Advanced.ToggleDebugClicks"); view_listener_t::addMenu(new LLAdvancedCheckDebugClicks(), "Advanced.CheckDebugClicks"); view_listener_t::addMenu(new LLAdvancedCheckDebugViews(), "Advanced.CheckDebugViews"); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index c1ccfe3faa..fe78b1232c 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -286,19 +286,19 @@ LLViewerStats::~LLViewerStats() void LLViewerStats::resetStats() { - LLViewerStats::getInstance()->mKBitStat.reset(); - LLViewerStats::getInstance()->mLayersKBitStat.reset(); - LLViewerStats::getInstance()->mObjectKBitStat.reset(); - LLViewerStats::getInstance()->mTextureKBitStat.reset(); - LLViewerStats::getInstance()->mVFSPendingOperations.reset(); - LLViewerStats::getInstance()->mAssetKBitStat.reset(); - LLViewerStats::getInstance()->mPacketsInStat.reset(); - LLViewerStats::getInstance()->mPacketsLostStat.reset(); - LLViewerStats::getInstance()->mPacketsOutStat.reset(); - LLViewerStats::getInstance()->mFPSStat.reset(); - LLViewerStats::getInstance()->mTexturePacketsStat.reset(); - - LLViewerStats::getInstance()->mAgentPositionSnaps.reset(); + LLViewerStats& stats = LLViewerStats::instance(); + stats.mKBitStat.reset(); + stats.mLayersKBitStat.reset(); + stats.mObjectKBitStat.reset(); + stats.mTextureKBitStat.reset(); + stats.mVFSPendingOperations.reset(); + stats.mAssetKBitStat.reset(); + stats.mPacketsInStat.reset(); + stats.mPacketsLostStat.reset(); + stats.mPacketsOutStat.reset(); + stats.mFPSStat.reset(); + stats.mTexturePacketsStat.reset(); + stats.mAgentPositionSnaps.reset(); } @@ -401,140 +401,6 @@ void LLViewerStats::addToMessage(LLSD &body) const // *NOTE:Mani The following methods used to exist in viewer.cpp // Moving them here, but not merging them into LLViewerStats yet. -void reset_statistics() -{ - if (LLSurface::sTextureUpdateTime) - { - LLSurface::sTexelsUpdated = 0; - LLSurface::sTextureUpdateTime = 0.f; - } -} - - -void output_statistics(void*) -{ - llinfos << "Number of orphans: " << gObjectList.getOrphanCount() << llendl; - llinfos << "Number of dead objects: " << gObjectList.mNumDeadObjects << llendl; - llinfos << "Num images: " << gTextureList.getNumImages() << llendl; - llinfos << "Texture usage: " << LLImageGL::sGlobalTextureMemoryInBytes << llendl; - llinfos << "Texture working set: " << LLImageGL::sBoundTextureMemoryInBytes << llendl; - llinfos << "Raw usage: " << LLImageRaw::sGlobalRawMemory << llendl; - llinfos << "Formatted usage: " << LLImageFormatted::sGlobalFormattedMemory << llendl; - llinfos << "Zombie Viewer Objects: " << LLViewerObject::getNumZombieObjects() << llendl; - llinfos << "Number of lights: " << gPipeline.getLightCount() << llendl; - - llinfos << "Memory Usage:" << llendl; - llinfos << "--------------------------------" << llendl; - llinfos << "Pipeline:" << llendl; - llinfos << llendl; - -#if LL_SMARTHEAP - llinfos << "--------------------------------" << llendl; - { - llinfos << "sizeof(LLVOVolume) = " << sizeof(LLVOVolume) << llendl; - - U32 total_pool_size = 0; - U32 total_used_size = 0; - MEM_POOL_INFO pool_info; - MEM_POOL_STATUS pool_status; - U32 pool_num = 0; - for(pool_status = MemPoolFirst( &pool_info, 1 ); - pool_status != MEM_POOL_END; - pool_status = MemPoolNext( &pool_info, 1 ) ) - { - llinfos << "Pool #" << pool_num << llendl; - if( MEM_POOL_OK != pool_status ) - { - llwarns << "Pool not ok" << llendl; - continue; - } - - llinfos << "Pool blockSizeFS " << pool_info.blockSizeFS - << " pageSize " << pool_info.pageSize - << llendl; - - U32 pool_count = MemPoolCount(pool_info.pool); - llinfos << "Blocks " << pool_count << llendl; - - U32 pool_size = MemPoolSize( pool_info.pool ); - if( pool_size == MEM_ERROR_RET ) - { - llinfos << "MemPoolSize() failed (" << pool_num << ")" << llendl; - } - else - { - llinfos << "MemPool Size " << pool_size / 1024 << "K" << llendl; - } - - total_pool_size += pool_size; - - if( !MemPoolLock( pool_info.pool ) ) - { - llinfos << "MemPoolLock failed (" << pool_num << ") " << llendl; - continue; - } - - U32 used_size = 0; - MEM_POOL_ENTRY entry; - entry.entry = NULL; - while( MemPoolWalk( pool_info.pool, &entry ) == MEM_POOL_OK ) - { - if( entry.isInUse ) - { - used_size += entry.size; - } - } - - MemPoolUnlock( pool_info.pool ); - - llinfos << "MemPool Used " << used_size/1024 << "K" << llendl; - total_used_size += used_size; - pool_num++; - } - - llinfos << "Total Pool Size " << total_pool_size/1024 << "K" << llendl; - llinfos << "Total Used Size " << total_used_size/1024 << "K" << llendl; - - } -#endif - - llinfos << "--------------------------------" << llendl; - llinfos << "Avatar Memory (partly overlaps with above stats):" << llendl; - LLTexLayerStaticImageList::getInstance()->dumpByteCount(); - LLVOAvatarSelf::dumpScratchTextureByteCount(); - LLTexLayerSetBuffer::dumpTotalByteCount(); - LLVOAvatarSelf::dumpTotalLocalTextureByteCount(); - LLTexLayerParamAlpha::dumpCacheByteCount(); - LLVOAvatar::dumpBakedStatus(); - - llinfos << llendl; - - llinfos << "Object counts:" << llendl; - S32 i; - S32 obj_counts[256]; -// S32 app_angles[256]; - for (i = 0; i < 256; i++) - { - obj_counts[i] = 0; - } - for (i = 0; i < gObjectList.getNumObjects(); i++) - { - LLViewerObject *objectp = gObjectList.getObject(i); - if (objectp) - { - obj_counts[objectp->getPCode()]++; - } - } - for (i = 0; i < 256; i++) - { - if (obj_counts[i]) - { - llinfos << LLPrimitive::pCodeToString(i) << ":" << obj_counts[i] << llendl; - } - } -} - - U32 gTotalLandIn = 0, gTotalLandOut = 0; U32 gTotalWaterIn = 0, gTotalWaterOut = 0; @@ -552,16 +418,9 @@ U32 gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] extern U32 gVisCompared; extern U32 gVisTested; -std::map<S32,LLFrameTimer> gDebugTimers; -std::map<S32,std::string> gDebugTimerLabel; +extern LLFrameTimer gTextureTimer; -void init_statistics() -{ - // Label debug timers - gDebugTimerLabel[0] = "Texture"; -} - -void update_statistics(U32 frame_count) +void update_statistics() { gTotalWorldBytes += gVLManager.getTotalBytes(); gTotalObjectBytes += gObjectBits / 8; @@ -588,11 +447,7 @@ void update_statistics(U32 frame_count) stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); -#if 0 // 1.9.2 - stats.setStat(LLViewerStats::ST_SHADER_OBJECTS, (F64)gSavedSettings.getS32("VertexShaderLevelObject")); - stats.setStat(LLViewerStats::ST_SHADER_AVATAR, (F64)gSavedSettings.getBOOL("VertexShaderLevelAvatar")); - stats.setStat(LLViewerStats::ST_SHADER_ENVIRONMENT, (F64)gSavedSettings.getBOOL("VertexShaderLevelEnvironment")); -#endif + stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle"); F64 network_secs = gDebugView->mFastTimerView->getTime("Network"); @@ -624,11 +479,11 @@ void update_statistics(U32 frame_count) if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) { - gDebugTimers[0].pause(); + gTextureTimer.pause(); } else { - gDebugTimers[0].unpause(); + gTextureTimer.unpause(); } { @@ -664,7 +519,6 @@ void update_statistics(U32 frame_count) texture_stats_timer.reset(); } } - } class ViewerStatsResponder : public LLHTTPClient::Responder @@ -824,10 +678,7 @@ void send_stats() S32 window_height = gViewerWindow->getWindowHeightRaw(); S32 window_size = (window_width * window_height) / 1024; misc["string_1"] = llformat("%d", window_size); - if (gDebugTimers.find(0) != gDebugTimers.end() && gFrameTimeSeconds > 0) - { - misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gDebugTimers[0].getElapsedTimeF32(), gFrameTimeSeconds); - } + misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds); // misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21 // misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21 @@ -918,13 +769,6 @@ LLSD LLViewerStats::PhaseMap::dumpPhases() const std::string& phase_name = iter->first; result[phase_name]["completed"] = !(iter->second.getStarted()); result[phase_name]["elapsed"] = iter->second.getElapsedTimeF32(); -#if 0 // global stats for each phase seem like overkill here - phase_stats_t::iterator stats_iter = sPhaseStats.find(phase_name); - if (stats_iter != sPhaseStats.end()) - { - result[phase_name]["stats"] = stats_iter->second.getData(); - } -#endif } return result; } diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 9a2a33fa7b..0402b82154 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -33,82 +33,82 @@ class LLViewerStats : public LLSingleton<LLViewerStats> { public: - LLStat mKBitStat; - LLStat mLayersKBitStat; - LLStat mObjectKBitStat; - LLStat mAssetKBitStat; - LLStat mTextureKBitStat; - LLStat mVFSPendingOperations; - LLStat mObjectsDrawnStat; - LLStat mObjectsCulledStat; - LLStat mObjectsTestedStat; - LLStat mObjectsComparedStat; - LLStat mObjectsOccludedStat; - LLStat mFPSStat; - LLStat mPacketsInStat; - LLStat mPacketsLostStat; - LLStat mPacketsOutStat; - LLStat mPacketsLostPercentStat; - LLStat mTexturePacketsStat; - LLStat mActualInKBitStat; // From the packet ring (when faking a bad connection) - LLStat mActualOutKBitStat; // From the packet ring (when faking a bad connection) - LLStat mTrianglesDrawnStat; + LLStat mKBitStat, + mLayersKBitStat, + mObjectKBitStat, + mAssetKBitStat, + mTextureKBitStat, + mVFSPendingOperations, + mObjectsDrawnStat, + mObjectsCulledStat, + mObjectsTestedStat, + mObjectsComparedStat, + mObjectsOccludedStat, + mFPSStat, + mPacketsInStat, + mPacketsLostStat, + mPacketsOutStat, + mPacketsLostPercentStat, + mTexturePacketsStat, + mActualInKBitStat, // From the packet ring (when faking a bad connection) + mActualOutKBitStat, // From the packet ring (when faking a bad connection) + mTrianglesDrawnStat; // Simulator stats - LLStat mSimTimeDilation; - - LLStat mSimFPS; - LLStat mSimPhysicsFPS; - LLStat mSimAgentUPS; - LLStat mSimScriptEPS; - - LLStat mSimFrameMsec; - LLStat mSimNetMsec; - LLStat mSimSimOtherMsec; - LLStat mSimSimPhysicsMsec; - - LLStat mSimSimPhysicsStepMsec; - LLStat mSimSimPhysicsShapeUpdateMsec; - LLStat mSimSimPhysicsOtherMsec; - - LLStat mSimAgentMsec; - LLStat mSimImagesMsec; - LLStat mSimScriptMsec; - LLStat mSimSpareMsec; - LLStat mSimSleepMsec; - LLStat mSimPumpIOMsec; - - LLStat mSimMainAgents; - LLStat mSimChildAgents; - LLStat mSimObjects; - LLStat mSimActiveObjects; - LLStat mSimActiveScripts; - - LLStat mSimInPPS; - LLStat mSimOutPPS; - LLStat mSimPendingDownloads; - LLStat mSimPendingUploads; - LLStat mSimPendingLocalUploads; - LLStat mSimTotalUnackedBytes; - - LLStat mPhysicsPinnedTasks; - LLStat mPhysicsLODTasks; - LLStat mPhysicsMemoryAllocated; - - LLStat mSimPingStat; - - LLStat mNumImagesStat; - LLStat mNumRawImagesStat; - LLStat mGLTexMemStat; - LLStat mGLBoundMemStat; - LLStat mRawMemStat; - LLStat mFormattedMemStat; - - LLStat mNumObjectsStat; - LLStat mNumActiveObjectsStat; - LLStat mNumNewObjectsStat; - LLStat mNumSizeCulledStat; - LLStat mNumVisCulledStat; + LLStat mSimTimeDilation, + + mSimFPS, + mSimPhysicsFPS, + mSimAgentUPS, + mSimScriptEPS, + + mSimFrameMsec, + mSimNetMsec, + mSimSimOtherMsec, + mSimSimPhysicsMsec, + + mSimSimPhysicsStepMsec, + mSimSimPhysicsShapeUpdateMsec, + mSimSimPhysicsOtherMsec, + + mSimAgentMsec, + mSimImagesMsec, + mSimScriptMsec, + mSimSpareMsec, + mSimSleepMsec, + mSimPumpIOMsec, + + mSimMainAgents, + mSimChildAgents, + mSimObjects, + mSimActiveObjects, + mSimActiveScripts, + + mSimInPPS, + mSimOutPPS, + mSimPendingDownloads, + mSimPendingUploads, + mSimPendingLocalUploads, + mSimTotalUnackedBytes, + + mPhysicsPinnedTasks, + mPhysicsLODTasks, + mPhysicsMemoryAllocated, + + mSimPingStat, + + mNumImagesStat, + mNumRawImagesStat, + mGLTexMemStat, + mGLBoundMemStat, + mRawMemStat, + mFormattedMemStat, + + mNumObjectsStat, + mNumActiveObjectsStat, + mNumNewObjectsStat, + mNumSizeCulledStat, + mNumVisCulledStat; void resetStats(); public: @@ -177,7 +177,6 @@ public: ST_COUNT = 58 }; - LLViewerStats(); ~LLViewerStats(); @@ -304,14 +303,10 @@ private: static const F32 SEND_STATS_PERIOD = 300.0f; // The following are from (older?) statistics code found in appviewer. -void init_statistics(); -void reset_statistics(); -void output_statistics(void*); -void update_statistics(U32 frame_count); +void update_statistics(); void send_stats(); -extern std::map<S32,LLFrameTimer> gDebugTimers; -extern std::map<S32,std::string> gDebugTimerLabel; +extern LLFrameTimer gTextureTimer; extern U32 gTotalTextureBytes; extern U32 gTotalObjectBytes; extern U32 gTotalTextureBytesPerBoostLevel[] ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 528e0080b7..9e1e92f8e8 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -906,14 +906,6 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) } min_count--; } - //if (fetch_count == 0) - //{ - // gDebugTimers[0].pause(); - //} - //else - //{ - // gDebugTimers[0].unpause(); - //} return image_op_timer.getElapsedTimeF32(); } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 39e330ad66..9e9b41d3c8 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -333,19 +333,13 @@ public: if (gSavedSettings.getBOOL("DebugShowTime")) { const U32 y_inc2 = 15; - for (std::map<S32,LLFrameTimer>::reverse_iterator iter = gDebugTimers.rbegin(); - iter != gDebugTimers.rend(); ++iter) - { - S32 idx = iter->first; - LLFrameTimer& timer = iter->second; - F32 time = timer.getElapsedTimeF32(); - S32 hours = (S32)(time / (60*60)); - S32 mins = (S32)((time - hours*(60*60)) / 60); - S32 secs = (S32)((time - hours*(60*60) - mins*60)); - std::string label = gDebugTimerLabel[idx]; - if (label.empty()) label = llformat("Debug: %d", idx); - addText(xpos, ypos, llformat(" %s: %d:%02d:%02d", label.c_str(), hours,mins,secs)); ypos += y_inc2; - } + LLFrameTimer& timer = gTextureTimer; + F32 time = timer.getElapsedTimeF32(); + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + addText(xpos, ypos, llformat(" "Texture": %d:%02d:%02d", hours,mins,secs)); ypos += y_inc2; + F32 time = gFrameTimeSeconds; S32 hours = (S32)(time / (60*60)); diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index ec932501e5..abb5153480 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -457,8 +457,6 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, texturep->createGLTexture(0, raw); } texturep->setSubImage(raw, tex_x_begin, tex_y_begin, tex_x_end - tex_x_begin, tex_y_end - tex_y_begin); - LLSurface::sTextureUpdateTime += gen_timer.getElapsedTimeF32(); - LLSurface::sTexelsUpdated += (tex_x_end - tex_x_begin) * (tex_y_end - tex_y_begin); for (S32 i = 0; i < 4; i++) { -- cgit v1.2.3 From 4d395a0de044328cf318598ef9b88eddde8e82af Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 18 Jul 2012 16:58:23 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages fixed build --- indra/newview/llviewerstats.cpp | 2 +- indra/newview/llviewerwindow.cpp | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index fe78b1232c..0e2436ae30 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -418,7 +418,7 @@ U32 gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] extern U32 gVisCompared; extern U32 gVisTested; -extern LLFrameTimer gTextureTimer; +LLFrameTimer gTextureTimer; void update_statistics() { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9e9b41d3c8..fa4eed9e50 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -332,20 +332,23 @@ public: if (gSavedSettings.getBOOL("DebugShowTime")) { - const U32 y_inc2 = 15; - LLFrameTimer& timer = gTextureTimer; - F32 time = timer.getElapsedTimeF32(); - S32 hours = (S32)(time / (60*60)); - S32 mins = (S32)((time - hours*(60*60)) / 60); - S32 secs = (S32)((time - hours*(60*60) - mins*60)); - addText(xpos, ypos, llformat(" "Texture": %d:%02d:%02d", hours,mins,secs)); ypos += y_inc2; - + { + const U32 y_inc2 = 15; + LLFrameTimer& timer = gTextureTimer; + F32 time = timer.getElapsedTimeF32(); + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + addText(xpos, ypos, llformat("Texture: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc2; + } - F32 time = gFrameTimeSeconds; - S32 hours = (S32)(time / (60*60)); - S32 mins = (S32)((time - hours*(60*60)) / 60); - S32 secs = (S32)((time - hours*(60*60) - mins*60)); - addText(xpos, ypos, llformat("Time: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc; + { + F32 time = gFrameTimeSeconds; + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + addText(xpos, ypos, llformat("Time: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc; + } } #if LL_WINDOWS -- cgit v1.2.3 From a98c7e150b3404cbbb7324bfe2a5f547f613346b Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 6 Aug 2012 16:08:04 -0700 Subject: llfasttimer cleanup removed unnecessary cache miss from fast timers renamed llfasttimer_class back to llfasttimer --- indra/llcommon/CMakeLists.txt | 3 +- indra/llcommon/llfasttimer.cpp | 661 +++++++++++++++++++++++++ indra/llcommon/llfasttimer.h | 362 +++++++++++++- indra/llcommon/llfasttimer_class.cpp | 913 ----------------------------------- indra/llcommon/llfasttimer_class.h | 258 ---------- indra/newview/llappviewer.cpp | 7 +- indra/newview/llappviewer.h | 3 + indra/newview/lldrawpoolbump.cpp | 2 +- indra/newview/llfasttimerview.cpp | 28 +- indra/newview/llfasttimerview.h | 1 + 10 files changed, 1046 insertions(+), 1192 deletions(-) create mode 100644 indra/llcommon/llfasttimer.cpp delete mode 100644 indra/llcommon/llfasttimer_class.cpp delete mode 100644 indra/llcommon/llfasttimer_class.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index dd7b8c6eb8..7795d55d62 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -53,7 +53,7 @@ set(llcommon_SOURCE_FILES lleventfilter.cpp llevents.cpp lleventtimer.cpp - llfasttimer_class.cpp + llfasttimer.cpp llfile.cpp llfindlocale.cpp llfixedbuffer.cpp @@ -167,7 +167,6 @@ set(llcommon_HEADER_FILES lleventemitter.h llextendedstatus.h llfasttimer.h - llfasttimer_class.h llfile.h llfindlocale.h llfixedbuffer.h diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp new file mode 100644 index 0000000000..ff6806082c --- /dev/null +++ b/indra/llcommon/llfasttimer.cpp @@ -0,0 +1,661 @@ +/** + * @file llfasttimer.cpp + * @brief Implementation of the fast timer. + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llfasttimer.h" + +#include "llmemory.h" +#include "llprocessor.h" +#include "llsingleton.h" +#include "lltreeiterators.h" +#include "llsdserialize.h" + +#include <boost/bind.hpp> + + +#if LL_WINDOWS +#include "lltimer.h" +#elif LL_LINUX || LL_SOLARIS +#include <sys/time.h> +#include <sched.h> +#include "lltimer.h" +#elif LL_DARWIN +#include <sys/time.h> +#include "lltimer.h" // get_clock_count() +#else +#error "architecture not supported" +#endif + +////////////////////////////////////////////////////////////////////////////// +// statics + +S32 LLFastTimer::sCurFrameIndex = -1; +S32 LLFastTimer::sLastFrameIndex = -1; +U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64(); +bool LLFastTimer::sPauseHistory = 0; +bool LLFastTimer::sResetHistory = 0; +LLFastTimer::CurTimerData LLFastTimer::sCurTimerData; +BOOL LLFastTimer::sLog = FALSE; +std::string LLFastTimer::sLogName = ""; +BOOL LLFastTimer::sMetricLog = FALSE; +LLMutex* LLFastTimer::sLogLock = NULL; +std::queue<LLSD> LLFastTimer::sLogQueue; + +#if LL_LINUX || LL_SOLARIS +U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution +#else +U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution +#endif + +// FIXME: move these declarations to the relevant modules + +// helper functions +typedef LLTreeDFSPostIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_bottom_up_iterator_t; + +static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(LLFastTimer::NamedTimer& id) +{ + return timer_tree_bottom_up_iterator_t(&id, + boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); +} + +static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() +{ + return timer_tree_bottom_up_iterator_t(); +} + +typedef LLTreeDFSIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_dfs_iterator_t; + + +static timer_tree_dfs_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) +{ + return timer_tree_dfs_iterator_t(&id, + boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); +} + +static timer_tree_dfs_iterator_t end_timer_tree() +{ + return timer_tree_dfs_iterator_t(); +} + +// factory class that creates NamedTimers via static DeclareTimer objects +class NamedTimerFactory : public LLSingleton<NamedTimerFactory> +{ +public: + NamedTimerFactory() + : mTimerRoot(NULL) + {} + + /*virtual */ void initSingleton() + { + mTimerRoot = new LLFastTimer::NamedTimer("root"); + mRootFrameState.setNamedTimer(mTimerRoot); + mTimerRoot->setFrameState(&mRootFrameState); + mTimerRoot->mParent = mTimerRoot; + mRootFrameState.mParent = &mRootFrameState; + } + + ~NamedTimerFactory() + { + std::for_each(mTimers.begin(), mTimers.end(), DeletePairedPointer()); + + delete mTimerRoot; + } + + LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state) + { + timer_map_t::iterator found_it = mTimers.find(name); + if (found_it != mTimers.end()) + { + llerrs << "Duplicate timer declaration for: " << name << llendl; + return *found_it->second; + } + + LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); + timer->setFrameState(state); + timer->setParent(mTimerRoot); + mTimers.insert(std::make_pair(name, timer)); + + return *timer; + } + + LLFastTimer::NamedTimer* getTimerByName(const std::string& name) + { + timer_map_t::iterator found_it = mTimers.find(name); + if (found_it != mTimers.end()) + { + return found_it->second; + } + return NULL; + } + + LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; } + + typedef std::map<std::string, LLFastTimer::NamedTimer*> timer_map_t; + timer_map_t::iterator beginTimers() { return mTimers.begin(); } + timer_map_t::iterator endTimers() { return mTimers.end(); } + S32 timerCount() { return mTimers.size(); } + +private: + timer_map_t mTimers; + + LLFastTimer::NamedTimer* mTimerRoot; + LLFastTimer::FrameState mRootFrameState; +}; + +LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open ) +: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) +{ + mTimer.setCollapsed(!open); +} + +LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name) +: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) +{ +} + +//static +#if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) +U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer +{ + return sClockResolution >> 8; +} +#else // windows or x86-mac or x86-linux or x86-solaris +U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer +{ +#if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS + //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz + static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0); + + // we drop the low-order byte in our timers, so report a lower frequency +#else + // If we're not using RDTSC, each fasttimer tick is just a performance counter tick. + // Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency()) + // since that would change displayed MHz stats for CPUs + static bool firstcall = true; + static U64 sCPUClockFrequency; + if (firstcall) + { + QueryPerformanceFrequency((LARGE_INTEGER*)&sCPUClockFrequency); + firstcall = false; + } +#endif + return sCPUClockFrequency >> 8; +} +#endif + +LLFastTimer::FrameState::FrameState() +: mActiveCount(0), + mCalls(0), + mSelfTimeCounter(0), + mParent(NULL), + mLastCaller(NULL), + mMoveUpTree(false) +{} + + +LLFastTimer::NamedTimer::NamedTimer(const std::string& name) +: mName(name), + mCollapsed(true), + mParent(NULL), + mTotalTimeCounter(0), + mCountAverage(0), + mCallAverage(0), + mNeedsSorting(false), + mFrameState(NULL) +{ + mCountHistory = new U32[HISTORY_NUM]; + memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM); + mCallHistory = new U32[HISTORY_NUM]; + memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); +} + +LLFastTimer::NamedTimer::~NamedTimer() +{ + delete[] mCountHistory; + delete[] mCallHistory; +} + +std::string LLFastTimer::NamedTimer::getToolTip(S32 history_idx) +{ + F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + if (history_idx < 0) + { + // by default, show average number of call + return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getCountAverage() * ms_multiplier), (S32)getCallAverage()); + } + else + { + return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getHistoricalCount(history_idx) * ms_multiplier), (S32)getHistoricalCalls(history_idx)); + } +} + +void LLFastTimer::NamedTimer::setParent(NamedTimer* parent) +{ + llassert_always(parent != this); + llassert_always(parent != NULL); + + if (mParent) + { + // subtract our accumulated from previous parent + for (S32 i = 0; i < HISTORY_NUM; i++) + { + mParent->mCountHistory[i] -= mCountHistory[i]; + } + + // subtract average timing from previous parent + mParent->mCountAverage -= mCountAverage; + + std::vector<NamedTimer*>& children = mParent->getChildren(); + std::vector<NamedTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); + if (found_it != children.end()) + { + children.erase(found_it); + } + } + + mParent = parent; + if (parent) + { + getFrameState().mParent = &parent->getFrameState(); + parent->getChildren().push_back(this); + parent->mNeedsSorting = true; + } +} + +S32 LLFastTimer::NamedTimer::getDepth() +{ + S32 depth = 0; + NamedTimer* timerp = mParent; + while(timerp) + { + depth++; + timerp = timerp->mParent; + } + return depth; +} + +// static +void LLFastTimer::NamedTimer::processTimes() +{ + if (sCurFrameIndex < 0) return; + + buildHierarchy(); + accumulateTimings(); +} + +// sort child timers by name +struct SortTimerByName +{ + bool operator()(const LLFastTimer::NamedTimer* i1, const LLFastTimer::NamedTimer* i2) + { + return i1->getName() < i2->getName(); + } +}; + +//static +void LLFastTimer::NamedTimer::buildHierarchy() +{ + if (sCurFrameIndex < 0 ) return; + + // set up initial tree + { + for (instance_iter it = beginInstances(); it != endInstances(); ++it) + { + NamedTimer& timer = *it; + if (&timer == NamedTimerFactory::instance().getRootTimer()) continue; + + // bootstrap tree construction by attaching to last timer to be on stack + // when this timer was called + if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer()) + { + timer.setParent(timer.getFrameState().mLastCaller->mTimer); + // no need to push up tree on first use, flag can be set spuriously + timer.getFrameState().mMoveUpTree = false; + } + } + } + + // bump timers up tree if they've been flagged as being in the wrong place + // do this in a bottom up order to promote descendants first before promoting ancestors + // this preserves partial order derived from current frame's observations + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getRootTimer()); + it != end_timer_tree_bottom_up(); + ++it) + { + NamedTimer* timerp = *it; + // skip root timer + if (timerp == NamedTimerFactory::instance().getRootTimer()) continue; + + if (timerp->getFrameState().mMoveUpTree) + { + // since ancestors have already been visited, reparenting won't affect tree traversal + //step up tree, bringing our descendants with us + LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << + " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; + timerp->setParent(timerp->getParent()->getParent()); + timerp->getFrameState().mMoveUpTree = false; + + // don't bubble up any ancestors until descendants are done bubbling up + it.skipAncestors(); + } + } + + // sort timers by time last called, so call graph makes sense + for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); + it != end_timer_tree(); + ++it) + { + NamedTimer* timerp = (*it); + if (timerp->mNeedsSorting) + { + std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); + } + timerp->mNeedsSorting = false; + } +} + +//static +void LLFastTimer::NamedTimer::accumulateTimings() +{ + U32 cur_time = getCPUClockCount32(); + + // walk up stack of active timers and accumulate current time while leaving timing structures active + LLFastTimer* cur_timer = sCurTimerData.mCurTimer; + // root defined by parent pointing to self + CurTimerData* cur_data = &sCurTimerData; + while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) + { + U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; + U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; + cur_data->mChildTime = 0; + cur_timer->mFrameState->mSelfTimeCounter += self_time_delta; + cur_timer->mStartTime = cur_time; + + cur_data = &cur_timer->mLastTimerData; + cur_data->mChildTime += cumulative_time_delta; + + cur_timer = cur_timer->mLastTimerData.mCurTimer; + } + + // traverse tree in DFS post order, or bottom up + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getRootTimer()); + it != end_timer_tree_bottom_up(); + ++it) + { + NamedTimer* timerp = (*it); + timerp->mTotalTimeCounter = timerp->getFrameState().mSelfTimeCounter; + for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) + { + timerp->mTotalTimeCounter += (*child_it)->mTotalTimeCounter; + } + + S32 cur_frame = sCurFrameIndex; + if (cur_frame >= 0) + { + // update timer history + int hidx = cur_frame % HISTORY_NUM; + + timerp->mCountHistory[hidx] = timerp->mTotalTimeCounter; + timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTotalTimeCounter) / (cur_frame+1); + timerp->mCallHistory[hidx] = timerp->getFrameState().mCalls; + timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->getFrameState().mCalls) / (cur_frame+1); + } + } +} + +// static +void LLFastTimer::NamedTimer::resetFrame() +{ + if (sLog) + { //output current frame counts to performance log + + static S32 call_count = 0; + if (call_count % 100 == 0) + { + LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL; + LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << llendl; + LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; + LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64())/((F64)LLProcessorInfo().getCPUFrequency()*1000000.0) << LL_ENDL; + } + call_count++; + + F64 iclock_freq = 1000.0 / countsPerSecond(); // good place to calculate clock frequency + + F64 total_time = 0; + LLSD sd; + + { + for (instance_iter it = beginInstances(); it != endInstances(); ++it) + { + NamedTimer& timer = *it; + FrameState& info = timer.getFrameState(); + sd[timer.getName()]["Time"] = (LLSD::Real) (info.mSelfTimeCounter*iclock_freq); + sd[timer.getName()]["Calls"] = (LLSD::Integer) info.mCalls; + + // computing total time here because getting the root timer's getCountHistory + // doesn't work correctly on the first frame + total_time = total_time + info.mSelfTimeCounter * iclock_freq; + } + } + + sd["Total"]["Time"] = (LLSD::Real) total_time; + sd["Total"]["Calls"] = (LLSD::Integer) 1; + + { + LLMutexLock lock(sLogLock); + sLogQueue.push(sd); + } + } + + // reset for next frame + for (instance_iter it = beginInstances(); it != endInstances(); ++it) + { + NamedTimer& timer = *it; + + FrameState& info = timer.getFrameState(); + info.mSelfTimeCounter = 0; + info.mCalls = 0; + info.mLastCaller = NULL; + info.mMoveUpTree = false; + // update parent pointer in timer state struct + if (timer.mParent) + { + info.mParent = &timer.mParent->getFrameState(); + } + } +} + +//static +void LLFastTimer::NamedTimer::reset() +{ + resetFrame(); // reset frame data + + // walk up stack of active timers and reset start times to current time + // effectively zeroing out any accumulated time + U32 cur_time = getCPUClockCount32(); + + // root defined by parent pointing to self + CurTimerData* cur_data = &sCurTimerData; + LLFastTimer* cur_timer = cur_data->mCurTimer; + while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) + { + cur_timer->mStartTime = cur_time; + cur_data->mChildTime = 0; + + cur_data = &cur_timer->mLastTimerData; + cur_timer = cur_data->mCurTimer; + } + + // reset all history + { + for (instance_iter it = beginInstances(); it != endInstances(); ++it) + { + NamedTimer& timer = *it; + if (&timer != NamedTimerFactory::instance().getRootTimer()) + { + timer.setParent(NamedTimerFactory::instance().getRootTimer()); + } + + timer.mCountAverage = 0; + timer.mCallAverage = 0; + memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM); + memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM); + } + } + + sLastFrameIndex = 0; + sCurFrameIndex = 0; +} + +U32 LLFastTimer::NamedTimer::getHistoricalCount(S32 history_index) const +{ + S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; + return mCountHistory[history_idx]; +} + +U32 LLFastTimer::NamedTimer::getHistoricalCalls(S32 history_index ) const +{ + S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; + return mCallHistory[history_idx]; +} + +LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const +{ + return *mFrameState; +} + +std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::beginChildren() +{ + return mChildren.begin(); +} + +std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::endChildren() +{ + return mChildren.end(); +} + +std::vector<LLFastTimer::NamedTimer*>& LLFastTimer::NamedTimer::getChildren() +{ + return mChildren; +} + +//static +void LLFastTimer::nextFrame() +{ + countsPerSecond(); // good place to calculate clock frequency + U64 frame_time = getCPUClockCount64(); + if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) + { + llinfos << "Slow frame, fast timers inaccurate" << llendl; + } + + if (!sPauseHistory) + { + NamedTimer::processTimes(); + sLastFrameIndex = sCurFrameIndex++; + } + + // get ready for next frame + NamedTimer::resetFrame(); + sLastFrameTime = frame_time; +} + +//static +void LLFastTimer::dumpCurTimes() +{ + // accumulate timings, etc. + NamedTimer::processTimes(); + + F64 clock_freq = (F64)countsPerSecond(); + F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds + + // walk over timers in depth order and output timings + for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); + it != end_timer_tree(); + ++it) + { + NamedTimer* timerp = (*it); + F64 total_time_ms = ((F64)timerp->getHistoricalCount(0) * iclock_freq); + // Don't bother with really brief times, keep output concise + if (total_time_ms < 0.1) continue; + + std::ostringstream out_str; + for (S32 i = 0; i < timerp->getDepth(); i++) + { + out_str << "\t"; + } + + + out_str << timerp->getName() << " " + << std::setprecision(3) << total_time_ms << " ms, " + << timerp->getHistoricalCalls(0) << " calls"; + + llinfos << out_str.str() << llendl; + } +} + +//static +void LLFastTimer::reset() +{ + NamedTimer::reset(); +} + + +//static +void LLFastTimer::writeLog(std::ostream& os) +{ + while (!sLogQueue.empty()) + { + LLSD& sd = sLogQueue.front(); + LLSDSerialize::toXML(sd, os); + LLMutexLock lock(sLogLock); + sLogQueue.pop(); + } +} + +//static +const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& name) +{ + return NamedTimerFactory::instance().getTimerByName(name); +} + +LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) +: mFrameState(state) +{ + U32 start_time = getCPUClockCount32(); + mStartTime = start_time; + mFrameState->mActiveCount++; + LLFastTimer::sCurTimerData.mCurTimer = this; + LLFastTimer::sCurTimerData.mFrameState = mFrameState; + LLFastTimer::sCurTimerData.mChildTime = 0; + mLastTimerData = LLFastTimer::sCurTimerData; +} + + diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 2b25f2fabb..e42e549df5 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -1,6 +1,6 @@ /** * @file llfasttimer.h - * @brief Inline implementations of fast timers. + * @brief Declaration of a fast timer. * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code @@ -27,9 +27,363 @@ #ifndef LL_FASTTIMER_H #define LL_FASTTIMER_H -// Implementation of getCPUClockCount32() and getCPUClockCount64 are now in llfastertimer_class.cpp. +#include "llinstancetracker.h" -// pull in the actual class definition -#include "llfasttimer_class.h" +#define FAST_TIMER_ON 1 +#define DEBUG_FAST_TIMER_THREADS 1 + +class LLMutex; + +#include <queue> +#include "llsd.h" + +#define LL_FASTTIMER_USE_RDTSC 1 + + +LL_COMMON_API void assert_main_thread(); + +class LL_COMMON_API LLFastTimer +{ +public: + class NamedTimer; + + struct LL_COMMON_API FrameState + { + FrameState(); + void setNamedTimer(NamedTimer* timerp) { mTimer = timerp; } + + U32 mSelfTimeCounter; + U32 mCalls; + FrameState* mParent; // info for caller timer + FrameState* mLastCaller; // used to bootstrap tree construction + NamedTimer* mTimer; + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + }; + + // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances + class LL_COMMON_API NamedTimer + : public LLInstanceTracker<NamedTimer> + { + friend class DeclareTimer; + public: + ~NamedTimer(); + + enum { HISTORY_NUM = 300 }; + + const std::string& getName() const { return mName; } + NamedTimer* getParent() const { return mParent; } + void setParent(NamedTimer* parent); + S32 getDepth(); + std::string getToolTip(S32 history_index = -1); + + typedef std::vector<NamedTimer*>::const_iterator child_const_iter; + child_const_iter beginChildren(); + child_const_iter endChildren(); + std::vector<NamedTimer*>& getChildren(); + + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } + + U32 getCountAverage() const { return mCountAverage; } + U32 getCallAverage() const { return mCallAverage; } + + U32 getHistoricalCount(S32 history_index = 0) const; + U32 getHistoricalCalls(S32 history_index = 0) const; + + void setFrameState(FrameState* state) { mFrameState = state; state->setNamedTimer(this); } + FrameState& getFrameState() const; + + private: + friend class LLFastTimer; + friend class NamedTimerFactory; + + // + // methods + // + NamedTimer(const std::string& name); + // recursive call to gather total time from children + static void accumulateTimings(); + + // updates cumulative times and hierarchy, + // can be called multiple times in a frame, at any point + static void processTimes(); + + static void buildHierarchy(); + static void resetFrame(); + static void reset(); + + // + // members + // + FrameState* mFrameState; + + std::string mName; + + U32 mTotalTimeCounter; + + U32 mCountAverage; + U32 mCallAverage; + + U32* mCountHistory; + U32* mCallHistory; + + // tree structure + NamedTimer* mParent; // NamedTimer of caller(parent) + std::vector<NamedTimer*> mChildren; + bool mCollapsed; // don't show children + bool mNeedsSorting; // sort children whenever child added + }; + + // used to statically declare a new named timer + class LL_COMMON_API DeclareTimer + : public LLInstanceTracker<DeclareTimer> + { + friend class LLFastTimer; + public: + DeclareTimer(const std::string& name, bool open); + DeclareTimer(const std::string& name); + + NamedTimer& getNamedTimer() { return mTimer; } + + private: + FrameState mFrameState; + NamedTimer& mTimer; + }; + +public: + LLFastTimer(LLFastTimer::FrameState* state); + + LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) + : mFrameState(&timer.mFrameState) + { +#if FAST_TIMER_ON + LLFastTimer::FrameState* frame_state = mFrameState; + mStartTime = getCPUClockCount32(); + + frame_state->mActiveCount++; + frame_state->mCalls++; + // keep current parent as long as it is active when we are + frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); + + LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; + mLastTimerData = *cur_timer_data; + cur_timer_data->mCurTimer = this; + cur_timer_data->mFrameState = frame_state; + cur_timer_data->mChildTime = 0; +#endif +#if DEBUG_FAST_TIMER_THREADS +#if !LL_RELEASE + assert_main_thread(); +#endif +#endif + } + + LL_FORCE_INLINE ~LLFastTimer() + { +#if FAST_TIMER_ON + LLFastTimer::FrameState* frame_state = mFrameState; + U32 total_time = getCPUClockCount32() - mStartTime; + + frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + frame_state->mActiveCount--; + + // store last caller to bootstrap tree creation + // do this in the destructor in case of recursion to get topmost caller + frame_state->mLastCaller = mLastTimerData.mFrameState; + + // we are only tracking self time, so subtract our total time delta from parents + mLastTimerData.mChildTime += total_time; + + LLFastTimer::sCurTimerData = mLastTimerData; +#endif + } + +public: + static LLMutex* sLogLock; + static std::queue<LLSD> sLogQueue; + static BOOL sLog; + static BOOL sMetricLog; + static std::string sLogName; + static bool sPauseHistory; + static bool sResetHistory; + + // call this once a frame to reset timers + static void nextFrame(); + + // dumps current cumulative frame stats to log + // call nextFrame() to reset timers + static void dumpCurTimes(); + + // call this to reset timer hierarchy, averages, etc. + static void reset(); + + static U64 countsPerSecond(); + static S32 getLastFrameIndex() { return sLastFrameIndex; } + static S32 getCurFrameIndex() { return sCurFrameIndex; } + + static void writeLog(std::ostream& os); + static const NamedTimer* getTimerByName(const std::string& name); + + struct CurTimerData + { + LLFastTimer* mCurTimer; + FrameState* mFrameState; + U32 mChildTime; + }; + static CurTimerData sCurTimerData; + +private: + + + ////////////////////////////////////////////////////////////////////////////// + // + // Important note: These implementations must be FAST! + // + + +#if LL_WINDOWS + // + // Windows implementation of CPU clock + // + + // + // NOTE: put back in when we aren't using platform sdk anymore + // + // because MS has different signatures for these functions in winnt.h + // need to rename them to avoid conflicts + //#define _interlockedbittestandset _renamed_interlockedbittestandset + //#define _interlockedbittestandreset _renamed_interlockedbittestandreset + //#include <intrin.h> + //#undef _interlockedbittestandset + //#undef _interlockedbittestandreset + + //inline U32 LLFastTimer::getCPUClockCount32() + //{ + // U64 time_stamp = __rdtsc(); + // return (U32)(time_stamp >> 8); + //} + // + //// return full timer value, *not* shifted by 8 bits + //inline U64 LLFastTimer::getCPUClockCount64() + //{ + // return __rdtsc(); + //} + + // shift off lower 8 bits for lower resolution but longer term timing + // on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing +#if LL_FASTTIMER_USE_RDTSC + static U32 getCPUClockCount32() + { + U32 ret_val; + __asm + { + _emit 0x0f + _emit 0x31 + shr eax,8 + shl edx,24 + or eax, edx + mov dword ptr [ret_val], eax + } + return ret_val; + } + + // return full timer value, *not* shifted by 8 bits + static U64 getCPUClockCount64() + { + U64 ret_val; + __asm + { + _emit 0x0f + _emit 0x31 + mov eax,eax + mov edx,edx + mov dword ptr [ret_val+4], edx + mov dword ptr [ret_val], eax + } + return ret_val; + } + +#else + //LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp + // These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures. + static U32 getCPUClockCount32() + { + return (U32)(get_clock_count()>>8); + } + + static U64 getCPUClockCount64() + { + return get_clock_count(); + } + +#endif + +#endif + + +#if (LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) + // + // Linux and Solaris implementation of CPU clock - non-x86. + // This is accurate but SLOW! Only use out of desperation. + // + // Try to use the MONOTONIC clock if available, this is a constant time counter + // with nanosecond resolution (but not necessarily accuracy) and attempts are + // made to synchronize this value between cores at kernel start. It should not + // be affected by CPU frequency. If not available use the REALTIME clock, but + // this may be affected by NTP adjustments or other user activity affecting + // the system time. + static U64 getCPUClockCount64() + { + struct timespec tp; + +#ifdef CLOCK_MONOTONIC // MONOTONIC supported at build-time? + if (-1 == clock_gettime(CLOCK_MONOTONIC,&tp)) // if MONOTONIC isn't supported at runtime then ouch, try REALTIME +#endif + clock_gettime(CLOCK_REALTIME,&tp); + + return (tp.tv_sec*sClockResolution)+tp.tv_nsec; + } + + static U32 getCPUClockCount32() + { + return (U32)(getCPUClockCount64() >> 8); + } + +#endif // (LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) + + +#if (LL_LINUX || LL_SOLARIS || LL_DARWIN) && (defined(__i386__) || defined(__amd64__)) + // + // Mac+Linux+Solaris FAST x86 implementation of CPU clock + static U32 getCPUClockCount32() + { + U64 x; + __asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); + return (U32)(x >> 8); + } + + static U64 getCPUClockCount64() + { + U64 x; + __asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); + return x; + } + +#endif + + static U64 sClockResolution; + + static S32 sCurFrameIndex; + static S32 sLastFrameIndex; + static U64 sLastFrameTime; + + U32 mStartTime; + LLFastTimer::FrameState* mFrameState; + LLFastTimer::CurTimerData mLastTimerData; + +}; + +typedef class LLFastTimer LLFastTimer; #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp deleted file mode 100644 index 449074dbfe..0000000000 --- a/indra/llcommon/llfasttimer_class.cpp +++ /dev/null @@ -1,913 +0,0 @@ -/** - * @file llfasttimer_class.cpp - * @brief Implementation of the fast timer. - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#include "linden_common.h" - -#include "llfasttimer.h" - -#include "llmemory.h" -#include "llprocessor.h" -#include "llsingleton.h" -#include "lltreeiterators.h" -#include "llsdserialize.h" - -#include <boost/bind.hpp> - - -#if LL_WINDOWS -#include "lltimer.h" -#elif LL_LINUX || LL_SOLARIS -#include <sys/time.h> -#include <sched.h> -#include "lltimer.h" -#elif LL_DARWIN -#include <sys/time.h> -#include "lltimer.h" // get_clock_count() -#else -#error "architecture not supported" -#endif - -////////////////////////////////////////////////////////////////////////////// -// statics - -S32 LLFastTimer::sCurFrameIndex = -1; -S32 LLFastTimer::sLastFrameIndex = -1; -U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64(); -bool LLFastTimer::sPauseHistory = 0; -bool LLFastTimer::sResetHistory = 0; -LLFastTimer::CurTimerData LLFastTimer::sCurTimerData; -BOOL LLFastTimer::sLog = FALSE; -std::string LLFastTimer::sLogName = ""; -BOOL LLFastTimer::sMetricLog = FALSE; -LLMutex* LLFastTimer::sLogLock = NULL; -std::queue<LLSD> LLFastTimer::sLogQueue; - -#define USE_RDTSC 0 - -#if LL_LINUX || LL_SOLARIS -U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution -#else -U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution -#endif - -std::vector<LLFastTimer::FrameState>* LLFastTimer::sTimerInfos = NULL; - -// FIXME: move these declarations to the relevant modules - -// helper functions -typedef LLTreeDFSPostIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_bottom_up_iterator_t; - -static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(LLFastTimer::NamedTimer& id) -{ - return timer_tree_bottom_up_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); -} - -static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() -{ - return timer_tree_bottom_up_iterator_t(); -} - -typedef LLTreeDFSIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_dfs_iterator_t; - - -static timer_tree_dfs_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) -{ - return timer_tree_dfs_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); -} - -static timer_tree_dfs_iterator_t end_timer_tree() -{ - return timer_tree_dfs_iterator_t(); -} - - - -// factory class that creates NamedTimers via static DeclareTimer objects -class NamedTimerFactory : public LLSingleton<NamedTimerFactory> -{ -public: - NamedTimerFactory() - : mActiveTimerRoot(NULL), - mTimerRoot(NULL), - mAppTimer(NULL), - mRootFrameState(NULL) - {} - - /*virtual */ void initSingleton() - { - mTimerRoot = new LLFastTimer::NamedTimer("root"); - - mActiveTimerRoot = new LLFastTimer::NamedTimer("Frame"); - mActiveTimerRoot->setCollapsed(false); - - mRootFrameState = new LLFastTimer::FrameState(mActiveTimerRoot); - mRootFrameState->mParent = &mTimerRoot->getFrameState(); - mActiveTimerRoot->setParent(mTimerRoot); - - mAppTimer = new LLFastTimer(mRootFrameState); - } - - ~NamedTimerFactory() - { - std::for_each(mTimers.begin(), mTimers.end(), DeletePairedPointer()); - - delete mAppTimer; - delete mActiveTimerRoot; - delete mTimerRoot; - delete mRootFrameState; - } - - LLFastTimer::NamedTimer& createNamedTimer(const std::string& name) - { - timer_map_t::iterator found_it = mTimers.find(name); - if (found_it != mTimers.end()) - { - return *found_it->second; - } - - LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); - timer->setParent(mTimerRoot); - mTimers.insert(std::make_pair(name, timer)); - - return *timer; - } - - LLFastTimer::NamedTimer* getTimerByName(const std::string& name) - { - timer_map_t::iterator found_it = mTimers.find(name); - if (found_it != mTimers.end()) - { - return found_it->second; - } - return NULL; - } - - LLFastTimer::NamedTimer* getActiveRootTimer() { return mActiveTimerRoot; } - LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; } - const LLFastTimer* getAppTimer() { return mAppTimer; } - LLFastTimer::FrameState& getRootFrameState() { return *mRootFrameState; } - - typedef std::map<std::string, LLFastTimer::NamedTimer*> timer_map_t; - timer_map_t::iterator beginTimers() { return mTimers.begin(); } - timer_map_t::iterator endTimers() { return mTimers.end(); } - S32 timerCount() { return mTimers.size(); } - -private: - timer_map_t mTimers; - - LLFastTimer::NamedTimer* mActiveTimerRoot; - LLFastTimer::NamedTimer* mTimerRoot; - LLFastTimer* mAppTimer; - LLFastTimer::FrameState* mRootFrameState; -}; - -void update_cached_pointers_if_changed() -{ - // detect when elements have moved and update cached pointers - static LLFastTimer::FrameState* sFirstTimerAddress = NULL; - if (&*(LLFastTimer::getFrameStateList().begin()) != sFirstTimerAddress) - { - LLFastTimer::DeclareTimer::updateCachedPointers(); - } - sFirstTimerAddress = &*(LLFastTimer::getFrameStateList().begin()); -} - -LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open ) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name)) -{ - mTimer.setCollapsed(!open); - mFrameState = &mTimer.getFrameState(); - update_cached_pointers_if_changed(); -} - -LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name)) -{ - mFrameState = &mTimer.getFrameState(); - update_cached_pointers_if_changed(); -} - -// static -void LLFastTimer::DeclareTimer::updateCachedPointers() -{ - // propagate frame state pointers to timer declarations - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - // update cached pointer - it->mFrameState = &it->mTimer.getFrameState(); - } - - // also update frame states of timers on stack - LLFastTimer* cur_timerp = LLFastTimer::sCurTimerData.mCurTimer; - while(cur_timerp->mLastTimerData.mCurTimer != cur_timerp) - { - cur_timerp->mFrameState = &cur_timerp->mFrameState->mTimer->getFrameState(); - cur_timerp = cur_timerp->mLastTimerData.mCurTimer; - } -} - -//static -#if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer -{ - return sClockResolution >> 8; -} -#else // windows or x86-mac or x86-linux or x86-solaris -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer -{ -#if USE_RDTSC || !LL_WINDOWS - //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz - static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0); - - // we drop the low-order byte in our timers, so report a lower frequency -#else - // If we're not using RDTSC, each fasttimer tick is just a performance counter tick. - // Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency()) - // since that would change displayed MHz stats for CPUs - static bool firstcall = true; - static U64 sCPUClockFrequency; - if (firstcall) - { - QueryPerformanceFrequency((LARGE_INTEGER*)&sCPUClockFrequency); - firstcall = false; - } -#endif - return sCPUClockFrequency >> 8; -} -#endif - -LLFastTimer::FrameState::FrameState(LLFastTimer::NamedTimer* timerp) -: mActiveCount(0), - mCalls(0), - mSelfTimeCounter(0), - mParent(NULL), - mLastCaller(NULL), - mMoveUpTree(false), - mTimer(timerp) -{} - - -LLFastTimer::NamedTimer::NamedTimer(const std::string& name) -: mName(name), - mCollapsed(true), - mParent(NULL), - mTotalTimeCounter(0), - mCountAverage(0), - mCallAverage(0), - mNeedsSorting(false) -{ - info_list_t& frame_state_list = getFrameStateList(); - mFrameStateIndex = frame_state_list.size(); - getFrameStateList().push_back(FrameState(this)); - - mCountHistory = new U32[HISTORY_NUM]; - memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM); - mCallHistory = new U32[HISTORY_NUM]; - memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); -} - -LLFastTimer::NamedTimer::~NamedTimer() -{ - delete[] mCountHistory; - delete[] mCallHistory; -} - -std::string LLFastTimer::NamedTimer::getToolTip(S32 history_idx) -{ - F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); - if (history_idx < 0) - { - // by default, show average number of call - return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getCountAverage() * ms_multiplier), (S32)getCallAverage()); - } - else - { - return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getHistoricalCount(history_idx) * ms_multiplier), (S32)getHistoricalCalls(history_idx)); - } -} - -void LLFastTimer::NamedTimer::setParent(NamedTimer* parent) -{ - llassert_always(parent != this); - llassert_always(parent != NULL); - - if (mParent) - { - // subtract our accumulated from previous parent - for (S32 i = 0; i < HISTORY_NUM; i++) - { - mParent->mCountHistory[i] -= mCountHistory[i]; - } - - // subtract average timing from previous parent - mParent->mCountAverage -= mCountAverage; - - std::vector<NamedTimer*>& children = mParent->getChildren(); - std::vector<NamedTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); - if (found_it != children.end()) - { - children.erase(found_it); - } - } - - mParent = parent; - if (parent) - { - getFrameState().mParent = &parent->getFrameState(); - parent->getChildren().push_back(this); - parent->mNeedsSorting = true; - } -} - -S32 LLFastTimer::NamedTimer::getDepth() -{ - S32 depth = 0; - NamedTimer* timerp = mParent; - while(timerp) - { - depth++; - timerp = timerp->mParent; - } - return depth; -} - -// static -void LLFastTimer::NamedTimer::processTimes() -{ - if (sCurFrameIndex < 0) return; - - buildHierarchy(); - accumulateTimings(); -} - -// sort timer info structs by depth first traversal order -struct SortTimersDFS -{ - bool operator()(const LLFastTimer::FrameState& i1, const LLFastTimer::FrameState& i2) - { - return i1.mTimer->getFrameStateIndex() < i2.mTimer->getFrameStateIndex(); - } -}; - -// sort child timers by name -struct SortTimerByName -{ - bool operator()(const LLFastTimer::NamedTimer* i1, const LLFastTimer::NamedTimer* i2) - { - return i1->getName() < i2->getName(); - } -}; - -//static -void LLFastTimer::NamedTimer::buildHierarchy() -{ - if (sCurFrameIndex < 0 ) return; - - // set up initial tree - { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - NamedTimer& timer = *it; - if (&timer == NamedTimerFactory::instance().getRootTimer()) continue; - - // bootstrap tree construction by attaching to last timer to be on stack - // when this timer was called - if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer()) - { - timer.setParent(timer.getFrameState().mLastCaller->mTimer); - // no need to push up tree on first use, flag can be set spuriously - timer.getFrameState().mMoveUpTree = false; - } - } - } - - // bump timers up tree if they've been flagged as being in the wrong place - // do this in a bottom up order to promote descendants first before promoting ancestors - // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getRootTimer()); - it != end_timer_tree_bottom_up(); - ++it) - { - NamedTimer* timerp = *it; - // skip root timer - if (timerp == NamedTimerFactory::instance().getRootTimer()) continue; - - if (timerp->getFrameState().mMoveUpTree) - { - // since ancestors have already been visited, reparenting won't affect tree traversal - //step up tree, bringing our descendants with us - LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << - " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; - timerp->setParent(timerp->getParent()->getParent()); - timerp->getFrameState().mMoveUpTree = false; - - // don't bubble up any ancestors until descendants are done bubbling up - it.skipAncestors(); - } - } - - // sort timers by time last called, so call graph makes sense - for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); - it != end_timer_tree(); - ++it) - { - NamedTimer* timerp = (*it); - if (timerp->mNeedsSorting) - { - std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); - } - timerp->mNeedsSorting = false; - } -} - -//static -void LLFastTimer::NamedTimer::accumulateTimings() -{ - U32 cur_time = getCPUClockCount32(); - - // walk up stack of active timers and accumulate current time while leaving timing structures active - LLFastTimer* cur_timer = sCurTimerData.mCurTimer; - // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; - while(cur_timer->mLastTimerData.mCurTimer != cur_timer) - { - U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; - U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; - cur_data->mChildTime = 0; - cur_timer->mFrameState->mSelfTimeCounter += self_time_delta; - cur_timer->mStartTime = cur_time; - - cur_data = &cur_timer->mLastTimerData; - cur_data->mChildTime += cumulative_time_delta; - - cur_timer = cur_timer->mLastTimerData.mCurTimer; - } - - // traverse tree in DFS post order, or bottom up - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getActiveRootTimer()); - it != end_timer_tree_bottom_up(); - ++it) - { - NamedTimer* timerp = (*it); - timerp->mTotalTimeCounter = timerp->getFrameState().mSelfTimeCounter; - for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) - { - timerp->mTotalTimeCounter += (*child_it)->mTotalTimeCounter; - } - - S32 cur_frame = sCurFrameIndex; - if (cur_frame >= 0) - { - // update timer history - int hidx = cur_frame % HISTORY_NUM; - - timerp->mCountHistory[hidx] = timerp->mTotalTimeCounter; - timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTotalTimeCounter) / (cur_frame+1); - timerp->mCallHistory[hidx] = timerp->getFrameState().mCalls; - timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->getFrameState().mCalls) / (cur_frame+1); - } - } -} - -// static -void LLFastTimer::NamedTimer::resetFrame() -{ - if (sLog) - { //output current frame counts to performance log - - static S32 call_count = 0; - if (call_count % 100 == 0) - { - LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL; - LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << llendl; - LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; - LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64())/((F64)LLProcessorInfo().getCPUFrequency()*1000000.0) << LL_ENDL; - } - call_count++; - - F64 iclock_freq = 1000.0 / countsPerSecond(); // good place to calculate clock frequency - - F64 total_time = 0; - LLSD sd; - - { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - NamedTimer& timer = *it; - FrameState& info = timer.getFrameState(); - sd[timer.getName()]["Time"] = (LLSD::Real) (info.mSelfTimeCounter*iclock_freq); - sd[timer.getName()]["Calls"] = (LLSD::Integer) info.mCalls; - - // computing total time here because getting the root timer's getCountHistory - // doesn't work correctly on the first frame - total_time = total_time + info.mSelfTimeCounter * iclock_freq; - } - } - - sd["Total"]["Time"] = (LLSD::Real) total_time; - sd["Total"]["Calls"] = (LLSD::Integer) 1; - - { - LLMutexLock lock(sLogLock); - sLogQueue.push(sd); - } - } - - - // tag timers by position in depth first traversal of tree - S32 index = 0; - for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); - it != end_timer_tree(); - ++it) - { - NamedTimer* timerp = (*it); - - timerp->mFrameStateIndex = index; - index++; - - llassert_always(timerp->mFrameStateIndex < (S32)getFrameStateList().size()); - } - - // sort timers by DFS traversal order to improve cache coherency - std::sort(getFrameStateList().begin(), getFrameStateList().end(), SortTimersDFS()); - - // update pointers into framestatelist now that we've sorted it - DeclareTimer::updateCachedPointers(); - - // reset for next frame - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - NamedTimer& timer = *it; - - FrameState& info = timer.getFrameState(); - info.mSelfTimeCounter = 0; - info.mCalls = 0; - info.mLastCaller = NULL; - info.mMoveUpTree = false; - // update parent pointer in timer state struct - if (timer.mParent) - { - info.mParent = &timer.mParent->getFrameState(); - } - } -} - -//static -void LLFastTimer::NamedTimer::reset() -{ - resetFrame(); // reset frame data - - // walk up stack of active timers and reset start times to current time - // effectively zeroing out any accumulated time - U32 cur_time = getCPUClockCount32(); - - // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; - LLFastTimer* cur_timer = cur_data->mCurTimer; - while(cur_timer->mLastTimerData.mCurTimer != cur_timer) - { - cur_timer->mStartTime = cur_time; - cur_data->mChildTime = 0; - - cur_data = &cur_timer->mLastTimerData; - cur_timer = cur_data->mCurTimer; - } - - // reset all history - { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) - { - NamedTimer& timer = *it; - if (&timer != NamedTimerFactory::instance().getRootTimer()) - { - timer.setParent(NamedTimerFactory::instance().getRootTimer()); - } - - timer.mCountAverage = 0; - timer.mCallAverage = 0; - memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM); - memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM); - } - } - - sLastFrameIndex = 0; - sCurFrameIndex = 0; -} - -//static -LLFastTimer::info_list_t& LLFastTimer::getFrameStateList() -{ - if (!sTimerInfos) - { - sTimerInfos = new info_list_t(); - } - return *sTimerInfos; -} - - -U32 LLFastTimer::NamedTimer::getHistoricalCount(S32 history_index) const -{ - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; - return mCountHistory[history_idx]; -} - -U32 LLFastTimer::NamedTimer::getHistoricalCalls(S32 history_index ) const -{ - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; - return mCallHistory[history_idx]; -} - -LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const -{ - llassert_always(mFrameStateIndex >= 0); - if (this == NamedTimerFactory::instance().getActiveRootTimer()) - { - return NamedTimerFactory::instance().getRootFrameState(); - } - return getFrameStateList()[mFrameStateIndex]; -} - -// static -LLFastTimer::NamedTimer& LLFastTimer::NamedTimer::getRootNamedTimer() -{ - return *NamedTimerFactory::instance().getActiveRootTimer(); -} - -std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::beginChildren() -{ - return mChildren.begin(); -} - -std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::endChildren() -{ - return mChildren.end(); -} - -std::vector<LLFastTimer::NamedTimer*>& LLFastTimer::NamedTimer::getChildren() -{ - return mChildren; -} - -//static -void LLFastTimer::nextFrame() -{ - countsPerSecond(); // good place to calculate clock frequency - U64 frame_time = getCPUClockCount64(); - if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) - { - llinfos << "Slow frame, fast timers inaccurate" << llendl; - } - - if (!sPauseHistory) - { - NamedTimer::processTimes(); - sLastFrameIndex = sCurFrameIndex++; - } - - // get ready for next frame - NamedTimer::resetFrame(); - sLastFrameTime = frame_time; -} - -//static -void LLFastTimer::dumpCurTimes() -{ - // accumulate timings, etc. - NamedTimer::processTimes(); - - F64 clock_freq = (F64)countsPerSecond(); - F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds - - // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); - it != end_timer_tree(); - ++it) - { - NamedTimer* timerp = (*it); - F64 total_time_ms = ((F64)timerp->getHistoricalCount(0) * iclock_freq); - // Don't bother with really brief times, keep output concise - if (total_time_ms < 0.1) continue; - - std::ostringstream out_str; - for (S32 i = 0; i < timerp->getDepth(); i++) - { - out_str << "\t"; - } - - - out_str << timerp->getName() << " " - << std::setprecision(3) << total_time_ms << " ms, " - << timerp->getHistoricalCalls(0) << " calls"; - - llinfos << out_str.str() << llendl; - } -} - -//static -void LLFastTimer::reset() -{ - NamedTimer::reset(); -} - - -//static -void LLFastTimer::writeLog(std::ostream& os) -{ - while (!sLogQueue.empty()) - { - LLSD& sd = sLogQueue.front(); - LLSDSerialize::toXML(sd, os); - LLMutexLock lock(sLogLock); - sLogQueue.pop(); - } -} - -//static -const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& name) -{ - return NamedTimerFactory::instance().getTimerByName(name); -} - -LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) -: mFrameState(state) -{ - U32 start_time = getCPUClockCount32(); - mStartTime = start_time; - mFrameState->mActiveCount++; - LLFastTimer::sCurTimerData.mCurTimer = this; - LLFastTimer::sCurTimerData.mFrameState = mFrameState; - LLFastTimer::sCurTimerData.mChildTime = 0; - mLastTimerData = LLFastTimer::sCurTimerData; -} - - -////////////////////////////////////////////////////////////////////////////// -// -// Important note: These implementations must be FAST! -// - - -#if LL_WINDOWS -// -// Windows implementation of CPU clock -// - -// -// NOTE: put back in when we aren't using platform sdk anymore -// -// because MS has different signatures for these functions in winnt.h -// need to rename them to avoid conflicts -//#define _interlockedbittestandset _renamed_interlockedbittestandset -//#define _interlockedbittestandreset _renamed_interlockedbittestandreset -//#include <intrin.h> -//#undef _interlockedbittestandset -//#undef _interlockedbittestandreset - -//inline U32 LLFastTimer::getCPUClockCount32() -//{ -// U64 time_stamp = __rdtsc(); -// return (U32)(time_stamp >> 8); -//} -// -//// return full timer value, *not* shifted by 8 bits -//inline U64 LLFastTimer::getCPUClockCount64() -//{ -// return __rdtsc(); -//} - -// shift off lower 8 bits for lower resolution but longer term timing -// on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing -#if USE_RDTSC -U32 LLFastTimer::getCPUClockCount32() -{ - U32 ret_val; - __asm - { - _emit 0x0f - _emit 0x31 - shr eax,8 - shl edx,24 - or eax, edx - mov dword ptr [ret_val], eax - } - return ret_val; -} - -// return full timer value, *not* shifted by 8 bits -U64 LLFastTimer::getCPUClockCount64() -{ - U64 ret_val; - __asm - { - _emit 0x0f - _emit 0x31 - mov eax,eax - mov edx,edx - mov dword ptr [ret_val+4], edx - mov dword ptr [ret_val], eax - } - return ret_val; -} - -std::string LLFastTimer::sClockType = "rdtsc"; - -#else -//LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp -// These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures. -U32 LLFastTimer::getCPUClockCount32() -{ - return (U32)(get_clock_count()>>8); -} - -U64 LLFastTimer::getCPUClockCount64() -{ - return get_clock_count(); -} - -std::string LLFastTimer::sClockType = "QueryPerformanceCounter"; -#endif - -#endif - - -#if (LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -// -// Linux and Solaris implementation of CPU clock - non-x86. -// This is accurate but SLOW! Only use out of desperation. -// -// Try to use the MONOTONIC clock if available, this is a constant time counter -// with nanosecond resolution (but not necessarily accuracy) and attempts are -// made to synchronize this value between cores at kernel start. It should not -// be affected by CPU frequency. If not available use the REALTIME clock, but -// this may be affected by NTP adjustments or other user activity affecting -// the system time. -U64 LLFastTimer::getCPUClockCount64() -{ - struct timespec tp; - -#ifdef CLOCK_MONOTONIC // MONOTONIC supported at build-time? - if (-1 == clock_gettime(CLOCK_MONOTONIC,&tp)) // if MONOTONIC isn't supported at runtime then ouch, try REALTIME -#endif - clock_gettime(CLOCK_REALTIME,&tp); - - return (tp.tv_sec*LLFastTimer::sClockResolution)+tp.tv_nsec; -} - -U32 LLFastTimer::getCPUClockCount32() -{ - return (U32)(LLFastTimer::getCPUClockCount64() >> 8); -} - -std::string LLFastTimer::sClockType = "clock_gettime"; - -#endif // (LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) - - -#if (LL_LINUX || LL_SOLARIS || LL_DARWIN) && (defined(__i386__) || defined(__amd64__)) -// -// Mac+Linux+Solaris FAST x86 implementation of CPU clock -U32 LLFastTimer::getCPUClockCount32() -{ - U64 x; - __asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); - return (U32)(x >> 8); -} - -U64 LLFastTimer::getCPUClockCount64() -{ - U64 x; - __asm__ volatile (".byte 0x0f, 0x31": "=A"(x)); - return x; -} - -std::string LLFastTimer::sClockType = "rdtsc"; -#endif - diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h deleted file mode 100644 index 8a12aa1372..0000000000 --- a/indra/llcommon/llfasttimer_class.h +++ /dev/null @@ -1,258 +0,0 @@ -/** - * @file llfasttimer_class.h - * @brief Declaration of a fast timer. - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_FASTTIMER_CLASS_H -#define LL_FASTTIMER_CLASS_H - -#include "llinstancetracker.h" - -#define FAST_TIMER_ON 1 -#define DEBUG_FAST_TIMER_THREADS 1 - -class LLMutex; - -#include <queue> -#include "llsd.h" - -LL_COMMON_API void assert_main_thread(); - -class LL_COMMON_API LLFastTimer -{ -public: - class NamedTimer; - - struct LL_COMMON_API FrameState - { - FrameState(NamedTimer* timerp); - - U32 mSelfTimeCounter; - U32 mCalls; - FrameState* mParent; // info for caller timer - FrameState* mLastCaller; // used to bootstrap tree construction - NamedTimer* mTimer; - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - }; - - // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances - class LL_COMMON_API NamedTimer - : public LLInstanceTracker<NamedTimer> - { - friend class DeclareTimer; - public: - ~NamedTimer(); - - enum { HISTORY_NUM = 300 }; - - const std::string& getName() const { return mName; } - NamedTimer* getParent() const { return mParent; } - void setParent(NamedTimer* parent); - S32 getDepth(); - std::string getToolTip(S32 history_index = -1); - - typedef std::vector<NamedTimer*>::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); - std::vector<NamedTimer*>& getChildren(); - - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U32 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; - - static NamedTimer& getRootNamedTimer(); - - S32 getFrameStateIndex() const { return mFrameStateIndex; } - - FrameState& getFrameState() const; - - private: - friend class LLFastTimer; - friend class NamedTimerFactory; - - // - // methods - // - NamedTimer(const std::string& name); - // recursive call to gather total time from children - static void accumulateTimings(); - - // updates cumulative times and hierarchy, - // can be called multiple times in a frame, at any point - static void processTimes(); - - static void buildHierarchy(); - static void resetFrame(); - static void reset(); - - // - // members - // - S32 mFrameStateIndex; - - std::string mName; - - U32 mTotalTimeCounter; - - U32 mCountAverage; - U32 mCallAverage; - - U32* mCountHistory; - U32* mCallHistory; - - // tree structure - NamedTimer* mParent; // NamedTimer of caller(parent) - std::vector<NamedTimer*> mChildren; - bool mCollapsed; // don't show children - bool mNeedsSorting; // sort children whenever child added - }; - - // used to statically declare a new named timer - class LL_COMMON_API DeclareTimer - : public LLInstanceTracker<DeclareTimer> - { - friend class LLFastTimer; - public: - DeclareTimer(const std::string& name, bool open); - DeclareTimer(const std::string& name); - - static void updateCachedPointers(); - - private: - NamedTimer& mTimer; - FrameState* mFrameState; - }; - -public: - LLFastTimer(LLFastTimer::FrameState* state); - - LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - : mFrameState(timer.mFrameState) - { -#if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; - mStartTime = getCPUClockCount32(); - - frame_state->mActiveCount++; - frame_state->mCalls++; - // keep current parent as long as it is active when we are - frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); - - LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; - mLastTimerData = *cur_timer_data; - cur_timer_data->mCurTimer = this; - cur_timer_data->mFrameState = frame_state; - cur_timer_data->mChildTime = 0; -#endif -#if DEBUG_FAST_TIMER_THREADS -#if !LL_RELEASE - assert_main_thread(); -#endif -#endif - } - - LL_FORCE_INLINE ~LLFastTimer() - { -#if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; - U32 total_time = getCPUClockCount32() - mStartTime; - - frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; - frame_state->mActiveCount--; - - // store last caller to bootstrap tree creation - // do this in the destructor in case of recursion to get topmost caller - frame_state->mLastCaller = mLastTimerData.mFrameState; - - // we are only tracking self time, so subtract our total time delta from parents - mLastTimerData.mChildTime += total_time; - - LLFastTimer::sCurTimerData = mLastTimerData; -#endif - } - -public: - static LLMutex* sLogLock; - static std::queue<LLSD> sLogQueue; - static BOOL sLog; - static BOOL sMetricLog; - static std::string sLogName; - static bool sPauseHistory; - static bool sResetHistory; - - typedef std::vector<FrameState> info_list_t; - static info_list_t& getFrameStateList(); - - - // call this once a frame to reset timers - static void nextFrame(); - - // dumps current cumulative frame stats to log - // call nextFrame() to reset timers - static void dumpCurTimes(); - - // call this to reset timer hierarchy, averages, etc. - static void reset(); - - static U64 countsPerSecond(); - static S32 getLastFrameIndex() { return sLastFrameIndex; } - static S32 getCurFrameIndex() { return sCurFrameIndex; } - - static void writeLog(std::ostream& os); - static const NamedTimer* getTimerByName(const std::string& name); - - struct CurTimerData - { - LLFastTimer* mCurTimer; - FrameState* mFrameState; - U32 mChildTime; - }; - static CurTimerData sCurTimerData; - static std::string sClockType; - -private: - static U32 getCPUClockCount32(); - static U64 getCPUClockCount64(); - static U64 sClockResolution; - - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; - static U64 sLastFrameTime; - static info_list_t* sTimerInfos; - - U32 mStartTime; - LLFastTimer::FrameState* mFrameState; - LLFastTimer::CurTimerData mLastTimerData; - -}; - -typedef class LLFastTimer LLFastTimer; - -#endif // LL_LLFASTTIMER_CLASS_H diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 161cc418dd..c717a64501 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1168,6 +1168,8 @@ static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback"); static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot"); static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update"); +LLFastTimer::DeclareTimer FTM_FRAME("Frame"); + bool LLAppViewer::mainLoop() { LLMemType mt1(LLMemType::MTYPE_MAIN); @@ -1206,7 +1208,8 @@ bool LLAppViewer::mainLoop() // Handle messages while (!LLApp::isExiting()) { - LLFastTimer::nextFrame(); // Should be outside of any timer instances + LLFastTimer _(FTM_FRAME); + LLFastTimer::nextFrame(); //clear call stack records llclearcallstacks; @@ -3106,8 +3109,6 @@ void LLAppViewer::writeSystemInfo() LL_INFOS("SystemInfo") << "OS: " << getOSInfo().getOSStringSimple() << LL_ENDL; LL_INFOS("SystemInfo") << "OS info: " << getOSInfo() << LL_ENDL; - LL_INFOS("SystemInfo") << "Timers: " << LLFastTimer::sClockType << LL_ENDL; - writeDebugInfo(); // Save out debug_info.log early, in case of crash. } diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index f7d019ccba..304b084d39 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -41,6 +41,9 @@ class LLTextureFetch; class LLWatchdogTimeout; class LLUpdaterService; +extern LLFastTimer::DeclareTimer FTM_FRAME; + + class LLAppViewer : public LLApp { public: diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 6f71e6ebc8..a340f43594 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -1192,7 +1192,7 @@ static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_MIN_MAX("Min/Max"); static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_RGB2LUM("RGB to Luminance"); static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_RESCALE("Rescale"); static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_GEN_NORMAL("Generate Normal"); -static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_CREATE("Create"); +static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_CREATE("Bump Source Create"); // static void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code ) diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index c032d5d049..59bf70f488 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -160,7 +160,7 @@ LLFastTimer::NamedTimer* LLFastTimerView::getLegendID(S32 y) BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask) { - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it) { @@ -257,7 +257,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { @@ -419,11 +419,11 @@ void LLFastTimerView::draw() y -= (texth + 2); - sTimerColors[&LLFastTimer::NamedTimer::getRootNamedTimer()] = LLColor4::grey; + sTimerColors[&getFrameTimer()] = LLColor4::grey; F32 hue = 0.f; - for (timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { @@ -448,7 +448,7 @@ void LLFastTimerView::draw() S32 cur_line = 0; ft_display_idx.clear(); std::map<LLFastTimer::NamedTimer*, S32> display_line; - for (timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { @@ -558,7 +558,7 @@ void LLFastTimerView::draw() U64 totalticks; if (!LLFastTimer::sPauseHistory) { - U64 ticks = LLFastTimer::NamedTimer::getRootNamedTimer().getHistoricalCount(mScrollIndex); + U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex); if (LLFastTimer::getCurFrameIndex() >= 10) { @@ -598,7 +598,7 @@ void LLFastTimerView::draw() totalticks = 0; for (S32 j=0; j<histmax; j++) { - U64 ticks = LLFastTimer::NamedTimer::getRootNamedTimer().getHistoricalCount(j); + U64 ticks = getFrameTimer().getHistoricalCount(j); if (ticks > totalticks) totalticks = ticks; @@ -704,7 +704,7 @@ void LLFastTimerView::draw() LLFastTimer::NamedTimer* prev_id = NULL; S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { @@ -867,7 +867,7 @@ void LLFastTimerView::draw() } U64 cur_max = 0; - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it) { @@ -968,7 +968,7 @@ void LLFastTimerView::draw() { std::string legend_stat; bool first = true; - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it) { @@ -990,7 +990,7 @@ void LLFastTimerView::draw() std::string timer_stat; first = true; - for(timer_tree_iterator_t it = begin_timer_tree(LLFastTimer::NamedTimer::getRootNamedTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it) { @@ -1551,3 +1551,9 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } +LLFastTimer::NamedTimer& LLFastTimerView::getFrameTimer() +{ + return FTM_FRAME.getNamedTimer(); +} + + diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 1fda91f173..5766cfa0b0 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -46,6 +46,7 @@ private: static LLSD analyzePerformanceLogDefault(std::istream& is) ; static void exportCharts(const std::string& base, const std::string& target); void onPause(); + LLFastTimer::NamedTimer& getFrameTimer(); public: -- cgit v1.2.3 From 03dd09b1620b8331529f6aae742b2d341c29ce0d Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 6 Aug 2012 16:15:54 -0700 Subject: removed some duplicate fast timer declarations --- indra/newview/llviewermessage.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a9bff67f40..6e61c87117 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4264,7 +4264,7 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_ gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED); } -static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Objects"); +static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Kill Objects"); void process_kill_object(LLMessageSystem *mesgsys, void **user_data) diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 5a23b55fa7..eee68ba474 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1854,13 +1854,10 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi } -static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object"); - LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRegion *regionp, const LLUUID &uuid, const U32 local_id, const LLHost &sender) { LLMemType mt(LLMemType::MTYPE_OBJECT); - LLFastTimer t(FTM_CREATE_OBJECT); LLUUID fullid; if (uuid == LLUUID::null) -- cgit v1.2.3 From c8a36e9cfd1e90a1aa385667c7272c25e2ef9136 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 7 Aug 2012 19:55:47 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages cleaned up LLStat and removed unnecessary includes --- indra/llcommon/llstat.cpp | 324 ++++++----------------------- indra/llcommon/llstat.h | 62 ++---- indra/llmessage/llcircuit.h | 1 - indra/llmessage/lliohttpserver.cpp | 1 - indra/llmessage/llmessagetemplate.h | 1 - indra/llmessage/llpumpio.cpp | 1 - indra/newview/llfloaterjoystick.cpp | 4 +- indra/newview/lltexturefetch.h | 1 + indra/newview/llviewercamera.h | 10 +- indra/newview/llviewerprecompiledheaders.h | 7 - indra/newview/llviewertexturelist.cpp | 12 +- indra/newview/llviewerwindow.cpp | 8 +- indra/newview/llviewerwindow.h | 7 +- 13 files changed, 108 insertions(+), 331 deletions(-) diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 5cf5ae3c12..2c91e10404 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -42,25 +42,25 @@ LLStat::stat_map_t LLStat::sStatList; LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; -void LLStat::init() +void LLStat::reset() { - llassert(mNumBins > 0); mNumValues = 0; mLastValue = 0.f; - mLastTime = 0.f; - mCurBin = (mNumBins-1); + delete[] mBins; + mBins = new ValueEntry[mNumBins]; + mCurBin = mNumBins-1; mNextBin = 0; - mBins = new F32[mNumBins]; - mBeginTime = new F64[mNumBins]; - mTime = new F64[mNumBins]; - mDT = new F32[mNumBins]; - for (U32 i = 0; i < mNumBins; i++) - { - mBins[i] = 0.f; - mBeginTime[i] = 0.0; - mTime[i] = 0.0; - mDT[i] = 0.f; - } +} + +LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer) +: mUseFrameTimer(use_frame_timer), + mNumBins(num_bins), + mName(name) +{ + llassert(mNumBins > 0); + mLastTime = 0.f; + + reset(); if (!mName.empty()) { @@ -71,27 +71,9 @@ void LLStat::init() } } -LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer) - : mUseFrameTimer(use_frame_timer), - mNumBins(num_bins) -{ - init(); -} - -LLStat::LLStat(std::string name, U32 num_bins, BOOL use_frame_timer) -: mUseFrameTimer(use_frame_timer), - mNumBins(num_bins), - mName(name) -{ - init(); -} - LLStat::~LLStat() { delete[] mBins; - delete[] mBeginTime; - delete[] mTime; - delete[] mDT; if (!mName.empty()) { @@ -103,76 +85,15 @@ LLStat::~LLStat() } } -void LLStat::reset() -{ - U32 i; - - mNumValues = 0; - mLastValue = 0.f; - mCurBin = (mNumBins-1); - delete[] mBins; - delete[] mBeginTime; - delete[] mTime; - delete[] mDT; - mBins = new F32[mNumBins]; - mBeginTime = new F64[mNumBins]; - mTime = new F64[mNumBins]; - mDT = new F32[mNumBins]; - for (i = 0; i < mNumBins; i++) - { - mBins[i] = 0.f; - mBeginTime[i] = 0.0; - mTime[i] = 0.0; - mDT[i] = 0.f; - } -} - -void LLStat::setBeginTime(const F64 time) -{ - mBeginTime[mNextBin] = time; -} - -void LLStat::addValueTime(const F64 time, const F32 value) -{ - if (mNumValues < mNumBins) - { - mNumValues++; - } - - // Increment the bin counters. - mCurBin++; - if ((U32)mCurBin == mNumBins) - { - mCurBin = 0; - } - mNextBin++; - if ((U32)mNextBin == mNumBins) - { - mNextBin = 0; - } - - mBins[mCurBin] = value; - mTime[mCurBin] = time; - mDT[mCurBin] = (F32)(mTime[mCurBin] - mBeginTime[mCurBin]); - //this value is used to prime the min/max calls - mLastTime = mTime[mCurBin]; - mLastValue = value; - - // Set the begin time for the next stat segment. - mBeginTime[mNextBin] = mTime[mCurBin]; - mTime[mNextBin] = mTime[mCurBin]; - mDT[mNextBin] = 0.f; -} - void LLStat::start() { if (mUseFrameTimer) { - mBeginTime[mNextBin] = sFrameTimer.getElapsedSeconds(); + mBins[mNextBin].mBeginTime = sFrameTimer.getElapsedSeconds(); } else { - mBeginTime[mNextBin] = sTimer.getElapsedTimeF64(); + mBins[mNextBin].mBeginTime = sTimer.getElapsedTimeF64(); } } @@ -185,41 +106,41 @@ void LLStat::addValue(const F32 value) // Increment the bin counters. mCurBin++; - if ((U32)mCurBin == mNumBins) + if (mCurBin >= mNumBins) { mCurBin = 0; } mNextBin++; - if ((U32)mNextBin == mNumBins) + if (mNextBin >= mNumBins) { mNextBin = 0; } - mBins[mCurBin] = value; + mBins[mCurBin].mValue = value; if (mUseFrameTimer) { - mTime[mCurBin] = sFrameTimer.getElapsedSeconds(); + mBins[mCurBin].mTime = sFrameTimer.getElapsedSeconds(); } else { - mTime[mCurBin] = sTimer.getElapsedTimeF64(); + mBins[mCurBin].mTime = sTimer.getElapsedTimeF64(); } - mDT[mCurBin] = (F32)(mTime[mCurBin] - mBeginTime[mCurBin]); + mBins[mCurBin].mDT = (F32)(mBins[mCurBin].mTime - mBins[mCurBin].mBeginTime); //this value is used to prime the min/max calls - mLastTime = mTime[mCurBin]; + mLastTime = mBins[mCurBin].mTime; mLastValue = value; // Set the begin time for the next stat segment. - mBeginTime[mNextBin] = mTime[mCurBin]; - mTime[mNextBin] = mTime[mCurBin]; - mDT[mNextBin] = 0.f; + mBins[mNextBin].mBeginTime = mBins[mCurBin].mTime; + mBins[mNextBin].mTime = mBins[mCurBin].mTime; + mBins[mNextBin].mDT = 0.f; } F32 LLStat::getMax() const { - U32 i; + S32 i; F32 current_max = mLastValue; if (mNumBins == 0) { @@ -230,13 +151,13 @@ F32 LLStat::getMax() const for (i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - if (mBins[i] > current_max) + if (mBins[i].mValue > current_max) { - current_max = mBins[i]; + current_max = mBins[i].mValue; } } } @@ -245,17 +166,17 @@ F32 LLStat::getMax() const F32 LLStat::getMean() const { - U32 i; + S32 i; F32 current_mean = 0.f; - U32 samples = 0; + S32 samples = 0; for (i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - current_mean += mBins[i]; + current_mean += mBins[i].mValue; samples++; } @@ -273,7 +194,7 @@ F32 LLStat::getMean() const F32 LLStat::getMin() const { - U32 i; + S32 i; F32 current_min = mLastValue; if (mNumBins == 0) @@ -285,53 +206,19 @@ F32 LLStat::getMin() const for (i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - if (mBins[i] < current_min) + if (mBins[i].mValue < current_min) { - current_min = mBins[i]; + current_min = mBins[i].mValue; } } } return current_min; } -F32 LLStat::getSum() const -{ - U32 i; - F32 sum = 0.f; - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == (U32)mNextBin) - { - continue; - } - sum += mBins[i]; - } - - return sum; -} - -F32 LLStat::getSumDuration() const -{ - U32 i; - F32 sum = 0.f; - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == (U32)mNextBin) - { - continue; - } - sum += mDT[i]; - } - - return sum; -} - F32 LLStat::getPrev(S32 age) const { S32 bin; @@ -347,7 +234,7 @@ F32 LLStat::getPrev(S32 age) const // Bogus for bin we're currently working on. return 0.f; } - return mBins[bin]; + return mBins[bin].mValue; } F32 LLStat::getPrevPerSec(S32 age) const @@ -365,107 +252,34 @@ F32 LLStat::getPrevPerSec(S32 age) const // Bogus for bin we're currently working on. return 0.f; } - return mBins[bin] / mDT[bin]; -} - -F64 LLStat::getPrevBeginTime(S32 age) const -{ - S32 bin; - bin = mCurBin - age; - - while (bin < 0) - { - bin += mNumBins; - } - - if (bin == mNextBin) - { - // Bogus for bin we're currently working on. - return 0.f; - } - - return mBeginTime[bin]; -} - -F64 LLStat::getPrevTime(S32 age) const -{ - S32 bin; - bin = mCurBin - age; - - while (bin < 0) - { - bin += mNumBins; - } - - if (bin == mNextBin) - { - // Bogus for bin we're currently working on. - return 0.f; - } - - return mTime[bin]; -} - -F32 LLStat::getBin(S32 bin) const -{ - return mBins[bin]; -} - -F32 LLStat::getBinPerSec(S32 bin) const -{ - return mBins[bin] / mDT[bin]; -} - -F64 LLStat::getBinBeginTime(S32 bin) const -{ - return mBeginTime[bin]; -} - -F64 LLStat::getBinTime(S32 bin) const -{ - return mTime[bin]; + return mBins[bin].mValue / mBins[bin].mDT; } F32 LLStat::getCurrent() const { - return mBins[mCurBin]; + return mBins[mCurBin].mValue; } F32 LLStat::getCurrentPerSec() const { - return mBins[mCurBin] / mDT[mCurBin]; -} - -F64 LLStat::getCurrentBeginTime() const -{ - return mBeginTime[mCurBin]; -} - -F64 LLStat::getCurrentTime() const -{ - return mTime[mCurBin]; -} - -F32 LLStat::getCurrentDuration() const -{ - return mDT[mCurBin]; + return mBins[mCurBin].mValue / mBins[mCurBin].mDT; } F32 LLStat::getMeanPerSec() const { - U32 i; + S32 i; F32 value = 0.f; F32 dt = 0.f; for (i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - value += mBins[i]; - dt += mDT[i]; + value += mBins[i].mValue; + dt += mBins[i].mDT; } if (dt > 0.f) @@ -481,14 +295,14 @@ F32 LLStat::getMeanPerSec() const F32 LLStat::getMeanDuration() const { F32 dur = 0.0f; - U32 count = 0; - for (U32 i=0; (i < mNumBins) && (i < mNumValues); i++) + S32 count = 0; + for (S32 i=0; (i < mNumBins) && (i < mNumValues); i++) { - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - dur += mDT[i]; + dur += mBins[i].mDT; count++; } @@ -505,46 +319,45 @@ F32 LLStat::getMeanDuration() const F32 LLStat::getMaxPerSec() const { - U32 i; F32 value; if (mNextBin != 0) { - value = mBins[0]/mDT[0]; + value = mBins[0].mValue/mBins[0].mDT; } else if (mNumValues > 0) { - value = mBins[1]/mDT[1]; + value = mBins[1].mValue/mBins[1].mDT; } else { value = 0.f; } - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) + for (S32 i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - value = llmax(value, mBins[i]/mDT[i]); + value = llmax(value, mBins[i].mValue/mBins[i].mDT); } return value; } F32 LLStat::getMinPerSec() const { - U32 i; + S32 i; F32 value; if (mNextBin != 0) { - value = mBins[0]/mDT[0]; + value = mBins[0].mValue/mBins[0].mDT; } else if (mNumValues > 0) { - value = mBins[1]/mDT[1]; + value = mBins[1].mValue/mBins[0].mDT; } else { @@ -554,25 +367,15 @@ F32 LLStat::getMinPerSec() const for (i = 0; (i < mNumBins) && (i < mNumValues); i++) { // Skip the bin we're currently filling. - if (i == (U32)mNextBin) + if (i == mNextBin) { continue; } - value = llmin(value, mBins[i]/mDT[i]); + value = llmin(value, mBins[i].mValue/mBins[i].mDT); } return value; } -F32 LLStat::getMinDuration() const -{ - F32 dur = 0.0f; - for (U32 i=0; (i < mNumBins) && (i < mNumValues); i++) - { - dur = llmin(dur, mDT[i]); - } - return dur; -} - U32 LLStat::getNumValues() const { return mNumValues; @@ -583,11 +386,6 @@ S32 LLStat::getNumBins() const return mNumBins; } -S32 LLStat::getCurBin() const -{ - return mCurBin; -} - S32 LLStat::getNextBin() const { return mNextBin; diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index 7718d40ffb..3dc52aa507 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -27,12 +27,10 @@ #ifndef LL_LLSTAT_H #define LL_LLSTAT_H -#include <deque> #include <map> #include "lltimer.h" #include "llframetimer.h" -#include "llfile.h" class LLSD; @@ -43,56 +41,31 @@ private: typedef std::multimap<std::string, LLStat*> stat_map_t; static stat_map_t sStatList; - void init(); - public: - LLStat(U32 num_bins = 32, BOOL use_frame_timer = FALSE); - LLStat(std::string name, U32 num_bins = 32, BOOL use_frame_timer = FALSE); + LLStat(std::string name = std::string(), S32 num_bins = 32, BOOL use_frame_timer = FALSE); ~LLStat(); - void reset(); - void start(); // Start the timer for the current "frame", otherwise uses the time tracked from // the last addValue + void reset(); void addValue(const F32 value = 1.f); // Adds the current value being tracked, and tracks the DT. void addValue(const S32 value) { addValue((F32)value); } void addValue(const U32 value) { addValue((F32)value); } - void setBeginTime(const F64 time); - void addValueTime(const F64 time, const F32 value = 1.f); - - S32 getCurBin() const; S32 getNextBin() const; - F32 getCurrent() const; - F32 getCurrentPerSec() const; - F64 getCurrentBeginTime() const; - F64 getCurrentTime() const; - F32 getCurrentDuration() const; - F32 getPrev(S32 age) const; // Age is how many "addValues" previously - zero is current F32 getPrevPerSec(S32 age) const; // Age is how many "addValues" previously - zero is current - F64 getPrevBeginTime(S32 age) const; - F64 getPrevTime(S32 age) const; - - F32 getBin(S32 bin) const; - F32 getBinPerSec(S32 bin) const; - F64 getBinBeginTime(S32 bin) const; - F64 getBinTime(S32 bin) const; - - F32 getMax() const; - F32 getMaxPerSec() const; + F32 getCurrent() const; + F32 getCurrentPerSec() const; + F32 getMin() const; + F32 getMinPerSec() const; F32 getMean() const; F32 getMeanPerSec() const; F32 getMeanDuration() const; - - F32 getMin() const; - F32 getMinPerSec() const; - F32 getMinDuration() const; - - F32 getSum() const; - F32 getSumDuration() const; + F32 getMax() const; + F32 getMaxPerSec() const; U32 getNumValues() const; S32 getNumBins() const; @@ -104,10 +77,21 @@ private: U32 mNumBins; F32 mLastValue; F64 mLastTime; - F32 *mBins; - F64 *mBeginTime; - F64 *mTime; - F32 *mDT; + + struct ValueEntry + { + ValueEntry() + : mValue(0.f), + mBeginTime(0.0), + mTime(0.0), + mDT(0.f) + {} + F32 mValue; + F64 mBeginTime; + F64 mTime; + F32 mDT; + }; + ValueEntry* mBins; S32 mCurBin; S32 mNextBin; diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h index c46fd56acc..430d6358f7 100644 --- a/indra/llmessage/llcircuit.h +++ b/indra/llmessage/llcircuit.h @@ -40,7 +40,6 @@ #include "llpacketack.h" #include "lluuid.h" #include "llthrottle.h" -#include "llstat.h" // // Constants diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 74eaf9f025..20dc5ae968 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -42,7 +42,6 @@ #include "llpumpio.h" #include "llsd.h" #include "llsdserialize_xml.h" -#include "llstat.h" #include "llstl.h" #include "lltimer.h" diff --git a/indra/llmessage/llmessagetemplate.h b/indra/llmessage/llmessagetemplate.h index a2024166ee..ae8e0087c1 100644 --- a/indra/llmessage/llmessagetemplate.h +++ b/indra/llmessage/llmessagetemplate.h @@ -29,7 +29,6 @@ #include "lldarray.h" #include "message.h" // TODO: babbage: Remove... -#include "llstat.h" #include "llstl.h" class LLMsgVarData diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp index fcb77a23a9..8272240ef4 100644 --- a/indra/llmessage/llpumpio.cpp +++ b/indra/llmessage/llpumpio.cpp @@ -36,7 +36,6 @@ #include "llapr.h" #include "llmemtype.h" #include "llstl.h" -#include "llstat.h" // These should not be enabled in production, but they can be // intensely useful during development for finding certain kinds of diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index c37798c330..d0c22d25f2 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -33,6 +33,7 @@ #include "llerror.h" #include "llrect.h" #include "llstring.h" +#include "llstat.h" // project includes #include "lluictrlfactory.h" @@ -83,7 +84,8 @@ BOOL LLFloaterJoystick::postBuild() for (U32 i = 0; i < 6; i++) { - mAxisStats[i] = new LLStat(4); + std::string stat_name(llformat("Joystick axis %d", i)); + mAxisStats[i] = new LLStat(stat_name, 4); std::string axisname = llformat("axis%d", i); mAxisStatsBar[i] = getChild<LLStatBar>(axisname); if (mAxisStatsBar[i]) diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 107e1623b0..dbe46444d2 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -35,6 +35,7 @@ #include "lltextureinfo.h" #include "llapr.h" #include "llimageworker.h" +#include "llstat.h" //#include "lltexturecache.h" class LLViewerTexture; diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 184033de42..df4ecc74ec 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -120,11 +120,11 @@ public: protected: void calcProjection(const F32 far_distance) const; - LLStat mVelocityStat; - LLStat mAngularVelocityStat; - LLVector3 mVelocityDir ; - F32 mAverageSpeed ; - F32 mAverageAngularSpeed ; + LLStat mVelocityStat; + LLStat mAngularVelocityStat; + LLVector3 mVelocityDir ; + F32 mAverageSpeed ; + F32 mAverageAngularSpeed ; mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix mutable LLMatrix4 mModelviewMatrix; diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h index 6c8a827ba3..0316f79973 100644 --- a/indra/newview/llviewerprecompiledheaders.h +++ b/indra/newview/llviewerprecompiledheaders.h @@ -59,8 +59,6 @@ #include "indra_constants.h" #include "llinitparam.h" -//#include "linden_common.h" -//#include "llpreprocessor.h" #include "llallocator.h" #include "llapp.h" #include "llcriticaldamp.h" @@ -77,10 +75,8 @@ #include "llprocessor.h" #include "llrefcount.h" #include "llsafehandle.h" -//#include "llsecondlifeurls.h" #include "llsd.h" #include "llsingleton.h" -#include "llstat.h" #include "llstl.h" #include "llstrider.h" #include "llstring.h" @@ -88,11 +84,8 @@ #include "llthread.h" #include "lltimer.h" #include "lluuidhashmap.h" -//#include "processor.h" #include "stdenums.h" #include "stdtypes.h" -//#include "string_table.h" -//#include "timer.h" #include "timing.h" #include "u64.h" diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 528e0080b7..6d517e48a4 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -67,12 +67,12 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; U32 LLViewerTextureList::sTextureBits = 0; U32 LLViewerTextureList::sTexturePackets = 0; S32 LLViewerTextureList::sNumImages = 0; -LLStat LLViewerTextureList::sNumImagesStat(32, TRUE); -LLStat LLViewerTextureList::sNumRawImagesStat(32, TRUE); -LLStat LLViewerTextureList::sGLTexMemStat(32, TRUE); -LLStat LLViewerTextureList::sGLBoundMemStat(32, TRUE); -LLStat LLViewerTextureList::sRawMemStat(32, TRUE); -LLStat LLViewerTextureList::sFormattedMemStat(32, TRUE); +LLStat LLViewerTextureList::sNumImagesStat("Num Images", 32, TRUE); +LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", 32, TRUE); +LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", 32, TRUE); +LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", 32, TRUE); +LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", 32, TRUE); +LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", 32, TRUE); LLViewerTextureList gTextureList; static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 39e330ad66..bbce53bc9a 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -77,6 +77,7 @@ #include "llmediaentry.h" #include "llurldispatcher.h" #include "raytrace.h" +#include "llstat.h" // newview includes #include "llagent.h" @@ -1540,7 +1541,8 @@ LLViewerWindow::LLViewerWindow(const Params& p) mResDirty(false), mStatesDirty(false), mCurrResolutionIndex(0), - mProgressView(NULL) + mProgressView(NULL), + mMouseVelocityStat(new LLStat("Mouse Velocity")) { // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to // pass its value right now. Instead, pass it a nullary function that @@ -2064,6 +2066,8 @@ LLViewerWindow::~LLViewerWindow() delete mDebugText; mDebugText = NULL; + + delete mMouseVelocityStat; } @@ -3238,7 +3242,7 @@ void LLViewerWindow::updateMouseDelta() mouse_vel.setVec((F32) dx, (F32) dy); } - mMouseVelocityStat.addValue(mouse_vel.magVec()); + mMouseVelocityStat->addValue(mouse_vel.magVec()); } void LLViewerWindow::updateKeyboardFocus() diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 6efcaeaf18..5f475fe145 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -41,7 +41,6 @@ #include "llcursortypes.h" #include "llwindowcallbacks.h" #include "lltimer.h" -#include "llstat.h" #include "llmousehandler.h" #include "llhandle.h" #include "llinitparam.h" @@ -50,7 +49,7 @@ #include <boost/signals2.hpp> #include <boost/scoped_ptr.hpp> - +class LLStat; class LLView; class LLViewerObject; class LLUUID; @@ -251,7 +250,7 @@ public: S32 getCurrentMouseDX() const { return mCurrentMouseDelta.mX; } S32 getCurrentMouseDY() const { return mCurrentMouseDelta.mY; } LLCoordGL getCurrentMouseDelta() const { return mCurrentMouseDelta; } - LLStat * getMouseVelocityStat() { return &mMouseVelocityStat; } + LLStat* getMouseVelocityStat() { return mMouseVelocityStat; } BOOL getLeftMouseDown() const { return mLeftMouseDown; } BOOL getMiddleMouseDown() const { return mMiddleMouseDown; } BOOL getRightMouseDown() const { return mRightMouseDown; } @@ -428,7 +427,7 @@ private: LLCoordGL mCurrentMousePoint; // last mouse position in GL coords LLCoordGL mLastMousePoint; // Mouse point at last frame. LLCoordGL mCurrentMouseDelta; //amount mouse moved this frame - LLStat mMouseVelocityStat; + LLStat* mMouseVelocityStat; BOOL mLeftMouseDown; BOOL mMiddleMouseDown; BOOL mRightMouseDown; -- cgit v1.2.3 From 86a6f5478c91d292f2becfb93e958dabc1d58dc3 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 13:31:23 +0300 Subject: MAINT-1121 FIXED Disable "Open" if several calling cards are selected. --- indra/newview/llinventorybridge.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index b86c453d61..f752c37c2e 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4624,6 +4624,10 @@ void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { disabled_items.push_back(std::string("Share")); } + if ((flags & FIRST_SELECTED_ITEM) == 0) + { + disabled_items.push_back(std::string("Open")); + } addOpenRightClickMenuOption(items); items.push_back(std::string("Properties")); -- cgit v1.2.3 From eafbdb0dfea3b780b3bedced81b225bcc48ebb09 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 13:49:13 +0300 Subject: MAINT-297 FIXED Reset selection after collapsing all folders --- indra/newview/llpanelteleporthistory.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index c63d89fc98..0756faf5c0 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -972,6 +972,11 @@ void LLTeleportHistoryPanel::onCollapseAllFolders() mItemContainers.get(n)->setDisplayChildren(false); } mHistoryAccordion->arrange(); + + if (mLastSelectedFlatlList) + { + mLastSelectedFlatlList->resetSelection(); + } } void LLTeleportHistoryPanel::onClearTeleportHistory() -- cgit v1.2.3 From d047042edcb4407689db6b7a218ca16dd3bf12b0 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 14:11:37 +0300 Subject: MAINT-481 FIXED Disable creating new folders in Favorites folder --- indra/newview/llinventorybridge.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index f752c37c2e..6aa55f9183 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -3173,6 +3173,7 @@ void LLFolderBridge::buildContextMenuBaseOptions(U32 flags) const LLUUID trash_id = model->findCategoryUUIDForType(LLFolderType::FT_TRASH); const LLUUID lost_and_found_id = model->findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); + const LLUUID favorites = model->findCategoryUUIDForType(LLFolderType::FT_FAVORITE); if (lost_and_found_id == mUUID) { @@ -3186,7 +3187,10 @@ void LLFolderBridge::buildContextMenuBaseOptions(U32 flags) mDisabledItems.push_back(std::string("New Clothes")); mDisabledItems.push_back(std::string("New Body Parts")); } - + if (favorites == mUUID) + { + mDisabledItems.push_back(std::string("New Folder")); + } if(trash_id == mUUID) { // This is the trash. -- cgit v1.2.3 From 2e55692a68987bfdf8f0bf55c871bd2d682c10ad Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 14:34:58 +0300 Subject: MAINT-65 FIXED Disable "Edit" in context menu if wearable has status "no modify" --- indra/newview/llinventorybridge.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 6aa55f9183..c067a86104 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -5598,7 +5598,8 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags) items.push_back(std::string("Wearable Edit")); - if ((flags & FIRST_SELECTED_ITEM) == 0) + bool modifiable = !gAgentWearables.isWearableModifiable(item->getUUID()); + if (((flags & FIRST_SELECTED_ITEM) == 0) || modifiable) { disabled_items.push_back(std::string("Wearable Edit")); } -- cgit v1.2.3 From eb9f84be17d28d7c41d24376261fa3c085331e15 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 15:28:05 +0300 Subject: MAINT-44 FIXED Change value for MiniMapAutoCenter in settings.xml to persist after restart --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9e2c529eb3..f896b1ec64 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -5168,7 +5168,7 @@ <key>Comment</key> <string>Center the focal point of the minimap.</string> <key>Persist</key> - <integer>0</integer> + <integer>1</integer> <key>Type</key> <string>Boolean</string> <key>Value</key> -- cgit v1.2.3 From 1341d591e3b9183de8568e7be81f7e2f4146727f Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 16:01:28 +0300 Subject: MAINT-269 FIXED Check if current agent is owner of the parcel before enabling "Buy pass" --- indra/newview/llfloaterland.cpp | 3 ++- indra/newview/llviewermenu.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 55f3d548ec..be743d57d2 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -783,8 +783,9 @@ void LLPanelLandGeneral::refresh() mBtnReleaseLand->setEnabled( can_release ); } - BOOL use_pass = parcel->getParcelFlag(PF_USE_PASS_LIST) && !LLViewerParcelMgr::getInstance()->isCollisionBanned();; + BOOL use_pass = parcel->getOwnerID()!= gAgent.getID() && parcel->getParcelFlag(PF_USE_PASS_LIST) && !LLViewerParcelMgr::getInstance()->isCollisionBanned();; mBtnBuyPass->setEnabled(use_pass); + } } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9aa4cfa494..54efcd61a8 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -341,7 +341,8 @@ LLMenuParcelObserver::~LLMenuParcelObserver() void LLMenuParcelObserver::changed() { - gMenuHolder->childSetEnabled("Land Buy Pass", LLPanelLandGeneral::enableBuyPass(NULL)); + LLParcel *parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); + gMenuHolder->childSetEnabled("Land Buy Pass", LLPanelLandGeneral::enableBuyPass(NULL) && !(parcel->getOwnerID()== gAgent.getID())); BOOL buyable = enable_buy_land(NULL); gMenuHolder->childSetEnabled("Land Buy", buyable); -- cgit v1.2.3 From 0092e8c32d8cca4c9eb9983014f5e7a8d8d4ea9b Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 16:28:07 +0300 Subject: MAINT-1334 FIXED Enable "Close all windows" menu item if Snapshot floater is opened. Close Snapshot floater by close all command. --- indra/newview/llviewermenufile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index dc2ea4bd1f..f791d906e6 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -494,7 +494,7 @@ class LLFileEnableCloseAllWindows : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool open_children = gFloaterView->allChildrenClosed(); + bool open_children = gFloaterView->allChildrenClosed() && !LLFloaterSnapshot::getInstance()->isInVisibleChain(); return !open_children; } }; @@ -505,7 +505,7 @@ class LLFileCloseAllWindows : public view_listener_t { bool app_quitting = false; gFloaterView->closeAllChildren(app_quitting); - + LLFloaterSnapshot::getInstance()->closeFloater(app_quitting); return true; } }; -- cgit v1.2.3 From 4e96efd42e44197fc33bae3c61871457213f9764 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 16:55:13 +0300 Subject: MAINT-257 FIXED Increase minimum width to avoid overlaping --- indra/newview/skins/default/xui/en/floater_ui_preview.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/floater_ui_preview.xml b/indra/newview/skins/default/xui/en/floater_ui_preview.xml index 06d4327293..eb01294831 100644 --- a/indra/newview/skins/default/xui/en/floater_ui_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_ui_preview.xml @@ -5,7 +5,7 @@ height="640" layout="topleft" min_height="230" - min_width="650" + min_width="750" name="gui_preview_tool" help_topic="gui_preview_tool" single_instance="true" -- cgit v1.2.3 From f02ec7b00cdbac7ba8be3baac5a12646a85235b6 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 17:20:59 +0300 Subject: MAINT-1069 FIXED Change "follows" attribute for scroll list to "left|top|right" --- indra/newview/skins/default/xui/en/panel_group_roles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml index eea2606125..df91ad8b5e 100644 --- a/indra/newview/skins/default/xui/en/panel_group_roles.xml +++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml @@ -254,7 +254,7 @@ things in this group. There's a broad variety of Abilities. column_padding="0" draw_stripes="true" height="200" - follows="left|top" + follows="left|top|right" layout="topleft" left="0" right="-1" -- cgit v1.2.3 From e5e8652e2c8c7dd8b22bc49dc8d422fff714624a Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 17:32:47 +0300 Subject: MAINT-403 FIXED Trash button is now disabled if neither landmark nor folder isn't selected. --- indra/newview/llpanellandmarks.cpp | 13 +++++++------ indra/newview/llpanellandmarks.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 68a3b6d1cd..d6fccb9705 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -418,12 +418,13 @@ void LLLandmarksPanel::setItemSelected(const LLUUID& obj_id, BOOL take_keyboard_ bool LLLandmarksPanel::isLandmarkSelected() const { LLFolderViewItem* current_item = getCurSelectedItem(); - if(current_item && current_item->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK) - { - return true; - } + return current_item && current_item->getListener()->getInventoryType() == LLInventoryType::IT_LANDMARK; +} - return false; +bool LLLandmarksPanel::isFolderSelected() const +{ + LLFolderViewItem* current_item = getCurSelectedItem(); + return current_item && current_item->getListener()->getInventoryType() == LLInventoryType::IT_CATEGORY; } bool LLLandmarksPanel::isReceivedFolderSelected() const @@ -720,7 +721,7 @@ void LLLandmarksPanel::initListCommandsHandlers() void LLLandmarksPanel::updateListCommands() { bool add_folder_enabled = isActionEnabled("category"); - bool trash_enabled = isActionEnabled("delete"); + bool trash_enabled = isActionEnabled("delete") && (isFolderSelected() || isLandmarkSelected()); // keep Options & Add Landmark buttons always enabled mListCommands->getChildView(ADD_FOLDER_BUTTON_NAME)->setEnabled(add_folder_enabled); diff --git a/indra/newview/llpanellandmarks.h b/indra/newview/llpanellandmarks.h index b2f4e92473..4e787317ba 100644 --- a/indra/newview/llpanellandmarks.h +++ b/indra/newview/llpanellandmarks.h @@ -84,6 +84,7 @@ protected: * @return true - if current selected panel is not null and selected item is a landmark */ bool isLandmarkSelected() const; + bool isFolderSelected() const; bool isReceivedFolderSelected() const; void doActionOnCurSelectedLandmark(LLLandmarkList::loaded_callback_t cb); LLFolderViewItem* getCurSelectedItem() const; -- cgit v1.2.3 From ba7e1ec1d44898ba670b814b860bd0ec73c48129 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 17:55:04 +0300 Subject: MAINT-328 FIXED Use stopTracking() before each new beacon --- indra/newview/llfloatermap.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp index a65e9e911a..539869a084 100644 --- a/indra/newview/llfloatermap.cpp +++ b/indra/newview/llfloatermap.cpp @@ -122,16 +122,13 @@ BOOL LLFloaterMap::handleDoubleClick(S32 x, S32 y, MASK mask) LLVector3d pos_global = mMap->viewPosToGlobal(x, y); - // If we're not tracking a beacon already, double-click will set one - if (!LLTracker::isTracking(NULL)) + LLTracker::stopTracking(NULL); + LLFloaterWorldMap* world_map = LLFloaterWorldMap::getInstance(); + if (world_map) { - LLFloaterWorldMap* world_map = LLFloaterWorldMap::getInstance(); - if (world_map) - { - world_map->trackLocation(pos_global); - } + world_map->trackLocation(pos_global); } - + if (gSavedSettings.getBOOL("DoubleClickTeleport")) { // If DoubleClickTeleport is on, double clicking the minimap will teleport there -- cgit v1.2.3 From ff2bb96a55e8869843174be7324b0a59578a4f0d Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 8 Aug 2012 18:26:19 +0300 Subject: MAINT-105 FIXED New function to check People tabs visibility --- indra/newview/llviewermenu.cpp | 15 ++++++++++++ indra/newview/skins/default/xui/en/menu_viewer.xml | 27 ++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 54efcd61a8..67cc171eef 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3464,6 +3464,20 @@ bool enable_sitdown_self() return isAgentAvatarValid() && !gAgentAvatarp->isSitting() && !gAgent.getFlying(); } +class LLCheckPanelPeopleTab : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + std::string panel_name = userdata.asString(); + + LLPanel *panel = LLFloaterSidePanelContainer::getPanel("people", panel_name); + if(panel && panel->isInVisibleChain()) + { + return true; + } + return false; + } +}; // Toggle one of "People" panel tabs in side tray. class LLTogglePanelPeopleTab : public view_listener_t { @@ -8553,6 +8567,7 @@ void initialize_menus() // we don't use boost::bind directly to delay side tray construction view_listener_t::addMenu( new LLTogglePanelPeopleTab(), "SideTray.PanelPeopleTab"); + view_listener_t::addMenu( new LLCheckPanelPeopleTab(), "SideTray.CheckPanelPeopleTab"); // Avatar pie menu view_listener_t::addMenu(new LLObjectMute(), "Avatar.Mute"); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 1aa55acf2d..c6d9f9ef8f 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -276,30 +276,39 @@ parameter="gestures" /> </menu_item_check> <menu_item_separator/> - <menu_item_call + <menu_item_check label="Friends" name="My Friends" shortcut="control|shift|F"> - <menu_item_call.on_click + <menu_item_check.on_check + function="SideTray.CheckPanelPeopleTab" + parameter="friends_panel" /> + <menu_item_check.on_click function="SideTray.PanelPeopleTab" parameter="friends_panel" /> - </menu_item_call> - <menu_item_call + </menu_item_check> + <menu_item_check label="Groups" name="My Groups" shortcut="control|shift|G"> - <menu_item_call.on_click + <menu_item_check.on_check + function="SideTray.CheckPanelPeopleTab" + parameter="groups_panel" /> + <menu_item_check.on_click function="SideTray.PanelPeopleTab" parameter="groups_panel" /> - </menu_item_call> - <menu_item_call + </menu_item_check> + <menu_item_check label="Nearby people" name="Active Speakers" shortcut="control|shift|A"> - <menu_item_call.on_click + <menu_item_check.on_check + function="SideTray.CheckPanelPeopleTab" + parameter="nearby_panel" /> + <menu_item_check.on_click function="SideTray.PanelPeopleTab" parameter="nearby_panel" /> - </menu_item_call> + </menu_item_check> <menu_item_call label="Block List" name="Block List"> -- cgit v1.2.3 From b38d8b1e15d9d2c52e7f2fa7d654e06039eb7b2f Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 13:01:13 +0300 Subject: MAINT-881 FIXED Whisper in nearby chat after pressing shift-enter --- indra/newview/llnearbychatbar.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index f8f0f7d243..7f8fea88d2 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -203,7 +203,12 @@ BOOL LLNearbyChatBar::handleKeyHere( KEY key, MASK mask ) sendChat(CHAT_TYPE_SHOUT); handled = TRUE; } - + else if (KEY_RETURN == key && mask == MASK_SHIFT) + { + // whisper + sendChat(CHAT_TYPE_WHISPER); + handled = TRUE; + } return handled; } -- cgit v1.2.3 From 182edd329beda3c7a03885a804c2ff9ad012fb99 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 13:34:15 +0300 Subject: MAINT-712 FIXED Set "isLandmarkEditModeOn" to "false" before updating verbs for Landmark tab --- indra/newview/llpanelplaces.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp index 6d321d4716..6c2a01fc82 100644 --- a/indra/newview/llpanelplaces.cpp +++ b/indra/newview/llpanelplaces.cpp @@ -366,6 +366,7 @@ void LLPanelPlaces::onOpen(const LLSD& key) if (key.size() != 0) { + isLandmarkEditModeOn = false; std::string key_type = key["type"].asString(); if (key_type == LANDMARK_TAB_INFO_TYPE) { @@ -392,7 +393,6 @@ void LLPanelPlaces::onOpen(const LLSD& key) mPlaceInfoType = key_type; mPosGlobal.setZero(); mItem = NULL; - isLandmarkEditModeOn = false; togglePlaceInfoPanel(TRUE); if (mPlaceInfoType == AGENT_INFO_TYPE) -- cgit v1.2.3 From 160c6d4d3baa3b7402a1efc1e779d2306ee906a2 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 13:45:20 +0300 Subject: MAINT-274 FIXED "media_info" width is decreased to avoid overlaying --- indra/newview/skins/default/xui/en/floater_tools.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 5204efbf65..436e9f8fed 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2994,7 +2994,7 @@ even though the user gets a free copy. use_ellipses="true" read_only="true" name="media_info" - width="280" /> + width="180" /> <web_browser visible="false" enabled="false" -- cgit v1.2.3 From 66391be51338e766ee0724aa06ef8f022269e0a3 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 14:42:35 +0300 Subject: MAINT-967 FIXED Use stopChat() even if Chat box is empty --- indra/newview/llnearbychatbar.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index 7f8fea88d2..c00dc4bc89 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -395,12 +395,6 @@ void LLNearbyChatBar::sendChat( EChatType type ) gAgent.stopTyping(); - // If the user wants to stop chatting on hitting return, lose focus - // and go out of chat mode. - if (gSavedSettings.getBOOL("CloseChatOnReturn")) - { - stopChat(); - } } void LLNearbyChatBar::showNearbyChatPanel(bool show) @@ -451,7 +445,12 @@ void LLNearbyChatBar::onChatBoxCommit() { sendChat(CHAT_TYPE_NORMAL); } - + // If the user wants to stop chatting on hitting return, lose focus + // and go out of chat mode. + if (gSavedSettings.getBOOL("CloseChatOnReturn")) + { + stopChat(); + } gAgent.stopTyping(); } -- cgit v1.2.3 From 3e6c27aa1d31065b82b7d19e7fecae72798e003d Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 15:14:53 +0300 Subject: MAINT-171 FIXED Show "Ad-hoc conference" instead of "Session 1" in floater title --- indra/newview/llinventorypanel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index c6df207552..f7567baa2b 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -44,6 +44,7 @@ #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" #include "llsidepanelinventory.h" +#include "lltrans.h" #include "llviewerattachmenu.h" #include "llviewerfoldertype.h" #include "llvoavatarself.h" @@ -973,7 +974,6 @@ bool LLInventoryPanel::beginIMSession() std::set<LLUUID> selected_items = mFolderRoot->getSelectionList(); std::string name; - static int session_num = 1; LLDynamicArray<LLUUID> members; EInstantMessage type = IM_SESSION_CONFERENCE_START; @@ -1053,7 +1053,7 @@ bool LLInventoryPanel::beginIMSession() if (name.empty()) { - name = llformat("Session %d", session_num++); + name = LLTrans::getString("conference-title"); } LLUUID session_id = gIMMgr->addSession(name, type, members[0], members); -- cgit v1.2.3 From 1408a0831bf7c713052e0b73f4c5e8a3deddd9d2 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 15:44:10 +0300 Subject: MAINT-913 FIXED Added "Zoom" combobox menu item --- indra/newview/skins/default/xui/en/sidepanel_task_info.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml index e9a787cef0..f1ae14809f 100644 --- a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml +++ b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml @@ -292,6 +292,10 @@ label="Open" name="Open" value="Open" /> + <combo_box.item + label="Zoom" + name="Zoom" + value="Zoom" /> </combo_box> <panel border="false" -- cgit v1.2.3 From 1c4a3e2ef307afc02fac0fb21678cc5e8f7cc77d Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 9 Aug 2012 17:54:33 +0300 Subject: MAINT-1118 FIXED Change panel mode before closing floater --- indra/newview/llfloatercamera.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 21b58d3e3d..c85d048c5a 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -330,6 +330,10 @@ void LLFloaterCamera::onClose(bool app_quitting) //We don't care of camera mode if app is quitting if(app_quitting) return; + // It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so + // to avoid seeing an empty floater when reopening the control. + if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA) + mCurrMode = CAMERA_CTRL_MODE_PAN; // When mCurrMode is in CAMERA_CTRL_MODE_PAN // switchMode won't modify mPrevMode, so force it here. // It is needed to correctly return to previous mode on open, see EXT-2727. -- cgit v1.2.3 From 22561c0fc79bd9d645b5556790e9c270c06b31c1 Mon Sep 17 00:00:00 2001 From: MaksymS ProductEngine <msavchenko@productengine.com> Date: Thu, 16 Aug 2012 01:25:50 +0300 Subject: MAINT-417 FIXED The agent_push_backward() updated with new check for reaction of key DOWN, when avatar is in 'sitting mode' and view mode is 'mouselook'. --- indra/newview/llviewerkeyboard.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index 1aa9fd8a45..f5d3341c66 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -160,6 +160,11 @@ void agent_push_backward( EKeystate s ) camera_move_backward(s); return; } + else if (gAgentAvatarp->isSitting()) + { + gAgentCamera.changeCameraToThirdPerson(); + return; + } agent_push_forwardbackward(s, -1, LLAgent::DOUBLETAP_BACKWARD); } -- cgit v1.2.3 From 2e1f38695f72020062a09038cc021fff462785bd Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 16 Aug 2012 12:32:39 +0300 Subject: MAINT-915 FIXED Changed max_length to max_length_bytes --- indra/newview/skins/default/xui/en/panel_media_settings_general.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml index cdf14572fe..e844a15118 100644 --- a/indra/newview/skins/default/xui/en/panel_media_settings_general.xml +++ b/indra/newview/skins/default/xui/en/panel_media_settings_general.xml @@ -30,7 +30,7 @@ (This page does not pass the specified whitelist) </text> <line_editor - max_length="1024" + max_length_bytes="1024" bottom_delta="-24" enabled="true" follows="left|top" -- cgit v1.2.3 From 7f8f2d7f8a35b877e882a575c14d50b7e895b88e Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 16 Aug 2012 13:03:10 +0300 Subject: MAINT-1099 FIXED Toggle on MyOutfits panel before showing Wearable panel for new item --- indra/newview/llsidepanelappearance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 853656905c..d909a218e3 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -456,10 +456,10 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name) void LLSidepanelAppearance::editWearable(LLWearable *wearable, LLView *data, BOOL disable_camera_switch) { LLFloaterSidePanelContainer::showPanel("appearance", LLSD()); - LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(data); if (panel) { + panel->showOutfitsInventoryPanel(); panel->showWearableEditPanel(wearable, disable_camera_switch); } } -- cgit v1.2.3 From 00346422b6554e0b982973e6f8f05f0335b99852 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Tue, 21 Aug 2012 17:25:59 +0300 Subject: MAINT-1433 FIXED Register callback for "TopInfoBar.Action" in handleRightMouseDown --- indra/newview/llpaneltopinfobar.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp index 280cc11179..1830086da2 100644 --- a/indra/newview/llpaneltopinfobar.cpp +++ b/indra/newview/llpaneltopinfobar.cpp @@ -64,9 +64,6 @@ private: LLPanelTopInfoBar::LLPanelTopInfoBar(): mParcelChangedObserver(0) { - LLUICtrl::CommitCallbackRegistry::currentRegistrar() - .add("TopInfoBar.Action", boost::bind(&LLPanelTopInfoBar::onContextMenuItemClicked, this, _2)); - buildFromFile( "panel_topinfo_bar.xml"); } @@ -132,6 +129,11 @@ void LLPanelTopInfoBar::handleLoginComplete() BOOL LLPanelTopInfoBar::handleRightMouseDown(S32 x, S32 y, MASK mask) { + if(!LLUICtrl::CommitCallbackRegistry::getValue("TopInfoBar.Action")) + { + LLUICtrl::CommitCallbackRegistry::currentRegistrar() + .add("TopInfoBar.Action", boost::bind(&LLPanelTopInfoBar::onContextMenuItemClicked, this, _2)); + } show_topinfobar_context_menu(this, x, y); return TRUE; } -- cgit v1.2.3 From 4b44be799a578b946e440a4bc90aca0610734003 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Tue, 21 Aug 2012 18:10:45 +0300 Subject: MAINT-1416 FIXED Close Mini-map floater after Ctrl-W if it's opened and other floaters are not in focus --- indra/newview/llfloatermap.cpp | 5 +++++ indra/newview/llfloatermap.h | 1 + indra/newview/llviewermenufile.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp index 539869a084..473e2938be 100644 --- a/indra/newview/llfloatermap.cpp +++ b/indra/newview/llfloatermap.cpp @@ -246,3 +246,8 @@ void LLFloaterMap::handleZoom(const LLSD& userdata) mMap->setScale(scale); } } + +LLFloaterMap* LLFloaterMap::getInstance() +{ + return LLFloaterReg::getTypedInstance<LLFloaterMap>("mini_map"); +} diff --git a/indra/newview/llfloatermap.h b/indra/newview/llfloatermap.h index 8a1b965e62..ff2fb20535 100644 --- a/indra/newview/llfloatermap.h +++ b/indra/newview/llfloatermap.h @@ -39,6 +39,7 @@ class LLFloaterMap : public LLFloater { public: LLFloaterMap(const LLSD& key); + static LLFloaterMap* getInstance(); virtual ~LLFloaterMap(); /*virtual*/ BOOL postBuild(); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index f791d906e6..21a323941d 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -34,6 +34,7 @@ #include "llfilepicker.h" #include "llfloaterreg.h" #include "llbuycurrencyhtml.h" +#include "llfloatermap.h" #include "llfloatermodelpreview.h" #include "llfloatersnapshot.h" #include "llimage.h" @@ -476,7 +477,7 @@ class LLFileEnableCloseWindow : public view_listener_t bool handleEvent(const LLSD& userdata) { bool new_value = NULL != LLFloater::getClosableFloaterFromFocus(); - return new_value; + return new_value || LLFloaterMap::getInstance()->isInVisibleChain(); } }; @@ -484,8 +485,12 @@ class LLFileCloseWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) { + bool new_value = (NULL == LLFloater::getClosableFloaterFromFocus()); + if(new_value && LLFloaterMap::getInstance()->isInVisibleChain()) + { + LLFloaterMap::getInstance()->closeFloater(false); + } LLFloater::closeFocusedFloater(); - return true; } }; -- cgit v1.2.3 From f93b94daa978e1bcf1897e0459fa8700f58d62d1 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Wed, 22 Aug 2012 11:42:44 +0300 Subject: MAINT-56 FIXED collapse_all_folders() and expand_all_folders() functions are added, which are called by menu items in gear menu. --- indra/newview/lloutfitslist.cpp | 30 ++++++++++++++++++++++ indra/newview/lloutfitslist.h | 10 ++++++++ .../skins/default/xui/en/menu_outfit_gear.xml | 14 ++++++++++ 3 files changed, 54 insertions(+) diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index ef5ef2ddc8..c15b6bd0d3 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -117,6 +117,8 @@ public: registrar.add("Gear.Rename", boost::bind(&LLOutfitListGearMenu::onRename, this)); registrar.add("Gear.Delete", boost::bind(&LLOutfitsList::removeSelected, mOutfitList)); registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2)); + registrar.add("Gear.Collapse", boost::bind(&LLOutfitsList::collapse_all_folders, mOutfitList)); + registrar.add("Gear.Expand", boost::bind(&LLOutfitsList::expand_all_folders, mOutfitList)); registrar.add("Gear.WearAdd", boost::bind(&LLOutfitListGearMenu::onAdd, this)); @@ -743,6 +745,34 @@ void LLOutfitsList::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const } } +void LLOutfitsList::collapse_all_folders() +{ + for (outfits_map_t::iterator iter = mOutfitsMap.begin(); + iter != mOutfitsMap.end(); + ++iter) + { + LLAccordionCtrlTab* tab = iter->second; + if(tab && tab->isExpanded()) + { + tab->changeOpenClose(true); + } + } +} + +void LLOutfitsList::expand_all_folders() +{ + for (outfits_map_t::iterator iter = mOutfitsMap.begin(); + iter != mOutfitsMap.end(); + ++iter) + { + LLAccordionCtrlTab* tab = iter->second; + if(tab && !tab->isExpanded()) + { + tab->changeOpenClose(false); + } + } +} + boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb) { return mSelectionChangeSignal.connect(cb); diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index a0598737f1..2e3fb3f488 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -108,6 +108,16 @@ public: */ bool hasItemSelected(); + /** + Collapses all outfit accordions. + */ + void collapse_all_folders(); + /** + Expands all outfit accordions. + */ + void expand_all_folders(); + + private: void onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response); diff --git a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml index fc7272b904..3b8ace6308 100644 --- a/indra/newview/skins/default/xui/en/menu_outfit_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_outfit_gear.xml @@ -194,6 +194,20 @@ <!-- copied from menu_inventory_add.xml --> <menu_item_separator name="sepatator2" /> + <menu_item_call + label="Expand all folders" + layout="topleft" + name="expand"> + <on_click + function="Gear.Expand" /> + </menu_item_call> + <menu_item_call + label="Collapse all folders" + layout="topleft" + name="collapse"> + <on_click + function="Gear.Collapse" /> + </menu_item_call> <menu_item_call label="Rename Outfit" layout="topleft" -- cgit v1.2.3 From cf498ad1dec06221f0843097ef4b4b1161d9826c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 22 Aug 2012 19:34:28 -0700 Subject: MAINT-1416 FIXED Close Mini-map floater after Ctrl-W if it's opened and other floaters are not in focus changed fix to always close front most closable floater whether or not it has focus to eliminate special case for mini map --- indra/llui/llfloater.cpp | 72 +++++++++++++------------------------- indra/llui/llfloater.h | 7 ++-- indra/llui/llresizebar.cpp | 7 ---- indra/newview/llviewermenufile.cpp | 11 ++---- 4 files changed, 30 insertions(+), 67 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 8ca1e685a9..ad64a9a5e5 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1103,6 +1103,10 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) if (by_user && !isMinimized()) { + if (isDocked()) + { + setDocked( false, false); + } storeRectControl(); mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; LLRect screen_rect = calcScreenRect(); @@ -1707,56 +1711,10 @@ void LLFloater::onClickHelp( LLFloater* self ) } } -// static -LLFloater* LLFloater::getClosableFloaterFromFocus() -{ - LLFloater* focused_floater = NULL; - LLInstanceTracker<LLFloater>::instance_iter it = beginInstances(); - LLInstanceTracker<LLFloater>::instance_iter end_it = endInstances(); - for (; it != end_it; ++it) - { - if (it->hasFocus()) - { - LLFloater& floater = *it; - focused_floater = &floater; - break; - } - } - - if (it == endInstances()) - { - // nothing found, return - return NULL; - } - - // The focused floater may not be closable, - // Find and close a parental floater that is closeable, if any. - LLFloater* prev_floater = NULL; - for(LLFloater* floater_to_close = focused_floater; - NULL != floater_to_close; - floater_to_close = gFloaterView->getParentFloater(floater_to_close)) - { - if(floater_to_close->isCloseable()) - { - return floater_to_close; - } - - // If floater has as parent root view - // gFloaterView->getParentFloater(floater_to_close) returns - // the same floater_to_close, so we need to check this. - if (prev_floater == floater_to_close) { - break; - } - prev_floater = floater_to_close; - } - - return NULL; -} - // static -void LLFloater::closeFocusedFloater() +void LLFloater::closeFrontmostFloater() { - LLFloater* floater_to_close = LLFloater::getClosableFloaterFromFocus(); + LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater(); if(floater_to_close) { floater_to_close->closeFloater(); @@ -2474,6 +2432,24 @@ void LLFloaterView::highlightFocusedFloater() } } +LLFloater* LLFloaterView::getFrontmostClosableFloater() +{ + child_list_const_iter_t child_it; + LLFloater* frontmost_floater = NULL; + + for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) + { + frontmost_floater = (LLFloater *)(*child_it); + + if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable()) + { + return frontmost_floater; + } + } + + return NULL; +} + void LLFloaterView::unhighlightFocusedFloater() { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 64d6dcea04..0484ca622b 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -325,12 +325,10 @@ public: virtual void setTornOff(bool torn_off) { mTornOff = torn_off; } - // Return a closeable floater, if any, given the current focus. - static LLFloater* getClosableFloaterFromFocus(); - // Close the floater returned by getClosableFloaterFromFocus() and + // Close the floater returned by getFrontmostClosableFloater() and // handle refocusing. - static void closeFocusedFloater(); + static void closeFrontmostFloater(); // LLNotification::Params contextualNotification(const std::string& name) // { @@ -559,6 +557,7 @@ public: S32 getZOrder(LLFloater* child); void setFloaterSnapView(LLHandle<LLView> snap_view) {mSnapView = snap_view; } + LLFloater* getFrontmostClosableFloater(); private: void hiddenFloaterClosed(LLFloater* floater); diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index 87aeb4d7a7..85e0aba824 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -139,13 +139,6 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView ) { - // undock floater when user resize it - LLFloater* parent = dynamic_cast<LLFloater*>( getParent()); - if (parent && parent->isDocked()) - { - parent->setDocked( false, false); - } - // Resize the parent LLRect orig_rect = mResizingView->getRect(); LLRect scaled_rect = orig_rect; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 21a323941d..be78603e2d 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -476,8 +476,8 @@ class LLFileEnableCloseWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = NULL != LLFloater::getClosableFloaterFromFocus(); - return new_value || LLFloaterMap::getInstance()->isInVisibleChain(); + bool new_value = NULL != gFloaterView->getFrontmostClosableFloater(); + return new_value; } }; @@ -485,12 +485,7 @@ class LLFileCloseWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) { - bool new_value = (NULL == LLFloater::getClosableFloaterFromFocus()); - if(new_value && LLFloaterMap::getInstance()->isInVisibleChain()) - { - LLFloaterMap::getInstance()->closeFloater(false); - } - LLFloater::closeFocusedFloater(); + LLFloater::closeFrontmostFloater(); return true; } }; -- cgit v1.2.3 From 67750daf2318f5b91694fc8beb78f7b89880a6d1 Mon Sep 17 00:00:00 2001 From: maxim_productengine <mnikolenko@productengine.com> Date: Thu, 23 Aug 2012 12:35:10 +0300 Subject: MAINT-836 FIXED Set title and description for Preview Texture floater if it's called from link in notecard --- indra/newview/llviewertexteditor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 99102309a1..122d8f4a96 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -1144,6 +1144,14 @@ void LLViewerTextEditor::openEmbeddedTexture( LLInventoryItem* item, llwchar wc { preview->setAuxItem( item ); preview->setNotecardInfo(mNotecardInventoryID, mObjectID); + if (preview->hasString("Title")) + { + LLStringUtil::format_map_t args; + args["[NAME]"] = item->getName(); + LLUIString title = preview->getString("Title", args); + preview->setTitle(title.getString()); + } + preview->getChild<LLUICtrl>("desc")->setValue(item->getDescription()); } } -- cgit v1.2.3 From 99300085d4d1e71035be22ab4f671624a4bd28c2 Mon Sep 17 00:00:00 2001 From: MaksymS ProductEngine <msavchenko@productengine.com> Date: Fri, 24 Aug 2012 00:22:40 +0300 Subject: MAINT-1415 FIXED Empty non-functional 'Take off' menu is presented in inspector: - class LLToggleableMenu had been updated with two methods like: appendContextSubMenu and addChild, which based on similar in LLContextMenu --- indra/llui/llmenugl.cpp | 114 ++++++++++++++++------------------------ indra/llui/llmenugl.h | 41 ++++++++++++++- indra/llui/lltoggleablemenu.cpp | 5 ++ indra/llui/lltoggleablemenu.h | 2 + 4 files changed, 90 insertions(+), 72 deletions(-) diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index efb9848a90..cd6cc6a75e 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1764,6 +1764,25 @@ bool LLMenuGL::addChild(LLView* view, S32 tab_group) return false; } +// Used in LLContextMenu and in LLTogleableMenu +// to add an item of context menu branch +bool LLMenuGL::addContextChild(LLView* view, S32 tab_group) +{ + LLContextMenu* context = dynamic_cast<LLContextMenu*>(view); + if (context) + return appendContextSubMenu(context); + + LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view); + if (separator) + return append(separator); + + LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view); + if (item) + return append(item); + + return false; +} + void LLMenuGL::removeChild( LLView* ctrl) { // previously a dynamic_cast with if statement to check validity @@ -2501,6 +2520,30 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu ) return success; } +// add a context menu branch +BOOL LLMenuGL::appendContextSubMenu(LLMenuGL *menu) +{ + if (menu == this) + { + llerrs << "Can't attach a context menu to itself" << llendl; + } + + LLContextMenuBranch *item; + LLContextMenuBranch::Params p; + p.name = menu->getName(); + p.label = menu->getLabel(); + p.branch = (LLContextMenu *)menu; + p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); + p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); + p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); + p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + + item = LLUICtrlFactory::create<LLContextMenuBranch>(p); + LLMenuGL::sMenuContainer->addChild(item->getBranch()); + + return append( item ); +} + void LLMenuGL::setEnabledSubMenus(BOOL enable) { setEnabled(enable); @@ -3725,39 +3768,6 @@ void LLTearOffMenu::closeTearOff() mMenu->setDropShadowed(TRUE); } - -//----------------------------------------------------------------------------- -// class LLContextMenuBranch -// A branch to another context menu -//----------------------------------------------------------------------------- -class LLContextMenuBranch : public LLMenuItemGL -{ -public: - struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params> - { - Mandatory<LLContextMenu*> branch; - }; - - LLContextMenuBranch(const Params&); - - virtual ~LLContextMenuBranch() - {} - - // called to rebuild the draw label - virtual void buildDrawLabel( void ); - - // onCommit() - do the primary funcationality of the menu item. - virtual void onCommit( void ); - - LLContextMenu* getBranch() { return mBranch.get(); } - void setHighlight( BOOL highlight ); - -protected: - void showSubMenu(); - - LLHandle<LLContextMenu> mBranch; -}; - LLContextMenuBranch::LLContextMenuBranch(const LLContextMenuBranch::Params& p) : LLMenuItemGL(p), mBranch( p.branch()->getHandle() ) @@ -4034,44 +4044,8 @@ void LLContextMenu::draw() LLMenuGL::draw(); } -BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu) -{ - - if (menu == this) - { - llerrs << "Can't attach a context menu to itself" << llendl; - } - - LLContextMenuBranch *item; - LLContextMenuBranch::Params p; - p.name = menu->getName(); - p.label = menu->getLabel(); - p.branch = menu; - p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); - p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor"); - p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); - p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); - - item = LLUICtrlFactory::create<LLContextMenuBranch>(p); - LLMenuGL::sMenuContainer->addChild(item->getBranch()); - - return append( item ); -} - bool LLContextMenu::addChild(LLView* view, S32 tab_group) { - LLContextMenu* context = dynamic_cast<LLContextMenu*>(view); - if (context) - return appendContextSubMenu(context); - - LLMenuItemSeparatorGL* separator = dynamic_cast<LLMenuItemSeparatorGL*>(view); - if (separator) - return append(separator); - - LLMenuItemGL* item = dynamic_cast<LLMenuItemGL*>(view); - if (item) - return append(item); - - return false; + return addContextChild(view, tab_group); } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 67b3e1fbe6..00899020bc 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -519,6 +519,9 @@ public: void resetScrollPositionOnShow(bool reset_scroll_pos) { mResetScrollPositionOnShow = reset_scroll_pos; } bool isScrollPositionOnShowReset() { return mResetScrollPositionOnShow; } + // add a context menu branch + BOOL appendContextSubMenu(LLMenuGL *menu); + protected: void createSpilloverBranch(); void cleanupSpilloverBranch(); @@ -528,6 +531,10 @@ protected: // add a menu - this will create a cascading menu virtual BOOL appendMenu( LLMenuGL* menu ); + // Used in LLContextMenu and in LLTogleableMenu + // to add an item of context menu branch + bool addContextChild(LLView* view, S32 tab_group); + // TODO: create accessor methods for these? typedef std::list< LLMenuItemGL* > item_list_t; item_list_t mItems; @@ -679,8 +686,6 @@ public: virtual bool addChild (LLView* view, S32 tab_group = 0); - BOOL appendContextSubMenu(LLContextMenu *menu); - LLHandle<LLContextMenu> getHandle() { return getDerivedHandle<LLContextMenu>(); } LLView* getSpawningView() const { return mSpawningViewHandle.get(); } @@ -694,6 +699,38 @@ protected: }; +//----------------------------------------------------------------------------- +// class LLContextMenuBranch +// A branch to another context menu +//----------------------------------------------------------------------------- +class LLContextMenuBranch : public LLMenuItemGL +{ +public: + struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params> + { + Mandatory<LLContextMenu*> branch; + }; + + LLContextMenuBranch(const Params&); + + virtual ~LLContextMenuBranch() + {} + + // called to rebuild the draw label + virtual void buildDrawLabel( void ); + + // onCommit() - do the primary funcationality of the menu item. + virtual void onCommit( void ); + + LLContextMenu* getBranch() { return mBranch.get(); } + void setHighlight( BOOL highlight ); + +protected: + void showSubMenu(); + + LLHandle<LLContextMenu> mBranch; +}; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuBarGL diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index d29260750f..b4c6c6162b 100644 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -99,3 +99,8 @@ bool LLToggleableMenu::toggleVisibility() return true; } + +bool LLToggleableMenu::addChild(LLView* view, S32 tab_group) +{ + return addContextChild(view, tab_group); +} diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index 2094bd776f..4717b0d0ba 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -47,6 +47,8 @@ public: virtual void handleVisibilityChange (BOOL curVisibilityIn); + virtual bool addChild (LLView* view, S32 tab_group = 0); + const LLRect& getButtonRect() const { return mButtonRect; } // Converts the given local button rect to a screen rect -- cgit v1.2.3 From 632618be6540c7e9cc0022f01badda8b989866ed Mon Sep 17 00:00:00 2001 From: MaksymS ProductEngine <msavchenko@productengine.com> Date: Fri, 24 Aug 2012 01:02:42 +0300 Subject: MAINT-1400 FIXED duplicated IDs in two files: notifications.xml and floater_texture_ctrl.xml --- indra/newview/skins/default/xui/en/floater_texture_ctrl.xml | 10 ---------- indra/newview/skins/default/xui/en/notifications.xml | 12 ------------ 2 files changed, 22 deletions(-) diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml index 2e29c61cb2..6021ba0a5a 100644 --- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml +++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml @@ -134,16 +134,6 @@ top_delta="-25" name="Pipette" width="28" /> - <check_box - follows="left|bottom" - height="20" - initial_value="true" - label="Live Preview" - layout="topleft" - left="4" - name="apply_immediate_check" - top="262" - width="120" /> <text follows="left|bottom" height="20" diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 13f073a1c2..bfb8d61ca6 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -7569,18 +7569,6 @@ You locally updated a [RESOLUTION] baked texture for '[BODYREGION]' after [TIME] name="LivePreviewUnavailable" type="alert"> -We cannot display a preview of this texture because it is no-copy and/or no-transfer. - <usetemplate - ignoretext="Warn me that Live Preview mode is not available for no-copy and/or no-transfer textures" - name="okignore" - yestext="OK"/> - </notification> - - <notification - icon="alertmodal.tga" - name="LivePreviewUnavailable" - type="alert"> - We cannot display a preview of this texture because it is no-copy and/or no-transfer. <usetemplate ignoretext="Warn me that Live Preview mode is not available for no-copy and/or no-transfer textures" -- cgit v1.2.3 From 141dbef088187368268f9eeddbc107802c14e085 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 23 Aug 2012 15:47:40 -0700 Subject: MAINT-1473 FIXED Resizing floater past edge of screen causes opposite side of floater to move updated resize logic to reset floater extents when resizing past bounds --- indra/llui/llfloater.cpp | 23 ++++++++++------- indra/llui/llresizebar.cpp | 48 ++++++++++++++++++++++++++++++++++- indra/llui/llresizehandle.cpp | 58 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 111 insertions(+), 18 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index ad64a9a5e5..dea746db60 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1101,21 +1101,26 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) const LLRect old_rect = getRect(); LLView::handleReshape(new_rect, by_user); - if (by_user && !isMinimized()) + if (by_user && !getHost()) { - if (isDocked()) - { - setDocked( false, false); - } - storeRectControl(); - mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; - LLRect screen_rect = calcScreenRect(); - mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + static_cast<LLFloaterView*>(getParent())->adjustToFitScreen(this, !isMinimized()); } // if not minimized, adjust all snapped dependents to new shape if (!isMinimized()) { + if (by_user) + { + if (isDocked()) + { + setDocked( false, false); + } + storeRectControl(); + mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; + LLRect screen_rect = calcScreenRect(); + mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert(); + } + // gather all snapped dependents for(handle_set_iter_t dependent_it = mDependents.begin(); dependent_it != mDependents.end(); ++dependent_it) diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index 85e0aba824..ba90fa5e0c 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -212,20 +212,66 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) // update last valid mouse cursor position based on resized view's actual size LLRect new_rect = mResizingView->getRect(); + switch(mSide) { case LEFT: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; + { + S32 actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + if (actual_delta_x != delta_x) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mTop = orig_rect.mTop; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } + mDragLastScreenX += actual_delta_x; + break; + } case RIGHT: + { + S32 actual_delta_x = new_rect.mRight - orig_rect.mRight; + if (actual_delta_x != delta_x) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mTop = orig_rect.mTop; + new_rect.mLeft = orig_rect.mLeft; + mResizingView->setShape(new_rect, true); + } mDragLastScreenX += new_rect.mRight - orig_rect.mRight; break; + } case TOP: + { + S32 actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_y != delta_y) + { + // restore everything by left + new_rect.mBottom = orig_rect.mBottom; + new_rect.mLeft = orig_rect.mLeft; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } mDragLastScreenY += new_rect.mTop - orig_rect.mTop; break; + } case BOTTOM: + { + S32 actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_y != delta_y) + { + // restore everything by left + new_rect.mTop = orig_rect.mTop; + new_rect.mLeft = orig_rect.mLeft; + new_rect.mRight = orig_rect.mRight; + mResizingView->setShape(new_rect, true); + } mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; break; + } default: break; } diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index c3a51c36c9..24794305ac 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -257,23 +257,65 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) // update last valid mouse cursor position based on resized view's actual size LLRect new_rect = resizing_view->getRect(); + S32 actual_delta_x = 0; + S32 actual_delta_y = 0; switch(mCorner) { case LEFT_TOP: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; - mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mRight = orig_rect.mRight; + new_rect.mBottom = orig_rect.mBottom; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case LEFT_BOTTOM: - mDragLastScreenX += new_rect.mLeft - orig_rect.mLeft; - mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + actual_delta_x = new_rect.mLeft - orig_rect.mLeft; + actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mRight = orig_rect.mRight; + new_rect.mTop = orig_rect.mTop; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case RIGHT_TOP: - mDragLastScreenX += new_rect.mRight - orig_rect.mRight; - mDragLastScreenY += new_rect.mTop - orig_rect.mTop; + actual_delta_x = new_rect.mRight - orig_rect.mRight; + actual_delta_y = new_rect.mTop - orig_rect.mTop; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mLeft = orig_rect.mLeft; + new_rect.mBottom = orig_rect.mBottom; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; case RIGHT_BOTTOM: - mDragLastScreenX += new_rect.mRight - orig_rect.mRight; - mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom; + actual_delta_x = new_rect.mRight - orig_rect.mRight; + actual_delta_y = new_rect.mBottom - orig_rect.mBottom; + if (actual_delta_x != delta_x + || actual_delta_y != delta_y) + { + new_rect.mLeft = orig_rect.mLeft; + new_rect.mTop = orig_rect.mTop; + resizing_view->setShape(new_rect, true); + } + + mDragLastScreenX += actual_delta_x; + mDragLastScreenY += actual_delta_y; break; default: break; -- cgit v1.2.3 From e6dc88241b58ebc1f05f96279f1f189b1d5e8885 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 23 Aug 2012 17:07:03 -0700 Subject: MAINT-1474 FIXED World map tracking ring renders in incorrect position with UI scale != 1 --- indra/newview/llworldmapview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index a3ccf87cfc..ccc513b80d 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -1320,7 +1320,7 @@ void LLWorldMapView::drawTrackingCircle( const LLRect& rect, S32 x, S32 y, const gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - gGL.translatef((F32)x, (F32)y, 0.f); + gGL.translatef((F32)x * LLUI::sGLScaleFactor.mV[VX], (F32)y * LLUI::sGLScaleFactor.mV[VY], 0.f); gl_washer_segment_2d(inner_radius, outer_radius, start_theta, end_theta, 40, color, color); gGL.popMatrix(); -- cgit v1.2.3 From d6a7046c4bb833ce57e7a86204b62bcdfeeb25ec Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 24 Aug 2012 17:02:46 -0700 Subject: build fix --- indra/newview/llviewerstats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 906b2a57e3..e02a4ccdc7 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -70,7 +70,7 @@ public: mSimSimPhysicsStepMsec, mSimSimPhysicsShapeUpdateMsec, mSimSimPhysicsOtherMsec, - mSimSimAIStepMSec, + mSimSimAIStepMsec, mSimSimSkippedSilhouetteSteps, mSimSimPctSteppedCharacters, -- cgit v1.2.3 From cc7043ecf6b58e7d5a38167b5f507abc6b0b70b1 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sat, 25 Aug 2012 12:49:40 -0700 Subject: fixed crash on startup --- indra/llcommon/llstat.cpp | 25 +++++++++++++++++-------- indra/llcommon/llstat.h | 7 ++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 2c91e10404..d265d77a4d 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -37,7 +37,8 @@ // statics -LLStat::stat_map_t LLStat::sStatList; + + //------------------------------------------------------------------------ LLTimer LLStat::sTimer; LLFrameTimer LLStat::sFrameTimer; @@ -55,7 +56,8 @@ void LLStat::reset() LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer) : mUseFrameTimer(use_frame_timer), mNumBins(num_bins), - mName(name) + mName(name), + mBins(NULL) { llassert(mNumBins > 0); mLastTime = 0.f; @@ -64,13 +66,20 @@ LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer) if (!mName.empty()) { - stat_map_t::iterator iter = sStatList.find(mName); - if (iter != sStatList.end()) + stat_map_t::iterator iter = getStatList().find(mName); + if (iter != getStatList().end()) llwarns << "LLStat with duplicate name: " << mName << llendl; - sStatList.insert(std::make_pair(mName, this)); + getStatList().insert(std::make_pair(mName, this)); } } +LLStat::stat_map_t& LLStat::getStatList() +{ + static LLStat::stat_map_t stat_list; + return stat_list; +} + + LLStat::~LLStat() { delete[] mBins; @@ -78,10 +87,10 @@ LLStat::~LLStat() if (!mName.empty()) { // handle multiple entries with the same name - stat_map_t::iterator iter = sStatList.find(mName); - while (iter != sStatList.end() && iter->second != this) + stat_map_t::iterator iter = getStatList().find(mName); + while (iter != getStatList().end() && iter->second != this) ++iter; - sStatList.erase(iter); + getStatList().erase(iter); } } diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index 3dc52aa507..38377a010b 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -39,7 +39,8 @@ class LL_COMMON_API LLStat { private: typedef std::multimap<std::string, LLStat*> stat_map_t; - static stat_map_t sStatList; + + static stat_map_t& getStatList(); public: LLStat(std::string name = std::string(), S32 num_bins = 32, BOOL use_frame_timer = FALSE); @@ -104,8 +105,8 @@ public: static LLStat* getStat(const std::string& name) { // return the first stat that matches 'name' - stat_map_t::iterator iter = sStatList.find(name); - if (iter != sStatList.end()) + stat_map_t::iterator iter = getStatList().find(name); + if (iter != getStatList().end()) return iter->second; else return NULL; -- cgit v1.2.3 From b3e9c46c94dad0c81a5adcb9152521b5368c66a7 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 29 Aug 2012 22:50:56 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages further cleanup of LLStat removed llfloaterlagmeter --- indra/llcommon/llstat.cpp | 84 +---- indra/llcommon/llstat.h | 31 +- indra/llui/llstatbar.cpp | 2 +- indra/llui/llstatbar.h | 6 +- indra/newview/CMakeLists.txt | 2 - indra/newview/llfloaterlagmeter.cpp | 375 --------------------- indra/newview/llfloaterlagmeter.h | 80 ----- indra/newview/llstatusbar.cpp | 1 - indra/newview/llviewerassetstats.cpp | 4 +- indra/newview/llviewerfloaterreg.cpp | 2 - indra/newview/llviewerstats.cpp | 150 ++++----- indra/newview/llviewerstats.h | 50 ++- indra/newview/llviewertexturelist.cpp | 12 +- indra/newview/llvoavatarself.cpp | 4 +- indra/newview/llworld.cpp | 2 +- .../skins/default/xui/da/floater_lagmeter.xml | 151 --------- .../skins/default/xui/de/floater_lagmeter.xml | 151 --------- .../skins/default/xui/en/floater_lagmeter.xml | 336 ------------------ .../skins/default/xui/es/floater_lagmeter.xml | 154 --------- .../skins/default/xui/fr/floater_lagmeter.xml | 151 --------- .../skins/default/xui/it/floater_lagmeter.xml | 154 --------- .../skins/default/xui/ja/floater_lagmeter.xml | 151 --------- .../skins/default/xui/pl/floater_lagmeter.xml | 151 --------- .../skins/default/xui/pt/floater_lagmeter.xml | 154 --------- .../skins/default/xui/ru/floater_lagmeter.xml | 151 --------- .../skins/default/xui/tr/floater_lagmeter.xml | 151 --------- .../skins/default/xui/zh/floater_lagmeter.xml | 151 --------- 27 files changed, 131 insertions(+), 2680 deletions(-) delete mode 100644 indra/newview/llfloaterlagmeter.cpp delete mode 100644 indra/newview/llfloaterlagmeter.h delete mode 100644 indra/newview/skins/default/xui/da/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/de/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/en/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/es/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/fr/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/it/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/ja/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/pl/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/pt/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/ru/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/tr/floater_lagmeter.xml delete mode 100644 indra/newview/skins/default/xui/zh/floater_lagmeter.xml diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp index 3678c8e1c1..b46d2e58b2 100644 --- a/indra/llcommon/llstat.cpp +++ b/indra/llcommon/llstat.cpp @@ -51,9 +51,10 @@ void LLStat::reset() mNextBin = 0; } -LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer) -: mUseFrameTimer(use_frame_timer), - mNumBins(num_bins), +LLStat::LLStat(std::string name, BOOL use_frame_timer) +: LLInstanceTracker<LLStat, std::string>(name), + mUseFrameTimer(use_frame_timer), + mNumBins(50), mName(name), mBins(NULL) { @@ -61,48 +62,24 @@ LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer) mLastTime = 0.f; reset(); - - if (!mName.empty()) - { - stat_map_t::iterator iter = getStatList().find(mName); - if (iter != getStatList().end()) - llwarns << "LLStat with duplicate name: " << mName << llendl; - getStatList().insert(std::make_pair(mName, this)); - } -} - -LLStat::stat_map_t& LLStat::getStatList() -{ - static LLStat::stat_map_t stat_list; - return stat_list; } - LLStat::~LLStat() { delete[] mBins; - - if (!mName.empty()) - { - // handle multiple entries with the same name - stat_map_t::iterator iter = getStatList().find(mName); - while (iter != getStatList().end() && iter->second != this) - ++iter; - getStatList().erase(iter); - } -} - -void LLStat::start() -{ - if (mUseFrameTimer) - { - mBins[mNextBin].mBeginTime = sFrameTimer.getElapsedSeconds(); - } - else - { - mBins[mNextBin].mBeginTime = sTimer.getElapsedTimeF64(); - } } +// +//void LLStat::start() +//{ +// if (mUseFrameTimer) +// { +// mBins[mNextBin].mBeginTime = sFrameTimer.getElapsedSeconds(); +// } +// else +// { +// mBins[mNextBin].mBeginTime = sTimer.getElapsedTimeF64(); +// } +//} void LLStat::addValue(const F32 value) { @@ -299,31 +276,6 @@ F32 LLStat::getMeanPerSec() const } } -F32 LLStat::getMeanDuration() const -{ - F32 dur = 0.0f; - S32 count = 0; - for (S32 i=0; (i < mNumBins) && (i < mNumValues); i++) - { - if (i == mNextBin) - { - continue; - } - dur += mBins[i].mDT; - count++; - } - - if (count > 0) - { - dur /= F32(count); - return dur; - } - else - { - return 0.f; - } -} - F32 LLStat::getMaxPerSec() const { F32 value; @@ -398,7 +350,3 @@ S32 LLStat::getNextBin() const return mNextBin; } -F64 LLStat::getLastTime() const -{ - return mLastTime; -} diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h index 38377a010b..82a246275d 100644 --- a/indra/llcommon/llstat.h +++ b/indra/llcommon/llstat.h @@ -31,22 +31,18 @@ #include "lltimer.h" #include "llframetimer.h" +#include "llinstancetracker.h" class LLSD; // ---------------------------------------------------------------------------- -class LL_COMMON_API LLStat +class LL_COMMON_API LLStat : public LLInstanceTracker<LLStat, std::string> { -private: - typedef std::multimap<std::string, LLStat*> stat_map_t; - - static stat_map_t& getStatList(); - public: - LLStat(std::string name = std::string(), S32 num_bins = 32, BOOL use_frame_timer = FALSE); + LLStat(std::string name = std::string(), BOOL use_frame_timer = FALSE); ~LLStat(); - void start(); // Start the timer for the current "frame", otherwise uses the time tracked from + //void start(); // Start the timer for the current "frame", otherwise uses the time tracked from // the last addValue void reset(); void addValue(const F32 value = 1.f); // Adds the current value being tracked, and tracks the DT. @@ -57,23 +53,24 @@ public: F32 getPrev(S32 age) const; // Age is how many "addValues" previously - zero is current F32 getPrevPerSec(S32 age) const; // Age is how many "addValues" previously - zero is current + F32 getCurrent() const; F32 getCurrentPerSec() const; F32 getMin() const; F32 getMinPerSec() const; + F32 getMean() const; F32 getMeanPerSec() const; - F32 getMeanDuration() const; + F32 getMax() const; F32 getMaxPerSec() const; U32 getNumValues() const; S32 getNumBins() const; - F64 getLastTime() const; private: - BOOL mUseFrameTimer; + bool mUseFrameTimer; U32 mNumValues; U32 mNumBins; F32 mLastValue; @@ -93,6 +90,7 @@ private: F32 mDT; }; ValueEntry* mBins; + S32 mCurBin; S32 mNextBin; @@ -100,17 +98,6 @@ private: static LLTimer sTimer; static LLFrameTimer sFrameTimer; - -public: - static LLStat* getStat(const std::string& name) - { - // return the first stat that matches 'name' - stat_map_t::iterator iter = getStatList().find(name); - if (iter != getStatList().end()) - return iter->second; - else - return NULL; - } }; #endif // LL_STAT_ diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 04cce7878e..a21d7aa6a1 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -45,7 +45,7 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), - mStatp(LLStat::getStat(p.stat)), + mStatp(LLStat::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 513fff3234..7e636d0aa7 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -59,10 +59,10 @@ public: label_spacing("label_spacing", 10.0f), precision("precision", 0), update_rate("update_rate", 5.0f), - show_per_sec("show_per_sec", TRUE), + show_per_sec("show_per_sec", true), show_bar("show_bar", TRUE), - show_history("show_history", FALSE), - show_mean("show_mean", TRUE), + show_history("show_history", false), + show_mean("show_mean", true), stat("stat") { changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4c0657b61d..b3aa6949b3 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -209,7 +209,6 @@ set(viewer_SOURCE_FILES llfloaterinspect.cpp llfloaterinventory.cpp llfloaterjoystick.cpp - llfloaterlagmeter.cpp llfloaterland.cpp llfloaterlandholdings.cpp llfloatermap.cpp @@ -784,7 +783,6 @@ set(viewer_HEADER_FILES llfloaterinspect.h llfloaterinventory.h llfloaterjoystick.h - llfloaterlagmeter.h llfloaterland.h llfloaterlandholdings.h llfloatermap.h diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp deleted file mode 100644 index 68b1770bb2..0000000000 --- a/indra/newview/llfloaterlagmeter.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/** - * @file llfloaterlagmeter.cpp - * @brief The "Lag-o-Meter" floater used to tell users what is causing lag. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llfloaterlagmeter.h" - -#include "lluictrlfactory.h" -#include "llviewerstats.h" -#include "llviewertexture.h" -#include "llviewercontrol.h" -#include "llappviewer.h" - -#include "lltexturefetch.h" - -#include "llbutton.h" -#include "llfocusmgr.h" -#include "lltextbox.h" - -const std::string LAG_CRITICAL_IMAGE_NAME = "lag_status_critical.tga"; -const std::string LAG_WARNING_IMAGE_NAME = "lag_status_warning.tga"; -const std::string LAG_GOOD_IMAGE_NAME = "lag_status_good.tga"; - -LLFloaterLagMeter::LLFloaterLagMeter(const LLSD& key) - : LLFloater(key) -{ - mCommitCallbackRegistrar.add("LagMeter.ClickShrink", boost::bind(&LLFloaterLagMeter::onClickShrink, this)); -} - -BOOL LLFloaterLagMeter::postBuild() -{ - // Don't let this window take keyboard focus -- it's confusing to - // lose arrow-key driving when testing lag. - setIsChrome(TRUE); - - // were we shrunk last time? - if (isShrunk()) - { - onClickShrink(); - } - - mClientButton = getChild<LLButton>("client_lagmeter"); - mClientText = getChild<LLTextBox>("client_text"); - mClientCause = getChild<LLTextBox>("client_lag_cause"); - - mNetworkButton = getChild<LLButton>("network_lagmeter"); - mNetworkText = getChild<LLTextBox>("network_text"); - mNetworkCause = getChild<LLTextBox>("network_lag_cause"); - - mServerButton = getChild<LLButton>("server_lagmeter"); - mServerText = getChild<LLTextBox>("server_text"); - mServerCause = getChild<LLTextBox>("server_lag_cause"); - - std::string config_string = getString("client_frame_rate_critical_fps", mStringArgs); - mClientFrameTimeCritical = 1.0f / (float)atof( config_string.c_str() ); - config_string = getString("client_frame_rate_warning_fps", mStringArgs); - mClientFrameTimeWarning = 1.0f / (float)atof( config_string.c_str() ); - - config_string = getString("network_packet_loss_critical_pct", mStringArgs); - mNetworkPacketLossCritical = (float)atof( config_string.c_str() ); - config_string = getString("network_packet_loss_warning_pct", mStringArgs); - mNetworkPacketLossWarning = (float)atof( config_string.c_str() ); - - config_string = getString("network_ping_critical_ms", mStringArgs); - mNetworkPingCritical = (float)atof( config_string.c_str() ); - config_string = getString("network_ping_warning_ms", mStringArgs); - mNetworkPingWarning = (float)atof( config_string.c_str() ); - config_string = getString("server_frame_rate_critical_fps", mStringArgs); - - mServerFrameTimeCritical = 1000.0f / (float)atof( config_string.c_str() ); - config_string = getString("server_frame_rate_warning_fps", mStringArgs); - mServerFrameTimeWarning = 1000.0f / (float)atof( config_string.c_str() ); - config_string = getString("server_single_process_max_time_ms", mStringArgs); - mServerSingleProcessMaxTime = (float)atof( config_string.c_str() ); - -// mShrunk = false; - config_string = getString("max_width_px", mStringArgs); - mMaxWidth = atoi( config_string.c_str() ); - config_string = getString("min_width_px", mStringArgs); - mMinWidth = atoi( config_string.c_str() ); - - mStringArgs["[CLIENT_FRAME_RATE_CRITICAL]"] = getString("client_frame_rate_critical_fps"); - mStringArgs["[CLIENT_FRAME_RATE_WARNING]"] = getString("client_frame_rate_warning_fps"); - - mStringArgs["[NETWORK_PACKET_LOSS_CRITICAL]"] = getString("network_packet_loss_critical_pct"); - mStringArgs["[NETWORK_PACKET_LOSS_WARNING]"] = getString("network_packet_loss_warning_pct"); - - mStringArgs["[NETWORK_PING_CRITICAL]"] = getString("network_ping_critical_ms"); - mStringArgs["[NETWORK_PING_WARNING]"] = getString("network_ping_warning_ms"); - - mStringArgs["[SERVER_FRAME_RATE_CRITICAL]"] = getString("server_frame_rate_critical_fps"); - mStringArgs["[SERVER_FRAME_RATE_WARNING]"] = getString("server_frame_rate_warning_fps"); - -// childSetAction("minimize", onClickShrink, this); - updateControls(isShrunk()); // if expanded append colon to the labels (EXT-4079) - - return TRUE; -} -LLFloaterLagMeter::~LLFloaterLagMeter() -{ - // save shrunk status for next time -// gSavedSettings.setBOOL("LagMeterShrunk", mShrunk); - // expand so we save the large window rectangle - if (isShrunk()) - { - onClickShrink(); - } -} - -void LLFloaterLagMeter::draw() -{ - determineClient(); - determineNetwork(); - determineServer(); - - LLFloater::draw(); -} - -void LLFloaterLagMeter::determineClient() -{ - F32 client_frame_time = LLViewerStats::getInstance()->mFPSStat.getMeanDuration(); - bool find_cause = false; - - if (!gFocusMgr.getAppHasFocus()) - { - mClientButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME)); - mClientText->setText( getString("client_frame_time_window_bg_msg", mStringArgs) ); - mClientCause->setText( LLStringUtil::null ); - } - else if(client_frame_time >= mClientFrameTimeCritical) - { - mClientButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME)); - mClientText->setText( getString("client_frame_time_critical_msg", mStringArgs) ); - find_cause = true; - } - else if(client_frame_time >= mClientFrameTimeWarning) - { - mClientButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME)); - mClientText->setText( getString("client_frame_time_warning_msg", mStringArgs) ); - find_cause = true; - } - else - { - mClientButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME)); - mClientText->setText( getString("client_frame_time_normal_msg", mStringArgs) ); - mClientCause->setText( LLStringUtil::null ); - } - - if(find_cause) - { - if(gSavedSettings.getF32("RenderFarClip") > 128) - { - mClientCause->setText( getString("client_draw_distance_cause_msg", mStringArgs) ); - } - else if(LLAppViewer::instance()->getTextureFetch()->getNumRequests() > 2) - { - mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) ); - } - else if((BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes)) > LLViewerTexture::sMaxBoundTextureMemInMegaBytes) - { - mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) ); - } - else - { - mClientCause->setText( getString("client_complex_objects_cause_msg", mStringArgs) ); - } - } -} - -void LLFloaterLagMeter::determineNetwork() -{ - F32 packet_loss = LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean(); - F32 ping_time = LLViewerStats::getInstance()->mSimPingStat.getMean(); - bool find_cause_loss = false; - bool find_cause_ping = false; - - // *FIXME: We can't blame a large ping time on anything in - // particular if the frame rate is low, because a low frame - // rate is a sure recipe for bad ping times right now until - // the network handlers are de-synched from the rendering. - F32 client_frame_time_ms = 1000.0f * LLViewerStats::getInstance()->mFPSStat.getMeanDuration(); - - if(packet_loss >= mNetworkPacketLossCritical) - { - mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME)); - mNetworkText->setText( getString("network_packet_loss_critical_msg", mStringArgs) ); - find_cause_loss = true; - } - else if(ping_time >= mNetworkPingCritical) - { - mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME)); - if (client_frame_time_ms < mNetworkPingCritical) - { - mNetworkText->setText( getString("network_ping_critical_msg", mStringArgs) ); - find_cause_ping = true; - } - } - else if(packet_loss >= mNetworkPacketLossWarning) - { - mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME)); - mNetworkText->setText( getString("network_packet_loss_warning_msg", mStringArgs) ); - find_cause_loss = true; - } - else if(ping_time >= mNetworkPingWarning) - { - mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME)); - if (client_frame_time_ms < mNetworkPingWarning) - { - mNetworkText->setText( getString("network_ping_warning_msg", mStringArgs) ); - find_cause_ping = true; - } - } - else - { - mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME)); - mNetworkText->setText( getString("network_performance_normal_msg", mStringArgs) ); - } - - if(find_cause_loss) - { - mNetworkCause->setText( getString("network_packet_loss_cause_msg", mStringArgs) ); - } - else if(find_cause_ping) - { - mNetworkCause->setText( getString("network_ping_cause_msg", mStringArgs) ); - } - else - { - mNetworkCause->setText( LLStringUtil::null ); - } -} - -void LLFloaterLagMeter::determineServer() -{ - F32 sim_frame_time = LLViewerStats::getInstance()->mSimFrameMsec.getCurrent(); - bool find_cause = false; - - if(sim_frame_time >= mServerFrameTimeCritical) - { - mServerButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME)); - mServerText->setText( getString("server_frame_time_critical_msg", mStringArgs) ); - find_cause = true; - } - else if(sim_frame_time >= mServerFrameTimeWarning) - { - mServerButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME)); - mServerText->setText( getString("server_frame_time_warning_msg", mStringArgs) ); - find_cause = true; - } - else - { - mServerButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME)); - mServerText->setText( getString("server_frame_time_normal_msg", mStringArgs) ); - mServerCause->setText( LLStringUtil::null ); - } - - if(find_cause) - { - if(LLViewerStats::getInstance()->mSimSimPhysicsMsec.getCurrent() > mServerSingleProcessMaxTime) - { - mServerCause->setText( getString("server_physics_cause_msg", mStringArgs) ); - } - else if(LLViewerStats::getInstance()->mSimScriptMsec.getCurrent() > mServerSingleProcessMaxTime) - { - mServerCause->setText( getString("server_scripts_cause_msg", mStringArgs) ); - } - else if(LLViewerStats::getInstance()->mSimNetMsec.getCurrent() > mServerSingleProcessMaxTime) - { - mServerCause->setText( getString("server_net_cause_msg", mStringArgs) ); - } - else if(LLViewerStats::getInstance()->mSimAgentMsec.getCurrent() > mServerSingleProcessMaxTime) - { - mServerCause->setText( getString("server_agent_cause_msg", mStringArgs) ); - } - else if(LLViewerStats::getInstance()->mSimImagesMsec.getCurrent() > mServerSingleProcessMaxTime) - { - mServerCause->setText( getString("server_images_cause_msg", mStringArgs) ); - } - else - { - mServerCause->setText( getString("server_generic_cause_msg", mStringArgs) ); - } - } -} - -void LLFloaterLagMeter::updateControls(bool shrink) -{ -// LLFloaterLagMeter * self = (LLFloaterLagMeter*)data; - - LLButton * button = getChild<LLButton>("minimize"); - S32 delta_width = mMaxWidth -mMinWidth; - LLRect r = getRect(); - - if(!shrink) - { - setTitle(getString("max_title_msg", mStringArgs) ); - // make left edge appear to expand - r.translate(-delta_width, 0); - setRect(r); - reshape(mMaxWidth, getRect().getHeight()); - - getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) + ":"); - getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) + ":"); - getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) + ":"); - - // usually "<<" - button->setLabel( getString("smaller_label", mStringArgs) ); - } - else - { - setTitle( getString("min_title_msg", mStringArgs) ); - // make left edge appear to collapse - r.translate(delta_width, 0); - setRect(r); - reshape(mMinWidth, getRect().getHeight()); - - getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) ); - getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) ); - getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) ); - - // usually ">>" - button->setLabel( getString("bigger_label", mStringArgs) ); - } - // Don't put keyboard focus on the button - button->setFocus(FALSE); - -// self->mClientText->setVisible(self->mShrunk); -// self->mClientCause->setVisible(self->mShrunk); -// self->getChildView("client_help")->setVisible( self->mShrunk); - -// self->mNetworkText->setVisible(self->mShrunk); -// self->mNetworkCause->setVisible(self->mShrunk); -// self->getChildView("network_help")->setVisible( self->mShrunk); - -// self->mServerText->setVisible(self->mShrunk); -// self->mServerCause->setVisible(self->mShrunk); -// self->getChildView("server_help")->setVisible( self->mShrunk); - -// self->mShrunk = !self->mShrunk; -} - -BOOL LLFloaterLagMeter::isShrunk() -{ - return gSavedSettings.getBOOL("LagMeterShrunk"); -} - -void LLFloaterLagMeter::onClickShrink() // toggle "LagMeterShrunk" -{ - bool shrunk = isShrunk(); - updateControls(!shrunk); - gSavedSettings.setBOOL("LagMeterShrunk", !shrunk); -} diff --git a/indra/newview/llfloaterlagmeter.h b/indra/newview/llfloaterlagmeter.h deleted file mode 100644 index eef6955601..0000000000 --- a/indra/newview/llfloaterlagmeter.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file llfloaterlagmeter.h - * @brief The "Lag-o-Meter" floater used to tell users what is causing lag. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LLFLOATERLAGMETER_H -#define LLFLOATERLAGMETER_H - -#include "llfloater.h" - -class LLTextBox; - -class LLFloaterLagMeter : public LLFloater -{ - friend class LLFloaterReg; - -public: - /*virtual*/ void draw(); - /*virtual*/ BOOL postBuild(); -private: - - LLFloaterLagMeter(const LLSD& key); - /*virtual*/ ~LLFloaterLagMeter(); - void determineClient(); - void determineNetwork(); - void determineServer(); - void updateControls(bool shrink); - BOOL isShrunk(); - - void onClickShrink(); - - bool mShrunk; - S32 mMaxWidth, mMinWidth; - - F32 mClientFrameTimeCritical; - F32 mClientFrameTimeWarning; - LLButton * mClientButton; - LLTextBox * mClientText; - LLTextBox * mClientCause; - - F32 mNetworkPacketLossCritical; - F32 mNetworkPacketLossWarning; - F32 mNetworkPingCritical; - F32 mNetworkPingWarning; - LLButton * mNetworkButton; - LLTextBox * mNetworkText; - LLTextBox * mNetworkCause; - - F32 mServerFrameTimeCritical; - F32 mServerFrameTimeWarning; - F32 mServerSingleProcessMaxTime; - LLButton * mServerButton; - LLTextBox * mServerText; - LLTextBox * mServerCause; - - LLStringUtil::format_map_t mStringArgs; -}; - -#endif diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 89240c982f..fc6e9fd514 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -37,7 +37,6 @@ #include "llviewercontrol.h" #include "llfloaterbuycurrency.h" #include "llbuycurrencyhtml.h" -#include "llfloaterlagmeter.h" #include "llpanelnearbymedia.h" #include "llpanelvolumepulldown.h" #include "llfloaterregioninfo.h" diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index 4c59fd0371..e556743cbf 100644 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -369,8 +369,8 @@ LLViewerAssetStats::asLLSD(bool compact_output) std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat]; } - avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].getData(); - avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].getData(); + avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD(); + avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD(); ret[avatar_tag] = avatar_info; return ret; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 1f7cf0cdd4..69586e3634 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -73,7 +73,6 @@ #include "llfloaterinspect.h" #include "llfloaterinventory.h" #include "llfloaterjoystick.h" -#include "llfloaterlagmeter.h" #include "llfloaterland.h" #include "llfloaterlandholdings.h" #include "llfloatermap.h" @@ -227,7 +226,6 @@ void LLViewerFloaterReg::registerFloaters() LLNotificationsUI::registerFloater(); LLFloaterDisplayNameUtil::registerFloater(); - LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>); LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>); LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 1d6d5b7e72..58a7b3a463 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -66,137 +66,134 @@ class StatAttributes { public: StatAttributes(const char* name, - const BOOL enabled, - const BOOL is_timer) + const BOOL enabled) : mName(name), - mEnabled(enabled), - mIsTimer(is_timer) + mEnabled(enabled) { } std::string mName; BOOL mEnabled; - BOOL mIsTimer; }; const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] = { // ST_VERSION - StatAttributes("Version", TRUE, FALSE), + StatAttributes("Version", TRUE), // ST_AVATAR_EDIT_SECONDS - StatAttributes("Seconds in Edit Appearence", FALSE, TRUE), + StatAttributes("Seconds in Edit Appearence", FALSE), // ST_TOOLBOX_SECONDS - StatAttributes("Seconds using Toolbox", FALSE, TRUE), + StatAttributes("Seconds using Toolbox", FALSE), // ST_CHAT_COUNT - StatAttributes("Chat messages sent", FALSE, FALSE), + StatAttributes("Chat messages sent", FALSE), // ST_IM_COUNT - StatAttributes("IMs sent", FALSE, FALSE), + StatAttributes("IMs sent", FALSE), // ST_FULLSCREEN_BOOL - StatAttributes("Fullscreen mode", FALSE, FALSE), + StatAttributes("Fullscreen mode", FALSE), // ST_RELEASE_COUNT - StatAttributes("Object release count", FALSE, FALSE), + StatAttributes("Object release count", FALSE), // ST_CREATE_COUNT - StatAttributes("Object create count", FALSE, FALSE), + StatAttributes("Object create count", FALSE), // ST_REZ_COUNT - StatAttributes("Object rez count", FALSE, FALSE), + StatAttributes("Object rez count", FALSE), // ST_FPS_10_SECONDS - StatAttributes("Seconds below 10 FPS", FALSE, TRUE), + StatAttributes("Seconds below 10 FPS", FALSE), // ST_FPS_2_SECONDS - StatAttributes("Seconds below 2 FPS", FALSE, TRUE), + StatAttributes("Seconds below 2 FPS", FALSE), // ST_MOUSELOOK_SECONDS - StatAttributes("Seconds in Mouselook", FALSE, TRUE), + StatAttributes("Seconds in Mouselook", FALSE), // ST_FLY_COUNT - StatAttributes("Fly count", FALSE, FALSE), + StatAttributes("Fly count", FALSE), // ST_TELEPORT_COUNT - StatAttributes("Teleport count", FALSE, FALSE), + StatAttributes("Teleport count", FALSE), // ST_OBJECT_DELETE_COUNT - StatAttributes("Objects deleted", FALSE, FALSE), + StatAttributes("Objects deleted", FALSE), // ST_SNAPSHOT_COUNT - StatAttributes("Snapshots taken", FALSE, FALSE), + StatAttributes("Snapshots taken", FALSE), // ST_UPLOAD_SOUND_COUNT - StatAttributes("Sounds uploaded", FALSE, FALSE), + StatAttributes("Sounds uploaded", FALSE), // ST_UPLOAD_TEXTURE_COUNT - StatAttributes("Textures uploaded", FALSE, FALSE), + StatAttributes("Textures uploaded", FALSE), // ST_EDIT_TEXTURE_COUNT - StatAttributes("Changes to textures on objects", FALSE, FALSE), + StatAttributes("Changes to textures on objects", FALSE), // ST_KILLED_COUNT - StatAttributes("Number of times killed", FALSE, FALSE), + StatAttributes("Number of times killed", FALSE), // ST_FRAMETIME_JITTER - StatAttributes("Average delta between sucessive frame times", FALSE, FALSE), + StatAttributes("Average delta between successive frame times", FALSE), // ST_FRAMETIME_SLEW - StatAttributes("Average delta between frame time and mean", FALSE, FALSE), + StatAttributes("Average delta between frame time and mean", FALSE), // ST_INVENTORY_TOO_LONG - StatAttributes("Inventory took too long to load", FALSE, FALSE), + StatAttributes("Inventory took too long to load", FALSE), // ST_WEARABLES_TOO_LONG - StatAttributes("Wearables took too long to load", FALSE, FALSE), + StatAttributes("Wearables took too long to load", FALSE), // ST_LOGIN_SECONDS - StatAttributes("Time between LoginRequest and LoginReply", FALSE, FALSE), + StatAttributes("Time between LoginRequest and LoginReply", FALSE), // ST_LOGIN_TIMEOUT_COUNT - StatAttributes("Number of login attempts that timed out", FALSE, FALSE), + StatAttributes("Number of login attempts that timed out", FALSE), // ST_HAS_BAD_TIMER - StatAttributes("Known bad timer if != 0.0", FALSE, FALSE), + StatAttributes("Known bad timer if != 0.0", FALSE), // ST_DOWNLOAD_FAILED - StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE, FALSE), + StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE), // ST_LSL_SAVE_COUNT - StatAttributes("Number of times user has saved a script", FALSE, FALSE), + StatAttributes("Number of times user has saved a script", FALSE), // ST_UPLOAD_ANIM_COUNT - StatAttributes("Animations uploaded", FALSE, FALSE), + StatAttributes("Animations uploaded", FALSE), // ST_FPS_8_SECONDS - StatAttributes("Seconds below 8 FPS", FALSE, TRUE), + StatAttributes("Seconds below 8 FPS", FALSE), // ST_SIM_FPS_20_SECONDS - StatAttributes("Seconds with sim FPS below 20", FALSE, TRUE), + StatAttributes("Seconds with sim FPS below 20", FALSE), // ST_PHYS_FPS_20_SECONDS - StatAttributes("Seconds with physics FPS below 20", FALSE, TRUE), + StatAttributes("Seconds with physics FPS below 20", FALSE), // ST_LOSS_05_SECONDS - StatAttributes("Seconds with packet loss > 5%", FALSE, TRUE), + StatAttributes("Seconds with packet loss > 5%", FALSE), // ST_FPS_DROP_50_RATIO - StatAttributes("Ratio of frames 2x longer than previous", FALSE, FALSE), + StatAttributes("Ratio of frames 2x longer than previous", FALSE), // ST_ENABLE_VBO - StatAttributes("Vertex Buffers Enabled", TRUE, FALSE), + StatAttributes("Vertex Buffers Enabled", TRUE), // ST_DELTA_BANDWIDTH - StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE, FALSE), + StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE), // ST_MAX_BANDWIDTH - StatAttributes("Max bandwidth setting", FALSE, FALSE), + StatAttributes("Max bandwidth setting", FALSE), // ST_LIGHTING_DETAIL - StatAttributes("Lighting Detail", FALSE, FALSE), + StatAttributes("Lighting Detail", FALSE), // ST_VISIBLE_AVATARS - StatAttributes("Visible Avatars", FALSE, FALSE), + StatAttributes("Visible Avatars", FALSE), // ST_SHADER_OJECTS - StatAttributes("Object Shaders", FALSE, FALSE), + StatAttributes("Object Shaders", FALSE), // ST_SHADER_ENVIRONMENT - StatAttributes("Environment Shaders", FALSE, FALSE), + StatAttributes("Environment Shaders", FALSE), // ST_VISIBLE_DRAW_DIST - StatAttributes("Draw Distance", FALSE, FALSE), + StatAttributes("Draw Distance", FALSE), // ST_VISIBLE_CHAT_BUBBLES - StatAttributes("Chat Bubbles Enabled", FALSE, FALSE), + StatAttributes("Chat Bubbles Enabled", FALSE), // ST_SHADER_AVATAR - StatAttributes("Avatar Shaders", FALSE, FALSE), + StatAttributes("Avatar Shaders", FALSE), // ST_FRAME_SECS - StatAttributes("FRAME_SECS", FALSE, FALSE), + StatAttributes("FRAME_SECS", FALSE), // ST_UPDATE_SECS - StatAttributes("UPDATE_SECS", FALSE, FALSE), + StatAttributes("UPDATE_SECS", FALSE), // ST_NETWORK_SECS - StatAttributes("NETWORK_SECS", FALSE, FALSE), + StatAttributes("NETWORK_SECS", FALSE), // ST_IMAGE_SECS - StatAttributes("IMAGE_SECS", FALSE, FALSE), + StatAttributes("IMAGE_SECS", FALSE), // ST_REBUILD_SECS - StatAttributes("REBUILD_SECS", FALSE, FALSE), + StatAttributes("REBUILD_SECS", FALSE), // ST_RENDER_SECS - StatAttributes("RENDER_SECS", FALSE, FALSE), + StatAttributes("RENDER_SECS", FALSE), // ST_CROSSING_AVG - StatAttributes("CROSSING_AVG", FALSE, FALSE), + StatAttributes("CROSSING_AVG", FALSE), // ST_CROSSING_MAX - StatAttributes("CROSSING_MAX", FALSE, FALSE), + StatAttributes("CROSSING_MAX", FALSE), // ST_LIBXUL_WIDGET_USED - StatAttributes("LibXUL Widget used", FALSE, FALSE), // Unused + StatAttributes("LibXUL Widget used", FALSE), // Unused // ST_WINDOW_WIDTH - StatAttributes("Window width", FALSE, FALSE), + StatAttributes("Window width", FALSE), // ST_WINDOW_HEIGHT - StatAttributes("Window height", FALSE, FALSE), + StatAttributes("Window height", FALSE), // ST_TEX_BAKES - StatAttributes("Texture Bakes", FALSE, FALSE), + StatAttributes("Texture Bakes", FALSE), // ST_TEX_REBAKES - StatAttributes("Texture Rebakes", FALSE, FALSE) + StatAttributes("Texture Rebakes", FALSE) }; @@ -207,16 +204,11 @@ LLViewerStats::LLViewerStats() : mAssetKBitStat("assetkbitstat"), mTextureKBitStat("texturekbitstat"), mVFSPendingOperations("vfspendingoperations"), - mObjectsDrawnStat("objectsdrawnstat"), - mObjectsCulledStat("objectsculledstat"), - mObjectsTestedStat("objectstestedstat"), - mObjectsComparedStat("objectscomparedstat"), - mObjectsOccludedStat("objectsoccludedstat"), mFPSStat("fpsstat"), mPacketsInStat("packetsinstat"), mPacketsLostStat("packetsloststat"), mPacketsOutStat("packetsoutstat"), - mPacketsLostPercentStat("packetslostpercentstat", 64), + mPacketsLostPercentStat("packetslostpercentstat"), mTexturePacketsStat("texturepacketsstat"), mActualInKBitStat("actualinkbitstat"), mActualOutKBitStat("actualoutkbitstat"), @@ -258,12 +250,12 @@ LLViewerStats::LLViewerStats() : mPhysicsLODTasks("physicslodtasks"), mPhysicsMemoryAllocated("physicsmemoryallocated"), mSimPingStat("simpingstat"), - mNumImagesStat("numimagesstat", 32, TRUE), - mNumRawImagesStat("numrawimagesstat", 32, TRUE), - mGLTexMemStat("gltexmemstat", 32, TRUE), - mGLBoundMemStat("glboundmemstat", 32, TRUE), - mRawMemStat("rawmemstat", 32, TRUE), - mFormattedMemStat("formattedmemstat", 32, TRUE), + mNumImagesStat("numimagesstat", TRUE), + mNumRawImagesStat("numrawimagesstat", TRUE), + mGLTexMemStat("gltexmemstat", TRUE), + mGLBoundMemStat("glboundmemstat", TRUE), + mRawMemStat("rawmemstat", TRUE), + mFormattedMemStat("formattedmemstat", TRUE), mNumObjectsStat("numobjectsstat"), mNumActiveObjectsStat("numactiveobjectsstat"), mNumNewObjectsStat("numnewobjectsstat"), @@ -284,10 +276,6 @@ LLViewerStats::LLViewerStats() : mAgentPositionSnaps.reset(); } -LLViewerStats::~LLViewerStats() -{ -} - void LLViewerStats::resetStats() { LLViewerStats& stats = LLViewerStats::instance(); @@ -398,7 +386,7 @@ void LLViewerStats::addToMessage(LLSD &body) const } } - body["AgentPositionSnaps"] = mAgentPositionSnaps.getData(); + body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD(); llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() << "; Count = " << mAgentPositionSnaps.getCount() << llendl; } @@ -783,7 +771,7 @@ void LLViewerStats::PhaseMap::clearPhases() mPhaseMap.clear(); } -LLSD LLViewerStats::PhaseMap::dumpPhases() +LLSD LLViewerStats::PhaseMap::asLLSD() { LLSD result; for (phase_map_t::iterator iter = mPhaseMap.begin(); iter != mPhaseMap.end(); ++iter) diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index e02a4ccdc7..0d8f2a45c0 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -39,11 +39,6 @@ public: mAssetKBitStat, mTextureKBitStat, mVFSPendingOperations, - mObjectsDrawnStat, - mObjectsCulledStat, - mObjectsTestedStat, - mObjectsComparedStat, - mObjectsOccludedStat, mFPSStat, mPacketsInStat, mPacketsLostStat, @@ -55,60 +50,60 @@ public: mTrianglesDrawnStat; // Simulator stats - LLStat mSimTimeDilation, + LLStat mSimTimeDilation; - mSimFPS, + LLStat mSimFPS, mSimPhysicsFPS, mSimAgentUPS, - mSimScriptEPS, + mSimScriptEPS; - mSimFrameMsec, + LLStat mSimFrameMsec, mSimNetMsec, mSimSimOtherMsec, - mSimSimPhysicsMsec, + mSimSimPhysicsMsec; - mSimSimPhysicsStepMsec, + LLStat mSimSimPhysicsStepMsec, mSimSimPhysicsShapeUpdateMsec, mSimSimPhysicsOtherMsec, mSimSimAIStepMsec, mSimSimSkippedSilhouetteSteps, - mSimSimPctSteppedCharacters, + mSimSimPctSteppedCharacters; - mSimAgentMsec, + LLStat mSimAgentMsec, mSimImagesMsec, mSimScriptMsec, mSimSpareMsec, mSimSleepMsec, - mSimPumpIOMsec, + mSimPumpIOMsec; - mSimMainAgents, + LLStat mSimMainAgents, mSimChildAgents, mSimObjects, mSimActiveObjects, mSimActiveScripts, - mSimPctScriptsRun, + mSimPctScriptsRun; - mSimInPPS, + LLStat mSimInPPS, mSimOutPPS, mSimPendingDownloads, mSimPendingUploads, mSimPendingLocalUploads, - mSimTotalUnackedBytes, + mSimTotalUnackedBytes; - mPhysicsPinnedTasks, + LLStat mPhysicsPinnedTasks, mPhysicsLODTasks, - mPhysicsMemoryAllocated, + mPhysicsMemoryAllocated; - mSimPingStat, + LLStat mSimPingStat; - mNumImagesStat, + LLStat mNumImagesStat, mNumRawImagesStat, mGLTexMemStat, mGLBoundMemStat, mRawMemStat, - mFormattedMemStat, + mFormattedMemStat; - mNumObjectsStat, + LLStat mNumObjectsStat, mNumActiveObjectsStat, mNumNewObjectsStat, mNumSizeCulledStat, @@ -182,7 +177,6 @@ public: }; LLViewerStats(); - ~LLViewerStats(); // all return latest value of given stat F64 getStat(EStatType type) const; @@ -203,7 +197,7 @@ public: U32 mCountOfNextUpdatesToIgnore; inline StatsAccumulator() - { + { reset(); } @@ -263,7 +257,7 @@ public: mCountOfNextUpdatesToIgnore = 0; } - inline LLSD getData() const + inline LLSD asLLSD() const { LLSD data; data["mean"] = getMean(); @@ -293,7 +287,7 @@ public: void stopPhase(const std::string& phase_name); void stopAllPhases(); void clearPhases(); - LLSD dumpPhases(); + LLSD asLLSD(); static StatsAccumulator& getPhaseStats(const std::string& phase_name); static void recordPhaseStat(const std::string& phase_name, F32 value); }; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 80cca9963e..c0b196918d 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -67,12 +67,12 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; U32 LLViewerTextureList::sTextureBits = 0; U32 LLViewerTextureList::sTexturePackets = 0; S32 LLViewerTextureList::sNumImages = 0; -LLStat LLViewerTextureList::sNumImagesStat("Num Images", 32, TRUE); -LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", 32, TRUE); -LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", 32, TRUE); -LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", 32, TRUE); -LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", 32, TRUE); -LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", 32, TRUE); +LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE); +LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE); +LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", TRUE); +LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", TRUE); +LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", TRUE); +LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", TRUE); LLViewerTextureList gTextureList; static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images"); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 6ef9bdd238..93573ed52e 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2140,8 +2140,8 @@ LLSD LLVOAvatarSelf::metricsData() result["timers"]["ruth"] = mRuthTimer.getElapsedTimeF32(); result["timers"]["invisible"] = mInvisibleTimer.getElapsedTimeF32(); result["timers"]["fully_loaded"] = mFullyLoadedTimer.getElapsedTimeF32(); - result["phases"] = getPhases().dumpPhases(); - result["startup"] = LLStartUp::getPhases().dumpPhases(); + result["phases"] = getPhases().asLLSD(); + result["startup"] = LLStartUp::getPhases().asLLSD(); return result; } diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 09d17b3701..43152c9025 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1157,7 +1157,7 @@ void send_agent_resume() } // Reset the FPS counter to avoid an invalid fps - LLViewerStats::getInstance()->mFPSStat.start(); + LLViewerStats::getInstance()->mFPSStat.reset(); LLAppViewer::instance()->resumeMainloopTimeout(); } diff --git a/indra/newview/skins/default/xui/da/floater_lagmeter.xml b/indra/newview/skins/default/xui/da/floater_lagmeter.xml deleted file mode 100644 index 149d174c34..0000000000 --- a/indra/newview/skins/default/xui/da/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="LAG METER"> - <floater.string name="max_title_msg"> - Lag måler - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Klient - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, vindue i baggrund - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Klients billeder/sek under [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Klients billeder/sek mellem [CLIENT_FRAME_RATE_CRITICAL] og [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Mulig årsag: 'Vis afstand' sat for højt i grafik indstillinger - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Mulig årsag: Billeder hentes - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Mulig årsag: For mange billeder i hukommelse - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Mulig årsag: For mange komplekse objekter i scenariet - </floater.string> - <floater.string name="network_text_msg"> - Netværk - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Forbindelsen mister over [NETWORK_PACKET_LOSS_CRITICAL]% pakker - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Forbindelsen mister [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% pakker - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Forbindelsens ping tider er over [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Forbindelsens ping tider er [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Muligvis dårlig forbindelse eller 'båndbredde' sat for højt i netværksopsætning. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Muligvis dårlig forbindelse eller fil delings program. - </floater.string> - <floater.string name="server_text_msg"> - Server - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Simulator framerate er under [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Simulator framerate er mellem [SERVER_FRAME_RATE_CRITICAL] og [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Mulig årsag: For mange fysiske objekter - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Mulig årsag: For mange objekter med script - </floater.string> - <floater.string name="server_net_cause_msg"> - Mulig årsag: For meget netværks trafik - </floater.string> - <floater.string name="server_agent_cause_msg"> - Mulig årsag: For mange avatarer i bevægelse i regionen - </floater.string> - <floater.string name="server_images_cause_msg"> - Mulig årsag: For mange billed udregninger - </floater.string> - <floater.string name="server_generic_cause_msg"> - Mulig årsag: Simulator belastning for stor - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button label="" label_selected="" name="client_lagmeter" tool_tip="Status for klient lag"/> - <text name="client"> - Klient - </text> - <text name="client_text"> - Normal - </text> - <button label="" label_selected="" name="network_lagmeter" tool_tip="Network lag status"/> - <text name="network"> - Netværk - </text> - <text name="network_text"> - Normal - </text> - <button label="" label_selected="" name="server_lagmeter" tool_tip="Status for server lag"/> - <text name="server"> - Server - </text> - <text name="server_text"> - Normal - </text> - <button label=">>" name="minimize" tool_tip="Ændre størrelse"/> -</floater> diff --git a/indra/newview/skins/default/xui/de/floater_lagmeter.xml b/indra/newview/skins/default/xui/de/floater_lagmeter.xml deleted file mode 100644 index 45ff37c147..0000000000 --- a/indra/newview/skins/default/xui/de/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="LAG METER"> - <floater.string name="max_title_msg"> - Lag-Anzeige - </floater.string> - <floater.string name="max_width_px"> - 350 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Client - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, Fenster im Hintergrund - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Client-Frame-Rate unter [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Client-Frame-Rate zwischen [CLIENT_FRAME_RATE_CRITICAL] und [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Mögliche Ursache: Sichtweite zu groß - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Mögliche Ursache: Bilder werden geladen - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Mögliche Ursache: Zu viele Bilder im Speicher - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Mögliche Ursache: Zu viele komplexe Objekte in der Szene - </floater.string> - <floater.string name="network_text_msg"> - Netzwerk - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Paketverlust der Verbindung übersteigt [NETWORK_PACKET_LOSS_CRITICAL]% - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Paketverlust der Verbindung liegt bei [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Ping-Zeit der Verbindung übersteigt [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Ping-Zeit der Verbindung liegt bei [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Möglicherweise schlechte Verbindung oder zu hoher Wert für „Bandbreite“. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Möglicherweise schlechte Verbindung oder File-Sharing-Anwendung. - </floater.string> - <floater.string name="server_text_msg"> - Server - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Simulator-Frame-Rate liegt unter [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Simulator-Frame-Rate liegt zwischen [SERVER_FRAME_RATE_CRITICAL] und [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Mögliche Ursache: Zu viele physische Objekte - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Mögliche Ursache: Zu viele geskriptete Objekte - </floater.string> - <floater.string name="server_net_cause_msg"> - Mögliche Ursache: Zu viel Netzwerktraffic - </floater.string> - <floater.string name="server_agent_cause_msg"> - Mögliche Ursache: Zu viele Personen in Bewegung in der Region - </floater.string> - <floater.string name="server_images_cause_msg"> - Mögliche Ursache: Zu viele Bildberechnungen - </floater.string> - <floater.string name="server_generic_cause_msg"> - Mögliche Ursache: Zu hohe Simulator-Last - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="Client-Lag-Status"/> - <text name="client"> - Client - </text> - <text name="client_text"> - Normal - </text> - <button name="network_lagmeter" tool_tip="Netzwerk-Lag-Status"/> - <text name="network"> - Netzwerk - </text> - <text name="network_text"> - Normal - </text> - <button name="server_lagmeter" tool_tip="Server-Lag-Status"/> - <text name="server"> - Server - </text> - <text name="server_text"> - Normal - </text> - <button label=">> " name="minimize" tool_tip="Fenstergröße ändern"/> -</floater> diff --git a/indra/newview/skins/default/xui/en/floater_lagmeter.xml b/indra/newview/skins/default/xui/en/floater_lagmeter.xml deleted file mode 100644 index b24c745bdd..0000000000 --- a/indra/newview/skins/default/xui/en/floater_lagmeter.xml +++ /dev/null @@ -1,336 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes" ?> -<floater - legacy_header_height="18" - height="170" - layout="topleft" - name="floater_lagmeter" - help_topic="floater_lagmeter" - save_rect="true" - title="LAG METER" - width="350"> - <floater.string - name="max_title_msg"> - Lag Meter - </floater.string> - <floater.string - name="max_width_px"> - 360 - </floater.string> - <floater.string - name="min_title_msg"> - Lag - </floater.string> - <floater.string - name="min_width_px"> - 90 - </floater.string> - <floater.string - name="client_text_msg"> - Client - </floater.string> - <floater.string - name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string - name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string - name="client_frame_time_window_bg_msg"> - Normal, window in background - </floater.string> - <floater.string - name="client_frame_time_critical_msg"> - Client frame rate below [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string - name="client_frame_time_warning_msg"> - Client frame rate between [CLIENT_FRAME_RATE_CRITICAL] and [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string - name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string - name="client_draw_distance_cause_msg"> - Possible cause: Draw distance set too high - </floater.string> - <floater.string - name="client_texture_loading_cause_msg"> - Possible cause: Images loading - </floater.string> - <floater.string - name="client_texture_memory_cause_msg"> - Possible cause: Too many images in memory - </floater.string> - <floater.string - name="client_complex_objects_cause_msg"> - Possible cause: Too many complex objects in scene - </floater.string> - <floater.string - name="network_text_msg"> - Network - </floater.string> - <floater.string - name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string - name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string - name="network_packet_loss_critical_msg"> - Connection is dropping over [NETWORK_PACKET_LOSS_CRITICAL]% of packets - </floater.string> - <floater.string - name="network_packet_loss_warning_msg"> - Connection is dropping [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% of packets - </floater.string> - <floater.string - name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string - name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string - name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string - name="network_ping_critical_msg"> - Connection ping time is over [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string - name="network_ping_warning_msg"> - Connection ping time is [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string - name="network_packet_loss_cause_msg"> - Possible bad connection or 'Bandwidth' pref too high. - </floater.string> - <floater.string - name="network_ping_cause_msg"> - Possible bad connection or file-sharing app. - </floater.string> - <floater.string - name="server_text_msg"> - Server - </floater.string> - <floater.string - name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string - name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string - name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string - name="server_frame_time_critical_msg"> - Simulator framerate below [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string - name="server_frame_time_warning_msg"> - Simulator framerate between [SERVER_FRAME_RATE_CRITICAL] and [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string - name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string - name="server_physics_cause_msg"> - Possible Cause: Too many physical objects - </floater.string> - <floater.string - name="server_scripts_cause_msg"> - Possible Cause: Too many scripted objects - </floater.string> - <floater.string - name="server_net_cause_msg"> - Possible Cause: Too much network traffic - </floater.string> - <floater.string - name="server_agent_cause_msg"> - Possible Cause: Too many moving people in region - </floater.string> - <floater.string - name="server_images_cause_msg"> - Possible Cause: Too many image calculations - </floater.string> - <floater.string - name="server_generic_cause_msg"> - Possible Cause: Simulator load too heavy - </floater.string> - <floater.string - name="smaller_label"> - >> - </floater.string> - <floater.string - name="bigger_label"> - << - </floater.string> - <button - follows="top|left" - height="16" - image_selected="lag_status_good.tga" - image_unselected="lag_status_good.tga" - layout="topleft" - left="8" - name="client_lagmeter" - tab_stop="false" - tool_tip="Client lag status" - top="24" - width="16" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="3" - name="client" - top_delta="0" - width="128"> - Client - </text> - <text - invisiblity_control="LagMeterShrunk" - type="string" - length="1" - bottom="40" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="110" - name="client_text" - right="-10"> - Normal - </text> - <text - invisiblity_control="LagMeterShrunk" - bottom="56" - follows="left|top" - height="16" - layout="topleft" - left="40" - name="client_lag_cause" - right="-32" /> - <button - follows="top|left" - height="16" - image_selected="lag_status_good.tga" - image_unselected="lag_status_good.tga" - layout="topleft" - left="8" - name="network_lagmeter" - tab_stop="false" - tool_tip="Network lag status" - top="64" - width="16" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="3" - name="network" - top_delta="0" - width="128"> - Network - </text> - <text - invisiblity_control="LagMeterShrunk" - type="string" - length="1" - bottom="80" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="110" - name="network_text" - right="-10"> - Normal - </text> - <text - invisiblity_control="LagMeterShrunk" - bottom="96" - follows="left|top" - height="16" - layout="topleft" - left="40" - name="network_lag_cause" - right="-32" /> - <button - follows="top|left" - height="16" - image_selected="lag_status_good.tga" - image_unselected="lag_status_good.tga" - layout="topleft" - left="8" - name="server_lagmeter" - tab_stop="false" - tool_tip="Server lag status" - top="104" - width="16" /> - <text - type="string" - length="1" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left_pad="3" - name="server" - top_delta="0" - width="60"> - Server - </text> - <text - invisiblity_control="LagMeterShrunk" - type="string" - length="1" - bottom="120" - follows="left|top" - font="SansSerif" - height="16" - layout="topleft" - left="110" - name="server_text" - right="-10"> - Normal - </text> - <text - invisiblity_control="LagMeterShrunk" - bottom="136" - follows="left|top" - height="16" - layout="topleft" - left="40" - name="server_lag_cause" - right="-32" /> - <button - follows="left|top" - height="20" - label=">>" - layout="topleft" - left="10" - name="minimize" - tool_tip="Toggle floater size" - top_delta="24" - width="40"> - <button.commit_callback - function="LagMeter.ClickShrink" /> - </button> -</floater> diff --git a/indra/newview/skins/default/xui/es/floater_lagmeter.xml b/indra/newview/skins/default/xui/es/floater_lagmeter.xml deleted file mode 100644 index 227689a194..0000000000 --- a/indra/newview/skins/default/xui/es/floater_lagmeter.xml +++ /dev/null @@ -1,154 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="MEDIDOR DEL LAG"> - <floater.string name="max_title_msg"> - Medidor del lag - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Cliente - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, ventana en segundo plano - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Frames del cliente valorados por debajo de [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Frames del cliente valorados entre [CLIENT_FRAME_RATE_CRITICAL] y [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Posible causa: distancia de dibujo fijada muy alta - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Posible causa: imágenes cargándose - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Posible causa: demasiadas imágenes en la memoria - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Posible causa: demasiados objetos complejos en la escena - </floater.string> - <floater.string name="network_text_msg"> - Red - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - La conexión deja caer más del [NETWORK_PACKET_LOSS_CRITICAL]% de los paquetes - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - La conexión deja caer [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% de los paquetes - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - El tiempo de conexión -ping- supera los [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - El tiempo de conexión -ping- es de [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Quizá una mala conexión o un ancho de banda fijado demasiado alto. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Quizá una mala conexión o una aplicación de archivos compartidos. - </floater.string> - <floater.string name="server_text_msg"> - Servidor - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Frecuencia (framerate) por debajo de [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Frecuencia (framerate) entre [SERVER_FRAME_RATE_CRITICAL] y [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Posible causa: demasiados objetos físicos - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Posible causa: demasiados objetos con script - </floater.string> - <floater.string name="server_net_cause_msg"> - Posible causa: demasiado tráfico en la red - </floater.string> - <floater.string name="server_agent_cause_msg"> - Posible causa: demasiada gente moviéndose en la región - </floater.string> - <floater.string name="server_images_cause_msg"> - Posible causa: demasiados cálculos de imáganes - </floater.string> - <floater.string name="server_generic_cause_msg"> - Posible causa: carga del simulador muy pesada - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button label="" label_selected="" name="client_lagmeter" tool_tip="Estado del lag del cliente"/> - <text name="client"> - Cliente - </text> - <text font="SansSerifSmall" name="client_text"> - Normal - </text> - <text left="30" name="client_lag_cause" right="-10"/> - <button label="" label_selected="" name="network_lagmeter" tool_tip="Estado del lag de la red"/> - <text name="network"> - Red - </text> - <text font="SansSerifSmall" name="network_text"> - Normal - </text> - <text left="30" name="network_lag_cause" right="-10"/> - <button label="" label_selected="" name="server_lagmeter" tool_tip="Estado del lag del servidor"/> - <text name="server"> - Servidor - </text> - <text font="SansSerifSmall" name="server_text"> - Normal - </text> - <text left="30" name="server_lag_cause" right="-32"/> - <button label=">>" name="minimize" tool_tip="Cambia el tamaño de la ventana"/> -</floater> diff --git a/indra/newview/skins/default/xui/fr/floater_lagmeter.xml b/indra/newview/skins/default/xui/fr/floater_lagmeter.xml deleted file mode 100644 index 39a861d8bd..0000000000 --- a/indra/newview/skins/default/xui/fr/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="MESURE DU LAG"> - <floater.string name="max_title_msg"> - Mesure du lag - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Client - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, fenêtre en arrière-plan - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Taux de défilement [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Taux de défilement entre [CLIENT_FRAME_RATE_CRITICAL] et [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Cause possible : limite d'affichage trop élevée - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Cause possible : images en cours de chargement - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Cause possible : trop d'images en mémoire - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Cause possible : trop d'objets complexes - </floater.string> - <floater.string name="network_text_msg"> - Réseau - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - La connexion perd plus de [NETWORK_PACKET_LOSS_CRITICAL] % de paquets - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - La connexion perd entre [NETWORK_PACKET_LOSS_WARNING] % et [NETWORK_PACKET_LOSS_CRITICAL] % de paquets - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Connexion ping > [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Connexion ping entre [NETWORK_PING_WARNING] et [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Mauvaise connexion possible ou réglage de la bande passante trop élevé. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Mauvaise connexion possible ou app. de partage des fichiers - </floater.string> - <floater.string name="server_text_msg"> - Serveur - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Défilement du simulateur < [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Défilement simulateur entre [SERVER_FRAME_RATE_CRITICAL] et [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Cause possible : trop d'objets physiques - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Cause possible : trop d'objets scriptés - </floater.string> - <floater.string name="server_net_cause_msg"> - Cause possible : trop de trafic réseau - </floater.string> - <floater.string name="server_agent_cause_msg"> - Cause possible : trop de personnes en mouvement - </floater.string> - <floater.string name="server_images_cause_msg"> - Cause possible : trop de calculs d'images - </floater.string> - <floater.string name="server_generic_cause_msg"> - Cause possible : charge simulateur trop lourde - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="Statut du lag client"/> - <text name="client"> - Client - </text> - <text name="client_text"> - Normal - </text> - <button name="network_lagmeter" tool_tip="Statut du lag réseau"/> - <text name="network"> - Réseau - </text> - <text name="network_text"> - Normal - </text> - <button name="server_lagmeter" tool_tip="Statut du lag serveur"/> - <text name="server"> - Serveur - </text> - <text name="server_text"> - Normal - </text> - <button label=">>" name="minimize" tool_tip="Activer/désactiver la taille du floater"/> -</floater> diff --git a/indra/newview/skins/default/xui/it/floater_lagmeter.xml b/indra/newview/skins/default/xui/it/floater_lagmeter.xml deleted file mode 100644 index f7b2b1ab4a..0000000000 --- a/indra/newview/skins/default/xui/it/floater_lagmeter.xml +++ /dev/null @@ -1,154 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="MISURATORE LAG"> - <floater.string name="max_title_msg"> - Misuratore del lag - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Programma in locale - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normale, finestra sullo sfondo - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Velocità dei frame al di sotto di [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Velocità dei frame tra [CLIENT_FRAME_RATE_CRITICAL] e [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normale - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Possibile causa: Campo visivo impostato troppo alto - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Possibile causa: Caricamento immagini - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Possibile causa: Troppe immagini in memoria - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Possibile causa: Troppi oggetti complessi intorno - </floater.string> - <floater.string name="network_text_msg"> - Network - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - La connessione sta calando al di sotto del [NETWORK_PACKET_LOSS_CRITICAL]% di pacchetti - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - La connessione sta calando tra il [NETWORK_PACKET_LOSS_WARNING]% e il [NETWORK_PACKET_LOSS_CRITICAL]% di pacchetti - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normale - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Il tempo di ping della connessione è al di sopra di [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Il tempo di ping della connessione è tra [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Possibile cattiva connessione o la larghezza di banda impostata nelle preferenze troppo alta. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Possibile cattiva connessione o l'apertura di un programma di scambio files. - </floater.string> - <floater.string name="server_text_msg"> - Server - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Velocità dei frame al di sotto di [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Velocità dei frame tra [SERVER_FRAME_RATE_CRITICAL] e [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normale - </floater.string> - <floater.string name="server_physics_cause_msg"> - Possibile causa: troppi oggetti fisici - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Possibile causa: troppi oggetti scriptati - </floater.string> - <floater.string name="server_net_cause_msg"> - Possibile causa: eccessivo traffico sulla rete - </floater.string> - <floater.string name="server_agent_cause_msg"> - Possibile causa: troppi residenti in movimento nella regione - </floater.string> - <floater.string name="server_images_cause_msg"> - Possibile causa: troppe elaborazioni di immagini - </floater.string> - <floater.string name="server_generic_cause_msg"> - Possibile causa: carico eccessivo del simulatore - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button label="" label_selected="" name="client_lagmeter" tool_tip="Stato del lag del programma in locale"/> - <text name="client"> - Client - </text> - <text font="SansSerifSmall" left="145" name="client_text"> - Normale - </text> - <text left="30" name="client_lag_cause" right="-10"/> - <button label="" label_selected="" name="network_lagmeter" tool_tip="Stato del lag del network"/> - <text name="network"> - Rete - </text> - <text font="SansSerifSmall" name="network_text"> - Normale - </text> - <text left="30" name="network_lag_cause" right="-10"/> - <button label="" label_selected="" name="server_lagmeter" tool_tip="Stato del lag del server"/> - <text name="server"> - Server - </text> - <text font="SansSerifSmall" name="server_text"> - Normale - </text> - <text left="30" name="server_lag_cause" right="-32"/> - <button label=">>" name="minimize" tool_tip="Cambia dimensioni floater"/> -</floater> diff --git a/indra/newview/skins/default/xui/ja/floater_lagmeter.xml b/indra/newview/skins/default/xui/ja/floater_lagmeter.xml deleted file mode 100644 index e3546cd837..0000000000 --- a/indra/newview/skins/default/xui/ja/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="ラグメーター"> - <floater.string name="max_title_msg"> - ラグ メーター - </floater.string> - <floater.string name="max_width_px"> - 350 - </floater.string> - <floater.string name="min_title_msg"> - ラグ - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - クライアント - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - ノーマル、ウィンドウは背景に - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - クライアント フレームレート < [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - クライアント フレームレート: [CLIENT_FRAME_RATE_CRITICAL] ~ [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - ノーマル - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - 考えられる原因: 描画距離の設定が大きすぎる - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - 考えられる原因: 画像のロード中 - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - 考えられる原因: メモリ内の画像数が多すぎる - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - 考えられる原因: 画面に含まれる複雑なオブジェクトが多すぎる - </floater.string> - <floater.string name="network_text_msg"> - ネットワーク - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - 接続でドロップされるパケットの割合: > [NETWORK_PACKET_LOSS_CRITICAL] - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - 接続でドロップされるパケットの割合:[NETWORK_PACKET_LOSS_WARNING] ~ [NETWORK_PACKET_LOSS_CRITICAL] - </floater.string> - <floater.string name="network_performance_normal_msg"> - ノーマル - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - 接続の ping 時間: > [NETWORK_PING_CRITICAL] ミリ秒 - </floater.string> - <floater.string name="network_ping_warning_msg"> - 接続の ping 時間: [NETWORK_PING_WARNING] ~ [NETWORK_PING_CRITICAL] ミリ秒 - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - 接続不良になっているか、帯域幅設定が高すぎます。 - </floater.string> - <floater.string name="network_ping_cause_msg"> - 接続不良になっているか、ファイル共有アプリケーションに問題があります。 - </floater.string> - <floater.string name="server_text_msg"> - サーバー - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - シミュレーターのフレームレート: < [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - シミュレーターのフレームレート: [SERVER_FRAME_RATE_CRITICAL] ~ [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - ノーマル - </floater.string> - <floater.string name="server_physics_cause_msg"> - 考えられる原因: 物理的オブジェクトが多すぎる - </floater.string> - <floater.string name="server_scripts_cause_msg"> - 考えられる原因: スクリプトを含むオブジェクトが多すぎる - </floater.string> - <floater.string name="server_net_cause_msg"> - 考えられる原因: ネットワーク トラフィック過大 - </floater.string> - <floater.string name="server_agent_cause_msg"> - 考えられる原因: 地域内にて動いているアバターが多すぎる - </floater.string> - <floater.string name="server_images_cause_msg"> - 考えられる原因: 画像計算が多すぎる - </floater.string> - <floater.string name="server_generic_cause_msg"> - 考えられる原因: シミュレーターの過負荷 - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="クライアント ラグ ステータス"/> - <text name="client"> - クライアント - </text> - <text name="client_text"> - ノーマル - </text> - <button name="network_lagmeter" tool_tip="ネットワーク ラグ ステータス"/> - <text name="network"> - ネットワーク - </text> - <text name="network_text"> - ノーマル - </text> - <button name="server_lagmeter" tool_tip="サーバー ラグ ステータス"/> - <text name="server"> - サーバー - </text> - <text name="server_text"> - ノーマル - </text> - <button label=">> " name="minimize" tool_tip="フローターのサイズをトグル"/> -</floater> diff --git a/indra/newview/skins/default/xui/pl/floater_lagmeter.xml b/indra/newview/skins/default/xui/pl/floater_lagmeter.xml deleted file mode 100644 index 8038550bcb..0000000000 --- a/indra/newview/skins/default/xui/pl/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="POMIAR LAGÓW"> - <floater.string name="max_title_msg"> - Pomiar lagów - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Klient - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - W normie, okno w tle - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Ilość klatek na sekundę klienta poniżej [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Ilość klatek na sekundę pomiędzy [CLIENT_FRAME_RATE_CRITICAL] i [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - W normie - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Przyczyna: dystans rysowania jest za wysoki - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Przyczyna: ładowanie obrazu - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Przyczyna: za dużo obrazów w pamięci - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Przyczyna: za dużo złożonych obiektów - </floater.string> - <floater.string name="network_text_msg"> - Sieć - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Utrata pakietów przekracza [NETWORK_PACKET_LOSS_CRITICAL]% - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Utrata pakietów przekracza [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% - </floater.string> - <floater.string name="network_performance_normal_msg"> - W normie - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Fatalny ping - [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Wolny ping - [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Złe połączenie lub przepustowość. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Złe połączenie lub aplikacja współdzieląca pliki. - </floater.string> - <floater.string name="server_text_msg"> - Serwer - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Ilość klatek na sekundę poniżej [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Ilość klatek na sekundę pomiędzy [SERVER_FRAME_RATE_CRITICAL] i [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - W normie - </floater.string> - <floater.string name="server_physics_cause_msg"> - Przyczyna: za dużo obiektów fizycznych - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Przyczyna: za dużo obieków skryptowanych - </floater.string> - <floater.string name="server_net_cause_msg"> - Przyczyna: za duży ruch w sieci - </floater.string> - <floater.string name="server_agent_cause_msg"> - Przyczyna: za dużo poruszających się awatarów w regionie - </floater.string> - <floater.string name="server_images_cause_msg"> - Przyczyna: za dużo kalkulacji obrazu - </floater.string> - <floater.string name="server_generic_cause_msg"> - Przyczyna: symulator ładuje się zbyt powoli - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button label="" label_selected="" name="client_lagmeter" tool_tip="Status lagów klienta"/> - <text name="client"> - Klient - </text> - <text name="client_text"> - W normie - </text> - <button label="" label_selected="" name="network_lagmeter" tool_tip="Network lag status"/> - <text name="network"> - Sieć - </text> - <text name="network_text"> - W normie - </text> - <button label="" label_selected="" name="server_lagmeter" tool_tip="Server lag status"/> - <text name="server"> - Serwer - </text> - <text name="server_text"> - W normie - </text> - <button label=">>" name="minimize" tool_tip="Złącz rozmiar pliku xml"/> -</floater> diff --git a/indra/newview/skins/default/xui/pt/floater_lagmeter.xml b/indra/newview/skins/default/xui/pt/floater_lagmeter.xml deleted file mode 100644 index 9932318293..0000000000 --- a/indra/newview/skins/default/xui/pt/floater_lagmeter.xml +++ /dev/null @@ -1,154 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="LAG - Índice"> - <floater.string name="max_title_msg"> - Medidor de Atraso - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Atraso - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Cliente - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, janela por baixo - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Taxa de quadros do Cliente abaixo de [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Taxa de quadros do Cliente entre [CLIENT_FRAME_RATE_CRITICAL] e [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Causa possível: Distância de desenho ajustada muito alta - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Causa possível: Carregamento de Imagens - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Causa possível: Muitas imagens na memória - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Causa possível: Muitos objetos complexos na cena - </floater.string> - <floater.string name="network_text_msg"> - Rede - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Conexão está caindo para cerca de [NETWORK_PACKET_LOSS_CRITICAL]% de pacotes - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Conexão está caindo [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% de pacotes - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Tempo de conexão de ping é cerca de [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Tempo de conexão de ping é [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Possível conexão ruim ou 'Largura de Banda' escolhida muito alta. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Possível conexão ruim ou aplicativos compartilhando arquivos. - </floater.string> - <floater.string name="server_text_msg"> - Servidor - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Taxa de quadros abaixo de [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Taxa de quadros entre [SERVER_FRAME_RATE_CRITICAL] e [SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Causa possível: Muitos objetos físicos - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Causa possível: Muitos objetos com scripts - </floater.string> - <floater.string name="server_net_cause_msg"> - Causa possível: Muito tráfego na rede - </floater.string> - <floater.string name="server_agent_cause_msg"> - Causa possível: Muitas pessoas se movendo na região - </floater.string> - <floater.string name="server_images_cause_msg"> - Causa possível: Muitos cálculos de imagem - </floater.string> - <floater.string name="server_generic_cause_msg"> - Causa possível: Carga no simulador muito pesada - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button label="" label_selected="" name="client_lagmeter" tool_tip="Status de atraso no Cliente"/> - <text name="client"> - Cliente - </text> - <text font="SansSerifSmall" name="client_text"> - Normal - </text> - <text left="30" name="client_lag_cause" right="-10"/> - <button label="" label_selected="" name="network_lagmeter" tool_tip="Status de atraso na rede"/> - <text name="network"> - Rede - </text> - <text font="SansSerifSmall" name="network_text"> - Normal - </text> - <text left="30" name="network_lag_cause" right="-10"/> - <button label="" label_selected="" name="server_lagmeter" tool_tip="Status de atraso no servidor"/> - <text name="server"> - Servidor - </text> - <text font="SansSerifSmall" name="server_text"> - Normal - </text> - <text left="30" name="server_lag_cause" right="-32"/> - <button label=">>" name="minimize" tool_tip="Alternar o tamanho da janela"/> -</floater> diff --git a/indra/newview/skins/default/xui/ru/floater_lagmeter.xml b/indra/newview/skins/default/xui/ru/floater_lagmeter.xml deleted file mode 100644 index c420006a03..0000000000 --- a/indra/newview/skins/default/xui/ru/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="УРОВЕНЬ ЛАГОВ"> - <floater.string name="max_title_msg"> - Уровень лагов - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Лаг - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - Клиент - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Нормально, окно в фоне - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Частота кадров клиента ниже [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Частота кадров клиента от [CLIENT_FRAME_RATE_CRITICAL] до [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Нормально - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Возможная причина: дальность отрисовки слишком велика - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Возможная причина: загрузка изображений - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Возможная причина: слишком много изображений в памяти - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Возможная причина: слишком много сложных объектов в сцене - </floater.string> - <floater.string name="network_text_msg"> - Сеть - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Сеть теряет более [NETWORK_PACKET_LOSS_CRITICAL]% пакетов - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Сеть теряет [NETWORK_PACKET_LOSS_WARNING]–[NETWORK_PACKET_LOSS_CRITICAL]% пакетов - </floater.string> - <floater.string name="network_performance_normal_msg"> - Нормально - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Пинг соединения более [NETWORK_PING_CRITICAL] мс - </floater.string> - <floater.string name="network_ping_warning_msg"> - Пинг соединения [NETWORK_PING_WARNING]–[NETWORK_PING_CRITICAL] мс - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Возможно, плохое соединение, или параметр «Ширина канала» слишком велик. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Возможно, плохое соединение или есть работающие файлообменные программы. - </floater.string> - <floater.string name="server_text_msg"> - Сервер - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Частота кадров сервера ниже [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Частота кадров сервера [SERVER_FRAME_RATE_CRITICAL]–[SERVER_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Нормально - </floater.string> - <floater.string name="server_physics_cause_msg"> - Возможная причина: слишком много физических объектов - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Возможная причина: слишком много скриптовых объектов - </floater.string> - <floater.string name="server_net_cause_msg"> - Возможная причина: слишком большой сетевой трафик - </floater.string> - <floater.string name="server_agent_cause_msg"> - Возможная причина: слишком много людей в регионе - </floater.string> - <floater.string name="server_images_cause_msg"> - Возможная причина: слишком много изображений - </floater.string> - <floater.string name="server_generic_cause_msg"> - Возможная причина: сервер сильно загружен - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="Уровень лагов клиента"/> - <text name="client"> - Клиент - </text> - <text name="client_text"> - Нормально - </text> - <button name="network_lagmeter" tool_tip="Уровень лагов сети"/> - <text name="network"> - Сеть - </text> - <text name="network_text"> - Нормально - </text> - <button name="server_lagmeter" tool_tip="Уровень лагов сервера"/> - <text name="server"> - Сервер - </text> - <text name="server_text"> - Нормально - </text> - <button label=">>" name="minimize" tool_tip="Переключение размера"/> -</floater> diff --git a/indra/newview/skins/default/xui/tr/floater_lagmeter.xml b/indra/newview/skins/default/xui/tr/floater_lagmeter.xml deleted file mode 100644 index 736c50be90..0000000000 --- a/indra/newview/skins/default/xui/tr/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="GECİKME ÖLÇER"> - <floater.string name="max_title_msg"> - Gecikme Ölçer - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Gecikme - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - İstemci - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, pencere alt zeminde - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - İstemci kare hızı [CLIENT_FRAME_RATE_CRITICAL] altında - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - İstemci kare hızı [CLIENT_FRAME_RATE_CRITICAL] ile [CLIENT_FRAME_RATE_WARNING] arasınad - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Muhtemel neden: Çizme mesafesi çok yüksek - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Muhtemel neden: Görüntüler yükleniyor - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Muhtemel neden: Bellekte çok fazla görüntü - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Muhtemel neden: Sahnede çok fazla karmaşık nesne - </floater.string> - <floater.string name="network_text_msg"> - Ağ - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Bağlantı paketlerin % [NETWORK_PACKET_LOSS_CRITICAL]'sinden fazlasını bırakıyor - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Bağlantı paketlerin % [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]'sini bırakıyor - </floater.string> - <floater.string name="network_performance_normal_msg"> - Normal - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Bağlantı ping süresi [NETWORK_PING_CRITICAL] ms.den fazla - </floater.string> - <floater.string name="network_ping_warning_msg"> - Bağlantı ping süresi [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Muhtemel yetersiz bağlantı veya 'Bant Genişliği' tercihi çok yüksek. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Muhtemel yetersiz bağlantı veya dosya paylaşım uygulaması. - </floater.string> - <floater.string name="server_text_msg"> - Sunucu - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - Simülatör kare hızı [SERVER_FRAME_RATE_CRITICAL] altında - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - Simülatör kare hızı [SERVER_FRAME_RATE_CRITICAL] ve [SERVER_FRAME_RATE_WARNING] arasında - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - Normal - </floater.string> - <floater.string name="server_physics_cause_msg"> - Muhtemel Neden: Çok fazla fiziki nesne - </floater.string> - <floater.string name="server_scripts_cause_msg"> - Muhtemel Neden: Çok fazla komut dosyalı nesne - </floater.string> - <floater.string name="server_net_cause_msg"> - Muhtemel Neden: Çok fazla ağ trafiği - </floater.string> - <floater.string name="server_agent_cause_msg"> - Muhtemel Neden: Bölgede hareket eden çok fazla insan var - </floater.string> - <floater.string name="server_images_cause_msg"> - Muhtemel Neden: Çok fazla görüntü hesabı - </floater.string> - <floater.string name="server_generic_cause_msg"> - Muhtemel Neden: Simülatör yükü çok ağır - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="İstemci gecikme durumu"/> - <text name="client"> - İstemci - </text> - <text name="client_text"> - Normal - </text> - <button name="network_lagmeter" tool_tip="Ağ gecikme durumu"/> - <text name="network"> - Ağ - </text> - <text name="network_text"> - Normal - </text> - <button name="server_lagmeter" tool_tip="Sunucu gecikme durumu"/> - <text name="server"> - Sunucu - </text> - <text name="server_text"> - Normal - </text> - <button label=">>" name="minimize" tool_tip="Gezdirici büyüklüğünü değiştir"/> -</floater> diff --git a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml b/indra/newview/skins/default/xui/zh/floater_lagmeter.xml deleted file mode 100644 index 6e58e7332f..0000000000 --- a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="LAG 測量器"> - <floater.string name="max_title_msg"> - Lag 測量器 - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - Lag - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - 客戶端 - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - Normal, window in background - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - Client frame rate below [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - Client frame rate between [CLIENT_FRAME_RATE_CRITICAL] and [CLIENT_FRAME_RATE_WARNING] - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - 正常 - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - Possible cause: Draw distance set too high - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - Possible cause: Images loading - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - Possible cause: Too many images in memory - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - Possible cause: Too many complex objects in scene - </floater.string> - <floater.string name="network_text_msg"> - 網路 - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - Connection is dropping over [NETWORK_PACKET_LOSS_CRITICAL]% of packets - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - Connection is dropping [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% of packets - </floater.string> - <floater.string name="network_performance_normal_msg"> - 正常 - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - Connection ping time is over [NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_ping_warning_msg"> - Connection ping time is [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - Possible bad connection or 'Bandwidth' pref too high. - </floater.string> - <floater.string name="network_ping_cause_msg"> - Possible bad connection or file-sharing app. - </floater.string> - <floater.string name="server_text_msg"> - 伺服器 - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - 模擬器 framerate 低於 [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - 模擬器 framerate 介於 [SERVER_FRAME_RATE_CRITICAL] 與 [SERVER_FRAME_RATE_WARNING] 之間 - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - 正常 - </floater.string> - <floater.string name="server_physics_cause_msg"> - 可能原因:太多物理物件 - </floater.string> - <floater.string name="server_scripts_cause_msg"> - 可能原因:太多腳本物件 - </floater.string> - <floater.string name="server_net_cause_msg"> - 可能原因:太多網路流量 - </floater.string> - <floater.string name="server_agent_cause_msg"> - 可能原因:地區有太多移動的人 - </floater.string> - <floater.string name="server_images_cause_msg"> - 可能原因:太多圖像計算 - </floater.string> - <floater.string name="server_generic_cause_msg"> - 可能原因:模擬器負載過重 - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="客戶端 lag 狀態"/> - <text name="client"> - 客戶端 - </text> - <text name="client_text"> - 正常 - </text> - <button name="network_lagmeter" tool_tip="網路 lag 狀態"/> - <text name="network"> - 網路 - </text> - <text name="network_text"> - 正常 - </text> - <button name="server_lagmeter" tool_tip="伺服器 lag 狀態"/> - <text name="server"> - 伺服器 - </text> - <text name="server_text"> - 正常 - </text> - <button label=">>" name="minimize" tool_tip="切換浮動視窗尺寸"/> -</floater> -- cgit v1.2.3 From d1481a599fa8bd65f505e0bd9dec33370a3c68c8 Mon Sep 17 00:00:00 2001 From: MaksymS ProductEngine <msavchenko@productengine.com> Date: Fri, 31 Aug 2012 00:38:16 +0300 Subject: MAINT-1486 FIXED Crash on login (Unhandled exception) --- indra/llcommon/llfasttimer.cpp | 39 ++++++++++++++++++++++++++++-------- indra/llcommon/llfasttimer.h | 1 + indra/newview/llappviewer.cpp | 8 ++++++++ indra/newview/llflexibleobject.cpp | 2 +- indra/newview/llspatialpartition.cpp | 2 +- indra/newview/llviewerdisplay.cpp | 2 +- indra/newview/llvowlsky.cpp | 2 +- 7 files changed, 44 insertions(+), 12 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index ff6806082c..670c90351e 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -128,13 +128,6 @@ public: LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state) { - timer_map_t::iterator found_it = mTimers.find(name); - if (found_it != mTimers.end()) - { - llerrs << "Duplicate timer declaration for: " << name << llendl; - return *found_it->second; - } - LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); timer->setFrameState(state); timer->setParent(mTimerRoot); @@ -155,7 +148,7 @@ public: LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; } - typedef std::map<std::string, LLFastTimer::NamedTimer*> timer_map_t; + typedef std::multimap<std::string, LLFastTimer::NamedTimer*> timer_map_t; timer_map_t::iterator beginTimers() { return mTimers.begin(); } timer_map_t::iterator endTimers() { return mTimers.end(); } S32 timerCount() { return mTimers.size(); } @@ -646,6 +639,36 @@ const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& na return NamedTimerFactory::instance().getTimerByName(name); } +//static +bool LLFastTimer::checkForDuplicates(std::string& duplicates) +{ + typedef NamedTimerFactory::timer_map_t::iterator timer_iterator; + + bool duplicateFound = false; + NamedTimerFactory& namedFactory = NamedTimerFactory::instance(); + + if (namedFactory.timerCount() > 1) + { + timer_iterator endPosition = namedFactory.endTimers(); + timer_iterator ti = namedFactory.beginTimers(); + std::string prevKey = ti->first; + + for (ti++; ti != endPosition; ti++) + { + const std::string& curKey = ti->first; + if (0 == curKey.compare(prevKey)) + { + if (duplicateFound) duplicates += ", "; + duplicates += curKey; + duplicateFound = true; + } + prevKey = curKey; + } + } + + return duplicateFound; +} + LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) : mFrameState(state) { diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..b0d3ea5d60 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -224,6 +224,7 @@ public: static void writeLog(std::ostream& os); static const NamedTimer* getTimerByName(const std::string& name); + static bool checkForDuplicates(std::string& duplicates); struct CurTimerData { diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index bf01627bad..78151510d5 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -703,6 +703,14 @@ bool LLAppViewer::init() LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ; + std::string duplicates; + if(LLFastTimer::checkForDuplicates(duplicates)) + { + LL_WARNS("InitInfo") << "There are duplicates created by LLFastTimer::DeclareTimer with names: '" + << duplicates << "'" << LL_ENDL; + return false; + } + //set the max heap size. initMaxHeapSize() ; diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 22c265cb8a..a37e27363f 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -48,7 +48,7 @@ std::vector<LLVolumeImplFlexible*> LLVolumeImplFlexible::sInstanceList; std::vector<S32> LLVolumeImplFlexible::sUpdateDelay; static LLFastTimer::DeclareTimer FTM_FLEXIBLE_REBUILD("Rebuild"); -static LLFastTimer::DeclareTimer FTM_DO_FLEXIBLE_UPDATE("Update"); +static LLFastTimer::DeclareTimer FTM_DO_FLEXIBLE_UPDATE("Flexible Update"); // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 30f796a78e..5083478392 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -55,7 +55,7 @@ #include "llviewershadermgr.h" static LLFastTimer::DeclareTimer FTM_FRUSTUM_CULL("Frustum Culling"); -static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); +static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound Partition"); const F32 SG_OCCLUSION_FUDGE = 0.25f; #define SG_DISCARD_TOLERANCE 0.01f diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 705edc27f6..ffeea2f4df 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -217,7 +217,7 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_SKY("Update Sky"); static LLFastTimer::DeclareTimer FTM_UPDATE_TEXTURES("Update Textures"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE("Update Images"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_CLASS("Class"); -static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Bump"); +static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Image Update Bump"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List"); static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_DELETE("Delete"); static LLFastTimer::DeclareTimer FTM_RESIZE_WINDOW("Resize Window"); diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index a33f42cf84..7f17fd3e56 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -301,7 +301,7 @@ void LLVOWLSky::restoreGL() gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE); } -static LLFastTimer::DeclareTimer FTM_GEO_SKY("Sky Geometry"); +static LLFastTimer::DeclareTimer FTM_GEO_SKY("Windlight Sky Geometry"); BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) { -- cgit v1.2.3 From 64201b21b3d02f98969981723ef5426cdbfc16be Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 30 Aug 2012 16:46:37 -0700 Subject: MAINT-1486 FIX Crash on login (Unhandled exception) allow duplicate named fast timers again, refactored timer code --- indra/llcommon/llfasttimer.cpp | 34 +++++++++++++++++++--------------- indra/llcommon/llfasttimer.h | 10 +++++----- indra/newview/llfasttimerview.cpp | 4 ++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index ff6806082c..b233b18f45 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -113,10 +113,9 @@ public: /*virtual */ void initSingleton() { mTimerRoot = new LLFastTimer::NamedTimer("root"); - mRootFrameState.setNamedTimer(mTimerRoot); - mTimerRoot->setFrameState(&mRootFrameState); + mRootFrameState = &mTimerRoot->getFrameState(); mTimerRoot->mParent = mTimerRoot; - mRootFrameState.mParent = &mRootFrameState; + mRootFrameState->mParent = mRootFrameState; } ~NamedTimerFactory() @@ -126,17 +125,15 @@ public: delete mTimerRoot; } - LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state) + LLFastTimer::NamedTimer& createNamedTimer(const std::string& name) { timer_map_t::iterator found_it = mTimers.find(name); if (found_it != mTimers.end()) { - llerrs << "Duplicate timer declaration for: " << name << llendl; return *found_it->second; } LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); - timer->setFrameState(state); timer->setParent(mTimerRoot); mTimers.insert(std::make_pair(name, timer)); @@ -163,19 +160,21 @@ public: private: timer_map_t mTimers; - LLFastTimer::NamedTimer* mTimerRoot; - LLFastTimer::FrameState mRootFrameState; + LLFastTimer::NamedTimer* mTimerRoot; + LLFastTimer::FrameState* mRootFrameState; }; LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open ) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) +: mTimer(NamedTimerFactory::instance().createNamedTimer(name)) { + mFrameState = &mTimer.getFrameState(); mTimer.setCollapsed(!open); } LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) +: mTimer(NamedTimerFactory::instance().createNamedTimer(name)) { + mFrameState = &mTimer.getFrameState(); } //static @@ -225,13 +224,13 @@ LLFastTimer::NamedTimer::NamedTimer(const std::string& name) mTotalTimeCounter(0), mCountAverage(0), mCallAverage(0), - mNeedsSorting(false), - mFrameState(NULL) + mNeedsSorting(false) { mCountHistory = new U32[HISTORY_NUM]; memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM); mCallHistory = new U32[HISTORY_NUM]; memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); + mFrameState.setNamedTimer(this); } LLFastTimer::NamedTimer::~NamedTimer() @@ -291,7 +290,7 @@ S32 LLFastTimer::NamedTimer::getDepth() { S32 depth = 0; NamedTimer* timerp = mParent; - while(timerp) + while(timerp && timerp->mParent != timerp) { depth++; timerp = timerp->mParent; @@ -546,9 +545,14 @@ U32 LLFastTimer::NamedTimer::getHistoricalCalls(S32 history_index ) const return mCallHistory[history_idx]; } -LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const +const LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const { - return *mFrameState; + return mFrameState; +} + +LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() +{ + return mFrameState; } std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::beginChildren() diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..07af0f1d4d 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -91,8 +91,8 @@ public: U32 getHistoricalCount(S32 history_index = 0) const; U32 getHistoricalCalls(S32 history_index = 0) const; - void setFrameState(FrameState* state) { mFrameState = state; state->setNamedTimer(this); } - FrameState& getFrameState() const; + const FrameState& getFrameState() const; + FrameState& getFrameState(); private: friend class LLFastTimer; @@ -116,7 +116,7 @@ public: // // members // - FrameState* mFrameState; + FrameState mFrameState; std::string mName; @@ -147,7 +147,7 @@ public: NamedTimer& getNamedTimer() { return mTimer; } private: - FrameState mFrameState; + FrameState* mFrameState; NamedTimer& mTimer; }; @@ -155,7 +155,7 @@ public: LLFastTimer(LLFastTimer::FrameState* state); LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - : mFrameState(&timer.mFrameState) + : mFrameState(timer.mFrameState) { #if FAST_TIMER_ON LLFastTimer::FrameState* frame_state = mFrameState; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 59bf70f488..fd92f8ac18 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -511,7 +511,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); LLFastTimer::NamedTimer* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) + while(!is_child_of_hover_item && next_parent && next_parent != next_parent->getParent()) { is_child_of_hover_item = (mHoverID == next_parent); next_parent = next_parent->getParent(); @@ -778,7 +778,7 @@ void LLFastTimerView::draw() BOOL is_child_of_hover_item = (idp == mHoverID); LLFastTimer::NamedTimer* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) + while(!is_child_of_hover_item && next_parent && next_parent != next_parent->getParent()) { is_child_of_hover_item = (mHoverID == next_parent); next_parent = next_parent->getParent(); -- cgit v1.2.3 From 9e031934461c72fb97eecd4f074e1fe6d43fc1c0 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 30 Aug 2012 16:49:25 -0700 Subject: MAINT-1486 FIX Crash on login (Unhandled exception) removed checkforDuplicates since we support duplicates again --- indra/newview/llappviewer.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 78151510d5..bf01627bad 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -703,14 +703,6 @@ bool LLAppViewer::init() LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ; - std::string duplicates; - if(LLFastTimer::checkForDuplicates(duplicates)) - { - LL_WARNS("InitInfo") << "There are duplicates created by LLFastTimer::DeclareTimer with names: '" - << duplicates << "'" << LL_ENDL; - return false; - } - //set the max heap size. initMaxHeapSize() ; -- cgit v1.2.3 From afc2807302f2a94b5cbb0fe86f304984ac7e50b8 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 30 Aug 2012 18:35:29 -0700 Subject: MAINT-1486 FIX Crash on login (Unhandled exception) cleaner implementation of llfasttimers...don't bother to share similarly named timers just create multiple timers with same name...doesn't break anything --- indra/llcommon/llfasttimer.cpp | 10 ++-------- indra/llcommon/llfasttimer.h | 1 + indra/newview/llfasttimerview.cpp | 2 ++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index ff6806082c..d54e1a93ea 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -128,13 +128,6 @@ public: LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state) { - timer_map_t::iterator found_it = mTimers.find(name); - if (found_it != mTimers.end()) - { - llerrs << "Duplicate timer declaration for: " << name << llendl; - return *found_it->second; - } - LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); timer->setFrameState(state); timer->setParent(mTimerRoot); @@ -155,7 +148,7 @@ public: LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; } - typedef std::map<std::string, LLFastTimer::NamedTimer*> timer_map_t; + typedef std::multimap<std::string, LLFastTimer::NamedTimer*> timer_map_t; timer_map_t::iterator beginTimers() { return mTimers.begin(); } timer_map_t::iterator endTimers() { return mTimers.end(); } S32 timerCount() { return mTimers.size(); } @@ -294,6 +287,7 @@ S32 LLFastTimer::NamedTimer::getDepth() while(timerp) { depth++; + if (timerp->getParent() == timerp) break; timerp = timerp->mParent; } return depth; diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..b3f7304664 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -145,6 +145,7 @@ public: DeclareTimer(const std::string& name); NamedTimer& getNamedTimer() { return mTimer; } + const NamedTimer& getNamedTimer() const { return mTimer; } private: FrameState mFrameState; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 59bf70f488..4dfb93f1bc 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -514,6 +514,7 @@ void LLFastTimerView::draw() while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; next_parent = next_parent->getParent(); } @@ -781,6 +782,7 @@ void LLFastTimerView::draw() while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; next_parent = next_parent->getParent(); } -- cgit v1.2.3 From d48889198b9f5b39c195e237ae253339b2d89ef3 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 30 Aug 2012 19:23:17 -0700 Subject: MAINT-1486 FIX Crash on login (Unhandled exception) open root timer by default --- indra/llcommon/llfasttimer.cpp | 1 + indra/newview/llappviewer.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index d54e1a93ea..6970c29092 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -116,6 +116,7 @@ public: mRootFrameState.setNamedTimer(mTimerRoot); mTimerRoot->setFrameState(&mRootFrameState); mTimerRoot->mParent = mTimerRoot; + mTimerRoot->setCollapsed(false); mRootFrameState.mParent = &mRootFrameState; } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index bf01627bad..a8763aae0c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1178,7 +1178,7 @@ static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback"); static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot"); static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update"); -LLFastTimer::DeclareTimer FTM_FRAME("Frame"); +LLFastTimer::DeclareTimer FTM_FRAME("Frame", true); bool LLAppViewer::mainLoop() { -- cgit v1.2.3 From 62fcbb063a191fa4789145c3937e7bef6ce544bd Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 5 Sep 2012 18:49:28 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages first pass at LLTrace framework --- indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/llfasttimer.cpp | 12 +-- indra/llcommon/llfasttimer.h | 9 ++- indra/llcommon/lltrace.h | 169 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+), 9 deletions(-) create mode 100644 indra/llcommon/lltrace.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 87fffec0c3..05477c5fa6 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -238,6 +238,7 @@ set(llcommon_HEADER_FILES llthread.h llthreadsafequeue.h lltimer.h + lltrace.h lltreeiterators.h lltypeinfolookup.h lluri.h diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 6970c29092..939e332c3b 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -216,7 +216,7 @@ LLFastTimer::NamedTimer::NamedTimer(const std::string& name) : mName(name), mCollapsed(true), mParent(NULL), - mTotalTimeCounter(0), + mTreeTimeCounter(0), mCountAverage(0), mCallAverage(0), mNeedsSorting(false), @@ -389,6 +389,8 @@ void LLFastTimer::NamedTimer::accumulateTimings() U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; cur_timer->mFrameState->mSelfTimeCounter += self_time_delta; + cur_timer->mFrameState->mTotalTimeCounter += cumulative_time_delta; + cur_timer->mStartTime = cur_time; cur_data = &cur_timer->mLastTimerData; @@ -403,10 +405,10 @@ void LLFastTimer::NamedTimer::accumulateTimings() ++it) { NamedTimer* timerp = (*it); - timerp->mTotalTimeCounter = timerp->getFrameState().mSelfTimeCounter; + timerp->mTreeTimeCounter = timerp->getFrameState().mSelfTimeCounter; for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) { - timerp->mTotalTimeCounter += (*child_it)->mTotalTimeCounter; + timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; } S32 cur_frame = sCurFrameIndex; @@ -415,8 +417,8 @@ void LLFastTimer::NamedTimer::accumulateTimings() // update timer history int hidx = cur_frame % HISTORY_NUM; - timerp->mCountHistory[hidx] = timerp->mTotalTimeCounter; - timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTotalTimeCounter) / (cur_frame+1); + timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; + timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); timerp->mCallHistory[hidx] = timerp->getFrameState().mCalls; timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->getFrameState().mCalls) / (cur_frame+1); } diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e42e549df5..061a37ae31 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -45,18 +45,17 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: - class NamedTimer; - struct LL_COMMON_API FrameState { FrameState(); void setNamedTimer(NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; + U32 mTotalTimeCounter; U32 mCalls; FrameState* mParent; // info for caller timer FrameState* mLastCaller; // used to bootstrap tree construction - NamedTimer* mTimer; + class NamedTimer* mTimer; U16 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame }; @@ -120,7 +119,8 @@ public: std::string mName; - U32 mTotalTimeCounter; + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; U32 mCountAverage; U32 mCallAverage; @@ -186,6 +186,7 @@ public: U32 total_time = getCPUClockCount32() - mStartTime; frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + frame_state->mTotalTimeCounter += total_time; frame_state->mActiveCount--; // store last caller to bootstrap tree creation diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h new file mode 100644 index 0000000000..3d3ee18100 --- /dev/null +++ b/indra/llcommon/lltrace.h @@ -0,0 +1,169 @@ +/** + * @file lltrace.h + * @brief Runtime statistics accumulation. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTRACE_H +#define LL_LLTRACE_H + +namespace LLTrace +{ + class Stat + { + public: + Stat(const char* name) + : mName(name) + {} + void record() {} + void record(int value) {} + void record(float value) {} + private: + const std::string mName; + }; + + class BlockTimer + { + public: + BlockTimer(const char* name) + : mName(name) + {} + + struct Accumulator + { + U32 mSelfTimeCounter; + U32 mTotalTimeCounter; + U32 mCalls; + Accumulator* mParent; // info for caller timer + Accumulator* mLastCaller; // used to bootstrap tree construction + const BlockTimer* mTimer; // points to block timer associated with this storage + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + std::vector<Accumulator*> mChildren; // currently assumed child timers + }; + + struct RecorderHead + { + struct Recorder* mRecorder; + Accumulator* mAccumulator; + U32 mChildTime; + }; + + struct Recorder + { + LL_FORCE_INLINE Recorder(BlockTimer& block_timer) + : mLastHead(sRecorderHead) + { + mStartTime = getCPUClockCount32(); + Accumulator* accumulator = ???; // get per-thread accumulator + accumulator->mActiveCount++; + accumulator->mCalls++; + accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); + + // push new timer on stack + sRecorderHead->mRecorder = this; + sRecorderHead->mAccumulator = accumulator; + sRecorderHead->mChildTime = 0; + } + + LL_FORCE_INLINE ~Recorder() + { + U32 total_time = getCPUClockCount32() - mStartTime; + + Accumulator* accumulator = sRecorderHead->mAccumulator; + accumulator->mSelfTimeCounter += total_time- sRecorderHead.mChildTime; + accumulator->mTotalTimeCounter += total_time; + accumulator->mActiveCount--; + + accumulator->mLastCaller = mLastHead->mAccumulator; + mLastHead->mChildTime += total_time; + + // pop stack + sRecorderHead = mLastHead; + } + + AccumulatorHead mLastHead; + U32 mStartTime; + }; + + private: + U32 getCPUClockCount32() + { + U32 ret_val; + __asm + { + _emit 0x0f + _emit 0x31 + shr eax,8 + shl edx,24 + or eax, edx + mov dword ptr [ret_val], eax + } + return ret_val; + } + + // return full timer value, *not* shifted by 8 bits + static U64 getCPUClockCount64() + { + U64 ret_val; + __asm + { + _emit 0x0f + _emit 0x31 + mov eax,eax + mov edx,edx + mov dword ptr [ret_val+4], edx + mov dword ptr [ret_val], eax + } + return ret_val; + } + + const std::string mName; + static RecorderHead* sRecorderHead; + }; + + BlockTimer::RecorderHead BlockTimer::sRecorderHead; + + class TimeInterval + { + public: + void start() {} + void stop() {} + void resume() {} + }; + + class SamplingTimeInterval + { + public: + void start() {} + void stop() {} + void resume() {} + }; + +} + +#define TOKEN_PASTE_ACTUAL(x, y) x##y +#define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) +#define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); + +#endif // LL_LLTRACE_H -- cgit v1.2.3 From 6814906fec95aeb90dbc99605f74f241a72af12b Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 5 Sep 2012 18:54:26 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages build fix --- indra/llcommon/llfasttimer.cpp | 26 +++++++++++++------------- indra/llcommon/llfasttimer.h | 12 ++++++------ indra/llcommon/lltrace.h | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 939e332c3b..0abaf73063 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -388,8 +388,8 @@ void LLFastTimer::NamedTimer::accumulateTimings() U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; - cur_timer->mFrameState->mSelfTimeCounter += self_time_delta; - cur_timer->mFrameState->mTotalTimeCounter += cumulative_time_delta; + cur_data->mFrameState->mSelfTimeCounter += self_time_delta; + cur_data->mFrameState->mTotalTimeCounter += cumulative_time_delta; cur_timer->mStartTime = cur_time; @@ -643,16 +643,16 @@ const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& na return NamedTimerFactory::instance().getTimerByName(name); } -LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) -: mFrameState(state) -{ - U32 start_time = getCPUClockCount32(); - mStartTime = start_time; - mFrameState->mActiveCount++; - LLFastTimer::sCurTimerData.mCurTimer = this; - LLFastTimer::sCurTimerData.mFrameState = mFrameState; - LLFastTimer::sCurTimerData.mChildTime = 0; - mLastTimerData = LLFastTimer::sCurTimerData; -} +//LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) +//: mFrameState(state) +//{ +// U32 start_time = getCPUClockCount32(); +// mStartTime = start_time; +// mFrameState->mActiveCount++; +// LLFastTimer::sCurTimerData.mCurTimer = this; +// LLFastTimer::sCurTimerData.mFrameState = mFrameState; +// LLFastTimer::sCurTimerData.mChildTime = 0; +// mLastTimerData = LLFastTimer::sCurTimerData; +//} diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 061a37ae31..4660fad5e3 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -45,10 +45,12 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: + class NamedTimer; + struct LL_COMMON_API FrameState { FrameState(); - void setNamedTimer(NamedTimer* timerp) { mTimer = timerp; } + void setNamedTimer(class NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; U32 mTotalTimeCounter; @@ -152,13 +154,12 @@ public: }; public: - LLFastTimer(LLFastTimer::FrameState* state); + //LLFastTimer(LLFastTimer::FrameState* state); LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - : mFrameState(&timer.mFrameState) { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; + LLFastTimer::FrameState* frame_state = &timer.mFrameState; mStartTime = getCPUClockCount32(); frame_state->mActiveCount++; @@ -182,7 +183,7 @@ public: LL_FORCE_INLINE ~LLFastTimer() { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = mFrameState; + LLFastTimer::FrameState* frame_state = LLFastTimer::sCurTimerData.mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; @@ -380,7 +381,6 @@ private: static U64 sLastFrameTime; U32 mStartTime; - LLFastTimer::FrameState* mFrameState; LLFastTimer::CurTimerData mLastTimerData; }; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3d3ee18100..6323091cb8 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -81,16 +81,16 @@ namespace LLTrace accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); // push new timer on stack - sRecorderHead->mRecorder = this; - sRecorderHead->mAccumulator = accumulator; - sRecorderHead->mChildTime = 0; + sRecorderHead.mRecorder = this; + sRecorderHead.mAccumulator = accumulator; + sRecorderHead.mChildTime = 0; } LL_FORCE_INLINE ~Recorder() { U32 total_time = getCPUClockCount32() - mStartTime; - Accumulator* accumulator = sRecorderHead->mAccumulator; + Accumulator* accumulator = sRecorderHead.mAccumulator; accumulator->mSelfTimeCounter += total_time- sRecorderHead.mChildTime; accumulator->mTotalTimeCounter += total_time; accumulator->mActiveCount--; -- cgit v1.2.3 From 2cdfb170216c798c637081b0e28ec8921f0b777b Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 5 Sep 2012 19:04:53 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages renamed some variables in lltrace --- indra/llcommon/lltrace.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 6323091cb8..f3ee90a721 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -51,18 +51,18 @@ namespace LLTrace struct Accumulator { - U32 mSelfTimeCounter; U32 mTotalTimeCounter; + U32 mChildTimeCounter; U32 mCalls; Accumulator* mParent; // info for caller timer Accumulator* mLastCaller; // used to bootstrap tree construction const BlockTimer* mTimer; // points to block timer associated with this storage - U16 mActiveCount; // number of timers with this ID active on stack + U8 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame std::vector<Accumulator*> mChildren; // currently assumed child timers }; - struct RecorderHead + struct RecorderStackEntry { struct Recorder* mRecorder; Accumulator* mAccumulator; @@ -72,7 +72,7 @@ namespace LLTrace struct Recorder { LL_FORCE_INLINE Recorder(BlockTimer& block_timer) - : mLastHead(sRecorderHead) + : mLastRecorder(sCurRecorder) { mStartTime = getCPUClockCount32(); Accumulator* accumulator = ???; // get per-thread accumulator @@ -81,28 +81,28 @@ namespace LLTrace accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); // push new timer on stack - sRecorderHead.mRecorder = this; - sRecorderHead.mAccumulator = accumulator; - sRecorderHead.mChildTime = 0; + sCurRecorder.mRecorder = this; + sCurRecorder.mAccumulator = accumulator; + sCurRecorder.mChildTime = 0; } LL_FORCE_INLINE ~Recorder() { U32 total_time = getCPUClockCount32() - mStartTime; - Accumulator* accumulator = sRecorderHead.mAccumulator; - accumulator->mSelfTimeCounter += total_time- sRecorderHead.mChildTime; + Accumulator* accumulator = sCurRecorder.mAccumulator; accumulator->mTotalTimeCounter += total_time; + accumulator->mChildTimeCounter += sCurRecorder.mChildTime; accumulator->mActiveCount--; - accumulator->mLastCaller = mLastHead->mAccumulator; - mLastHead->mChildTime += total_time; + accumulator->mLastCaller = mLastRecorder->mAccumulator; + mLastRecorder->mChildTime += total_time; // pop stack - sRecorderHead = mLastHead; + sCurRecorder = mLastRecorder; } - AccumulatorHead mLastHead; + RecorderStackEntry mLastRecorder; U32 mStartTime; }; @@ -139,10 +139,10 @@ namespace LLTrace } const std::string mName; - static RecorderHead* sRecorderHead; + static RecorderStackEntry* sCurRecorder; }; - BlockTimer::RecorderHead BlockTimer::sRecorderHead; + BlockTimer::RecorderStackEntry BlockTimer::sCurRecorder; class TimeInterval { -- cgit v1.2.3 From 3254f9fb5f44426494208927c464d2f1447f812a Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 11:52:11 -0700 Subject: removed unused file --- .../skins/default/xui/zh/floater_lagmeter.xml | 151 --------------------- 1 file changed, 151 deletions(-) delete mode 100644 indra/newview/skins/default/xui/zh/floater_lagmeter.xml diff --git a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml b/indra/newview/skins/default/xui/zh/floater_lagmeter.xml deleted file mode 100644 index e9a082288a..0000000000 --- a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<floater name="floater_lagmeter" title="LAG 測量器"> - <floater.string name="max_title_msg"> - Lag 測量器 - </floater.string> - <floater.string name="max_width_px"> - 360 - </floater.string> - <floater.string name="min_title_msg"> - 延遲 - </floater.string> - <floater.string name="min_width_px"> - 90 - </floater.string> - <floater.string name="client_text_msg"> - 客戶端 - </floater.string> - <floater.string name="client_frame_rate_critical_fps"> - 10 - </floater.string> - <floater.string name="client_frame_rate_warning_fps"> - 15 - </floater.string> - <floater.string name="client_frame_time_window_bg_msg"> - 正常,視窗位於背景 - </floater.string> - <floater.string name="client_frame_time_critical_msg"> - 客戶端幀率低於 [CLIENT_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="client_frame_time_warning_msg"> - 客戶端幀率介於 [CLIENT_FRAME_RATE_CRITICAL] 和 [CLIENT_FRAME_RATE_WARNING] 之間 - </floater.string> - <floater.string name="client_frame_time_normal_msg"> - 正常 - </floater.string> - <floater.string name="client_draw_distance_cause_msg"> - 可能原因:可視距離設得太遠 - </floater.string> - <floater.string name="client_texture_loading_cause_msg"> - 可能原因:正在載入圖像 - </floater.string> - <floater.string name="client_texture_memory_cause_msg"> - 可能原因:記憶體裡圖像太多 - </floater.string> - <floater.string name="client_complex_objects_cause_msg"> - 可能原因:場景內複雜物件太多 - </floater.string> - <floater.string name="network_text_msg"> - 網路 - </floater.string> - <floater.string name="network_packet_loss_critical_pct"> - 10 - </floater.string> - <floater.string name="network_packet_loss_warning_pct"> - 5 - </floater.string> - <floater.string name="network_packet_loss_critical_msg"> - 這次連通丟失了至少 [NETWORK_PACKET_LOSS_CRITICAL]% 的封包 - </floater.string> - <floater.string name="network_packet_loss_warning_msg"> - 這次連通丟失了 [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% 的封包 - </floater.string> - <floater.string name="network_performance_normal_msg"> - 正常 - </floater.string> - <floater.string name="network_ping_critical_ms"> - 600 - </floater.string> - <floater.string name="network_ping_warning_ms"> - 300 - </floater.string> - <floater.string name="network_ping_critical_msg"> - 探測連通回應時間超過 [NETWORK_PING_CRITICAL] 毫秒 - </floater.string> - <floater.string name="network_ping_warning_msg"> - 探測連通回應時間為 [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] 毫秒 - </floater.string> - <floater.string name="network_packet_loss_cause_msg"> - 可能連通不良,或所設的偏好連通頻寬過高。 - </floater.string> - <floater.string name="network_ping_cause_msg"> - 可能連通不良,或使用檔案分享應用程式。 - </floater.string> - <floater.string name="server_text_msg"> - 伺服器 - </floater.string> - <floater.string name="server_frame_rate_critical_fps"> - 20 - </floater.string> - <floater.string name="server_frame_rate_warning_fps"> - 30 - </floater.string> - <floater.string name="server_single_process_max_time_ms"> - 20 - </floater.string> - <floater.string name="server_frame_time_critical_msg"> - 模擬器 framerate 低於 [SERVER_FRAME_RATE_CRITICAL] - </floater.string> - <floater.string name="server_frame_time_warning_msg"> - 模擬器 framerate 介於 [SERVER_FRAME_RATE_CRITICAL] 與 [SERVER_FRAME_RATE_WARNING] 之間 - </floater.string> - <floater.string name="server_frame_time_normal_msg"> - 正常 - </floater.string> - <floater.string name="server_physics_cause_msg"> - 可能原因:太多物理物件 - </floater.string> - <floater.string name="server_scripts_cause_msg"> - 可能原因:太多腳本物件 - </floater.string> - <floater.string name="server_net_cause_msg"> - 可能原因:太多網路流量 - </floater.string> - <floater.string name="server_agent_cause_msg"> - 可能原因:地區有太多移動的人 - </floater.string> - <floater.string name="server_images_cause_msg"> - 可能原因:太多圖像計算 - </floater.string> - <floater.string name="server_generic_cause_msg"> - 可能原因:模擬器負載過重 - </floater.string> - <floater.string name="smaller_label"> - >> - </floater.string> - <floater.string name="bigger_label"> - << - </floater.string> - <button name="client_lagmeter" tool_tip="客戶端 lag 狀態"/> - <text name="client"> - 客戶端 - </text> - <text name="client_text"> - 正常 - </text> - <button name="network_lagmeter" tool_tip="網路 lag 狀態"/> - <text name="network"> - 網路 - </text> - <text name="network_text"> - 正常 - </text> - <button name="server_lagmeter" tool_tip="伺服器 lag 狀態"/> - <text name="server"> - 伺服器 - </text> - <text name="server_text"> - 正常 - </text> - <button label=">>" name="minimize" tool_tip="切換浮動視窗尺寸"/> -</floater> -- cgit v1.2.3 From 456a9a44d8bb039c21a9c125686778972077121d Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 14:11:42 -0700 Subject: fixed build --- indra/newview/lltexturefetch.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 216a022774..e7538d685d 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3427,18 +3427,20 @@ void LLTextureFetchDebugger::tryToStopDebug() } if(update(0.005f)) - { - //unlock the fetcher - mFetcher->lockFetcher(false); + { + //unlock the fetcher + mFetcher->lockFetcher(false); mFetcher->resetLoadSource(); - mFreezeHistory = FALSE; + mFreezeHistory = FALSE; mStopDebug = FALSE; if(mClearHistory) { mFetchingHistory.clear(); init(); - mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset + mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset + } + } } //called in the main thread and when the fetching queue is empty -- cgit v1.2.3 From 0027ee8a7ddc47da656fb542ea4a97c00ca2683b Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 14:38:23 -0700 Subject: another build fix --- indra/newview/llvoavatarself.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index ed84e8103d..fd892db3d3 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2138,7 +2138,7 @@ LLSD LLVOAvatarSelf::metricsData() result["timers"]["ruth"] = mRuthTimer.getElapsedTimeF32(); result["timers"]["invisible"] = mInvisibleTimer.getElapsedTimeF32(); result["timers"]["fully_loaded"] = mFullyLoadedTimer.getElapsedTimeF32(); - result["startup"] = LLStartUp::getPhases().dumpPhases(); + result["startup"] = LLStartUp::getPhases().asLLSD(); return result; } -- cgit v1.2.3 From d18a3f395fb2b29dbf83092896a5ed5eb9f75f16 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 17:18:12 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages lltrace cleanup --- indra/llcommon/lltrace.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index f3ee90a721..1d2dcff9b7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -27,6 +27,8 @@ #ifndef LL_LLTRACE_H #define LL_LLTRACE_H +#include <vector> + namespace LLTrace { class Stat @@ -51,11 +53,11 @@ namespace LLTrace struct Accumulator { - U32 mTotalTimeCounter; - U32 mChildTimeCounter; - U32 mCalls; - Accumulator* mParent; // info for caller timer - Accumulator* mLastCaller; // used to bootstrap tree construction + U32 mTotalTimeCounter, + mChildTimeCounter, + mCalls; + Accumulator* mParent, // info for caller timer + mLastCaller; // used to bootstrap tree construction const BlockTimer* mTimer; // points to block timer associated with this storage U8 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame -- cgit v1.2.3 From 21a7b6ea93e71a6b9e1e8bfa734b69931d7d5bfc Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 22:57:12 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages further development of lltrace --- indra/llcommon/lltrace.h | 102 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 12 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1d2dcff9b7..2c907c32ee 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -27,28 +27,107 @@ #ifndef LL_LLTRACE_H #define LL_LLTRACE_H +#include "stdtypes.h" + #include <vector> +#include <boost/type_traits/alignment_of.hpp> namespace LLTrace { - class Stat + //TODO figure out best way to do this and proper naming convention + + static + void init() + { + + } + + template<typename T> + class Accumulator { public: - Stat(const char* name) - : mName(name) + Accumulator() + : mSum(), + mMin(), + mMax(), + mNumSamples(0) + {} + + void sample(T value) + { + mNumSamples++; + mSum += value; + if (value < mMin) + { + mMin = value; + } + else if (value > mMax) + { + mMax = value; + } + } + + private: + T mSum, + mMin, + mMax; + + U32 mNumSamples; + }; + + class TraceStorage + { + protected: + TraceStorage(const size_t size, const size_t alignment) + { + mRecordOffset = sNextOffset + (alignment - 1); + mRecordOffset -= mRecordOffset % alignment; + sNextOffset = mRecordOffset + size; + sStorage.reserve((size_t)sNextOffset); + } + + // this needs to be thread local + static std::vector<U8> sStorage; + static ptrdiff_t sNextOffset; + + ptrdiff_t mRecordOffset; + }; + + std::vector<U8> TraceStorage::sStorage; + ptrdiff_t TraceStorage::sNextOffset = 0; + + template<typename T> + class Trace : public TraceStorage + { + public: + Trace(const std::string& name) + : TraceStorage(sizeof(Accumulator<T>), boost::alignment_of<Accumulator<T> >::value), + mName(name) {} - void record() {} - void record(int value) {} - void record(float value) {} + + void record(T value) + { + (reinterpret_cast<Accumulator<T>* >(sStorage + mRecordOffset))->sample(value); + } + private: - const std::string mName; + std::string mName; + }; + + template<typename T> + class Stat : public Trace<T> + { + public: + Stat(const char* name) + : Trace(name) + {} }; - class BlockTimer + class BlockTimer : public Trace<U32> { public: BlockTimer(const char* name) - : mName(name) + : Trace(name) {} struct Accumulator @@ -56,8 +135,8 @@ namespace LLTrace U32 mTotalTimeCounter, mChildTimeCounter, mCalls; - Accumulator* mParent, // info for caller timer - mLastCaller; // used to bootstrap tree construction + Accumulator* mParent; // info for caller timer + Accumulator* mLastCaller; // used to bootstrap tree construction const BlockTimer* mTimer; // points to block timer associated with this storage U8 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame @@ -140,7 +219,6 @@ namespace LLTrace return ret_val; } - const std::string mName; static RecorderStackEntry* sCurRecorder; }; -- cgit v1.2.3 From 8d4ceab6a34d58c5f4235baa870eb88d86df30f3 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Sep 2012 23:00:32 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages further development of lltrace (accumulator and storage classes) --- indra/llcommon/lltrace.h | 111 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 16 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1d2dcff9b7..c6940c12a2 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -27,28 +27,108 @@ #ifndef LL_LLTRACE_H #define LL_LLTRACE_H +#include "stdtypes.h" +#include "llpreprocessor.h" + #include <vector> +#include <boost/type_traits/alignment_of.hpp> namespace LLTrace { - class Stat + //TODO figure out best way to do this and proper naming convention + + static + void init() + { + + } + + template<typename T> + class Accumulator { public: - Stat(const char* name) - : mName(name) + Accumulator() + : mSum(), + mMin(), + mMax(), + mNumSamples(0) + {} + + void sample(T value) + { + mNumSamples++; + mSum += value; + if (value < mMin) + { + mMin = value; + } + else if (value > mMax) + { + mMax = value; + } + } + + private: + T mSum, + mMin, + mMax; + + U32 mNumSamples; + }; + + class TraceStorage + { + protected: + TraceStorage(const size_t size, const size_t alignment) + { + mRecordOffset = sNextOffset + (alignment - 1); + mRecordOffset -= mRecordOffset % alignment; + sNextOffset = mRecordOffset + size; + sStorage.reserve((size_t)sNextOffset); + } + + // this needs to be thread local + static std::vector<U8> sStorage; + static ptrdiff_t sNextOffset; + + ptrdiff_t mRecordOffset; + }; + + std::vector<U8> TraceStorage::sStorage; + ptrdiff_t TraceStorage::sNextOffset = 0; + + template<typename T> + class Trace : public TraceStorage + { + public: + Trace(const std::string& name) + : TraceStorage(sizeof(Accumulator<T>), boost::alignment_of<Accumulator<T> >::value), + mName(name) {} - void record() {} - void record(int value) {} - void record(float value) {} + + void record(T value) + { + (reinterpret_cast<Accumulator<T>* >(sStorage + mRecordOffset))->sample(value); + } + private: - const std::string mName; + std::string mName; + }; + + template<typename T> + class Stat : public Trace<T> + { + public: + Stat(const char* name) + : Trace(name) + {} }; - class BlockTimer + class BlockTimer : public Trace<U32> { public: BlockTimer(const char* name) - : mName(name) + : Trace(name) {} struct Accumulator @@ -56,8 +136,8 @@ namespace LLTrace U32 mTotalTimeCounter, mChildTimeCounter, mCalls; - Accumulator* mParent, // info for caller timer - mLastCaller; // used to bootstrap tree construction + Accumulator* mParent; // info for caller timer + Accumulator* mLastCaller; // used to bootstrap tree construction const BlockTimer* mTimer; // points to block timer associated with this storage U8 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame @@ -97,8 +177,8 @@ namespace LLTrace accumulator->mChildTimeCounter += sCurRecorder.mChildTime; accumulator->mActiveCount--; - accumulator->mLastCaller = mLastRecorder->mAccumulator; - mLastRecorder->mChildTime += total_time; + accumulator->mLastCaller = mLastRecorder.mAccumulator; + mLastRecorder.mChildTime += total_time; // pop stack sCurRecorder = mLastRecorder; @@ -109,7 +189,7 @@ namespace LLTrace }; private: - U32 getCPUClockCount32() + static U32 getCPUClockCount32() { U32 ret_val; __asm @@ -140,8 +220,7 @@ namespace LLTrace return ret_val; } - const std::string mName; - static RecorderStackEntry* sCurRecorder; + static RecorderStackEntry sCurRecorder; }; BlockTimer::RecorderStackEntry BlockTimer::sCurRecorder; -- cgit v1.2.3 From a8c0d23bdeb009f6797f1dfa727e8c0cf4f6bc96 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 7 Sep 2012 18:51:38 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages created buffer type for storing trace data added merging logic for different trace types --- indra/llcommon/lltrace.h | 156 +++++++++++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 66 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index c6940c12a2..c5bde0330a 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -37,24 +37,57 @@ namespace LLTrace { //TODO figure out best way to do this and proper naming convention - static - void init() + static void init() { } + template<typename ACCUMULATOR> + class Trace + { + public: + Trace(const std::string& name) + : mName(name) + { + mStorageIndex = sNextIndex++; + sStorage.reserve(sNextIndex); + } + + LL_FORCE_INLINE ACCUMULATOR& getAccumulator() + { + return sStorage[mStorageIndex]; + } + + void mergeFrom(const Trace<ACCUMULATOR>& other) + { + getAccumulator().mergeFrom(other.getAccumulator()); + } + + + private: + std::string mName; + ptrdiff_t mStorageIndex; + + // this needs to be thread local + static std::vector<ACCUMULATOR> sStorage; + static size_t sNextIndex; + }; + + template<typename ACCUMULATOR> std::vector<ACCUMULATOR> Trace<ACCUMULATOR>::sStorage; + template<typename ACCUMULATOR> size_t Trace<ACCUMULATOR>::sNextIndex = 0; + template<typename T> class Accumulator { public: Accumulator() - : mSum(), + : mSum(), mMin(), mMax(), mNumSamples(0) {} - void sample(T value) + LL_FORCE_INLINE void sample(T value) { mNumSamples++; mSum += value; @@ -68,6 +101,20 @@ namespace LLTrace } } + void mergeFrom(const Accumulator<T>& other) + { + mSum += other.mSum; + if (other.mMin < mMin) + { + mMin = other.mMin; + } + if (other.mMax > mMax) + { + mMax = other.mMax; + } + mNumSamples += other.mNumSamples; + } + private: T mSum, mMin, @@ -76,78 +123,55 @@ namespace LLTrace U32 mNumSamples; }; - class TraceStorage - { - protected: - TraceStorage(const size_t size, const size_t alignment) - { - mRecordOffset = sNextOffset + (alignment - 1); - mRecordOffset -= mRecordOffset % alignment; - sNextOffset = mRecordOffset + size; - sStorage.reserve((size_t)sNextOffset); - } - - // this needs to be thread local - static std::vector<U8> sStorage; - static ptrdiff_t sNextOffset; - - ptrdiff_t mRecordOffset; - }; - - std::vector<U8> TraceStorage::sStorage; - ptrdiff_t TraceStorage::sNextOffset = 0; template<typename T> - class Trace : public TraceStorage + class Stat : public Trace<Accumulator<T> > { public: - Trace(const std::string& name) - : TraceStorage(sizeof(Accumulator<T>), boost::alignment_of<Accumulator<T> >::value), - mName(name) + Stat(const char* name) + : Trace(name) {} - void record(T value) + void sample(T value) { - (reinterpret_cast<Accumulator<T>* >(sStorage + mRecordOffset))->sample(value); + getAccumulator().sample(value); } - private: - std::string mName; }; - template<typename T> - class Stat : public Trace<T> + struct TimerAccumulator { - public: - Stat(const char* name) - : Trace(name) - {} + U32 mTotalTimeCounter, + mChildTimeCounter, + mCalls; + TimerAccumulator* mParent; // info for caller timer + TimerAccumulator* mLastCaller; // used to bootstrap tree construction + const BlockTimer* mTimer; // points to block timer associated with this storage + U8 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + std::vector<TimerAccumulator*> mChildren; // currently assumed child timers + + void mergeFrom(const TimerAccumulator& other) + { + mTotalTimeCounter += other.mTotalTimeCounter; + mChildTimeCounter += other.mChildTimeCounter; + mCalls += other.mCalls; + } }; - class BlockTimer : public Trace<U32> + class BlockTimer : public Trace<TimerAccumulator> { public: BlockTimer(const char* name) : Trace(name) {} - struct Accumulator - { - U32 mTotalTimeCounter, - mChildTimeCounter, - mCalls; - Accumulator* mParent; // info for caller timer - Accumulator* mLastCaller; // used to bootstrap tree construction - const BlockTimer* mTimer; // points to block timer associated with this storage - U8 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - std::vector<Accumulator*> mChildren; // currently assumed child timers - }; + struct Recorder; struct RecorderStackEntry { - struct Recorder* mRecorder; - Accumulator* mAccumulator; + Recorder* mRecorder; + TimerAccumulator* mAccumulator; U32 mChildTime; }; @@ -157,7 +181,7 @@ namespace LLTrace : mLastRecorder(sCurRecorder) { mStartTime = getCPUClockCount32(); - Accumulator* accumulator = ???; // get per-thread accumulator + TimerAccumulator* accumulator = &block_timer.getAccumulator(); // get per-thread accumulator accumulator->mActiveCount++; accumulator->mCalls++; accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); @@ -172,7 +196,7 @@ namespace LLTrace { U32 total_time = getCPUClockCount32() - mStartTime; - Accumulator* accumulator = sCurRecorder.mAccumulator; + TimerAccumulator* accumulator = sCurRecorder.mAccumulator; accumulator->mTotalTimeCounter += total_time; accumulator->mChildTimeCounter += sCurRecorder.mChildTime; accumulator->mActiveCount--; @@ -195,11 +219,11 @@ namespace LLTrace __asm { _emit 0x0f - _emit 0x31 - shr eax,8 - shl edx,24 - or eax, edx - mov dword ptr [ret_val], eax + _emit 0x31 + shr eax,8 + shl edx,24 + or eax, edx + mov dword ptr [ret_val], eax } return ret_val; } @@ -211,11 +235,11 @@ namespace LLTrace __asm { _emit 0x0f - _emit 0x31 - mov eax,eax - mov edx,edx - mov dword ptr [ret_val+4], edx - mov dword ptr [ret_val], eax + _emit 0x31 + mov eax,eax + mov edx,edx + mov dword ptr [ret_val+4], edx + mov dword ptr [ret_val], eax } return ret_val; } @@ -233,7 +257,7 @@ namespace LLTrace void resume() {} }; - class SamplingTimeInterval + class Sampler { public: void start() {} -- cgit v1.2.3 From fa91ea69cca32e0dabcfabe18070f57cc4a4cfd0 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 7 Sep 2012 19:12:41 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added buffer merging and copying --- indra/llcommon/lltrace.h | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index c5bde0330a..6272492945 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -31,7 +31,6 @@ #include "llpreprocessor.h" #include <vector> -#include <boost/type_traits/alignment_of.hpp> namespace LLTrace { @@ -42,6 +41,35 @@ namespace LLTrace } + template<typename ACCUMULATOR> + struct AccumulatorStorage + { + std::vector<ACCUMULATOR> mStorage; + + ACCUMULATOR& operator[](size_t index) { return mStorage[index]; } + + void mergeFrom(const AccumulatorStorage<ACCUMULATOR>& other) + { + llassert(mStorage.size() == other.mStorage.size()); + + for (size_t i = 0; i < mStorage.size(); i++) + { + mStorage[i].mergeFrom(other.mStorage[i]); + } + } + + void copyFrom(const AccumulatorStorage<Accumulator>& other) + { + mStorage = other.mStorage; + } + + void resize(size_t size) + { + //TODO: get this grow more rapidly (as if with push back) + mStorage.reserve(size); + } + }; + template<typename ACCUMULATOR> class Trace { @@ -50,7 +78,7 @@ namespace LLTrace : mName(name) { mStorageIndex = sNextIndex++; - sStorage.reserve(sNextIndex); + sStorage.resize(sNextIndex); } LL_FORCE_INLINE ACCUMULATOR& getAccumulator() @@ -69,8 +97,8 @@ namespace LLTrace ptrdiff_t mStorageIndex; // this needs to be thread local - static std::vector<ACCUMULATOR> sStorage; - static size_t sNextIndex; + static AccumulatorStorage<ACCUMULATOR> sStorage; + static size_t sNextIndex; }; template<typename ACCUMULATOR> std::vector<ACCUMULATOR> Trace<ACCUMULATOR>::sStorage; @@ -81,7 +109,7 @@ namespace LLTrace { public: Accumulator() - : mSum(), + : mSum(), mMin(), mMax(), mNumSamples(0) -- cgit v1.2.3 From 917ed449daec0e0f91e2ff66a7d9b82866ed8b1e Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 14 Sep 2012 00:04:38 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added multi-threaded sampling to LLTrace first pass at data aggregation --- indra/llcommon/lltrace.h | 305 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 256 insertions(+), 49 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 6272492945..1b9a8db1c0 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -30,45 +30,90 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include <vector> +#include "llthread.h" + +#include <list> namespace LLTrace { //TODO figure out best way to do this and proper naming convention - static void init() { } + // one per thread per type template<typename ACCUMULATOR> - struct AccumulatorStorage + struct AccumulatorBuffer : public AccumulatorBufferBase { - std::vector<ACCUMULATOR> mStorage; + ACCUMULATOR* mStorage; + size_t mStorageSize; + size_t mNextStorageSlot; + static S32 sStorageKey; // key used to access thread local storage pointer to accumulator values - ACCUMULATOR& operator[](size_t index) { return mStorage[index]; } + AccumulatorBuffer() + : mStorageSize(64), + mStorage(new ACCUMULATOR[64]), + mNextStorageSlot(0) + {} + + AccumulatorBuffer(const AccumulatorBuffer& other) + : mStorageSize(other.mStorageSize), + mStorage(new ACCUMULATOR[other.mStorageSize]), + mNextStorageSlot(other.mNextStorageSlot) + { + + } + + LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index) { return (*mStorage)[index]; } - void mergeFrom(const AccumulatorStorage<ACCUMULATOR>& other) + void mergeFrom(const AccumulatorBuffer<ACCUMULATOR>& other) { - llassert(mStorage.size() == other.mStorage.size()); + llassert(mNextStorageSlot == other.mNextStorageSlot); - for (size_t i = 0; i < mStorage.size(); i++) + for (size_t i = 0; i < mNextStorageSlot; i++) { mStorage[i].mergeFrom(other.mStorage[i]); } } - void copyFrom(const AccumulatorStorage<Accumulator>& other) + void copyFrom(const AccumulatorBuffer<Accumulator>& other) + { + for (size_t i = 0; i < mNextStorageSlot; i++) + { + mStorage[i] = other.mStorage[i]; + } + } + + void reset() + { + for (size_t i = 0; i < mNextStorageSlot; i++) + { + mStorage[i].reset(); + } + } + + void makePrimary() { - mStorage = other.mStorage; + //TODO: use sStorageKey to set mStorage as active buffer } - void resize(size_t size) + // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned + size_t reserveSlot() { - //TODO: get this grow more rapidly (as if with push back) - mStorage.reserve(size); + size_t next_slot = mNextStorageSlot++; + if (next_slot >= mStorageSize) + { + size_t new_size = mStorageSize + (mStorageSize >> 2); + delete [] mStorage; + mStorage = new mStorage(new_size); + mStorageSize = new_size; + } + llassert(next_slot < mStorageSize); + return next_slot; } }; + template<typename ACCUMULATOR> S32 AccumulatorBuffer<ACCUMULATOR>::sStorageKey; template<typename ACCUMULATOR> class Trace @@ -77,38 +122,29 @@ namespace LLTrace Trace(const std::string& name) : mName(name) { - mStorageIndex = sNextIndex++; - sStorage.resize(sNextIndex); + mAccumulatorIndex = sAccumulatorBuffer.reserveSlot(); } LL_FORCE_INLINE ACCUMULATOR& getAccumulator() { - return sStorage[mStorageIndex]; - } - - void mergeFrom(const Trace<ACCUMULATOR>& other) - { - getAccumulator().mergeFrom(other.getAccumulator()); + return sAccumulatorBuffer[mAccumulatorIndex]; } - private: - std::string mName; - ptrdiff_t mStorageIndex; + std::string mName; + size_t mAccumulatorIndex; // this needs to be thread local - static AccumulatorStorage<ACCUMULATOR> sStorage; - static size_t sNextIndex; + static AccumulatorBuffer<ACCUMULATOR> sAccumulatorBuffer; }; - template<typename ACCUMULATOR> std::vector<ACCUMULATOR> Trace<ACCUMULATOR>::sStorage; - template<typename ACCUMULATOR> size_t Trace<ACCUMULATOR>::sNextIndex = 0; + template<typename ACCUMULATOR> std::vector<ACCUMULATOR> Trace<ACCUMULATOR>::sAccumulatorBuffer; template<typename T> - class Accumulator + class StatAccumulator { public: - Accumulator() + StatAccumulator() : mSum(), mMin(), mMax(), @@ -129,7 +165,7 @@ namespace LLTrace } } - void mergeFrom(const Accumulator<T>& other) + void mergeFrom(const Stat<T>& other) { mSum += other.mSum; if (other.mMin < mMin) @@ -143,6 +179,14 @@ namespace LLTrace mNumSamples += other.mNumSamples; } + void reset() + { + mNumSamples = 0; + mSum = 0; + mMin = 0; + mMax = 0; + } + private: T mSum, mMin, @@ -151,12 +195,11 @@ namespace LLTrace U32 mNumSamples; }; - - template<typename T> - class Stat : public Trace<Accumulator<T> > + template <typename T> + class Stat : public Trace<StatAccumulator<T> > { public: - Stat(const char* name) + Stat(const std::string& name) : Trace(name) {} @@ -164,7 +207,6 @@ namespace LLTrace { getAccumulator().sample(value); } - }; struct TimerAccumulator @@ -174,7 +216,7 @@ namespace LLTrace mCalls; TimerAccumulator* mParent; // info for caller timer TimerAccumulator* mLastCaller; // used to bootstrap tree construction - const BlockTimer* mTimer; // points to block timer associated with this storage + const class BlockTimer* mTimer; // points to block timer associated with this storage U8 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame std::vector<TimerAccumulator*> mChildren; // currently assumed child timers @@ -185,6 +227,14 @@ namespace LLTrace mChildTimeCounter += other.mChildTimeCounter; mCalls += other.mCalls; } + + void reset() + { + mTotalTimeCounter = 0; + mChildTimeCounter = 0; + mCalls = 0; + } + }; class BlockTimer : public Trace<TimerAccumulator> @@ -194,17 +244,15 @@ namespace LLTrace : Trace(name) {} - struct Recorder; - - struct RecorderStackEntry - { - Recorder* mRecorder; - TimerAccumulator* mAccumulator; - U32 mChildTime; - }; - struct Recorder { + struct StackEntry + { + Recorder* mRecorder; + TimerAccumulator* mAccumulator; + U32 mChildTime; + }; + LL_FORCE_INLINE Recorder(BlockTimer& block_timer) : mLastRecorder(sCurRecorder) { @@ -236,7 +284,7 @@ namespace LLTrace sCurRecorder = mLastRecorder; } - RecorderStackEntry mLastRecorder; + StackEntry mLastRecorder; U32 mStartTime; }; @@ -272,10 +320,169 @@ namespace LLTrace return ret_val; } - static RecorderStackEntry sCurRecorder; + static Recorder::StackEntry sCurRecorder; + }; + + BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; + + class Sampler + { + public: + Sampler(const Sampler& other) + : mF32Stats(other.mF32Stats), + mS32Stats(other.mS32Stats), + mTimers(other.mTimers) + {} + + ~Sampler() + { + stop(); + } + + void makePrimary() + { + mF32Stats.makePrimary(); + mS32Stats.makePrimary(); + mTimers.makePrimary(); + } + + void start() + { + reset(); + resume(); + } + + void stop() + { + getThreadData()->deactivate(this); + } + + void resume() + { + ThreadData* thread_data = getThreadData(); + thread_data->flushPrimarySampler(); + thread_data->activate(this); + } + + void mergeFrom(const Sampler& other) + { + mF32Stats.mergeFrom(other.mF32Stats); + mS32Stats.mergeFrom(other.mS32Stats); + mTimers.mergeFrom(other.mTimers); + } + + void reset() + { + mF32Stats.reset(); + mS32Stats.reset(); + mTimers.reset(); + } + + private: + // returns data for current thread + struct ThreadData* getThreadData() { return NULL; } + + AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; + AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; + + AccumulatorBuffer<TimerAccumulator> mTimers; + }; + + struct ThreadData + { + ThreadData(LLThread& this_thread, ThreadData& parent_data) + : mPrimarySampler(parent_data.mPrimarySampler), + mSharedSampler(parent_data.mSharedSampler), + mSharedSamplerMutex(this_thread.getAPRPool()), + mParent(parent_data) + { + mPrimarySampler.makePrimary(); + parent_data.addChildThread(this); + } + + ~ThreadData() + { + mParent.removeChildThread(this); + } + + void addChildThread(ThreadData* child) + { + mChildThreadData.push_back(child); + } + + void removeChildThread(ThreadData* child) + { + // TODO: replace with intrusive list + std::list<ThreadData*>::iterator found_it = std::find(mChildThreadData.begin(), mChildThreadData.end(), child); + if (found_it != mChildThreadData.end()) + { + mChildThreadData.erase(found_it); + } + } + + void flushPrimarySampler() + { + for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); + it != end_it; + ++it) + { + (*it)->mergeFrom(mPrimarySampler); + } + mPrimarySampler.reset(); + } + + void activate(Sampler* sampler) + { + mActiveSamplers.push_back(sampler); + } + + void deactivate(Sampler* sampler) + { + // TODO: replace with intrusive list + std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); + if (found_it != mActiveSamplers.end()) + { + mActiveSamplers.erase(found_it); + } + } + + // call this periodically to gather stats data in parent thread + void publishToParent() + { + mSharedSamplerMutex.lock(); + { + mSharedSampler.mergeFrom(mPrimarySampler); + } + mSharedSamplerMutex.unlock(); + } + + // call this periodically to gather stats data from children + void gatherChildData() + { + for (std::list<ThreadData*>::iterator child_it = mChildThreadData.begin(), end_it = mChildThreadData.end(); + child_it != end_it; + ++child_it) + { + (*child_it)->mSharedSamplerMutex.lock(); + { + //TODO for now, just aggregate, later keep track of thread data independently + mPrimarySampler.mergeFrom((*child_it)->mSharedSampler); + } + (*child_it)->mSharedSamplerMutex.unlock(); + } + } + + Sampler mPrimarySampler; + + ThreadData& mParent; + std::list<Sampler*> mActiveSamplers; + std::list<ThreadData*> mChildThreadData; + + // TODO: add unused space here to avoid false sharing? + LLMutex mSharedSamplerMutex; + Sampler mSharedSampler; }; - BlockTimer::RecorderStackEntry BlockTimer::sCurRecorder; class TimeInterval { -- cgit v1.2.3 From d5fce3a8093bb101b7a536f3611d3135167b05c4 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 14 Sep 2012 00:08:20 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages renamed some variables/methods --- indra/llcommon/lltrace.h | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1b9a8db1c0..7da182df1e 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -36,11 +36,6 @@ namespace LLTrace { - //TODO figure out best way to do this and proper naming convention - static void init() - { - - } // one per thread per type template<typename ACCUMULATOR> @@ -354,13 +349,13 @@ namespace LLTrace void stop() { - getThreadData()->deactivate(this); + getThreadTracer()->deactivate(this); } void resume() { - ThreadData* thread_data = getThreadData(); - thread_data->flushPrimarySampler(); + ThreadTracer* thread_data = getThreadTracer(); + thread_data->flushData(); thread_data->activate(this); } @@ -380,7 +375,7 @@ namespace LLTrace private: // returns data for current thread - struct ThreadData* getThreadData() { return NULL; } + struct ThreadTracer* getThreadTracer() { return NULL; } AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; @@ -388,9 +383,9 @@ namespace LLTrace AccumulatorBuffer<TimerAccumulator> mTimers; }; - struct ThreadData + struct ThreadTracer { - ThreadData(LLThread& this_thread, ThreadData& parent_data) + ThreadTracer(LLThread& this_thread, ThreadTracer& parent_data) : mPrimarySampler(parent_data.mPrimarySampler), mSharedSampler(parent_data.mSharedSampler), mSharedSamplerMutex(this_thread.getAPRPool()), @@ -400,27 +395,27 @@ namespace LLTrace parent_data.addChildThread(this); } - ~ThreadData() + ~ThreadTracer() { mParent.removeChildThread(this); } - void addChildThread(ThreadData* child) + void addChildThread(ThreadTracer* child) { - mChildThreadData.push_back(child); + mChildThreadTracers.push_back(child); } - void removeChildThread(ThreadData* child) + void removeChildThread(ThreadTracer* child) { // TODO: replace with intrusive list - std::list<ThreadData*>::iterator found_it = std::find(mChildThreadData.begin(), mChildThreadData.end(), child); - if (found_it != mChildThreadData.end()) + std::list<ThreadTracer*>::iterator found_it = std::find(mChildThreadTracers.begin(), mChildThreadTracers.end(), child); + if (found_it != mChildThreadTracers.end()) { - mChildThreadData.erase(found_it); + mChildThreadTracers.erase(found_it); } } - void flushPrimarySampler() + void flushData() { for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); it != end_it; @@ -459,7 +454,7 @@ namespace LLTrace // call this periodically to gather stats data from children void gatherChildData() { - for (std::list<ThreadData*>::iterator child_it = mChildThreadData.begin(), end_it = mChildThreadData.end(); + for (std::list<ThreadTracer*>::iterator child_it = mChildThreadTracers.begin(), end_it = mChildThreadTracers.end(); child_it != end_it; ++child_it) { @@ -474,9 +469,9 @@ namespace LLTrace Sampler mPrimarySampler; - ThreadData& mParent; - std::list<Sampler*> mActiveSamplers; - std::list<ThreadData*> mChildThreadData; + ThreadTracer& mParent; + std::list<Sampler*> mActiveSamplers; + std::list<ThreadTracer*> mChildThreadTracers; // TODO: add unused space here to avoid false sharing? LLMutex mSharedSamplerMutex; -- cgit v1.2.3 From 735fde8c742188d019e41faf26ff67aab6a24d25 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 21 Sep 2012 18:52:08 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added LLThreadLocalPtr broke llmutex out into llmutex.h got primary sampling buffer under thread local storage --- indra/llcommon/CMakeLists.txt | 4 + indra/llcommon/llmemory.h | 5 + indra/llcommon/llmutex.cpp | 229 ++++++++++++++++++++++++++++++++ indra/llcommon/llmutex.h | 168 ++++++++++++++++++++++++ indra/llcommon/llthread.cpp | 214 +++--------------------------- indra/llcommon/llthread.h | 171 +++--------------------- indra/llcommon/llthreadlocalptr.h | 141 ++++++++++++++++++++ indra/llcommon/lltrace.cpp | 95 ++++++++++++++ indra/llcommon/lltrace.h | 265 +++++++++++++++++++++----------------- 9 files changed, 826 insertions(+), 466 deletions(-) create mode 100644 indra/llcommon/llmutex.cpp create mode 100644 indra/llcommon/llmutex.h create mode 100644 indra/llcommon/llthreadlocalptr.h create mode 100644 indra/llcommon/lltrace.cpp diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 1812e39b36..eec2695dde 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -74,6 +74,7 @@ set(llcommon_SOURCE_FILES llmetrics.cpp llmetricperformancetester.cpp llmortician.cpp + llmutex.cpp lloptioninterface.cpp llptrto.cpp llprocess.cpp @@ -99,6 +100,7 @@ set(llcommon_SOURCE_FILES llthread.cpp llthreadsafequeue.cpp lltimer.cpp + lltrace.cpp lluri.cpp lluuid.cpp llworkerthread.cpp @@ -197,6 +199,7 @@ set(llcommon_HEADER_FILES llmetrics.h llmetricperformancetester.h llmortician.h + llmutex.h llnametable.h lloptioninterface.h llpointer.h @@ -237,6 +240,7 @@ set(llcommon_HEADER_FILES llstringtable.h llsys.h llthread.h + llthreadlocalptr.h llthreadsafequeue.h lltimer.h lltrace.h diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 6a2323e7d8..4480e381e8 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -30,6 +30,11 @@ class LLMutex ; +#ifdef LL_WINDOWS +#define LL_ALIGNED(x) __declspec(align(x)) +#else +#define LL_ALIGNED(x) __attribute__ ((aligned (16))) +#endif inline void* ll_aligned_malloc( size_t size, int align ) { void* mem = malloc( size + (align - 1) + sizeof(void*) ); diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp new file mode 100644 index 0000000000..2ce14b3a2e --- /dev/null +++ b/indra/llcommon/llmutex.cpp @@ -0,0 +1,229 @@ +/** + * @file llmutex.cpp + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llapr.h" + +#include "apr_portable.h" + +#include "llmutex.h" +#include "llthread.h" + +//============================================================================ + +LLMutex::LLMutex(apr_pool_t *poolp) : + mAPRMutexp(NULL), mCount(0), mLockingThread(NO_THREAD) +{ + //if (poolp) + //{ + // mIsLocalPool = FALSE; + // mAPRPoolp = poolp; + //} + //else + { + mIsLocalPool = TRUE; + apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread + } + apr_thread_mutex_create(&mAPRMutexp, APR_THREAD_MUTEX_UNNESTED, mAPRPoolp); +} + + +LLMutex::~LLMutex() +{ +#if MUTEX_DEBUG + //bad assertion, the subclass LLSignal might be "locked", and that's OK + //llassert_always(!isLocked()); // better not be locked! +#endif + apr_thread_mutex_destroy(mAPRMutexp); + mAPRMutexp = NULL; + if (mIsLocalPool) + { + apr_pool_destroy(mAPRPoolp); + } +} + + +void LLMutex::lock() +{ + if(isSelfLocked()) + { //redundant lock + mCount++; + return; + } + + apr_thread_mutex_lock(mAPRMutexp); + +#if MUTEX_DEBUG + // Have to have the lock before we can access the debug info + U32 id = LLThread::currentID(); + if (mIsLocked[id] != FALSE) + llerrs << "Already locked in Thread: " << id << llendl; + mIsLocked[id] = TRUE; +#endif + +#if LL_DARWIN + mLockingThread = LLThread::currentID(); +#else + mLockingThread = LLThread::sThreadIndex; +#endif +} + +void LLMutex::unlock() +{ + if (mCount > 0) + { //not the root unlock + mCount--; + return; + } + +#if MUTEX_DEBUG + // Access the debug info while we have the lock + U32 id = LLThread::currentID(); + if (mIsLocked[id] != TRUE) + llerrs << "Not locked in Thread: " << id << llendl; + mIsLocked[id] = FALSE; +#endif + + mLockingThread = NO_THREAD; + apr_thread_mutex_unlock(mAPRMutexp); +} + +bool LLMutex::isLocked() +{ + apr_status_t status = apr_thread_mutex_trylock(mAPRMutexp); + if (APR_STATUS_IS_EBUSY(status)) + { + return true; + } + else + { + apr_thread_mutex_unlock(mAPRMutexp); + return false; + } +} + +bool LLMutex::isSelfLocked() +{ +#if LL_DARWIN + return mLockingThread == LLThread::currentID(); +#else + return mLockingThread == LLThread::sThreadIndex; +#endif +} + +U32 LLMutex::lockingThread() const +{ + return mLockingThread; +} + +//============================================================================ + +LLCondition::LLCondition(apr_pool_t *poolp) : + LLMutex(poolp) +{ + // base class (LLMutex) has already ensured that mAPRPoolp is set up. + + apr_thread_cond_create(&mAPRCondp, mAPRPoolp); +} + + +LLCondition::~LLCondition() +{ + apr_thread_cond_destroy(mAPRCondp); + mAPRCondp = NULL; +} + + +void LLCondition::wait() +{ + if (!isLocked()) + { //mAPRMutexp MUST be locked before calling apr_thread_cond_wait + apr_thread_mutex_lock(mAPRMutexp); +#if MUTEX_DEBUG + // avoid asserts on destruction in non-release builds + U32 id = LLThread::currentID(); + mIsLocked[id] = TRUE; +#endif + } + apr_thread_cond_wait(mAPRCondp, mAPRMutexp); +} + +void LLCondition::signal() +{ + apr_thread_cond_signal(mAPRCondp); +} + +void LLCondition::broadcast() +{ + apr_thread_cond_broadcast(mAPRCondp); +} + + +//============================================================================ + +//---------------------------------------------------------------------------- + +//static +LLMutex* LLThreadSafeRefCount::sMutex = 0; + +//static +void LLThreadSafeRefCount::initThreadSafeRefCount() +{ + if (!sMutex) + { + sMutex = new LLMutex(0); + } +} + +//static +void LLThreadSafeRefCount::cleanupThreadSafeRefCount() +{ + delete sMutex; + sMutex = NULL; +} + + +//---------------------------------------------------------------------------- + +LLThreadSafeRefCount::LLThreadSafeRefCount() : +mRef(0) +{ +} + +LLThreadSafeRefCount::~LLThreadSafeRefCount() +{ + if (mRef != 0) + { + llerrs << "deleting non-zero reference" << llendl; + } +} + +//============================================================================ + +LLResponder::~LLResponder() +{ +} + +//============================================================================ diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h new file mode 100644 index 0000000000..bd0a59b577 --- /dev/null +++ b/indra/llcommon/llmutex.h @@ -0,0 +1,168 @@ +/** + * @file llmutex.h + * @brief Base classes for mutex and condition handling. + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLMUTEX_H +#define LL_LLMUTEX_H + +#include "llapr.h" +#include "apr_thread_cond.h" + +//============================================================================ + +#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) + +class LL_COMMON_API LLMutex +{ +public: + typedef enum + { + NO_THREAD = 0xFFFFFFFF + } e_locking_thread; + + LLMutex(apr_pool_t *apr_poolp = NULL); // NULL pool constructs a new pool for the mutex + virtual ~LLMutex(); + + void lock(); // blocks + void unlock(); + bool isLocked(); // non-blocking, but does do a lock/unlock so not free + bool isSelfLocked(); //return true if locked in a same thread + U32 lockingThread() const; //get ID of locking thread + +protected: + apr_thread_mutex_t *mAPRMutexp; + mutable U32 mCount; + mutable U32 mLockingThread; + + apr_pool_t *mAPRPoolp; + BOOL mIsLocalPool; + +#if MUTEX_DEBUG + std::map<U32, BOOL> mIsLocked; +#endif +}; + +// Actually a condition/mutex pair (since each condition needs to be associated with a mutex). +class LL_COMMON_API LLCondition : public LLMutex +{ +public: + LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well. + ~LLCondition(); + + void wait(); // blocks + void signal(); + void broadcast(); + +protected: + apr_thread_cond_t *mAPRCondp; +}; + +class LLMutexLock +{ +public: + LLMutexLock(LLMutex* mutex) + { + mMutex = mutex; + + if(mMutex) + mMutex->lock(); + } + ~LLMutexLock() + { + if(mMutex) + mMutex->unlock(); + } +private: + LLMutex* mMutex; +}; + + +//============================================================================ + +// see llmemory.h for LLPointer<> definition + +class LL_COMMON_API LLThreadSafeRefCount +{ +public: + static void initThreadSafeRefCount(); // creates sMutex + static void cleanupThreadSafeRefCount(); // destroys sMutex + +private: + static LLMutex* sMutex; + +private: + LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented + LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented + +protected: + virtual ~LLThreadSafeRefCount(); // use unref() + +public: + LLThreadSafeRefCount(); + + void ref() + { + if (sMutex) sMutex->lock(); + mRef++; + if (sMutex) sMutex->unlock(); + } + + S32 unref() + { + llassert(mRef >= 1); + if (sMutex) sMutex->lock(); + S32 res = --mRef; + if (sMutex) sMutex->unlock(); + if (0 == res) + { + delete this; + return 0; + } + return res; + } + S32 getNumRefs() const + { + return mRef; + } + +private: + S32 mRef; +}; + + +//============================================================================ + +// Simple responder for self destructing callbacks +// Pure virtual class +class LL_COMMON_API LLResponder : public LLThreadSafeRefCount +{ +protected: + virtual ~LLResponder(); +public: + virtual void completed(bool success) = 0; +}; + + +#endif // LL_LLTHREAD_H diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index a6ad6b125c..f3ab8aa40c 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -29,6 +29,7 @@ #include "apr_portable.h" #include "llthread.h" +#include "llmutex.h" #include "lltimer.h" @@ -56,12 +57,20 @@ // //---------------------------------------------------------------------------- -#if !LL_DARWIN -U32 ll_thread_local sThreadID = 0; -#endif +#if LL_DARWIN +// statically allocated thread local storage not supported in Darwin executable formats +#elif LL_WINDOWS +U32 __declspec(thread) LLThread::sThreadIndex = 0; +#elif LL_LINUX +U32 __thread LLThread::sThreadID = 0; +#endif U32 LLThread::sIDIter = 0; +LLTrace::MasterThreadTrace gMasterThreadTrace; +LLThreadLocalPtr<LLTrace::ThreadTraceData> LLThread::sTraceData(&gMasterThreadTrace); + + LL_COMMON_API void assert_main_thread() { static U32 s_thread_id = LLThread::currentID(); @@ -78,8 +87,10 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; + sTraceData = new LLTrace::SlaveThreadTrace(gMasterThreadTrace); + #if !LL_DARWIN - sThreadID = threadp->mID; + sThreadIndex = threadp->mID; #endif // Run the user supplied function @@ -93,7 +104,6 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap return NULL; } - LLThread::LLThread(const std::string& name, apr_pool_t *poolp) : mPaused(FALSE), mName(name), @@ -301,198 +311,12 @@ void LLThread::wakeLocked() } } -//============================================================================ - -LLMutex::LLMutex(apr_pool_t *poolp) : - mAPRMutexp(NULL), mCount(0), mLockingThread(NO_THREAD) -{ - //if (poolp) - //{ - // mIsLocalPool = FALSE; - // mAPRPoolp = poolp; - //} - //else - { - mIsLocalPool = TRUE; - apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread - } - apr_thread_mutex_create(&mAPRMutexp, APR_THREAD_MUTEX_UNNESTED, mAPRPoolp); -} - - -LLMutex::~LLMutex() -{ -#if MUTEX_DEBUG - //bad assertion, the subclass LLSignal might be "locked", and that's OK - //llassert_always(!isLocked()); // better not be locked! -#endif - apr_thread_mutex_destroy(mAPRMutexp); - mAPRMutexp = NULL; - if (mIsLocalPool) - { - apr_pool_destroy(mAPRPoolp); - } -} - - -void LLMutex::lock() -{ - if(isSelfLocked()) - { //redundant lock - mCount++; - return; - } - - apr_thread_mutex_lock(mAPRMutexp); - -#if MUTEX_DEBUG - // Have to have the lock before we can access the debug info - U32 id = LLThread::currentID(); - if (mIsLocked[id] != FALSE) - llerrs << "Already locked in Thread: " << id << llendl; - mIsLocked[id] = TRUE; -#endif - -#if LL_DARWIN - mLockingThread = LLThread::currentID(); -#else - mLockingThread = sThreadID; -#endif -} - -void LLMutex::unlock() -{ - if (mCount > 0) - { //not the root unlock - mCount--; - return; - } - -#if MUTEX_DEBUG - // Access the debug info while we have the lock - U32 id = LLThread::currentID(); - if (mIsLocked[id] != TRUE) - llerrs << "Not locked in Thread: " << id << llendl; - mIsLocked[id] = FALSE; -#endif - - mLockingThread = NO_THREAD; - apr_thread_mutex_unlock(mAPRMutexp); -} - -bool LLMutex::isLocked() -{ - apr_status_t status = apr_thread_mutex_trylock(mAPRMutexp); - if (APR_STATUS_IS_EBUSY(status)) - { - return true; - } - else - { - apr_thread_mutex_unlock(mAPRMutexp); - return false; - } -} - -bool LLMutex::isSelfLocked() -{ -#if LL_DARWIN - return mLockingThread == LLThread::currentID(); -#else - return mLockingThread == sThreadID; -#endif -} - -U32 LLMutex::lockingThread() const -{ - return mLockingThread; -} - -//============================================================================ - -LLCondition::LLCondition(apr_pool_t *poolp) : - LLMutex(poolp) -{ - // base class (LLMutex) has already ensured that mAPRPoolp is set up. - - apr_thread_cond_create(&mAPRCondp, mAPRPoolp); -} - - -LLCondition::~LLCondition() -{ - apr_thread_cond_destroy(mAPRCondp); - mAPRCondp = NULL; -} - - -void LLCondition::wait() -{ - if (!isLocked()) - { //mAPRMutexp MUST be locked before calling apr_thread_cond_wait - apr_thread_mutex_lock(mAPRMutexp); -#if MUTEX_DEBUG - // avoid asserts on destruction in non-release builds - U32 id = LLThread::currentID(); - mIsLocked[id] = TRUE; -#endif - } - apr_thread_cond_wait(mAPRCondp, mAPRMutexp); -} - -void LLCondition::signal() -{ - apr_thread_cond_signal(mAPRCondp); -} - -void LLCondition::broadcast() -{ - apr_thread_cond_broadcast(mAPRCondp); -} - -//============================================================================ - -//---------------------------------------------------------------------------- - -//static -LLMutex* LLThreadSafeRefCount::sMutex = 0; - -//static -void LLThreadSafeRefCount::initThreadSafeRefCount() -{ - if (!sMutex) - { - sMutex = new LLMutex(0); - } -} - -//static -void LLThreadSafeRefCount::cleanupThreadSafeRefCount() +void LLThread::lockData() { - delete sMutex; - sMutex = NULL; -} - - -//---------------------------------------------------------------------------- - -LLThreadSafeRefCount::LLThreadSafeRefCount() : - mRef(0) -{ -} - -LLThreadSafeRefCount::~LLThreadSafeRefCount() -{ - if (mRef != 0) - { - llerrs << "deleting non-zero reference" << llendl; - } + mRunCondition->lock(); } -//============================================================================ - -LLResponder::~LLResponder() +void LLThread::unlockData() { + mRunCondition->unlock(); } - -//============================================================================ diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index b52e70ab2e..e2de4c8b85 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -30,21 +30,21 @@ #include "llapp.h" #include "llapr.h" #include "apr_thread_cond.h" - -class LLThread; -class LLMutex; -class LLCondition; - -#if LL_WINDOWS -#define ll_thread_local __declspec(thread) -#else -#define ll_thread_local __thread -#endif +#include "lltrace.h" +#include "llthreadlocalptr.h" class LL_COMMON_API LLThread { private: + friend class LLMutex; static U32 sIDIter; +#if LL_DARWIN + // statically allocated thread local storage not supported in Darwin executable formats +#elif LL_WINDOWS + static U32 __declspec(thread) LLThread::sThreadIndex; +#elif LL_LINUX + static U32 __thread LLThread::sThreadID ; +#endif public: typedef enum e_thread_status @@ -88,6 +88,8 @@ public: U32 getID() const { return mID; } + static LLTrace::ThreadTraceData* getTraceData() { return sTraceData.get(); } + private: BOOL mPaused; @@ -96,7 +98,7 @@ private: protected: std::string mName; - LLCondition* mRunCondition; + class LLCondition* mRunCondition; apr_thread_t *mAPRThreadp; apr_pool_t *mAPRPoolp; @@ -104,6 +106,8 @@ protected: EThreadStatus mStatus; U32 mID; + static LLThreadLocalPtr<LLTrace::ThreadTraceData> sTraceData; + //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao @@ -135,149 +139,4 @@ protected: //============================================================================ -#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) - -class LL_COMMON_API LLMutex -{ -public: - typedef enum - { - NO_THREAD = 0xFFFFFFFF - } e_locking_thread; - - LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex - virtual ~LLMutex(); - - void lock(); // blocks - void unlock(); - bool isLocked(); // non-blocking, but does do a lock/unlock so not free - bool isSelfLocked(); //return true if locked in a same thread - U32 lockingThread() const; //get ID of locking thread - -protected: - apr_thread_mutex_t *mAPRMutexp; - mutable U32 mCount; - mutable U32 mLockingThread; - - apr_pool_t *mAPRPoolp; - BOOL mIsLocalPool; - -#if MUTEX_DEBUG - std::map<U32, BOOL> mIsLocked; -#endif -}; - -// Actually a condition/mutex pair (since each condition needs to be associated with a mutex). -class LL_COMMON_API LLCondition : public LLMutex -{ -public: - LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well. - ~LLCondition(); - - void wait(); // blocks - void signal(); - void broadcast(); - -protected: - apr_thread_cond_t *mAPRCondp; -}; - -class LLMutexLock -{ -public: - LLMutexLock(LLMutex* mutex) - { - mMutex = mutex; - - if(mMutex) - mMutex->lock(); - } - ~LLMutexLock() - { - if(mMutex) - mMutex->unlock(); - } -private: - LLMutex* mMutex; -}; - -//============================================================================ - -void LLThread::lockData() -{ - mRunCondition->lock(); -} - -void LLThread::unlockData() -{ - mRunCondition->unlock(); -} - - -//============================================================================ - -// see llmemory.h for LLPointer<> definition - -class LL_COMMON_API LLThreadSafeRefCount -{ -public: - static void initThreadSafeRefCount(); // creates sMutex - static void cleanupThreadSafeRefCount(); // destroys sMutex - -private: - static LLMutex* sMutex; - -private: - LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented - LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - - void ref() - { - if (sMutex) sMutex->lock(); - mRef++; - if (sMutex) sMutex->unlock(); - } - - S32 unref() - { - llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) - { - delete this; - return 0; - } - return res; - } - S32 getNumRefs() const - { - return mRef; - } - -private: - S32 mRef; -}; - -//============================================================================ - -// Simple responder for self destructing callbacks -// Pure virtual class -class LL_COMMON_API LLResponder : public LLThreadSafeRefCount -{ -protected: - virtual ~LLResponder(); -public: - virtual void completed(bool success) = 0; -}; - -//============================================================================ - #endif // LL_LLTHREAD_H diff --git a/indra/llcommon/llthreadlocalptr.h b/indra/llcommon/llthreadlocalptr.h new file mode 100644 index 0000000000..f02f4849ca --- /dev/null +++ b/indra/llcommon/llthreadlocalptr.h @@ -0,0 +1,141 @@ +/** + * @file llthreadlocalptr.h + * @brief manage thread local storage through non-copyable pointer + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTHREAD_LOCAL_PTR_H +#define LL_LLTHREAD_LOCAL_PTR_H + +#include "llapr.h" + +template <typename T> +class LLThreadLocalPtr +{ +public: + LLThreadLocalPtr(T* value = NULL, apr_pool_t* pool = NULL) + { + apr_status_t result = apr_threadkey_private_create(&mThreadKey, cleanup, pool); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to allocate thread local data" << llendl; + } + set(value); + } + + + ~LLThreadLocalPtr() + { + apr_status_t result = apr_threadkey_private_delete(mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to delete thread local data" << llendl; + } + } + + T* operator -> () + { + return get(); + } + + const T* operator -> () const + { + return get(); + } + + T& operator*() + { + return *get(); + } + + const T& operator*() const + { + return *get(); + } + + LLThreadLocalPtr<T>& operator = (T* value) + { + set(value); + return *this; + } + + void copyFrom(const LLThreadLocalPtr<T>& other) + { + set(other.get()); + } + + LL_FORCE_INLINE void set(T* value) + { + apr_status_t result = apr_threadkey_private_set((void*)value, mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to set thread local data" << llendl; + } + } + + LL_FORCE_INLINE T* get() + { + T* ptr; + //apr_status_t result = + apr_threadkey_private_get((void**)&ptr, mThreadKey); + //if (result != APR_SUCCESS) + //{ + // ll_apr_warn_status(s); + // llerrs << "Failed to get thread local data" << llendl; + //} + return ptr; + } + + LL_FORCE_INLINE const T* get() const + { + T* ptr; + //apr_status_t result = + apr_threadkey_private_get((void**)&ptr, mThreadKey); + //if (result != APR_SUCCESS) + //{ + // ll_apr_warn_status(s); + // llerrs << "Failed to get thread local data" << llendl; + //} + return ptr; + } + + +private: + static void cleanup(void* ptr) + { + delete reinterpret_cast<T*>(ptr); + } + + LLThreadLocalPtr(const LLThreadLocalPtr<T>& other) + { + // do not copy construct + llassert(false); + } + + apr_threadkey_t* mThreadKey; +}; + +#endif // LL_LLTHREAD_LOCAL_PTR_H diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp new file mode 100644 index 0000000000..037c52f8c1 --- /dev/null +++ b/indra/llcommon/lltrace.cpp @@ -0,0 +1,95 @@ +/** + * @file lltrace.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltrace.h" +#include "llthread.h" + +namespace LLTrace +{ + +BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; +LLThreadLocalPtr<ThreadTraceData> ThreadTraceData::sCurThreadTrace; + +/////////////////////////////////////////////////////////////////////// +// Sampler +/////////////////////////////////////////////////////////////////////// + +void Sampler::stop() +{ + getThreadTrace()->deactivate(this); +} + +void Sampler::resume() +{ + getThreadTrace()->activate(this); +} + +class ThreadTraceData* Sampler::getThreadTrace() +{ + return LLThread::getTraceData(); +} + +/////////////////////////////////////////////////////////////////////// +// MasterThreadTrace +/////////////////////////////////////////////////////////////////////// + +void MasterThreadTrace::pullFromWorkerThreads() +{ + LLMutexLock lock(&mSlaveListMutex); + + for (worker_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + it != end_it; + ++it) + { + it->mWorkerTrace->mSharedData.copyTo(it->mSamplerStorage); + } +} + +void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) +{ + LLMutexLock lock(&mSlaveListMutex); + + mSlaveThreadTraces.push_back(WorkerThreadTraceProxy(child)); +} + +void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) +{ + LLMutexLock lock(&mSlaveListMutex); + + for (worker_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + it != end_it; + ++it) + { + if (it->mWorkerTrace == child) + { + mSlaveThreadTraces.erase(it); + break; + } + } +} + +} diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 7da182df1e..401ddfd6f3 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -30,25 +30,27 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "llthread.h" +#include "llmutex.h" +#include "llmemory.h" +#include "llthreadlocalptr.h" #include <list> +#define TOKEN_PASTE_ACTUAL(x, y) x##y +#define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) +#define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); + namespace LLTrace { - // one per thread per type template<typename ACCUMULATOR> - struct AccumulatorBuffer : public AccumulatorBufferBase + class AccumulatorBuffer { - ACCUMULATOR* mStorage; - size_t mStorageSize; - size_t mNextStorageSlot; - static S32 sStorageKey; // key used to access thread local storage pointer to accumulator values - + static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; + public: AccumulatorBuffer() : mStorageSize(64), - mStorage(new ACCUMULATOR[64]), + mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE]), mNextStorageSlot(0) {} @@ -56,12 +58,13 @@ namespace LLTrace : mStorageSize(other.mStorageSize), mStorage(new ACCUMULATOR[other.mStorageSize]), mNextStorageSlot(other.mNextStorageSlot) - { + {} + LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index) + { + return mStorage[index]; } - LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index) { return (*mStorage)[index]; } - void mergeFrom(const AccumulatorBuffer<ACCUMULATOR>& other) { llassert(mNextStorageSlot == other.mNextStorageSlot); @@ -72,7 +75,7 @@ namespace LLTrace } } - void copyFrom(const AccumulatorBuffer<Accumulator>& other) + void copyFrom(const AccumulatorBuffer<ACCUMULATOR>& other) { for (size_t i = 0; i < mNextStorageSlot; i++) { @@ -90,7 +93,12 @@ namespace LLTrace void makePrimary() { - //TODO: use sStorageKey to set mStorage as active buffer + sPrimaryStorage = mStorage; + } + + LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage() + { + return sPrimaryStorage.get(); } // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned @@ -101,14 +109,29 @@ namespace LLTrace { size_t new_size = mStorageSize + (mStorageSize >> 2); delete [] mStorage; - mStorage = new mStorage(new_size); + mStorage = new ACCUMULATOR[new_size]; mStorageSize = new_size; } llassert(next_slot < mStorageSize); return next_slot; } + + private: + ACCUMULATOR* mStorage; + size_t mStorageSize; + size_t mNextStorageSlot; + static LLThreadLocalPtr<ACCUMULATOR> sPrimaryStorage; + }; + template<typename ACCUMULATOR> LLThreadLocalPtr<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; + + template<typename ACCUMULATOR> + class PrimaryAccumulatorBuffer : public AccumulatorBuffer<ACCUMULATOR + { + PrimaryAccumulatorBuffer() + { + makePrimary(); + } }; - template<typename ACCUMULATOR> S32 AccumulatorBuffer<ACCUMULATOR>::sStorageKey; template<typename ACCUMULATOR> class Trace @@ -117,32 +140,34 @@ namespace LLTrace Trace(const std::string& name) : mName(name) { - mAccumulatorIndex = sAccumulatorBuffer.reserveSlot(); + mAccumulatorIndex = getPrimaryBuffer().reserveSlot(); } LL_FORCE_INLINE ACCUMULATOR& getAccumulator() { - return sAccumulatorBuffer[mAccumulatorIndex]; + return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; + } + + static PrimaryAccumulatorBuffer& getPrimaryBuffer() + { + static PrimaryAccumulatorBuffer sBuffer; + return sBuffer; } private: std::string mName; size_t mAccumulatorIndex; - - // this needs to be thread local - static AccumulatorBuffer<ACCUMULATOR> sAccumulatorBuffer; }; - template<typename ACCUMULATOR> std::vector<ACCUMULATOR> Trace<ACCUMULATOR>::sAccumulatorBuffer; template<typename T> class StatAccumulator { public: StatAccumulator() - : mSum(), - mMin(), - mMax(), + : mSum(0), + mMin(0), + mMax(0), mNumSamples(0) {} @@ -160,7 +185,7 @@ namespace LLTrace } } - void mergeFrom(const Stat<T>& other) + void mergeFrom(const StatAccumulator<T>& other) { mSum += other.mSum; if (other.mMin < mMin) @@ -318,21 +343,13 @@ namespace LLTrace static Recorder::StackEntry sCurRecorder; }; - BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; - class Sampler { public: - Sampler(const Sampler& other) - : mF32Stats(other.mF32Stats), - mS32Stats(other.mS32Stats), - mTimers(other.mTimers) - {} + Sampler() {} + Sampler(const Sampler& other); - ~Sampler() - { - stop(); - } + ~Sampler(); void makePrimary() { @@ -347,17 +364,8 @@ namespace LLTrace resume(); } - void stop() - { - getThreadTracer()->deactivate(this); - } - - void resume() - { - ThreadTracer* thread_data = getThreadTracer(); - thread_data->flushData(); - thread_data->activate(this); - } + void stop(); + void resume(); void mergeFrom(const Sampler& other) { @@ -375,7 +383,7 @@ namespace LLTrace private: // returns data for current thread - struct ThreadTracer* getThreadTracer() { return NULL; } + class ThreadTraceData* getThreadTrace(); AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; @@ -383,39 +391,39 @@ namespace LLTrace AccumulatorBuffer<TimerAccumulator> mTimers; }; - struct ThreadTracer + class ThreadTraceData { - ThreadTracer(LLThread& this_thread, ThreadTracer& parent_data) - : mPrimarySampler(parent_data.mPrimarySampler), - mSharedSampler(parent_data.mSharedSampler), - mSharedSamplerMutex(this_thread.getAPRPool()), - mParent(parent_data) + public: + ThreadTraceData() { mPrimarySampler.makePrimary(); - parent_data.addChildThread(this); } - ~ThreadTracer() + ThreadTraceData(const ThreadTraceData& other) + : mPrimarySampler(other.mPrimarySampler) { - mParent.removeChildThread(this); + mPrimarySampler.makePrimary(); } - void addChildThread(ThreadTracer* child) + void activate(Sampler* sampler) { - mChildThreadTracers.push_back(child); + flushPrimary(); + mActiveSamplers.push_back(sampler); } - void removeChildThread(ThreadTracer* child) + void deactivate(Sampler* sampler) { + sampler->mergeFrom(mPrimarySampler); + // TODO: replace with intrusive list - std::list<ThreadTracer*>::iterator found_it = std::find(mChildThreadTracers.begin(), mChildThreadTracers.end(), child); - if (found_it != mChildThreadTracers.end()) + std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); + if (found_it != mActiveSamplers.end()) { - mChildThreadTracers.erase(found_it); + mActiveSamplers.erase(found_it); } } - void flushData() + void flushPrimary() { for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); it != end_it; @@ -426,56 +434,96 @@ namespace LLTrace mPrimarySampler.reset(); } - void activate(Sampler* sampler) + Sampler* getPrimarySampler() { return &mPrimarySampler; } + protected: + Sampler mPrimarySampler; + std::list<Sampler*> mActiveSamplers; + static LLThreadLocalPtr<ThreadTraceData> sCurThreadTrace; + }; + + class MasterThreadTrace : public ThreadTraceData + { + public: + MasterThreadTrace() + {} + + void addSlaveThread(class SlaveThreadTrace* child); + void removeSlaveThread(class SlaveThreadTrace* child); + + // call this periodically to gather stats data from worker threads + void pullFromWorkerThreads(); + + private: + struct WorkerThreadTraceProxy { - mActiveSamplers.push_back(sampler); + WorkerThreadTraceProxy(class SlaveThreadTrace* trace) + : mWorkerTrace(trace) + {} + class SlaveThreadTrace* mWorkerTrace; + Sampler mSamplerStorage; + }; + typedef std::list<WorkerThreadTraceProxy> worker_thread_trace_list_t; + + worker_thread_trace_list_t mSlaveThreadTraces; + LLMutex mSlaveListMutex; + }; + + class SlaveThreadTrace : public ThreadTraceData + { + public: + explicit + SlaveThreadTrace(MasterThreadTrace& master_trace) + : mMaster(master_trace), + ThreadTraceData(master_trace), + mSharedData(mPrimarySampler) + { + master_trace.addSlaveThread(this); } - void deactivate(Sampler* sampler) + ~SlaveThreadTrace() { - // TODO: replace with intrusive list - std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); - if (found_it != mActiveSamplers.end()) - { - mActiveSamplers.erase(found_it); - } + mMaster.removeSlaveThread(this); } - - // call this periodically to gather stats data in parent thread - void publishToParent() + + // call this periodically to gather stats data for master thread to consume + void pushToParent() { - mSharedSamplerMutex.lock(); - { - mSharedSampler.mergeFrom(mPrimarySampler); - } - mSharedSamplerMutex.unlock(); + mSharedData.copyFrom(mPrimarySampler); } - // call this periodically to gather stats data from children - void gatherChildData() + MasterThreadTrace& mMaster; + + // this data is accessed by other threads, so give it a 64 byte alignment + // to avoid false sharing on most x86 processors + LL_ALIGNED(64) class SharedData { - for (std::list<ThreadTracer*>::iterator child_it = mChildThreadTracers.begin(), end_it = mChildThreadTracers.end(); - child_it != end_it; - ++child_it) + public: + explicit + SharedData(const Sampler& other_sampler) + : mSampler(other_sampler) + {} + + void copyFrom(Sampler& source) { - (*child_it)->mSharedSamplerMutex.lock(); - { - //TODO for now, just aggregate, later keep track of thread data independently - mPrimarySampler.mergeFrom((*child_it)->mSharedSampler); + LLMutexLock lock(&mSamplerMutex); + { + mSampler.mergeFrom(source); } - (*child_it)->mSharedSamplerMutex.unlock(); } - } - Sampler mPrimarySampler; - - ThreadTracer& mParent; - std::list<Sampler*> mActiveSamplers; - std::list<ThreadTracer*> mChildThreadTracers; - - // TODO: add unused space here to avoid false sharing? - LLMutex mSharedSamplerMutex; - Sampler mSharedSampler; + void copyTo(Sampler& sink) + { + LLMutexLock lock(&mSamplerMutex); + { + sink.mergeFrom(mSampler); + } + } + private: + // add a cache line's worth of unused space to avoid any potential of false sharing + LLMutex mSamplerMutex; + Sampler mSampler; + }; + SharedData mSharedData; }; @@ -486,19 +534,6 @@ namespace LLTrace void stop() {} void resume() {} }; - - class Sampler - { - public: - void start() {} - void stop() {} - void resume() {} - }; - } -#define TOKEN_PASTE_ACTUAL(x, y) x##y -#define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) -#define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); - #endif // LL_LLTRACE_H -- cgit v1.2.3 From adeeabfc13c91dc99a1ea1949cd2f820c4150995 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 24 Sep 2012 18:56:01 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages moved LLThreadLocalPtr to llapr fixed various startup race conditions for LLThreadLocalPtr --- indra/llcommon/CMakeLists.txt | 1 - indra/llcommon/llapr.cpp | 82 ++++++++++++++++++++++ indra/llcommon/llapr.h | 117 +++++++++++++++++++++++++++++++ indra/llcommon/llcommon.cpp | 2 + indra/llcommon/llthread.cpp | 8 +-- indra/llcommon/llthread.h | 1 - indra/llcommon/llthreadlocalptr.h | 141 -------------------------------------- indra/llcommon/lltrace.cpp | 16 ++++- indra/llcommon/lltrace.h | 57 +++++++-------- 9 files changed, 249 insertions(+), 176 deletions(-) delete mode 100644 indra/llcommon/llthreadlocalptr.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index eec2695dde..f78751601c 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -240,7 +240,6 @@ set(llcommon_HEADER_FILES llstringtable.h llsys.h llthread.h - llthreadlocalptr.h llthreadsafequeue.h lltimer.h lltrace.h diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d1c44c9403..76749f8a91 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -54,6 +54,8 @@ void ll_init_apr() { LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE) ; } + + LLThreadLocalPtrBase::initAllThreadLocalStorage(); } @@ -476,6 +478,86 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset) return LLAPRFile::seek(mFile, where, offset) ; } +// +//LLThreadLocalPtrBase +// +bool LLThreadLocalPtrBase::sInitialized = false; + +LLThreadLocalPtrBase::LLThreadLocalPtrBase(void (*cleanup_func)(void*)) +: mCleanupFunc(cleanup_func), + mThreadKey(NULL) +{ + if (sInitialized) + { + initStorage(); + } +} + +LLThreadLocalPtrBase::LLThreadLocalPtrBase( const LLThreadLocalPtrBase& other) +: mCleanupFunc(other.mCleanupFunc), + mThreadKey(NULL) +{ + if (sInitialized) + { + initStorage(); + } +} + +LLThreadLocalPtrBase::~LLThreadLocalPtrBase() +{ + destroyStorage(); +} + +void LLThreadLocalPtrBase::set( void* value ) +{ + llassert(sInitialized && mThreadKey); + + apr_status_t result = apr_threadkey_private_set((void*)value, mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to set thread local data" << llendl; + } +} + +void LLThreadLocalPtrBase::initStorage( ) +{ + apr_status_t result = apr_threadkey_private_create(&mThreadKey, mCleanupFunc, gAPRPoolp); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to allocate thread local data" << llendl; + } +} + +void LLThreadLocalPtrBase::destroyStorage() +{ + if (mThreadKey) + { + apr_status_t result = apr_threadkey_private_delete(mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to delete thread local data" << llendl; + } + } +} + +void LLThreadLocalPtrBase::initAllThreadLocalStorage() +{ + if (!sInitialized) + { + sInitialized = true; + for (LLInstanceTracker<LLThreadLocalPtrBase>::instance_iter it = beginInstances(), end_it = endInstances(); + it != end_it; + ++it) + { + (*it).initStorage(); + } + } +} + + // //******************************************************************************************************************************* //static components of LLAPRFile diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index af33ce666f..eb0bf627a0 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -49,6 +49,7 @@ #include "apr_signal.h" #include "apr_atomic.h" #include "llstring.h" +#include "llinstancetracker.h" extern LL_COMMON_API apr_thread_mutex_t* gLogMutexp; extern apr_thread_mutex_t* gCallStacksLogMutexp; @@ -255,6 +256,122 @@ public: //******************************************************************************************************************************* }; +class LLThreadLocalPtrBase : LLInstanceTracker<LLThreadLocalPtrBase> +{ +public: + LLThreadLocalPtrBase(void (*cleanup_func)(void*) ); + LLThreadLocalPtrBase(const LLThreadLocalPtrBase& other); + ~LLThreadLocalPtrBase(); + +protected: + friend void LL_COMMON_API ll_init_apr(); + void set(void* value); + + LL_FORCE_INLINE void* get() + { + void* ptr; + //apr_status_t result = + apr_threadkey_private_get(&ptr, mThreadKey); + //if (result != APR_SUCCESS) + //{ + // ll_apr_warn_status(s); + // llerrs << "Failed to get thread local data" << llendl; + //} + return ptr; + } + + LL_FORCE_INLINE const void* get() const + { + void* ptr; + //apr_status_t result = + apr_threadkey_private_get(&ptr, mThreadKey); + //if (result != APR_SUCCESS) + //{ + // ll_apr_warn_status(s); + // llerrs << "Failed to get thread local data" << llendl; + //} + return ptr; + } + + void initStorage(); + + void destroyStorage(); + + static void initAllThreadLocalStorage(); + +private: + void (*mCleanupFunc)(void*); + apr_threadkey_t* mThreadKey; + static bool sInitialized; +}; + +template <typename T> +class LLThreadLocalPtr : public LLThreadLocalPtrBase +{ +public: + + LLThreadLocalPtr() + : LLThreadLocalPtrBase(&cleanup) + {} + + LLThreadLocalPtr(T* value) + : LLThreadLocalPtrBase(&cleanup) + { + set(value); + } + + + LLThreadLocalPtr(const LLThreadLocalPtr<T>& other) + : LLThreadLocalPtrBase(other, &cleanup) + { + set(other.get()); + } + + T* get() + { + return (T*)LLThreadLocalPtrBase::get(); + } + + const T* get() const + { + return (const T*)LLThreadLocalPtrBase::get(); + } + + T* operator -> () + { + return (T*)get(); + } + + const T* operator -> () const + { + return (T*)get(); + } + + T& operator*() + { + return *(T*)get(); + } + + const T& operator*() const + { + return *(T*)get(); + } + + LLThreadLocalPtr<T>& operator = (T* value) + { + set((void*)value); + return *this; + } + +private: + + static void cleanup(void* ptr) + { + delete reinterpret_cast<T*>(ptr); + } + +}; + /** * @brief Function which appropriately logs error or remains quiet on * APR_SUCCESS. diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 8be9e4f4de..512e7da840 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -44,6 +44,7 @@ void LLCommon::initClass() } LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); + LLTrace::init(); // LLWorkerThread::initClass(); // LLFrameCallbackManager::initClass(); } @@ -61,4 +62,5 @@ void LLCommon::cleanupClass() sAprInitialized = FALSE; } LLMemory::cleanupClass(); + LLTrace::cleanup(); } diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index f3ab8aa40c..023004eedd 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -66,9 +66,7 @@ U32 __thread LLThread::sThreadID = 0; #endif U32 LLThread::sIDIter = 0; - -LLTrace::MasterThreadTrace gMasterThreadTrace; -LLThreadLocalPtr<LLTrace::ThreadTraceData> LLThread::sTraceData(&gMasterThreadTrace); +LLThreadLocalPtr<LLTrace::ThreadTraceData> LLThread::sTraceData; LL_COMMON_API void assert_main_thread() @@ -87,7 +85,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - sTraceData = new LLTrace::SlaveThreadTrace(gMasterThreadTrace); + sTraceData = new LLTrace::SlaveThreadTrace(); #if !LL_DARWIN sThreadIndex = threadp->mID; @@ -155,7 +153,7 @@ void LLThread::shutdown() //llinfos << "LLThread::~LLThread() Killing thread " << mName << " Status: " << mStatus << llendl; // Now wait a bit for the thread to exit // It's unclear whether I should even bother doing this - this destructor - // should netver get called unless we're already stopped, really... + // should never get called unless we're already stopped, really... S32 counter = 0; const S32 MAX_WAIT = 600; while (counter < MAX_WAIT) diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index e2de4c8b85..e50fa7653d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -31,7 +31,6 @@ #include "llapr.h" #include "apr_thread_cond.h" #include "lltrace.h" -#include "llthreadlocalptr.h" class LL_COMMON_API LLThread { diff --git a/indra/llcommon/llthreadlocalptr.h b/indra/llcommon/llthreadlocalptr.h deleted file mode 100644 index f02f4849ca..0000000000 --- a/indra/llcommon/llthreadlocalptr.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file llthreadlocalptr.h - * @brief manage thread local storage through non-copyable pointer - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLTHREAD_LOCAL_PTR_H -#define LL_LLTHREAD_LOCAL_PTR_H - -#include "llapr.h" - -template <typename T> -class LLThreadLocalPtr -{ -public: - LLThreadLocalPtr(T* value = NULL, apr_pool_t* pool = NULL) - { - apr_status_t result = apr_threadkey_private_create(&mThreadKey, cleanup, pool); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to allocate thread local data" << llendl; - } - set(value); - } - - - ~LLThreadLocalPtr() - { - apr_status_t result = apr_threadkey_private_delete(mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to delete thread local data" << llendl; - } - } - - T* operator -> () - { - return get(); - } - - const T* operator -> () const - { - return get(); - } - - T& operator*() - { - return *get(); - } - - const T& operator*() const - { - return *get(); - } - - LLThreadLocalPtr<T>& operator = (T* value) - { - set(value); - return *this; - } - - void copyFrom(const LLThreadLocalPtr<T>& other) - { - set(other.get()); - } - - LL_FORCE_INLINE void set(T* value) - { - apr_status_t result = apr_threadkey_private_set((void*)value, mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to set thread local data" << llendl; - } - } - - LL_FORCE_INLINE T* get() - { - T* ptr; - //apr_status_t result = - apr_threadkey_private_get((void**)&ptr, mThreadKey); - //if (result != APR_SUCCESS) - //{ - // ll_apr_warn_status(s); - // llerrs << "Failed to get thread local data" << llendl; - //} - return ptr; - } - - LL_FORCE_INLINE const T* get() const - { - T* ptr; - //apr_status_t result = - apr_threadkey_private_get((void**)&ptr, mThreadKey); - //if (result != APR_SUCCESS) - //{ - // ll_apr_warn_status(s); - // llerrs << "Failed to get thread local data" << llendl; - //} - return ptr; - } - - -private: - static void cleanup(void* ptr) - { - delete reinterpret_cast<T*>(ptr); - } - - LLThreadLocalPtr(const LLThreadLocalPtr<T>& other) - { - // do not copy construct - llassert(false); - } - - apr_threadkey_t* mThreadKey; -}; - -#endif // LL_LLTHREAD_LOCAL_PTR_H diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 037c52f8c1..501414ebf3 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -32,7 +32,21 @@ namespace LLTrace { BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; -LLThreadLocalPtr<ThreadTraceData> ThreadTraceData::sCurThreadTrace; + +MasterThreadTrace *gMasterThreadTrace = NULL; +LLThreadLocalPtr<ThreadTraceData> gCurThreadTrace; + +void init() +{ + gMasterThreadTrace = new MasterThreadTrace(); + gCurThreadTrace = gMasterThreadTrace; +} + +void cleanup() +{ + delete gMasterThreadTrace; +} + /////////////////////////////////////////////////////////////////////// // Sampler diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 401ddfd6f3..3af05d67f9 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -32,7 +32,6 @@ #include "llmutex.h" #include "llmemory.h" -#include "llthreadlocalptr.h" #include <list> @@ -42,19 +41,29 @@ namespace LLTrace { + void init(); + void cleanup(); + + extern class MasterThreadTrace *gMasterThreadTrace; + extern LLThreadLocalPtr<class ThreadTraceData> gCurThreadTrace; + // one per thread per type template<typename ACCUMULATOR> class AccumulatorBuffer { static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; - public: - AccumulatorBuffer() + private: + enum StaticAllocationMarker { STATIC_ALLOC }; + + AccumulatorBuffer(StaticAllocationMarker m) : mStorageSize(64), - mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE]), - mNextStorageSlot(0) - {} + mNextStorageSlot(0), + mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE]) + { + } + public: - AccumulatorBuffer(const AccumulatorBuffer& other) + AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) : mStorageSize(other.mStorageSize), mStorage(new ACCUMULATOR[other.mStorageSize]), mNextStorageSlot(other.mNextStorageSlot) @@ -116,6 +125,12 @@ namespace LLTrace return next_slot; } + static AccumulatorBuffer<ACCUMULATOR>& getDefaultBuffer() + { + static AccumulatorBuffer sBuffer; + return sBuffer; + } + private: ACCUMULATOR* mStorage; size_t mStorageSize; @@ -124,15 +139,6 @@ namespace LLTrace }; template<typename ACCUMULATOR> LLThreadLocalPtr<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; - template<typename ACCUMULATOR> - class PrimaryAccumulatorBuffer : public AccumulatorBuffer<ACCUMULATOR - { - PrimaryAccumulatorBuffer() - { - makePrimary(); - } - }; - template<typename ACCUMULATOR> class Trace { @@ -140,7 +146,7 @@ namespace LLTrace Trace(const std::string& name) : mName(name) { - mAccumulatorIndex = getPrimaryBuffer().reserveSlot(); + mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } LL_FORCE_INLINE ACCUMULATOR& getAccumulator() @@ -148,12 +154,6 @@ namespace LLTrace return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; } - static PrimaryAccumulatorBuffer& getPrimaryBuffer() - { - static PrimaryAccumulatorBuffer sBuffer; - return sBuffer; - } - private: std::string mName; size_t mAccumulatorIndex; @@ -347,9 +347,13 @@ namespace LLTrace { public: Sampler() {} - Sampler(const Sampler& other); + Sampler(const Sampler& other) + : mF32Stats(other.mF32Stats), + mS32Stats(other.mS32Stats), + mTimers(other.mTimers) + {} - ~Sampler(); + ~Sampler() {} void makePrimary() { @@ -438,7 +442,6 @@ namespace LLTrace protected: Sampler mPrimarySampler; std::list<Sampler*> mActiveSamplers; - static LLThreadLocalPtr<ThreadTraceData> sCurThreadTrace; }; class MasterThreadTrace : public ThreadTraceData @@ -472,7 +475,7 @@ namespace LLTrace { public: explicit - SlaveThreadTrace(MasterThreadTrace& master_trace) + SlaveThreadTrace(MasterThreadTrace& master_trace = *gMasterThreadTrace) : mMaster(master_trace), ThreadTraceData(master_trace), mSharedData(mPrimarySampler) -- cgit v1.2.3 From 308ff886c3ab2aa561477921bc0d92e1bd7d399a Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 24 Sep 2012 19:01:48 -0700 Subject: fixed build moved LLThread::lockData and unlockData back to header --- indra/llcommon/llthread.cpp | 10 ---------- indra/llcommon/llthread.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 023004eedd..de1f0801a1 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -308,13 +308,3 @@ void LLThread::wakeLocked() mRunCondition->signal(); } } - -void LLThread::lockData() -{ - mRunCondition->lock(); -} - -void LLThread::unlockData() -{ - mRunCondition->unlock(); -} diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index e50fa7653d..fed111b0e4 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -136,6 +136,18 @@ protected: // mRunCondition->unlock(); }; + +void LLThread::lockData() +{ + mRunCondition->lock(); +} + +void LLThread::unlockData() +{ + mRunCondition->unlock(); +} + + //============================================================================ #endif // LL_LLTHREAD_H -- cgit v1.2.3 From 05a3203d8274a0a0999faad128f629614b8d62c5 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 26 Sep 2012 17:04:57 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages fixed various issues related to unit tests and LLThreadLocalPtr initialization and teardown --- indra/llcommon/llapr.cpp | 45 +++++++++++++++++++--------- indra/llcommon/llapr.h | 27 ++++++++--------- indra/llcommon/llcommon.cpp | 6 +--- indra/llcommon/llthread.cpp | 5 +++- indra/llcommon/llthread.h | 2 +- indra/llcommon/lltrace.cpp | 33 ++++++++++++++------- indra/llcommon/lltrace.h | 47 +++++++++++++++++------------- indra/llimage/tests/llimageworker_test.cpp | 5 ++++ indra/test/test.cpp | 15 ++++------ 9 files changed, 108 insertions(+), 77 deletions(-) diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 76749f8a91..e9930c10f7 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -52,7 +52,7 @@ void ll_init_apr() if(!LLAPRFile::sAPRFilePoolp) { - LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE) ; + LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE); } LLThreadLocalPtrBase::initAllThreadLocalStorage(); @@ -79,6 +79,9 @@ void ll_cleanup_apr() apr_thread_mutex_destroy(gCallStacksLogMutexp); gCallStacksLogMutexp = NULL; } + + LLThreadLocalPtrBase::destroyAllThreadLocalStorage(); + if (gAPRPoolp) { apr_pool_destroy(gAPRPoolp); @@ -86,7 +89,7 @@ void ll_cleanup_apr() } if (LLAPRFile::sAPRFilePoolp) { - delete LLAPRFile::sAPRFilePoolp ; + delete LLAPRFile::sAPRFilePoolp ; LLAPRFile::sAPRFilePoolp = NULL ; } apr_terminate(); @@ -483,9 +486,8 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset) // bool LLThreadLocalPtrBase::sInitialized = false; -LLThreadLocalPtrBase::LLThreadLocalPtrBase(void (*cleanup_func)(void*)) -: mCleanupFunc(cleanup_func), - mThreadKey(NULL) +LLThreadLocalPtrBase::LLThreadLocalPtrBase() +: mThreadKey(NULL) { if (sInitialized) { @@ -494,8 +496,7 @@ LLThreadLocalPtrBase::LLThreadLocalPtrBase(void (*cleanup_func)(void*)) } LLThreadLocalPtrBase::LLThreadLocalPtrBase( const LLThreadLocalPtrBase& other) -: mCleanupFunc(other.mCleanupFunc), - mThreadKey(NULL) +: mThreadKey(NULL) { if (sInitialized) { @@ -522,7 +523,7 @@ void LLThreadLocalPtrBase::set( void* value ) void LLThreadLocalPtrBase::initStorage( ) { - apr_status_t result = apr_threadkey_private_create(&mThreadKey, mCleanupFunc, gAPRPoolp); + apr_status_t result = apr_threadkey_private_create(&mThreadKey, NULL, gAPRPoolp); if (result != APR_SUCCESS) { ll_apr_warn_status(result); @@ -532,13 +533,16 @@ void LLThreadLocalPtrBase::initStorage( ) void LLThreadLocalPtrBase::destroyStorage() { - if (mThreadKey) + if (sInitialized) { - apr_status_t result = apr_threadkey_private_delete(mThreadKey); - if (result != APR_SUCCESS) + if (mThreadKey) { - ll_apr_warn_status(result); - llerrs << "Failed to delete thread local data" << llendl; + apr_status_t result = apr_threadkey_private_delete(mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to delete thread local data" << llendl; + } } } } @@ -547,16 +551,29 @@ void LLThreadLocalPtrBase::initAllThreadLocalStorage() { if (!sInitialized) { - sInitialized = true; for (LLInstanceTracker<LLThreadLocalPtrBase>::instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { (*it).initStorage(); } + sInitialized = true; } } +void LLThreadLocalPtrBase::destroyAllThreadLocalStorage() +{ + if (sInitialized) + { + for (LLInstanceTracker<LLThreadLocalPtrBase>::instance_iter it = beginInstances(), end_it = endInstances(); + it != end_it; + ++it) + { + (*it).destroyStorage(); + } + sInitialized = false; + } +} // //******************************************************************************************************************************* diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index eb0bf627a0..830e0a33fa 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -259,16 +259,19 @@ public: class LLThreadLocalPtrBase : LLInstanceTracker<LLThreadLocalPtrBase> { public: - LLThreadLocalPtrBase(void (*cleanup_func)(void*) ); + LLThreadLocalPtrBase(); LLThreadLocalPtrBase(const LLThreadLocalPtrBase& other); ~LLThreadLocalPtrBase(); + static void initAllThreadLocalStorage(); + static void destroyAllThreadLocalStorage(); + protected: - friend void LL_COMMON_API ll_init_apr(); void set(void* value); LL_FORCE_INLINE void* get() { + llassert(sInitialized); void* ptr; //apr_status_t result = apr_threadkey_private_get(&ptr, mThreadKey); @@ -294,13 +297,9 @@ protected: } void initStorage(); - void destroyStorage(); - static void initAllThreadLocalStorage(); - -private: - void (*mCleanupFunc)(void*); +protected: apr_threadkey_t* mThreadKey; static bool sInitialized; }; @@ -311,10 +310,10 @@ class LLThreadLocalPtr : public LLThreadLocalPtrBase public: LLThreadLocalPtr() - : LLThreadLocalPtrBase(&cleanup) + : LLThreadLocalPtrBase() {} - LLThreadLocalPtr(T* value) + explicit LLThreadLocalPtr(T* value) : LLThreadLocalPtrBase(&cleanup) { set(value); @@ -327,7 +326,7 @@ public: set(other.get()); } - T* get() + LL_FORCE_INLINE T* get() { return (T*)LLThreadLocalPtrBase::get(); } @@ -363,13 +362,11 @@ public: return *this; } -private: - - static void cleanup(void* ptr) + bool operator ==(T* other) { - delete reinterpret_cast<T*>(ptr); + if (!sInitialized) return false; + return get() == other; } - }; /** diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 512e7da840..c149a1fe5c 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -45,15 +45,12 @@ void LLCommon::initClass() LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); LLTrace::init(); -// LLWorkerThread::initClass(); -// LLFrameCallbackManager::initClass(); } //static void LLCommon::cleanupClass() { -// LLFrameCallbackManager::cleanupClass(); -// LLWorkerThread::cleanupClass(); + LLTrace::cleanup(); LLThreadSafeRefCount::cleanupThreadSafeRefCount(); LLTimer::cleanupClass(); if (sAprInitialized) @@ -62,5 +59,4 @@ void LLCommon::cleanupClass() sAprInitialized = FALSE; } LLMemory::cleanupClass(); - LLTrace::cleanup(); } diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index de1f0801a1..2e6eb085dc 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -66,7 +66,7 @@ U32 __thread LLThread::sThreadID = 0; #endif U32 LLThread::sIDIter = 0; -LLThreadLocalPtr<LLTrace::ThreadTraceData> LLThread::sTraceData; +LLThreadLocalPtr<LLTrace::SlaveThreadTrace> LLThread::sTraceData; LL_COMMON_API void assert_main_thread() @@ -99,6 +99,8 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap // We're done with the run function, this thread is done executing now. threadp->mStatus = STOPPED; + delete sTraceData.get(); + return NULL; } @@ -108,6 +110,7 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) : mAPRThreadp(NULL), mStatus(STOPPED) { + mID = ++sIDIter; // Thread creation probably CAN be paranoid about APR being initialized, if necessary diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index fed111b0e4..6889fab2c1 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -105,7 +105,7 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr<LLTrace::ThreadTraceData> sTraceData; + static LLThreadLocalPtr<LLTrace::SlaveThreadTrace> sTraceData; //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 501414ebf3..8cedcafd10 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -31,27 +31,37 @@ namespace LLTrace { -BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; - -MasterThreadTrace *gMasterThreadTrace = NULL; -LLThreadLocalPtr<ThreadTraceData> gCurThreadTrace; +static MasterThreadTrace* gMasterThreadTrace = NULL; void init() { gMasterThreadTrace = new MasterThreadTrace(); - gCurThreadTrace = gMasterThreadTrace; } void cleanup() { delete gMasterThreadTrace; + gMasterThreadTrace = NULL; } +BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; + + + +MasterThreadTrace& getMasterThreadTrace() +{ + llassert(gMasterThreadTrace != NULL); + return *gMasterThreadTrace; +} + + + /////////////////////////////////////////////////////////////////////// // Sampler /////////////////////////////////////////////////////////////////////// + void Sampler::stop() { getThreadTrace()->deactivate(this); @@ -71,15 +81,15 @@ class ThreadTraceData* Sampler::getThreadTrace() // MasterThreadTrace /////////////////////////////////////////////////////////////////////// -void MasterThreadTrace::pullFromWorkerThreads() +void MasterThreadTrace::pullFromSlaveThreads() { LLMutexLock lock(&mSlaveListMutex); - for (worker_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); it != end_it; ++it) { - it->mWorkerTrace->mSharedData.copyTo(it->mSamplerStorage); + it->mSlaveTrace->mSharedData.copyTo(it->mSamplerStorage); } } @@ -87,18 +97,18 @@ void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(WorkerThreadTraceProxy(child)); + mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child)); } void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - for (worker_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); it != end_it; ++it) { - if (it->mWorkerTrace == child) + if (it->mSlaveTrace == child) { mSlaveThreadTraces.erase(it); break; @@ -107,3 +117,4 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) } } + diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3af05d67f9..e4bec0a644 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -44,8 +44,7 @@ namespace LLTrace void init(); void cleanup(); - extern class MasterThreadTrace *gMasterThreadTrace; - extern LLThreadLocalPtr<class ThreadTraceData> gCurThreadTrace; + class MasterThreadTrace& getMasterThreadTrace(); // one per thread per type template<typename ACCUMULATOR> @@ -59,8 +58,8 @@ namespace LLTrace : mStorageSize(64), mNextStorageSlot(0), mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE]) - { - } + {} + public: AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) @@ -69,6 +68,15 @@ namespace LLTrace mNextStorageSlot(other.mNextStorageSlot) {} + ~AccumulatorBuffer() + { + if (sPrimaryStorage == mStorage) + { + //TODO pick another primary? + sPrimaryStorage = NULL; + } + } + LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index) { return mStorage[index]; @@ -353,7 +361,8 @@ namespace LLTrace mTimers(other.mTimers) {} - ~Sampler() {} + ~Sampler() + {} void makePrimary() { @@ -453,21 +462,21 @@ namespace LLTrace void addSlaveThread(class SlaveThreadTrace* child); void removeSlaveThread(class SlaveThreadTrace* child); - // call this periodically to gather stats data from worker threads - void pullFromWorkerThreads(); + // call this periodically to gather stats data from slave threads + void pullFromSlaveThreads(); private: - struct WorkerThreadTraceProxy + struct SlaveThreadTraceProxy { - WorkerThreadTraceProxy(class SlaveThreadTrace* trace) - : mWorkerTrace(trace) + SlaveThreadTraceProxy(class SlaveThreadTrace* trace) + : mSlaveTrace(trace) {} - class SlaveThreadTrace* mWorkerTrace; + class SlaveThreadTrace* mSlaveTrace; Sampler mSamplerStorage; }; - typedef std::list<WorkerThreadTraceProxy> worker_thread_trace_list_t; + typedef std::list<SlaveThreadTraceProxy> slave_thread_trace_list_t; - worker_thread_trace_list_t mSlaveThreadTraces; + slave_thread_trace_list_t mSlaveThreadTraces; LLMutex mSlaveListMutex; }; @@ -475,17 +484,16 @@ namespace LLTrace { public: explicit - SlaveThreadTrace(MasterThreadTrace& master_trace = *gMasterThreadTrace) - : mMaster(master_trace), - ThreadTraceData(master_trace), + SlaveThreadTrace() + : ThreadTraceData(getMasterThreadTrace()), mSharedData(mPrimarySampler) { - master_trace.addSlaveThread(this); + getMasterThreadTrace().addSlaveThread(this); } ~SlaveThreadTrace() { - mMaster.removeSlaveThread(this); + getMasterThreadTrace().removeSlaveThread(this); } // call this periodically to gather stats data for master thread to consume @@ -494,7 +502,7 @@ namespace LLTrace mSharedData.copyFrom(mPrimarySampler); } - MasterThreadTrace& mMaster; + MasterThreadTrace* mMaster; // this data is accessed by other threads, so give it a 64 byte alignment // to avoid false sharing on most x86 processors @@ -529,7 +537,6 @@ namespace LLTrace SharedData mSharedData; }; - class TimeInterval { public: diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index e255d65b43..be7aae4eb7 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -114,11 +114,13 @@ namespace tut // Constructor and destructor of the test wrapper imagedecodethread_test() { + LLTrace::init(); mThread = NULL; } ~imagedecodethread_test() { delete mThread; + LLTrace::cleanup(); } }; @@ -136,6 +138,8 @@ namespace tut imagerequest_test() { done = false; + LLTrace::init(); + mRequest = new LLImageDecodeThread::ImageRequest(0, 0, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, new responder_test(&done)); @@ -145,6 +149,7 @@ namespace tut // We should delete the object *but*, because its destructor is protected, that cannot be // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine... //delete mRequest; + LLTrace::cleanup(); } }; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index dc8580fe69..2b66c6aa26 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -512,15 +512,10 @@ int main(int argc, char **argv) ctype_workaround(); #endif - apr_initialize(); - apr_pool_t* pool = NULL; - if(APR_SUCCESS != apr_pool_create(&pool, NULL)) - { - std::cerr << "Unable to initialize pool" << std::endl; - return 1; - } + ll_init_apr(); + apr_getopt_t* os = NULL; - if(APR_SUCCESS != apr_getopt_init(&os, pool, argc, argv)) + if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { std::cerr << "apr_getopt_init() failed" << std::endl; return 1; @@ -602,7 +597,7 @@ int main(int argc, char **argv) if (LOGFAIL) { LLError::ELevel level = LLError::decodeLevel(LOGFAIL); - replayer.reset(new LLReplayLogReal(level, pool)); + replayer.reset(new LLReplayLogReal(level, gAPRPoolp)); } else { @@ -646,7 +641,7 @@ int main(int argc, char **argv) s.close(); } - apr_terminate(); + ll_cleanup_apr(); int retval = (success ? 0 : 1); return retval; -- cgit v1.2.3 From 07c4be092b276f0d7c14ba12872efb31c1f16764 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 26 Sep 2012 19:12:40 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages slave threads now pushing data to master thread --- indra/llcommon/llqueuedthread.cpp | 2 ++ indra/llcommon/llthread.cpp | 2 +- indra/llcommon/llthread.h | 5 +-- indra/llcommon/lltrace.cpp | 71 ++++++++++++++++++++++++++++++++++++++- indra/llcommon/lltrace.h | 63 +++++++++------------------------- indra/newview/llappviewer.cpp | 1 + 6 files changed, 93 insertions(+), 51 deletions(-) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 1738c16dea..a741d342d3 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -111,6 +111,8 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(F32 max_time_ms) { + LLThread::getTraceData()->pushToMaster(); + if (!mStarted) { if (!mThreaded) diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 2e6eb085dc..2ff524d9ba 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -66,7 +66,7 @@ U32 __thread LLThread::sThreadID = 0; #endif U32 LLThread::sIDIter = 0; -LLThreadLocalPtr<LLTrace::SlaveThreadTrace> LLThread::sTraceData; +LLThreadLocalPtr<LLTrace::ThreadTrace> LLThread::sTraceData; LL_COMMON_API void assert_main_thread() diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 6889fab2c1..5cd287ec39 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -87,7 +87,8 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTraceData* getTraceData() { return sTraceData.get(); } + static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); } + static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;} private: BOOL mPaused; @@ -105,7 +106,7 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr<LLTrace::SlaveThreadTrace> sTraceData; + static LLThreadLocalPtr<LLTrace::ThreadTrace> sTraceData; //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 8cedcafd10..24a2b33a5f 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -72,11 +72,69 @@ void Sampler::resume() getThreadTrace()->activate(this); } -class ThreadTraceData* Sampler::getThreadTrace() +class ThreadTrace* Sampler::getThreadTrace() { return LLThread::getTraceData(); } +/////////////////////////////////////////////////////////////////////// +// MasterThreadTrace +/////////////////////////////////////////////////////////////////////// + +ThreadTrace::ThreadTrace() +{ + mPrimarySampler.makePrimary(); +} + +ThreadTrace::ThreadTrace( const ThreadTrace& other ) : mPrimarySampler(other.mPrimarySampler) +{ + mPrimarySampler.makePrimary(); +} + +void ThreadTrace::activate( Sampler* sampler ) +{ + flushPrimary(); + mActiveSamplers.push_back(sampler); +} + +void ThreadTrace::deactivate( Sampler* sampler ) +{ + sampler->mergeFrom(mPrimarySampler); + + // TODO: replace with intrusive list + std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); + if (found_it != mActiveSamplers.end()) + { + mActiveSamplers.erase(found_it); + } +} + +void ThreadTrace::flushPrimary() +{ + for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); + it != end_it; + ++it) + { + (*it)->mergeFrom(mPrimarySampler); + } + mPrimarySampler.reset(); +} + + + + + + +/////////////////////////////////////////////////////////////////////// +// SlaveThreadTrace +/////////////////////////////////////////////////////////////////////// + +void SlaveThreadTrace::pushToMaster() +{ + mSharedData.copyFrom(mPrimarySampler); +} + + /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// @@ -116,5 +174,16 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) } } +void MasterThreadTrace::pushToMaster() +{ + +} + +MasterThreadTrace::MasterThreadTrace() +{ + LLThread::setTraceData(this); +} + + } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index e4bec0a644..601b5ed182 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -396,7 +396,7 @@ namespace LLTrace private: // returns data for current thread - class ThreadTraceData* getThreadTrace(); + class ThreadTrace* getThreadTrace(); AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; @@ -404,48 +404,19 @@ namespace LLTrace AccumulatorBuffer<TimerAccumulator> mTimers; }; - class ThreadTraceData + class ThreadTrace { public: - ThreadTraceData() - { - mPrimarySampler.makePrimary(); - } - - ThreadTraceData(const ThreadTraceData& other) - : mPrimarySampler(other.mPrimarySampler) - { - mPrimarySampler.makePrimary(); - } + ThreadTrace(); + ThreadTrace(const ThreadTrace& other); - void activate(Sampler* sampler) - { - flushPrimary(); - mActiveSamplers.push_back(sampler); - } + virtual ~ThreadTrace() {} - void deactivate(Sampler* sampler) - { - sampler->mergeFrom(mPrimarySampler); - - // TODO: replace with intrusive list - std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); - if (found_it != mActiveSamplers.end()) - { - mActiveSamplers.erase(found_it); - } - } + void activate(Sampler* sampler); + void deactivate(Sampler* sampler); + void flushPrimary(); - void flushPrimary() - { - for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); - it != end_it; - ++it) - { - (*it)->mergeFrom(mPrimarySampler); - } - mPrimarySampler.reset(); - } + virtual void pushToMaster() = 0; Sampler* getPrimarySampler() { return &mPrimarySampler; } protected: @@ -453,15 +424,16 @@ namespace LLTrace std::list<Sampler*> mActiveSamplers; }; - class MasterThreadTrace : public ThreadTraceData + class MasterThreadTrace : public ThreadTrace { public: - MasterThreadTrace() - {} + MasterThreadTrace(); void addSlaveThread(class SlaveThreadTrace* child); void removeSlaveThread(class SlaveThreadTrace* child); + /*virtual */ void pushToMaster(); + // call this periodically to gather stats data from slave threads void pullFromSlaveThreads(); @@ -480,12 +452,12 @@ namespace LLTrace LLMutex mSlaveListMutex; }; - class SlaveThreadTrace : public ThreadTraceData + class SlaveThreadTrace : public ThreadTrace { public: explicit SlaveThreadTrace() - : ThreadTraceData(getMasterThreadTrace()), + : ThreadTrace(getMasterThreadTrace()), mSharedData(mPrimarySampler) { getMasterThreadTrace().addSlaveThread(this); @@ -497,10 +469,7 @@ namespace LLTrace } // call this periodically to gather stats data for master thread to consume - void pushToParent() - { - mSharedData.copyFrom(mPrimarySampler); - } + /*virtual*/ void pushToMaster(); MasterThreadTrace* mMaster; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c3ac615169..fcbef491fe 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1222,6 +1222,7 @@ bool LLAppViewer::mainLoop() { LLFastTimer _(FTM_FRAME); LLFastTimer::nextFrame(); + LLTrace::getMasterThreadTrace().pullFromSlaveThreads(); //clear call stack records llclearcallstacks; -- cgit v1.2.3 From 38354e19063478c8cda0408547ad05023b457041 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 28 Sep 2012 10:45:14 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages created separate constructor for static allocation of sampler buffer fixed start/stop/resume semantics of samplers and added sampler time interval tracking --- indra/llcommon/llcommon.cpp | 1 + indra/llcommon/llqueuedthread.cpp | 1 + indra/llcommon/llthread.cpp | 14 +++- indra/llcommon/llthread.h | 10 ++- indra/llcommon/lltrace.cpp | 117 ++++++++++++++++++++++++----- indra/llcommon/lltrace.h | 108 ++++++++++++-------------- indra/llimage/tests/llimageworker_test.cpp | 2 + indra/newview/llappviewer.cpp | 2 +- 8 files changed, 170 insertions(+), 85 deletions(-) diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index c149a1fe5c..c720df7555 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -29,6 +29,7 @@ #include "llmemory.h" #include "llthread.h" +#include "lltrace.h" //static BOOL LLCommon::sAprInitialized = FALSE; diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index a741d342d3..0a35474b7f 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -28,6 +28,7 @@ #include "llstl.h" #include "lltimer.h" // ms_sleep() +#include "lltrace.h" //============================================================================ diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 2ff524d9ba..7384842627 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -32,6 +32,7 @@ #include "llmutex.h" #include "lltimer.h" +#include "lltrace.h" #if LL_LINUX || LL_SOLARIS #include <sched.h> @@ -85,7 +86,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - sTraceData = new LLTrace::SlaveThreadTrace(); + setTraceData(new LLTrace::SlaveThreadTrace()); #if !LL_DARWIN sThreadIndex = threadp->mID; @@ -100,6 +101,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap threadp->mStatus = STOPPED; delete sTraceData.get(); + sTraceData = NULL; return NULL; } @@ -311,3 +313,13 @@ void LLThread::wakeLocked() mRunCondition->signal(); } } + +LLTrace::ThreadTrace* LLThread::getTraceData() +{ + return sTraceData.get(); +} + +void LLThread::setTraceData( LLTrace::ThreadTrace* data ) +{ + sTraceData = data; +} diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 5cd287ec39..334ea2f0da 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -30,8 +30,12 @@ #include "llapp.h" #include "llapr.h" #include "apr_thread_cond.h" -#include "lltrace.h" +#include "llmutex.h" +namespace LLTrace +{ + class ThreadTrace; +} class LL_COMMON_API LLThread { private: @@ -87,8 +91,8 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); } - static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;} + static LLTrace::ThreadTrace* getTraceData(); + static void setTraceData(LLTrace::ThreadTrace* data); private: BOOL mPaused; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 24a2b33a5f..2da4363b1d 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -55,40 +55,97 @@ MasterThreadTrace& getMasterThreadTrace() return *gMasterThreadTrace; } - - /////////////////////////////////////////////////////////////////////// // Sampler /////////////////////////////////////////////////////////////////////// +Sampler::Sampler(ThreadTrace* thread_trace) +: mElapsedSeconds(0), + mIsStarted(false), + mThreadTrace(thread_trace) +{ +} -void Sampler::stop() +Sampler::~Sampler() { - getThreadTrace()->deactivate(this); +} + +void Sampler::start() +{ + reset(); + resume(); +} + +void Sampler::reset() +{ + mF32Stats.reset(); + mS32Stats.reset(); + mStackTimers.reset(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); } void Sampler::resume() { - getThreadTrace()->activate(this); + if (!mIsStarted) + { + mSamplingTimer.reset(); + getThreadTrace()->activate(this); + mIsStarted = true; + } +} + +void Sampler::stop() +{ + if (mIsStarted) + { + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + getThreadTrace()->deactivate(this); + mIsStarted = false; + } +} + +ThreadTrace* Sampler::getThreadTrace() +{ + return mThreadTrace; +} + +void Sampler::makePrimary() +{ + mF32Stats.makePrimary(); + mS32Stats.makePrimary(); + mStackTimers.makePrimary(); } -class ThreadTrace* Sampler::getThreadTrace() +void Sampler::mergeFrom( const Sampler* other ) { - return LLThread::getTraceData(); + mF32Stats.mergeFrom(other->mF32Stats); + mS32Stats.mergeFrom(other->mS32Stats); + mStackTimers.mergeFrom(other->mStackTimers); } + /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// ThreadTrace::ThreadTrace() { - mPrimarySampler.makePrimary(); + mPrimarySampler = createSampler(); + mPrimarySampler->makePrimary(); + mPrimarySampler->start(); } -ThreadTrace::ThreadTrace( const ThreadTrace& other ) : mPrimarySampler(other.mPrimarySampler) +ThreadTrace::ThreadTrace( const ThreadTrace& other ) +: mPrimarySampler(new Sampler(*(other.mPrimarySampler))) { - mPrimarySampler.makePrimary(); + mPrimarySampler->makePrimary(); +} + +ThreadTrace::~ThreadTrace() +{ + delete mPrimarySampler; } void ThreadTrace::activate( Sampler* sampler ) @@ -117,11 +174,13 @@ void ThreadTrace::flushPrimary() { (*it)->mergeFrom(mPrimarySampler); } - mPrimarySampler.reset(); + mPrimarySampler->reset(); } - - +Sampler* ThreadTrace::createSampler() +{ + return new Sampler(this); +} @@ -129,12 +188,23 @@ void ThreadTrace::flushPrimary() // SlaveThreadTrace /////////////////////////////////////////////////////////////////////// +SlaveThreadTrace::SlaveThreadTrace() +: ThreadTrace(getMasterThreadTrace()), + mSharedData(createSampler()) +{ + getMasterThreadTrace().addSlaveThread(this); +} + +SlaveThreadTrace::~SlaveThreadTrace() +{ + getMasterThreadTrace().removeSlaveThread(this); +} + void SlaveThreadTrace::pushToMaster() { mSharedData.copyFrom(mPrimarySampler); } - /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// @@ -155,7 +225,7 @@ void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child)); + mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child, createSampler())); } void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) @@ -175,15 +245,26 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) } void MasterThreadTrace::pushToMaster() -{ - -} +{} MasterThreadTrace::MasterThreadTrace() { LLThread::setTraceData(this); } +/////////////////////////////////////////////////////////////////////// +// MasterThreadTrace::SlaveThreadTraceProxy +/////////////////////////////////////////////////////////////////////// + +MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace, Sampler* storage ) +: mSlaveTrace(trace), + mSamplerStorage(storage) +{} +MasterThreadTrace::SlaveThreadTraceProxy::~SlaveThreadTraceProxy() +{ + delete mSamplerStorage; } + +} diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 601b5ed182..a443735e69 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -32,6 +32,7 @@ #include "llmutex.h" #include "llmemory.h" +#include "lltimer.h" #include <list> @@ -39,6 +40,7 @@ #define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) #define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); + namespace LLTrace { void init(); @@ -135,7 +137,7 @@ namespace LLTrace static AccumulatorBuffer<ACCUMULATOR>& getDefaultBuffer() { - static AccumulatorBuffer sBuffer; + static AccumulatorBuffer sBuffer(STATIC_ALLOC); return sBuffer; } @@ -354,54 +356,38 @@ namespace LLTrace class Sampler { public: - Sampler() {} - Sampler(const Sampler& other) - : mF32Stats(other.mF32Stats), - mS32Stats(other.mS32Stats), - mTimers(other.mTimers) - {} - - ~Sampler() - {} + ~Sampler(); - void makePrimary() - { - mF32Stats.makePrimary(); - mS32Stats.makePrimary(); - mTimers.makePrimary(); - } - - void start() - { - reset(); - resume(); - } + void makePrimary(); + void start(); void stop(); void resume(); - void mergeFrom(const Sampler& other) - { - mF32Stats.mergeFrom(other.mF32Stats); - mS32Stats.mergeFrom(other.mS32Stats); - mTimers.mergeFrom(other.mTimers); - } + void mergeFrom(const Sampler* other); - void reset() - { - mF32Stats.reset(); - mS32Stats.reset(); - mTimers.reset(); - } + void reset(); + + bool isStarted() { return mIsStarted; } private: + friend class ThreadTrace; + Sampler(class ThreadTrace* thread_trace); + + // no copy + Sampler(const Sampler& other) {} // returns data for current thread class ThreadTrace* getThreadTrace(); AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; - AccumulatorBuffer<TimerAccumulator> mTimers; + AccumulatorBuffer<TimerAccumulator> mStackTimers; + + bool mIsStarted; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + ThreadTrace* mThreadTrace; }; class ThreadTrace @@ -410,17 +396,19 @@ namespace LLTrace ThreadTrace(); ThreadTrace(const ThreadTrace& other); - virtual ~ThreadTrace() {} + virtual ~ThreadTrace(); void activate(Sampler* sampler); void deactivate(Sampler* sampler); void flushPrimary(); + Sampler* createSampler(); + virtual void pushToMaster() = 0; - Sampler* getPrimarySampler() { return &mPrimarySampler; } + Sampler* getPrimarySampler() { return mPrimarySampler; } protected: - Sampler mPrimarySampler; + Sampler* mPrimarySampler; std::list<Sampler*> mActiveSamplers; }; @@ -440,11 +428,11 @@ namespace LLTrace private: struct SlaveThreadTraceProxy { - SlaveThreadTraceProxy(class SlaveThreadTrace* trace) - : mSlaveTrace(trace) - {} + SlaveThreadTraceProxy(class SlaveThreadTrace* trace, Sampler* storage); + + ~SlaveThreadTraceProxy(); class SlaveThreadTrace* mSlaveTrace; - Sampler mSamplerStorage; + Sampler* mSamplerStorage; }; typedef std::list<SlaveThreadTraceProxy> slave_thread_trace_list_t; @@ -455,18 +443,8 @@ namespace LLTrace class SlaveThreadTrace : public ThreadTrace { public: - explicit - SlaveThreadTrace() - : ThreadTrace(getMasterThreadTrace()), - mSharedData(mPrimarySampler) - { - getMasterThreadTrace().addSlaveThread(this); - } - - ~SlaveThreadTrace() - { - getMasterThreadTrace().removeSlaveThread(this); - } + SlaveThreadTrace(); + ~SlaveThreadTrace(); // call this periodically to gather stats data for master thread to consume /*virtual*/ void pushToMaster(); @@ -479,29 +457,35 @@ namespace LLTrace { public: explicit - SharedData(const Sampler& other_sampler) - : mSampler(other_sampler) - {} + SharedData(Sampler* sampler) + : mSampler(sampler) + { + } + + ~SharedData() + { + delete mSampler; + } - void copyFrom(Sampler& source) + void copyFrom(Sampler* source) { LLMutexLock lock(&mSamplerMutex); { - mSampler.mergeFrom(source); + mSampler->mergeFrom(source); } } - void copyTo(Sampler& sink) + void copyTo(Sampler* sink) { LLMutexLock lock(&mSamplerMutex); { - sink.mergeFrom(mSampler); + sink->mergeFrom(mSampler); } } private: // add a cache line's worth of unused space to avoid any potential of false sharing LLMutex mSamplerMutex; - Sampler mSampler; + Sampler* mSampler; }; SharedData mSharedData; }; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index be7aae4eb7..29497257ac 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -31,6 +31,8 @@ #include "../llimageworker.h" // For timer class #include "../llcommon/lltimer.h" +// for lltrace class +#include "../llcommon/lltrace.h" // Tut header #include "../test/lltut.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index fcbef491fe..0bb87dfa6c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -60,7 +60,7 @@ #include "llcurl.h" #include "llcalc.h" #include "lltexturestats.h" -#include "lltexturestats.h" +#include "lltrace.h" #include "llviewerwindow.h" #include "llviewerdisplay.h" #include "llviewermedia.h" -- cgit v1.2.3 From b1baf982b1bd41a150233d0a28d3601226924c65 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sun, 30 Sep 2012 10:41:29 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages factored out lltrace::sampler into separate file added rudimentary lltrace support to llstatgraph made llstatgraph use param blocks more effectively moves initial set of stats over to lltrace removed windows.h #defines for min and max --- indra/llcommon/CMakeLists.txt | 2 + indra/llcommon/llapr.h | 2 + indra/llcommon/lltrace.cpp | 112 ++++++++++-------------------- indra/llcommon/lltrace.h | 127 +++++++++++----------------------- indra/llcommon/lltracesampler.cpp | 103 +++++++++++++++++++++++++++ indra/llcommon/lltracesampler.h | 91 ++++++++++++++++++++++++ indra/llrender/llglheaders.h | 2 + indra/llui/llstatbar.cpp | 79 +++++++++++++++------ indra/llui/llstatbar.h | 3 + indra/llui/llstatgraph.cpp | 123 +++++++++++++++++--------------- indra/llui/llstatgraph.h | 99 ++++++++++++++++++++++---- indra/newview/llstatusbar.cpp | 33 +++++---- indra/newview/llviewerstats.cpp | 38 ++++++---- indra/newview/llviewerstats.h | 20 ++++-- indra/newview/llviewertexturelist.cpp | 4 +- indra/newview/llworld.cpp | 3 +- 16 files changed, 553 insertions(+), 288 deletions(-) create mode 100644 indra/llcommon/lltracesampler.cpp create mode 100644 indra/llcommon/lltracesampler.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index f78751601c..e10dbb3e4d 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -101,6 +101,7 @@ set(llcommon_SOURCE_FILES llthreadsafequeue.cpp lltimer.cpp lltrace.cpp + lltracesampler.cpp lluri.cpp lluuid.cpp llworkerthread.cpp @@ -243,6 +244,7 @@ set(llcommon_HEADER_FILES llthreadsafequeue.h lltimer.h lltrace.h + lltracesampler.h lltreeiterators.h lltypeinfolookup.h lluri.h diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 830e0a33fa..4e704998c2 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -39,6 +39,8 @@ #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> + #undef min + #undef max #endif #include <boost/noncopyable.hpp> diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 2da4363b1d..e487e450a9 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lltrace.h" +#include "lltracesampler.h" #include "llthread.h" namespace LLTrace @@ -55,77 +56,6 @@ MasterThreadTrace& getMasterThreadTrace() return *gMasterThreadTrace; } -/////////////////////////////////////////////////////////////////////// -// Sampler -/////////////////////////////////////////////////////////////////////// - -Sampler::Sampler(ThreadTrace* thread_trace) -: mElapsedSeconds(0), - mIsStarted(false), - mThreadTrace(thread_trace) -{ -} - -Sampler::~Sampler() -{ -} - -void Sampler::start() -{ - reset(); - resume(); -} - -void Sampler::reset() -{ - mF32Stats.reset(); - mS32Stats.reset(); - mStackTimers.reset(); - - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); -} - -void Sampler::resume() -{ - if (!mIsStarted) - { - mSamplingTimer.reset(); - getThreadTrace()->activate(this); - mIsStarted = true; - } -} - -void Sampler::stop() -{ - if (mIsStarted) - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - getThreadTrace()->deactivate(this); - mIsStarted = false; - } -} - -ThreadTrace* Sampler::getThreadTrace() -{ - return mThreadTrace; -} - -void Sampler::makePrimary() -{ - mF32Stats.makePrimary(); - mS32Stats.makePrimary(); - mStackTimers.makePrimary(); -} - -void Sampler::mergeFrom( const Sampler* other ) -{ - mF32Stats.mergeFrom(other->mF32Stats); - mS32Stats.mergeFrom(other->mS32Stats); - mStackTimers.mergeFrom(other->mStackTimers); -} - - /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// @@ -148,6 +78,11 @@ ThreadTrace::~ThreadTrace() delete mPrimarySampler; } +Sampler* ThreadTrace::getPrimarySampler() +{ + return mPrimarySampler; +} + void ThreadTrace::activate( Sampler* sampler ) { flushPrimary(); @@ -205,6 +140,34 @@ void SlaveThreadTrace::pushToMaster() mSharedData.copyFrom(mPrimarySampler); } +void SlaveThreadTrace::SharedData::copyFrom( Sampler* source ) +{ + LLMutexLock lock(&mSamplerMutex); + { + mSampler->mergeFrom(source); + } +} + +void SlaveThreadTrace::SharedData::copyTo( Sampler* sink ) +{ + LLMutexLock lock(&mSamplerMutex); + { + sink->mergeFrom(mSampler); + } +} + +SlaveThreadTrace::SharedData::~SharedData() +{ + delete mSampler; +} + +SlaveThreadTrace::SharedData::SharedData( Sampler* sampler ) : mSampler(sampler) +{} + + + + + /////////////////////////////////////////////////////////////////////// // MasterThreadTrace /////////////////////////////////////////////////////////////////////// @@ -217,7 +180,7 @@ void MasterThreadTrace::pullFromSlaveThreads() it != end_it; ++it) { - it->mSlaveTrace->mSharedData.copyTo(it->mSamplerStorage); + (*it)->mSlaveTrace->mSharedData.copyTo((*it)->mSamplerStorage); } } @@ -225,7 +188,7 @@ void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(SlaveThreadTraceProxy(child, createSampler())); + mSlaveThreadTraces.push_back(new SlaveThreadTraceProxy(child, createSampler())); } void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) @@ -236,7 +199,7 @@ void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) it != end_it; ++it) { - if (it->mSlaveTrace == child) + if ((*it)->mSlaveTrace == child) { mSlaveThreadTraces.erase(it); break; @@ -266,5 +229,4 @@ MasterThreadTrace::SlaveThreadTraceProxy::~SlaveThreadTraceProxy() delete mSamplerStorage; } - } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index a443735e69..c6f920b5e4 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -43,14 +43,16 @@ namespace LLTrace { + class Sampler; + void init(); void cleanup(); - class MasterThreadTrace& getMasterThreadTrace(); + class LL_COMMON_API MasterThreadTrace& getMasterThreadTrace(); // one per thread per type template<typename ACCUMULATOR> - class AccumulatorBuffer + class LL_COMMON_API AccumulatorBuffer { static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; private: @@ -64,6 +66,8 @@ namespace LLTrace public: + // copying an accumulator buffer does not copy the actual contents, but simply initializes the buffer size + // to be identical to the other buffer AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) : mStorageSize(other.mStorageSize), mStorage(new ACCUMULATOR[other.mStorageSize]), @@ -150,28 +154,30 @@ namespace LLTrace template<typename ACCUMULATOR> LLThreadLocalPtr<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; template<typename ACCUMULATOR> - class Trace + class LL_COMMON_API TraceType { public: - Trace(const std::string& name) + TraceType(const std::string& name) : mName(name) { mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } - LL_FORCE_INLINE ACCUMULATOR& getAccumulator() + LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() { return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; } - private: + ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>& buffer) { return buffer[mAccumulatorIndex]; } + + protected: std::string mName; size_t mAccumulatorIndex; }; template<typename T> - class StatAccumulator + class LL_COMMON_API StatAccumulator { public: StatAccumulator() @@ -217,6 +223,11 @@ namespace LLTrace mMax = 0; } + T getSum() { return mSum; } + T getMin() { return mMin; } + T getMax() { return mMax; } + T getMean() { return mSum / (T)mNumSamples; } + private: T mSum, mMin, @@ -226,20 +237,23 @@ namespace LLTrace }; template <typename T> - class Stat : public Trace<StatAccumulator<T> > + class LL_COMMON_API Stat + : public TraceType<StatAccumulator<T> >, + public LLInstanceTracker<Stat<T>, std::string> { public: Stat(const std::string& name) - : Trace(name) + : TraceType(name), + LLInstanceTracker(name) {} void sample(T value) { - getAccumulator().sample(value); + getPrimaryAccumulator().sample(value); } }; - struct TimerAccumulator + struct LL_COMMON_API TimerAccumulator { U32 mTotalTimeCounter, mChildTimeCounter, @@ -267,11 +281,11 @@ namespace LLTrace }; - class BlockTimer : public Trace<TimerAccumulator> + class LL_COMMON_API BlockTimer : public TraceType<TimerAccumulator> { public: BlockTimer(const char* name) - : Trace(name) + : TraceType(name) {} struct Recorder @@ -287,7 +301,7 @@ namespace LLTrace : mLastRecorder(sCurRecorder) { mStartTime = getCPUClockCount32(); - TimerAccumulator* accumulator = &block_timer.getAccumulator(); // get per-thread accumulator + TimerAccumulator* accumulator = &block_timer.getPrimaryAccumulator(); // get per-thread accumulator accumulator->mActiveCount++; accumulator->mCalls++; accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); @@ -353,44 +367,7 @@ namespace LLTrace static Recorder::StackEntry sCurRecorder; }; - class Sampler - { - public: - ~Sampler(); - - void makePrimary(); - - void start(); - void stop(); - void resume(); - - void mergeFrom(const Sampler* other); - - void reset(); - - bool isStarted() { return mIsStarted; } - - private: - friend class ThreadTrace; - Sampler(class ThreadTrace* thread_trace); - - // no copy - Sampler(const Sampler& other) {} - // returns data for current thread - class ThreadTrace* getThreadTrace(); - - AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; - AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; - - AccumulatorBuffer<TimerAccumulator> mStackTimers; - - bool mIsStarted; - LLTimer mSamplingTimer; - F64 mElapsedSeconds; - ThreadTrace* mThreadTrace; - }; - - class ThreadTrace + class LL_COMMON_API ThreadTrace { public: ThreadTrace(); @@ -406,13 +383,13 @@ namespace LLTrace virtual void pushToMaster() = 0; - Sampler* getPrimarySampler() { return mPrimarySampler; } + Sampler* getPrimarySampler(); protected: Sampler* mPrimarySampler; std::list<Sampler*> mActiveSamplers; }; - class MasterThreadTrace : public ThreadTrace + class LL_COMMON_API MasterThreadTrace : public ThreadTrace { public: MasterThreadTrace(); @@ -433,14 +410,17 @@ namespace LLTrace ~SlaveThreadTraceProxy(); class SlaveThreadTrace* mSlaveTrace; Sampler* mSamplerStorage; + private: + //no need to copy these and then have to duplicate the storage + SlaveThreadTraceProxy(const SlaveThreadTraceProxy& other) {} }; - typedef std::list<SlaveThreadTraceProxy> slave_thread_trace_list_t; + typedef std::list<SlaveThreadTraceProxy*> slave_thread_trace_list_t; slave_thread_trace_list_t mSlaveThreadTraces; LLMutex mSlaveListMutex; }; - class SlaveThreadTrace : public ThreadTrace + class LL_COMMON_API SlaveThreadTrace : public ThreadTrace { public: SlaveThreadTrace(); @@ -457,31 +437,12 @@ namespace LLTrace { public: explicit - SharedData(Sampler* sampler) - : mSampler(sampler) - { - } + SharedData(Sampler* sampler); - ~SharedData() - { - delete mSampler; - } + ~SharedData(); - void copyFrom(Sampler* source) - { - LLMutexLock lock(&mSamplerMutex); - { - mSampler->mergeFrom(source); - } - } - - void copyTo(Sampler* sink) - { - LLMutexLock lock(&mSamplerMutex); - { - sink->mergeFrom(mSampler); - } - } + void copyFrom(Sampler* source); + void copyTo(Sampler* sink); private: // add a cache line's worth of unused space to avoid any potential of false sharing LLMutex mSamplerMutex; @@ -489,14 +450,6 @@ namespace LLTrace }; SharedData mSharedData; }; - - class TimeInterval - { - public: - void start() {} - void stop() {} - void resume() {} - }; } #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltracesampler.cpp b/indra/llcommon/lltracesampler.cpp new file mode 100644 index 0000000000..0cf01d7a3a --- /dev/null +++ b/indra/llcommon/lltracesampler.cpp @@ -0,0 +1,103 @@ +/** + * @file lltracesampler.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltracesampler.h" + +namespace LLTrace +{ + +/////////////////////////////////////////////////////////////////////// +// Sampler +/////////////////////////////////////////////////////////////////////// + +Sampler::Sampler(ThreadTrace* thread_trace) +: mElapsedSeconds(0), + mIsStarted(false), + mThreadTrace(thread_trace) +{ +} + +Sampler::~Sampler() +{ +} + +void Sampler::start() +{ + reset(); + resume(); +} + +void Sampler::reset() +{ + mF32Stats.reset(); + mS32Stats.reset(); + mStackTimers.reset(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + +void Sampler::resume() +{ + if (!mIsStarted) + { + mSamplingTimer.reset(); + getThreadTrace()->activate(this); + mIsStarted = true; + } +} + +void Sampler::stop() +{ + if (mIsStarted) + { + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + getThreadTrace()->deactivate(this); + mIsStarted = false; + } +} + +ThreadTrace* Sampler::getThreadTrace() +{ + return mThreadTrace; +} + +void Sampler::makePrimary() +{ + mF32Stats.makePrimary(); + mS32Stats.makePrimary(); + mStackTimers.makePrimary(); +} + +void Sampler::mergeFrom( const Sampler* other ) +{ + mF32Stats.mergeFrom(other->mF32Stats); + mS32Stats.mergeFrom(other->mS32Stats); + mStackTimers.mergeFrom(other->mStackTimers); +} + +} diff --git a/indra/llcommon/lltracesampler.h b/indra/llcommon/lltracesampler.h new file mode 100644 index 0000000000..d1ca7fc9bb --- /dev/null +++ b/indra/llcommon/lltracesampler.h @@ -0,0 +1,91 @@ +/** + * @file lltracesampler.h + * @brief Sampling object for collecting runtime statistics originating from lltrace. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTRACESAMPLER_H +#define LL_LLTRACESAMPLER_H + +#include "stdtypes.h" +#include "llpreprocessor.h" + +#include "lltrace.h" + +namespace LLTrace +{ + class LL_COMMON_API Sampler + { + public: + ~Sampler(); + + void makePrimary(); + + void start(); + void stop(); + void resume(); + + void mergeFrom(const Sampler* other); + + void reset(); + + bool isStarted() { return mIsStarted; } + + F32 getSum(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getSum(); } + F32 getMin(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMin(); } + F32 getMax(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMax(); } + F32 getMean(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMean(); } + + S32 getSum(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getSum(); } + S32 getMin(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMin(); } + S32 getMax(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMax(); } + S32 getMean(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMean(); } + + F64 getSampleTime() { return mElapsedSeconds; } + + private: + friend class ThreadTrace; + Sampler(class ThreadTrace* thread_trace); + + // no copy + Sampler(const Sampler& other) {} + // returns data for current thread + class ThreadTrace* getThreadTrace(); + + //TODO: take snapshot at sampler start so we can simplify updates + //AccumulatorBuffer<StatAccumulator<F32> > mF32StatsStart; + //AccumulatorBuffer<StatAccumulator<S32> > mS32StatsStart; + //AccumulatorBuffer<TimerAccumulator> mStackTimersStart; + + AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; + AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; + AccumulatorBuffer<TimerAccumulator> mStackTimers; + + bool mIsStarted; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + ThreadTrace* mThreadTrace; + }; +} + +#endif // LL_LLTRACESAMPLER_H diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 509de51f4d..605b424b35 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -543,6 +543,8 @@ extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> +#undef min +#undef max //---------------------------------------------------------------------------- #include <GL/gl.h> diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index a21d7aa6a1..2d1b582598 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -36,6 +36,7 @@ #include "llstat.h" #include "lluictrlfactory.h" +#include "lltracesampler.h" /////////////////////////////////////////////////////////////////////////////////// @@ -46,6 +47,8 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), + mFloatStatp(LLTrace::Stat<F32>::getInstance(p.stat)), + mIntStatp(LLTrace::Stat<S32>::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -84,30 +87,66 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) void LLStatBar::draw() { - if (!mStatp) + F32 current = 0.f, + min = 0.f, + max = 0.f, + mean = 0.f; + + if (mStatp) { -// llinfos << "No stats for statistics bar!" << llendl; - return; + // Get the values. + if (mPerSec) + { + current = mStatp->getCurrentPerSec(); + min = mStatp->getMinPerSec(); + max = mStatp->getMaxPerSec(); + mean = mStatp->getMeanPerSec(); + } + else + { + current = mStatp->getCurrent(); + min = mStatp->getMin(); + max = mStatp->getMax(); + mean = mStatp->getMean(); + } } - - // Get the values. - F32 current, min, max, mean; - if (mPerSec) + else if (mFloatStatp) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + if (mPerSec) + { + current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); + min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); + max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); + mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + } + else + { + current = sampler->getSum(*mFloatStatp); + min = sampler->getMin(*mFloatStatp); + max = sampler->getMax(*mFloatStatp); + mean = sampler->getMean(*mFloatStatp); + } } - else + else if (mIntStatp) { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + if (mPerSec) + { + current = (F32)sampler->getSum(*mIntStatp) / sampler->getSampleTime(); + min = (F32)sampler->getMin(*mIntStatp) / sampler->getSampleTime(); + max = (F32)sampler->getMax(*mIntStatp) / sampler->getSampleTime(); + mean = (F32)sampler->getMean(*mIntStatp) / sampler->getSampleTime(); + } + else + { + current = (F32)sampler->getSum(*mIntStatp); + min = (F32)sampler->getMin(*mIntStatp); + max = (F32)sampler->getMax(*mIntStatp); + mean = (F32)sampler->getMean(*mIntStatp); + } } - if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { if (mDisplayMean) @@ -153,7 +192,7 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar) + if (mDisplayBar && mStatp) { std::string tick_label; @@ -213,9 +252,9 @@ void LLStatBar::draw() right = (S32) ((max - mMinBar) * value_scale); gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); - S32 num_values = mStatp->getNumValues() - 1; if (mDisplayHistory) { + S32 num_values = mStatp->getNumValues() - 1; S32 i; for (i = 0; i < num_values; i++) { @@ -270,7 +309,7 @@ LLRect LLStatBar::getRequiredRect() if (mDisplayBar) { - if (mDisplayHistory) + if (mDisplayHistory && mStatp) { rect.mTop = 35 + mStatp->getNumBins(); } diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 7e636d0aa7..8348290abf 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -29,6 +29,7 @@ #include "llview.h" #include "llframetimer.h" +#include "lltrace.h" class LLStat; @@ -92,6 +93,8 @@ private: BOOL mDisplayMean; // If true, display mean, if false, display current value LLStat* mStatp; + LLTrace::Stat<F32>* mFloatStatp; + LLTrace::Stat<S32>* mIntStatp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index e44887ebf0..19896c4597 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -35,28 +35,38 @@ #include "llstat.h" #include "llgl.h" #include "llglheaders.h" +#include "lltracesampler.h" //#include "llviewercontrol.h" /////////////////////////////////////////////////////////////////////////////////// -LLStatGraph::LLStatGraph(const LLView::Params& p) -: LLView(p) +LLStatGraph::LLStatGraph(const Params& p) +: LLView(p), + mMin(p.min), + mMax(p.max), + mPerSec(true), + mPrecision(p.precision), + mValue(p.value), + mStatp(p.stat.legacy_stat), + mF32Statp(p.stat.f32_stat), + mS32Statp(p.stat.s32_stat) { - mStatp = NULL; setToolTip(p.name()); - mNumThresholds = 3; - mThresholdColors[0] = LLColor4(0.f, 1.f, 0.f, 1.f); - mThresholdColors[1] = LLColor4(1.f, 1.f, 0.f, 1.f); - mThresholdColors[2] = LLColor4(1.f, 0.f, 0.f, 1.f); - mThresholdColors[3] = LLColor4(1.f, 0.f, 0.f, 1.f); - mThresholds[0] = 50.f; - mThresholds[1] = 75.f; - mThresholds[2] = 100.f; - mMin = 0.f; - mMax = 125.f; - mPerSec = TRUE; - mValue = 0.f; - mPrecision = 0; + + for(LLInitParam::ParamIterator<ThresholdParams>::const_iterator it = p.thresholds.threshold.begin(), end_it = p.thresholds.threshold.end(); + it != end_it; + ++it) + { + mThresholds.push_back(Threshold(it->value(), it->color)); + } + + //mThresholdColors[0] = LLColor4(0.f, 1.f, 0.f, 1.f); + //mThresholdColors[1] = LLColor4(1.f, 1.f, 0.f, 1.f); + //mThresholdColors[2] = LLColor4(1.f, 0.f, 0.f, 1.f); + //mThresholdColors[3] = LLColor4(1.f, 0.f, 0.f, 1.f); + //mThresholds[0] = 50.f; + //mThresholds[1] = 75.f; + //mThresholds[2] = 100.f; } void LLStatGraph::draw() @@ -74,6 +84,33 @@ void LLStatGraph::draw() mValue = mStatp->getMean(); } } + else if (mF32Statp) + { + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + + if (mPerSec) + { + mValue = sampler->getSum(*mF32Statp) / sampler->getSampleTime(); + } + else + { + mValue = sampler->getSum(*mF32Statp); + } + + } + else if (mS32Statp) + { + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + + if (mPerSec) + { + mValue = sampler->getSum(*mS32Statp) / sampler->getSampleTime(); + } + else + { + mValue = sampler->getSum(*mS32Statp); + } + } frac = (mValue - mMin) / range; frac = llmax(0.f, frac); frac = llmin(1.f, frac); @@ -91,19 +128,22 @@ void LLStatGraph::draw() LLColor4 color; - S32 i; - for (i = 0; i < mNumThresholds - 1; i++) + //S32 i; + //for (i = 0; i < mNumThresholds - 1; i++) + //{ + // if (mThresholds[i] > mValue) + // { + // break; + // } + //} + + threshold_vec_t::iterator it = std::lower_bound(mThresholds.begin(), mThresholds.end(), Threshold(mValue / mMax, LLUIColor())); + + if (it != mThresholds.begin()) { - if (mThresholds[i] > mValue) - { - break; - } + it--; } - //gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, - // LLUIColorTable::instance().getColor("ColorDropShadow"), - // (S32) gSavedSettings.getF32("DropShadowFloater") ); - color = LLUIColorTable::instance().getColor( "MenuDefaultBgColor" ); gGL.color4fv(color.mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, TRUE); @@ -111,16 +151,11 @@ void LLStatGraph::draw() gGL.color4fv(LLColor4::black.mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, FALSE); - color = mThresholdColors[i]; + color = it->mColor; gGL.color4fv(color.mV); gl_rect_2d(1, llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE); } -void LLStatGraph::setValue(const LLSD& value) -{ - mValue = (F32)value.asReal(); -} - void LLStatGraph::setMin(const F32 min) { mMin = min; @@ -131,27 +166,3 @@ void LLStatGraph::setMax(const F32 max) mMax = max; } -void LLStatGraph::setStat(LLStat *statp) -{ - mStatp = statp; -} - -void LLStatGraph::setLabel(const std::string& label) -{ - mLabel = label; -} - -void LLStatGraph::setUnits(const std::string& units) -{ - mUnits = units; -} - -void LLStatGraph::setPrecision(const S32 precision) -{ - mPrecision = precision; -} - -void LLStatGraph::setThreshold(const S32 i, F32 value) -{ - mThresholds[i] = value; -} diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 757525e232..e7de945694 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -30,29 +30,88 @@ #include "llview.h" #include "llframetimer.h" #include "v4color.h" +#include "lltrace.h" class LLStat; class LLStatGraph : public LLView { public: - LLStatGraph(const LLView::Params&); + struct ThresholdParams : public LLInitParam::Block<ThresholdParams> + { + Mandatory<F32> value; + Optional<LLUIColor> color; - virtual void draw(); + ThresholdParams() + : value("value"), + color("color", LLColor4::white) + {} + }; + + struct Thresholds : public LLInitParam::Block<Thresholds> + { + Multiple<ThresholdParams> threshold; + + Thresholds() + : threshold("threshold") + {} + }; + + struct StatParams : public LLInitParam::ChoiceBlock<StatParams> + { + Alternative<LLStat*> legacy_stat; + Alternative<LLTrace::Stat<F32>* > f32_stat; + Alternative<LLTrace::Stat<S32>* > s32_stat; + }; + + struct Params : public LLInitParam::Block<Params, LLView::Params> + { + Mandatory<StatParams> stat; + Optional<std::string> label, + units; + Optional<S32> precision; + Optional<F32> min, + max; + Optional<bool> per_sec; + Optional<F32> value; + + Optional<Thresholds> thresholds; + + Params() + : stat("stat"), + label("label"), + units("units"), + precision("precision", 0), + min("min", 0.f), + max("max", 125.f), + per_sec("per_sec", true), + value("value", 0.f), + thresholds("thresholds") + { + Thresholds _thresholds; + _thresholds.threshold.add(ThresholdParams().value(0.f).color(LLColor4::green)) + .add(ThresholdParams().value(0.33f).color(LLColor4::yellow)) + .add(ThresholdParams().value(0.5f).color(LLColor4::red)) + .add(ThresholdParams().value(0.75f).color(LLColor4::red)); + thresholds = _thresholds; + } + }; + LLStatGraph(const Params&); - void setLabel(const std::string& label); - void setUnits(const std::string& units); - void setPrecision(const S32 precision); - void setStat(LLStat *statp); - void setThreshold(const S32 i, F32 value); void setMin(const F32 min); void setMax(const F32 max); + virtual void draw(); + /*virtual*/ void setValue(const LLSD& value); - LLStat *mStatp; - BOOL mPerSec; private: + LLStat* mStatp; + LLTrace::Stat<F32>* mF32Statp; + LLTrace::Stat<S32>* mS32Statp; + + BOOL mPerSec; + F32 mValue; F32 mMin; @@ -62,9 +121,25 @@ private: std::string mUnits; S32 mPrecision; // Num of digits of precision after dot - S32 mNumThresholds; - F32 mThresholds[4]; - LLColor4 mThresholdColors[4]; + struct Threshold + { + Threshold(F32 value, const LLUIColor& color) + : mValue(value), + mColor(color) + {} + + F32 mValue; + LLUIColor mColor; + bool operator <(const Threshold& other) + { + return mValue < other.mValue; + } + }; + typedef std::vector<Threshold> threshold_vec_t; + threshold_vec_t mThresholds; + //S32 mNumThresholds; + //F32 mThresholds[4]; + //LLColor4 mThresholdColors[4]; }; #endif // LL_LLSTATGRAPH_H diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 4892de9da0..9f499ef4ef 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -198,10 +198,10 @@ BOOL LLStatusBar::postBuild() sgp.rect(r); sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); sgp.mouse_opaque(false); + sgp.stat.f32_stat(&STAT_KBIT); + sgp.units("Kbps"); + sgp.precision(0); mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); - mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat); - mSGBandwidth->setUnits("Kbps"); - mSGBandwidth->setPrecision(0); addChild(mSGBandwidth); x -= SIM_STAT_WIDTH + 2; @@ -212,17 +212,20 @@ BOOL LLStatusBar::postBuild() pgp.rect(r); pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); pgp.mouse_opaque(false); + pgp.stat.legacy_stat(&LLViewerStats::getInstance()->mPacketsLostPercentStat); + pgp.units("%"); + pgp.min(0.f); + pgp.max(5.f); + pgp.precision(1); + pgp.per_sec(false); + LLStatGraph::Thresholds thresholds; + thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green)) + .add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow)) + .add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red)); + + pgp.thresholds(thresholds); mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp); - mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat); - mSGPacketLoss->setUnits("%"); - mSGPacketLoss->setMin(0.f); - mSGPacketLoss->setMax(5.f); - mSGPacketLoss->setThreshold(0, 0.5f); - mSGPacketLoss->setThreshold(1, 1.f); - mSGPacketLoss->setThreshold(2, 3.f); - mSGPacketLoss->setPrecision(1); - mSGPacketLoss->mPerSec = FALSE; addChild(mSGPacketLoss); mPanelVolumePulldown = new LLPanelVolumePulldown(); @@ -252,9 +255,9 @@ void LLStatusBar::refresh() F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f; mSGBandwidth->setMin(0.f); mSGBandwidth->setMax(bwtotal*1.25f); - mSGBandwidth->setThreshold(0, bwtotal*0.75f); - mSGBandwidth->setThreshold(1, bwtotal); - mSGBandwidth->setThreshold(2, bwtotal); + //mSGBandwidth->setThreshold(0, bwtotal*0.75f); + //mSGBandwidth->setThreshold(1, bwtotal); + //mSGBandwidth->setThreshold(2, bwtotal); } // update clock every 10 seconds diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index da87cc2673..b1aeaef91d 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -62,6 +62,13 @@ #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived +LLTrace::Stat<F32> STAT_KBIT("kbitstat"), + STAT_LAYERS_KBIT("layerskbitstat"), + STAT_OBJECT_KBIT("objectkbitstat"), + STAT_ASSET_KBIT("assetkbitstat"), + STAT_TEXTURE_KBIT("texturekbitstat"); + + class StatAttributes { public: @@ -198,11 +205,6 @@ const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] = }; LLViewerStats::LLViewerStats() : - mKBitStat("kbitstat"), - mLayersKBitStat("layerskbitstat"), - mObjectKBitStat("objectkbitstat"), - mAssetKBitStat("assetkbitstat"), - mTextureKBitStat("texturekbitstat"), mVFSPendingOperations("vfspendingoperations"), mFPSStat("fpsstat"), mPacketsInStat("packetsinstat"), @@ -261,7 +263,8 @@ LLViewerStats::LLViewerStats() : mNumNewObjectsStat("numnewobjectsstat"), mNumSizeCulledStat("numsizeculledstat"), mNumVisCulledStat("numvisculledstat"), - mLastTimeDiff(0.0) + mLastTimeDiff(0.0), + mSampler(LLThread::getTraceData()->createSampler()) { for (S32 i = 0; i < ST_COUNT; i++) { @@ -274,17 +277,18 @@ LLViewerStats::LLViewerStats() : } mAgentPositionSnaps.reset(); + mSampler->start(); +} + +LLViewerStats::~LLViewerStats() +{ + delete mSampler; } void LLViewerStats::resetStats() { LLViewerStats& stats = LLViewerStats::instance(); - stats.mKBitStat.reset(); - stats.mLayersKBitStat.reset(); - stats.mObjectKBitStat.reset(); - stats.mTextureKBitStat.reset(); stats.mVFSPendingOperations.reset(); - stats.mAssetKBitStat.reset(); stats.mPacketsInStat.reset(); stats.mPacketsLostStat.reset(); stats.mPacketsOutStat.reset(); @@ -463,10 +467,13 @@ void update_statistics() stats.mFPSStat.addValue(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - stats.mLayersKBitStat.addValue(layer_bits/1024.f); - stats.mObjectKBitStat.addValue(gObjectBits/1024.f); + STAT_LAYERS_KBIT.sample(layer_bits/1024.f); + //stats.mLayersKBitStat.addValue(layer_bits/1024.f); + STAT_OBJECT_KBIT.sample(gObjectBits/1024.f); + //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); - stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); + STAT_ASSET_KBIT.sample(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); + //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) @@ -503,7 +510,8 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); + STAT_TEXTURE_KBIT.sample(LLViewerTextureList::sTextureBits/1024.f); + //stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8; LLViewerTextureList::sTextureBits = 0; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 0d8f2a45c0..ca70660ce9 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -29,16 +29,18 @@ #include "llstat.h" #include "lltextureinfo.h" +#include "lltracesampler.h" + +extern LLTrace::Stat<F32> STAT_KBIT, + STAT_LAYERS_KBIT, + STAT_OBJECT_KBIT, + STAT_ASSET_KBIT, + STAT_TEXTURE_KBIT; class LLViewerStats : public LLSingleton<LLViewerStats> { public: - LLStat mKBitStat, - mLayersKBitStat, - mObjectKBitStat, - mAssetKBitStat, - mTextureKBitStat, - mVFSPendingOperations, + LLStat mVFSPendingOperations, mFPSStat, mPacketsInStat, mPacketsLostStat, @@ -110,7 +112,9 @@ public: mNumVisCulledStat; void resetStats(); + public: + // If you change this, please also add a corresponding text label in llviewerstats.cpp enum EStatType { @@ -177,6 +181,7 @@ public: }; LLViewerStats(); + ~LLViewerStats(); // all return latest value of given stat F64 getStat(EStatType type) const; @@ -292,8 +297,11 @@ public: static void recordPhaseStat(const std::string& phase_name, F32 value); }; + LLTrace::Sampler* getSampler() { return mSampler; } + private: F64 mStats[ST_COUNT]; + LLTrace::Sampler* mSampler; F64 mLastTimeDiff; // used for time stat updates }; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 17d8e5e4fa..034f8edf24 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -622,7 +622,9 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec()); + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + + LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime()); LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 43152c9025..97079e0588 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -704,7 +704,8 @@ void LLWorld::updateNetStats() S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); + STAT_KBIT.sample(bits/1024.f); + //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); -- cgit v1.2.3 From 14b1b0b2bb6bac5bc688cc4d14c33f1b680dd3b4 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 1 Oct 2012 19:39:04 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages cleaned up API samplers are now value types with copy-on-write buffers under the hood removed coupling with LLThread --- indra/llcommon/llapr.cpp | 28 +++--- indra/llcommon/llapr.h | 28 +++--- indra/llcommon/llpointer.h | 83 ++++++++++++---- indra/llcommon/llqueuedthread.cpp | 2 +- indra/llcommon/llthread.cpp | 15 +-- indra/llcommon/llthread.h | 9 -- indra/llcommon/lltrace.cpp | 108 +++++++++----------- indra/llcommon/lltrace.h | 180 +++++++++++++++++++++++++++------- indra/llcommon/lltracesampler.cpp | 98 ++++++++++++++---- indra/llcommon/lltracesampler.h | 59 ++++++----- indra/llui/llstatbar.cpp | 36 ++----- indra/llui/llstatbar.h | 4 +- indra/llui/llstatgraph.cpp | 17 +--- indra/llui/llstatgraph.h | 7 +- indra/newview/llstatusbar.cpp | 2 +- indra/newview/llviewerstats.cpp | 13 ++- indra/newview/llviewerstats.h | 2 +- indra/newview/llviewertexturelist.cpp | 2 +- indra/newview/llworld.cpp | 2 +- 19 files changed, 424 insertions(+), 271 deletions(-) diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index e9930c10f7..d23b70690d 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -55,7 +55,7 @@ void ll_init_apr() LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE); } - LLThreadLocalPtrBase::initAllThreadLocalStorage(); + LLThreadLocalPointerBase::initAllThreadLocalStorage(); } @@ -80,7 +80,7 @@ void ll_cleanup_apr() gCallStacksLogMutexp = NULL; } - LLThreadLocalPtrBase::destroyAllThreadLocalStorage(); + LLThreadLocalPointerBase::destroyAllThreadLocalStorage(); if (gAPRPoolp) { @@ -482,11 +482,11 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset) } // -//LLThreadLocalPtrBase +//LLThreadLocalPointerBase // -bool LLThreadLocalPtrBase::sInitialized = false; +bool LLThreadLocalPointerBase::sInitialized = false; -LLThreadLocalPtrBase::LLThreadLocalPtrBase() +LLThreadLocalPointerBase::LLThreadLocalPointerBase() : mThreadKey(NULL) { if (sInitialized) @@ -495,7 +495,7 @@ LLThreadLocalPtrBase::LLThreadLocalPtrBase() } } -LLThreadLocalPtrBase::LLThreadLocalPtrBase( const LLThreadLocalPtrBase& other) +LLThreadLocalPointerBase::LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) : mThreadKey(NULL) { if (sInitialized) @@ -504,12 +504,12 @@ LLThreadLocalPtrBase::LLThreadLocalPtrBase( const LLThreadLocalPtrBase& other) } } -LLThreadLocalPtrBase::~LLThreadLocalPtrBase() +LLThreadLocalPointerBase::~LLThreadLocalPointerBase() { destroyStorage(); } -void LLThreadLocalPtrBase::set( void* value ) +void LLThreadLocalPointerBase::set( void* value ) { llassert(sInitialized && mThreadKey); @@ -521,7 +521,7 @@ void LLThreadLocalPtrBase::set( void* value ) } } -void LLThreadLocalPtrBase::initStorage( ) +void LLThreadLocalPointerBase::initStorage( ) { apr_status_t result = apr_threadkey_private_create(&mThreadKey, NULL, gAPRPoolp); if (result != APR_SUCCESS) @@ -531,7 +531,7 @@ void LLThreadLocalPtrBase::initStorage( ) } } -void LLThreadLocalPtrBase::destroyStorage() +void LLThreadLocalPointerBase::destroyStorage() { if (sInitialized) { @@ -547,11 +547,11 @@ void LLThreadLocalPtrBase::destroyStorage() } } -void LLThreadLocalPtrBase::initAllThreadLocalStorage() +void LLThreadLocalPointerBase::initAllThreadLocalStorage() { if (!sInitialized) { - for (LLInstanceTracker<LLThreadLocalPtrBase>::instance_iter it = beginInstances(), end_it = endInstances(); + for (LLInstanceTracker<LLThreadLocalPointerBase>::instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { @@ -561,11 +561,11 @@ void LLThreadLocalPtrBase::initAllThreadLocalStorage() } } -void LLThreadLocalPtrBase::destroyAllThreadLocalStorage() +void LLThreadLocalPointerBase::destroyAllThreadLocalStorage() { if (sInitialized) { - for (LLInstanceTracker<LLThreadLocalPtrBase>::instance_iter it = beginInstances(), end_it = endInstances(); + for (LLInstanceTracker<LLThreadLocalPointerBase>::instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 4e704998c2..6efb44a663 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -258,12 +258,12 @@ public: //******************************************************************************************************************************* }; -class LLThreadLocalPtrBase : LLInstanceTracker<LLThreadLocalPtrBase> +class LLThreadLocalPointerBase : LLInstanceTracker<LLThreadLocalPointerBase> { public: - LLThreadLocalPtrBase(); - LLThreadLocalPtrBase(const LLThreadLocalPtrBase& other); - ~LLThreadLocalPtrBase(); + LLThreadLocalPointerBase(); + LLThreadLocalPointerBase(const LLThreadLocalPointerBase& other); + ~LLThreadLocalPointerBase(); static void initAllThreadLocalStorage(); static void destroyAllThreadLocalStorage(); @@ -307,35 +307,35 @@ protected: }; template <typename T> -class LLThreadLocalPtr : public LLThreadLocalPtrBase +class LLThreadLocalPointer : public LLThreadLocalPointerBase { public: - LLThreadLocalPtr() - : LLThreadLocalPtrBase() + LLThreadLocalPointer() + : LLThreadLocalPointerBase() {} - explicit LLThreadLocalPtr(T* value) - : LLThreadLocalPtrBase(&cleanup) + explicit LLThreadLocalPointer(T* value) + : LLThreadLocalPointerBase(&cleanup) { set(value); } - LLThreadLocalPtr(const LLThreadLocalPtr<T>& other) - : LLThreadLocalPtrBase(other, &cleanup) + LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) + : LLThreadLocalPointerBase(other, &cleanup) { set(other.get()); } LL_FORCE_INLINE T* get() { - return (T*)LLThreadLocalPtrBase::get(); + return (T*)LLThreadLocalPointerBase::get(); } const T* get() const { - return (const T*)LLThreadLocalPtrBase::get(); + return (const T*)LLThreadLocalPointerBase::get(); } T* operator -> () @@ -358,7 +358,7 @@ public: return *(T*)get(); } - LLThreadLocalPtr<T>& operator = (T* value) + LLThreadLocalPointer<T>& operator = (T* value) { set((void*)value); return *this; diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 88c09c8dca..0fee4f0990 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -97,24 +97,13 @@ public: LLPointer<Type>& operator =(Type* ptr) { - if( mPointer != ptr ) - { - unref(); - mPointer = ptr; - ref(); - } - + assign(ptr); return *this; } LLPointer<Type>& operator =(const LLPointer<Type>& ptr) { - if( mPointer != ptr.mPointer ) - { - unref(); - mPointer = ptr.mPointer; - ref(); - } + assign(ptr); return *this; } @@ -122,12 +111,7 @@ public: template<typename Subclass> LLPointer<Type>& operator =(const LLPointer<Subclass>& ptr) { - if( mPointer != ptr.get() ) - { - unref(); - mPointer = ptr.get(); - ref(); - } + assign(ptr.get()); return *this; } @@ -144,6 +128,16 @@ protected: void ref(); void unref(); #else + + void assign(const LLPointer<Type>& ptr) + { + if( mPointer != ptr.mPointer ) + { + unref(); + mPointer = ptr.mPointer; + ref(); + } + } void ref() { if (mPointer) @@ -156,9 +150,9 @@ protected: { if (mPointer) { - Type *tempp = mPointer; + Type *temp = mPointer; mPointer = NULL; - tempp->unref(); + temp->unref(); if (mPointer != NULL) { llwarns << "Unreference did assignment to non-NULL because of destructor" << llendl; @@ -171,4 +165,51 @@ protected: Type* mPointer; }; +template<typename Type> +class LLCopyOnWritePointer : public LLPointer<Type> +{ +public: + typedef LLPointer<Type> ref_pointer_t; + typedef LLCopyOnWritePointer<Type> self_t; + + LLCopyOnWritePointer() + { + } + + LLCopyOnWritePointer(Type* ptr) + : LLPointer(ptr) + { + } + + Type* write() + { + makeUnique(); + return mPointer; + } + + void makeUnique() + { + if (mPointer && mPointer->getNumRefs() > 1) + { + ref_pointer_t::assign(new Type(*mPointer)); + } + } + + using ref_pointer_t::operator BOOL; + using ref_pointer_t::operator bool; + using ref_pointer_t::operator!; + + using ref_pointer_t::operator !=; + using ref_pointer_t::operator ==; + using LLPointer<Type>::operator =; + + using LLPointer<Type>::operator <; + using LLPointer<Type>::operator >; + + + operator const Type*() const { return mPointer; } + const Type* operator->() const { return mPointer; } + +}; + #endif diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 0a35474b7f..9aa449d037 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -112,7 +112,7 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(F32 max_time_ms) { - LLThread::getTraceData()->pushToMaster(); + LLTrace::get_thread_trace()->pushToMaster(); if (!mStarted) { diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 7384842627..c705e5103b 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -67,7 +67,6 @@ U32 __thread LLThread::sThreadID = 0; #endif U32 LLThread::sIDIter = 0; -LLThreadLocalPtr<LLTrace::ThreadTrace> LLThread::sTraceData; LL_COMMON_API void assert_main_thread() @@ -86,7 +85,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - setTraceData(new LLTrace::SlaveThreadTrace()); + LLTrace::ThreadTrace* thread_trace = new LLTrace::SlaveThreadTrace(); #if !LL_DARWIN sThreadIndex = threadp->mID; @@ -100,8 +99,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap // We're done with the run function, this thread is done executing now. threadp->mStatus = STOPPED; - delete sTraceData.get(); - sTraceData = NULL; + delete thread_trace; return NULL; } @@ -314,12 +312,3 @@ void LLThread::wakeLocked() } } -LLTrace::ThreadTrace* LLThread::getTraceData() -{ - return sTraceData.get(); -} - -void LLThread::setTraceData( LLTrace::ThreadTrace* data ) -{ - sTraceData = data; -} diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 334ea2f0da..82ab5f47d2 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,10 +32,6 @@ #include "apr_thread_cond.h" #include "llmutex.h" -namespace LLTrace -{ - class ThreadTrace; -} class LL_COMMON_API LLThread { private: @@ -91,9 +87,6 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTrace* getTraceData(); - static void setTraceData(LLTrace::ThreadTrace* data); - private: BOOL mPaused; @@ -110,8 +103,6 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr<LLTrace::ThreadTrace> sTraceData; - //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index e487e450a9..04817fd4f4 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -27,7 +27,6 @@ #include "lltrace.h" #include "lltracesampler.h" -#include "llthread.h" namespace LLTrace { @@ -45,6 +44,12 @@ void cleanup() gMasterThreadTrace = NULL; } +LLThreadLocalPointer<ThreadTrace>& get_thread_trace() +{ + static LLThreadLocalPointer<ThreadTrace> s_trace_data; + return s_trace_data; + +} BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; @@ -62,36 +67,52 @@ MasterThreadTrace& getMasterThreadTrace() ThreadTrace::ThreadTrace() { - mPrimarySampler = createSampler(); - mPrimarySampler->makePrimary(); - mPrimarySampler->start(); + get_thread_trace() = this; + mPrimarySampler.makePrimary(); + mTotalSampler.start(); } ThreadTrace::ThreadTrace( const ThreadTrace& other ) -: mPrimarySampler(new Sampler(*(other.mPrimarySampler))) +: mPrimarySampler(other.mPrimarySampler), + mTotalSampler(other.mTotalSampler) { - mPrimarySampler->makePrimary(); + get_thread_trace() = this; + mPrimarySampler.makePrimary(); + mTotalSampler.start(); } ThreadTrace::~ThreadTrace() { - delete mPrimarySampler; + get_thread_trace() = NULL; } +//TODO: remove this and use llviewerstats sampler Sampler* ThreadTrace::getPrimarySampler() { - return mPrimarySampler; + return &mPrimarySampler; } void ThreadTrace::activate( Sampler* sampler ) { - flushPrimary(); - mActiveSamplers.push_back(sampler); + for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); + it != end_it; + ++it) + { + (*it)->mMeasurements.write()->mergeSamples(*mPrimarySampler.mMeasurements); + } + mPrimarySampler.mMeasurements.write()->reset(); + + sampler->initDeltas(mPrimarySampler); + + mActiveSamplers.push_front(sampler); } +//TODO: consider merging results down the list to one past the buffered item. +// this would require 2 buffers per sampler, to separate current total from running total + void ThreadTrace::deactivate( Sampler* sampler ) { - sampler->mergeFrom(mPrimarySampler); + sampler->mergeDeltas(mPrimarySampler); // TODO: replace with intrusive list std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); @@ -101,31 +122,12 @@ void ThreadTrace::deactivate( Sampler* sampler ) } } -void ThreadTrace::flushPrimary() -{ - for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); - it != end_it; - ++it) - { - (*it)->mergeFrom(mPrimarySampler); - } - mPrimarySampler->reset(); -} - -Sampler* ThreadTrace::createSampler() -{ - return new Sampler(this); -} - - - /////////////////////////////////////////////////////////////////////// // SlaveThreadTrace /////////////////////////////////////////////////////////////////////// SlaveThreadTrace::SlaveThreadTrace() -: ThreadTrace(getMasterThreadTrace()), - mSharedData(createSampler()) +: ThreadTrace(getMasterThreadTrace()) { getMasterThreadTrace().addSlaveThread(this); } @@ -137,34 +139,26 @@ SlaveThreadTrace::~SlaveThreadTrace() void SlaveThreadTrace::pushToMaster() { - mSharedData.copyFrom(mPrimarySampler); -} - -void SlaveThreadTrace::SharedData::copyFrom( Sampler* source ) -{ - LLMutexLock lock(&mSamplerMutex); - { - mSampler->mergeFrom(source); + mTotalSampler.stop(); + { + LLMutexLock(getMasterThreadTrace().getSlaveListMutex()); + mSharedData.copyFrom(mTotalSampler); } + mTotalSampler.start(); } -void SlaveThreadTrace::SharedData::copyTo( Sampler* sink ) +void SlaveThreadTrace::SharedData::copyFrom( const Sampler& source ) { LLMutexLock lock(&mSamplerMutex); - { - sink->mergeFrom(mSampler); - } + mSampler.mergeSamples(source); } -SlaveThreadTrace::SharedData::~SharedData() +void SlaveThreadTrace::SharedData::copyTo( Sampler& sink ) { - delete mSampler; + LLMutexLock lock(&mSamplerMutex); + sink.mergeSamples(mSampler); } -SlaveThreadTrace::SharedData::SharedData( Sampler* sampler ) : mSampler(sampler) -{} - - @@ -188,7 +182,7 @@ void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(new SlaveThreadTraceProxy(child, createSampler())); + mSlaveThreadTraces.push_back(new SlaveThreadTraceProxy(child)); } void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) @@ -211,22 +205,14 @@ void MasterThreadTrace::pushToMaster() {} MasterThreadTrace::MasterThreadTrace() -{ - LLThread::setTraceData(this); -} +{} /////////////////////////////////////////////////////////////////////// // MasterThreadTrace::SlaveThreadTraceProxy /////////////////////////////////////////////////////////////////////// -MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace, Sampler* storage ) -: mSlaveTrace(trace), - mSamplerStorage(storage) +MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace) +: mSlaveTrace(trace) {} -MasterThreadTrace::SlaveThreadTraceProxy::~SlaveThreadTraceProxy() -{ - delete mSamplerStorage; -} - } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index c6f920b5e4..5ec1c821c3 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -33,6 +33,8 @@ #include "llmutex.h" #include "llmemory.h" #include "lltimer.h" +#include "llrefcount.h" +#include "lltracesampler.h" #include <list> @@ -48,11 +50,13 @@ namespace LLTrace void init(); void cleanup(); + LLThreadLocalPointer<class ThreadTrace>& get_thread_trace(); + class LL_COMMON_API MasterThreadTrace& getMasterThreadTrace(); // one per thread per type template<typename ACCUMULATOR> - class LL_COMMON_API AccumulatorBuffer + class LL_COMMON_API AccumulatorBuffer : public LLRefCount { static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; private: @@ -88,13 +92,23 @@ namespace LLTrace return mStorage[index]; } - void mergeFrom(const AccumulatorBuffer<ACCUMULATOR>& other) + void mergeSamples(const AccumulatorBuffer<ACCUMULATOR>& other) { llassert(mNextStorageSlot == other.mNextStorageSlot); for (size_t i = 0; i < mNextStorageSlot; i++) { - mStorage[i].mergeFrom(other.mStorage[i]); + mStorage[i].mergeSamples(other.mStorage[i]); + } + } + + void mergeDeltas(const AccumulatorBuffer<ACCUMULATOR>& start, const AccumulatorBuffer<ACCUMULATOR>& finish) + { + llassert(mNextStorageSlot == start.mNextStorageSlot && mNextStorageSlot == finish.mNextStorageSlot); + + for (size_t i = 0; i < mNextStorageSlot; i++) + { + mStorage[i].mergeDeltas(start.mStorage[i], finish.mStorage[i]); } } @@ -119,6 +133,11 @@ namespace LLTrace sPrimaryStorage = mStorage; } + bool isPrimary() const + { + return sPrimaryStorage == mStorage; + } + LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage() { return sPrimaryStorage.get(); @@ -149,9 +168,9 @@ namespace LLTrace ACCUMULATOR* mStorage; size_t mStorageSize; size_t mNextStorageSlot; - static LLThreadLocalPtr<ACCUMULATOR> sPrimaryStorage; + static LLThreadLocalPointer<ACCUMULATOR> sPrimaryStorage; }; - template<typename ACCUMULATOR> LLThreadLocalPtr<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; + template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; template<typename ACCUMULATOR> class LL_COMMON_API TraceType @@ -168,7 +187,7 @@ namespace LLTrace return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; } - ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>& buffer) { return buffer[mAccumulatorIndex]; } + ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) { return (*buffer)[mAccumulatorIndex]; } protected: std::string mName; @@ -177,10 +196,10 @@ namespace LLTrace template<typename T> - class LL_COMMON_API StatAccumulator + class LL_COMMON_API MeasurementAccumulator { public: - StatAccumulator() + MeasurementAccumulator() : mSum(0), mMin(0), mMax(0), @@ -199,9 +218,12 @@ namespace LLTrace { mMax = value; } + F32 old_mean = mMean; + mMean += ((F32)value - old_mean) / (F32)mNumSamples; + mStandardDeviation += ((F32)value - old_mean) * ((F32)value - mMean); } - void mergeFrom(const StatAccumulator<T>& other) + void mergeSamples(const MeasurementAccumulator<T>& other) { mSum += other.mSum; if (other.mMin < mMin) @@ -213,6 +235,28 @@ namespace LLTrace mMax = other.mMax; } mNumSamples += other.mNumSamples; + F32 weight = (F32)mNumSamples / (F32)(mNumSamples + other.mNumSamples); + mMean = mMean * weight + other.mMean * (1.f - weight); + + F32 n_1 = (F32)mNumSamples, + n_2 = (F32)other.mNumSamples; + F32 m_1 = mMean, + m_2 = other.mMean; + F32 sd_1 = mStandardDeviation, + sd_2 = other.mStandardDeviation; + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F32 variance = ((((n_1 - 1.f) * sd_1 * sd_1) + + ((n_2 - 1.f) * sd_2 * sd_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + mStandardDeviation = sqrtf(variance); + } + + void mergeDeltas(const MeasurementAccumulator<T>& start, const MeasurementAccumulator<T>& finish) + { + llerrs << "Delta merge invalid for measurement accumulators" << llendl; } void reset() @@ -226,23 +270,68 @@ namespace LLTrace T getSum() { return mSum; } T getMin() { return mMin; } T getMax() { return mMax; } - T getMean() { return mSum / (T)mNumSamples; } + F32 getMean() { return mMean; } + F32 getStandardDeviation() { return mStandardDeviation; } private: T mSum, mMin, mMax; + F32 mMean, + mStandardDeviation; + + U32 mNumSamples; + }; + + template<typename T> + class LL_COMMON_API RateAccumulator + { + public: + RateAccumulator() + : mSum(0), + mNumSamples(0) + {} + + LL_FORCE_INLINE void add(T value) + { + mNumSamples++; + mSum += value; + } + + void mergeSamples(const RateAccumulator<T>& other) + { + mSum += other.mSum; + mNumSamples += other.mNumSamples; + } + + void mergeDeltas(const RateAccumulator<T>& start, const RateAccumulator<T>& finish) + { + mSum += finish.mSum - start.mSum; + mNumSamples += finish.mNumSamples - start.mNumSamples; + } + + void reset() + { + mNumSamples = 0; + mSum = 0; + } + + T getSum() { return mSum; } + + private: + T mSum; + U32 mNumSamples; }; template <typename T> - class LL_COMMON_API Stat - : public TraceType<StatAccumulator<T> >, - public LLInstanceTracker<Stat<T>, std::string> + class LL_COMMON_API Measurement + : public TraceType<MeasurementAccumulator<T> >, + public LLInstanceTracker<Measurement<T>, std::string> { public: - Stat(const std::string& name) + Measurement(const std::string& name) : TraceType(name), LLInstanceTracker(name) {} @@ -253,11 +342,30 @@ namespace LLTrace } }; - struct LL_COMMON_API TimerAccumulator + template <typename T> + class LL_COMMON_API Rate + : public TraceType<RateAccumulator<T> >, + public LLInstanceTracker<Rate<T>, std::string> { + public: + Rate(const std::string& name) + : TraceType(name), + LLInstanceTracker(name) + {} + + void add(T value) + { + getPrimaryAccumulator().add(value); + } + }; + + class LL_COMMON_API TimerAccumulator + { + public: U32 mTotalTimeCounter, mChildTimeCounter, mCalls; + TimerAccumulator* mParent; // info for caller timer TimerAccumulator* mLastCaller; // used to bootstrap tree construction const class BlockTimer* mTimer; // points to block timer associated with this storage @@ -265,13 +373,20 @@ namespace LLTrace bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame std::vector<TimerAccumulator*> mChildren; // currently assumed child timers - void mergeFrom(const TimerAccumulator& other) + void mergeSamples(const TimerAccumulator& other) { mTotalTimeCounter += other.mTotalTimeCounter; mChildTimeCounter += other.mChildTimeCounter; mCalls += other.mCalls; } + void mergeDeltas(const TimerAccumulator& start, const TimerAccumulator& finish) + { + mTotalTimeCounter += finish.mTotalTimeCounter - start.mTotalTimeCounter; + mChildTimeCounter += finish.mChildTimeCounter - start.mChildTimeCounter; + mCalls += finish.mCalls - start.mCalls; + } + void reset() { mTotalTimeCounter = 0; @@ -377,15 +492,13 @@ namespace LLTrace void activate(Sampler* sampler); void deactivate(Sampler* sampler); - void flushPrimary(); - - Sampler* createSampler(); virtual void pushToMaster() = 0; Sampler* getPrimarySampler(); protected: - Sampler* mPrimarySampler; + Sampler mPrimarySampler; + Sampler mTotalSampler; std::list<Sampler*> mActiveSamplers; }; @@ -402,14 +515,15 @@ namespace LLTrace // call this periodically to gather stats data from slave threads void pullFromSlaveThreads(); + LLMutex* getSlaveListMutex() { return &mSlaveListMutex; } + private: struct SlaveThreadTraceProxy { - SlaveThreadTraceProxy(class SlaveThreadTrace* trace, Sampler* storage); + SlaveThreadTraceProxy(class SlaveThreadTrace* trace); - ~SlaveThreadTraceProxy(); class SlaveThreadTrace* mSlaveTrace; - Sampler* mSamplerStorage; + Sampler mSamplerStorage; private: //no need to copy these and then have to duplicate the storage SlaveThreadTraceProxy(const SlaveThreadTraceProxy& other) {} @@ -431,24 +545,16 @@ namespace LLTrace MasterThreadTrace* mMaster; - // this data is accessed by other threads, so give it a 64 byte alignment - // to avoid false sharing on most x86 processors - LL_ALIGNED(64) class SharedData + class SharedData { public: - explicit - SharedData(Sampler* sampler); - - ~SharedData(); - - void copyFrom(Sampler* source); - void copyTo(Sampler* sink); + void copyFrom(const Sampler& source); + void copyTo(Sampler& sink); private: - // add a cache line's worth of unused space to avoid any potential of false sharing - LLMutex mSamplerMutex; - Sampler* mSampler; + LLMutex mSamplerMutex; + Sampler mSampler; }; - SharedData mSharedData; + SharedData mSharedData; }; } diff --git a/indra/llcommon/lltracesampler.cpp b/indra/llcommon/lltracesampler.cpp index 0cf01d7a3a..17e58b96e2 100644 --- a/indra/llcommon/lltracesampler.cpp +++ b/indra/llcommon/lltracesampler.cpp @@ -26,6 +26,8 @@ #include "linden_common.h" #include "lltracesampler.h" +#include "lltrace.h" +#include "llthread.h" namespace LLTrace { @@ -34,10 +36,14 @@ namespace LLTrace // Sampler /////////////////////////////////////////////////////////////////////// -Sampler::Sampler(ThreadTrace* thread_trace) +Sampler::Sampler() : mElapsedSeconds(0), mIsStarted(false), - mThreadTrace(thread_trace) + mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()), + mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), + mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), + mStackTimers(new AccumulatorBuffer<TimerAccumulator>()), + mStackTimersStart(new AccumulatorBuffer<TimerAccumulator>()) { } @@ -53,9 +59,9 @@ void Sampler::start() void Sampler::reset() { - mF32Stats.reset(); - mS32Stats.reset(); - mStackTimers.reset(); + mRates.write()->reset(); + mMeasurements.write()->reset(); + mStackTimers.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -66,7 +72,7 @@ void Sampler::resume() if (!mIsStarted) { mSamplingTimer.reset(); - getThreadTrace()->activate(this); + LLTrace::get_thread_trace()->activate(this); mIsStarted = true; } } @@ -76,28 +82,86 @@ void Sampler::stop() if (mIsStarted) { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - getThreadTrace()->deactivate(this); + LLTrace::get_thread_trace()->deactivate(this); mIsStarted = false; } } -ThreadTrace* Sampler::getThreadTrace() + +void Sampler::makePrimary() { - return mThreadTrace; + mRates.write()->makePrimary(); + mMeasurements.write()->makePrimary(); + mStackTimers.write()->makePrimary(); } -void Sampler::makePrimary() +bool Sampler::isPrimary() +{ + return mRates->isPrimary(); +} + +void Sampler::mergeSamples( const Sampler& other ) +{ + mRates.write()->mergeSamples(*other.mRates); + mMeasurements.write()->mergeSamples(*other.mMeasurements); + mStackTimers.write()->mergeSamples(*other.mStackTimers); +} + +void Sampler::initDeltas( const Sampler& other ) +{ + mRatesStart.write()->copyFrom(*other.mRates); + mStackTimersStart.write()->copyFrom(*other.mStackTimers); +} + + +void Sampler::mergeDeltas( const Sampler& other ) +{ + mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); + mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); + mMeasurements.write()->mergeSamples(*other.mMeasurements); +} + + +F32 Sampler::getSum( Rate<F32>& stat ) { - mF32Stats.makePrimary(); - mS32Stats.makePrimary(); - mStackTimers.makePrimary(); + return stat.getAccumulator(mRates).getSum(); } -void Sampler::mergeFrom( const Sampler* other ) +F32 Sampler::getSum( Measurement<F32>& stat ) { - mF32Stats.mergeFrom(other->mF32Stats); - mS32Stats.mergeFrom(other->mS32Stats); - mStackTimers.mergeFrom(other->mStackTimers); + return stat.getAccumulator(mMeasurements).getSum(); } + +F32 Sampler::getPerSec( Rate<F32>& stat ) +{ + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; +} + +F32 Sampler::getMin( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F32 Sampler::getMax( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F32 Sampler::getMean( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F32 Sampler::getStandardDeviation( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + + + + + + + } diff --git a/indra/llcommon/lltracesampler.h b/indra/llcommon/lltracesampler.h index d1ca7fc9bb..e3498fb39f 100644 --- a/indra/llcommon/lltracesampler.h +++ b/indra/llcommon/lltracesampler.h @@ -30,61 +30,70 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "lltrace.h" +#include "llpointer.h" +#include "lltimer.h" namespace LLTrace { + template<typename T> class Rate; + template<typename T> class Measurement; + template<typename T> class AccumulatorBuffer; + template<typename T> class RateAccumulator; + template<typename T> class MeasurementAccumulator; + class TimerAccumulator; + class LL_COMMON_API Sampler { public: + Sampler(); + ~Sampler(); void makePrimary(); + bool isPrimary(); void start(); void stop(); void resume(); - void mergeFrom(const Sampler* other); + void mergeSamples(const Sampler& other); + void initDeltas(const Sampler& other); + void mergeDeltas(const Sampler& other); void reset(); bool isStarted() { return mIsStarted; } - F32 getSum(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getSum(); } - F32 getMin(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMin(); } - F32 getMax(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMax(); } - F32 getMean(Stat<F32>& stat) { return stat.getAccumulator(mF32Stats).getMean(); } + F32 getSum(Rate<F32>& stat); + F32 getPerSec(Rate<F32>& stat); - S32 getSum(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getSum(); } - S32 getMin(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMin(); } - S32 getMax(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMax(); } - S32 getMean(Stat<S32>& stat) { return stat.getAccumulator(mS32Stats).getMean(); } + F32 getSum(Measurement<F32>& stat); + F32 getMin(Measurement<F32>& stat); + F32 getMax(Measurement<F32>& stat); + F32 getMean(Measurement<F32>& stat); + F32 getStandardDeviation(Measurement<F32>& stat); F64 getSampleTime() { return mElapsedSeconds; } private: friend class ThreadTrace; - Sampler(class ThreadTrace* thread_trace); - - // no copy - Sampler(const Sampler& other) {} // returns data for current thread class ThreadTrace* getThreadTrace(); - //TODO: take snapshot at sampler start so we can simplify updates - //AccumulatorBuffer<StatAccumulator<F32> > mF32StatsStart; - //AccumulatorBuffer<StatAccumulator<S32> > mS32StatsStart; - //AccumulatorBuffer<TimerAccumulator> mStackTimersStart; + LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRatesStart; + LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates; + LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; + LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimersStart; + LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; - AccumulatorBuffer<StatAccumulator<F32> > mF32Stats; - AccumulatorBuffer<StatAccumulator<S32> > mS32Stats; - AccumulatorBuffer<TimerAccumulator> mStackTimers; + bool mIsStarted; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + }; + + class LL_COMMON_API PeriodicSampler + { - bool mIsStarted; - LLTimer mSamplingTimer; - F64 mElapsedSeconds; - ThreadTrace* mThreadTrace; }; } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2d1b582598..1f8be3da62 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -47,8 +47,7 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), - mFloatStatp(LLTrace::Stat<F32>::getInstance(p.stat)), - mIntStatp(LLTrace::Stat<S32>::getInstance(p.stat)), + mFloatStatp(LLTrace::Rate<F32>::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -112,40 +111,23 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); if (mPerSec) { current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); - min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); - max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); - mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + //min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); + //max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); + //mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); } else { current = sampler->getSum(*mFloatStatp); - min = sampler->getMin(*mFloatStatp); - max = sampler->getMax(*mFloatStatp); - mean = sampler->getMean(*mFloatStatp); - } - } - else if (mIntStatp) - { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); - if (mPerSec) - { - current = (F32)sampler->getSum(*mIntStatp) / sampler->getSampleTime(); - min = (F32)sampler->getMin(*mIntStatp) / sampler->getSampleTime(); - max = (F32)sampler->getMax(*mIntStatp) / sampler->getSampleTime(); - mean = (F32)sampler->getMean(*mIntStatp) / sampler->getSampleTime(); - } - else - { - current = (F32)sampler->getSum(*mIntStatp); - min = (F32)sampler->getMin(*mIntStatp); - max = (F32)sampler->getMax(*mIntStatp); - mean = (F32)sampler->getMean(*mIntStatp); + //min = sampler->getMin(*mFloatStatp); + //max = sampler->getMax(*mFloatStatp); + //mean = sampler->getMean(*mFloatStatp); } } + if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 8348290abf..c735e7045b 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -36,6 +36,7 @@ class LLStat; class LLStatBar : public LLView { public: + struct Params : public LLInitParam::Block<Params, LLView::Params> { Optional<std::string> label; @@ -93,8 +94,7 @@ private: BOOL mDisplayMean; // If true, display mean, if false, display current value LLStat* mStatp; - LLTrace::Stat<F32>* mFloatStatp; - LLTrace::Stat<S32>* mIntStatp; + LLTrace::Rate<F32>* mFloatStatp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index 19896c4597..e0d7623999 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -48,8 +48,7 @@ LLStatGraph::LLStatGraph(const Params& p) mPrecision(p.precision), mValue(p.value), mStatp(p.stat.legacy_stat), - mF32Statp(p.stat.f32_stat), - mS32Statp(p.stat.s32_stat) + mF32Statp(p.stat.rate_stat) { setToolTip(p.name()); @@ -86,7 +85,7 @@ void LLStatGraph::draw() } else if (mF32Statp) { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); if (mPerSec) { @@ -98,19 +97,7 @@ void LLStatGraph::draw() } } - else if (mS32Statp) - { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); - if (mPerSec) - { - mValue = sampler->getSum(*mS32Statp) / sampler->getSampleTime(); - } - else - { - mValue = sampler->getSum(*mS32Statp); - } - } frac = (mValue - mMin) / range; frac = llmax(0.f, frac); frac = llmin(1.f, frac); diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index e7de945694..69fc36ea52 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -60,8 +60,7 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { Alternative<LLStat*> legacy_stat; - Alternative<LLTrace::Stat<F32>* > f32_stat; - Alternative<LLTrace::Stat<S32>* > s32_stat; + Alternative<LLTrace::Rate<F32>* > rate_stat; }; struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -107,8 +106,8 @@ public: private: LLStat* mStatp; - LLTrace::Stat<F32>* mF32Statp; - LLTrace::Stat<S32>* mS32Statp; + LLTrace::Rate<F32>* mF32Statp; + LLTrace::Rate<S32>* mS32Statp; BOOL mPerSec; diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 9f499ef4ef..ab97d6465a 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild() sgp.rect(r); sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); sgp.mouse_opaque(false); - sgp.stat.f32_stat(&STAT_KBIT); + sgp.stat.rate_stat(&STAT_KBIT); sgp.units("Kbps"); sgp.precision(0); mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index b1aeaef91d..e2b09a1902 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -62,7 +62,7 @@ #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived -LLTrace::Stat<F32> STAT_KBIT("kbitstat"), +LLTrace::Rate<F32> STAT_KBIT("kbitstat"), STAT_LAYERS_KBIT("layerskbitstat"), STAT_OBJECT_KBIT("objectkbitstat"), STAT_ASSET_KBIT("assetkbitstat"), @@ -263,8 +263,7 @@ LLViewerStats::LLViewerStats() : mNumNewObjectsStat("numnewobjectsstat"), mNumSizeCulledStat("numsizeculledstat"), mNumVisCulledStat("numvisculledstat"), - mLastTimeDiff(0.0), - mSampler(LLThread::getTraceData()->createSampler()) + mLastTimeDiff(0.0) { for (S32 i = 0; i < ST_COUNT; i++) { @@ -467,12 +466,12 @@ void update_statistics() stats.mFPSStat.addValue(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - STAT_LAYERS_KBIT.sample(layer_bits/1024.f); + STAT_LAYERS_KBIT.add(layer_bits/1024.f); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - STAT_OBJECT_KBIT.sample(gObjectBits/1024.f); + STAT_OBJECT_KBIT.add(gObjectBits/1024.f); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); - STAT_ASSET_KBIT.sample(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); + STAT_ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -510,7 +509,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - STAT_TEXTURE_KBIT.sample(LLViewerTextureList::sTextureBits/1024.f); + STAT_TEXTURE_KBIT.add(LLViewerTextureList::sTextureBits/1024.f); //stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index ca70660ce9..9e809dd08c 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -31,7 +31,7 @@ #include "lltextureinfo.h" #include "lltracesampler.h" -extern LLTrace::Stat<F32> STAT_KBIT, +extern LLTrace::Rate<F32> STAT_KBIT, STAT_LAYERS_KBIT, STAT_OBJECT_KBIT, STAT_ASSET_KBIT, diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 034f8edf24..21a83b1676 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -622,7 +622,7 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + LLTrace::Sampler* sampler = LLTrace::getThreadTrace()->getPrimarySampler(); LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime()); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 97079e0588..1e8665e229 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -704,7 +704,7 @@ void LLWorld::updateNetStats() S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - STAT_KBIT.sample(bits/1024.f); + STAT_KBIT.add(bits/1024.f); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); -- cgit v1.2.3 From dbe9742703cf14db85ec3d16c540efc68dce95a6 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 2 Oct 2012 15:37:16 -0700 Subject: SH-3404 create sampler class renamed LLTrace::ThreadTrace to LLTrace::ThreadRecorder renamed LLTrace::Sampler to LLTrace::Recording --- indra/llcommon/CMakeLists.txt | 4 +- indra/llcommon/llapr.cpp | 23 ----- indra/llcommon/llapr.h | 26 +++++- indra/llcommon/llqueuedthread.cpp | 2 +- indra/llcommon/llthread.cpp | 4 +- indra/llcommon/lltrace.cpp | 143 ++++++++++++++--------------- indra/llcommon/lltrace.h | 66 +++++++------- indra/llcommon/lltracerecording.cpp | 167 ++++++++++++++++++++++++++++++++++ indra/llcommon/lltracerecording.h | 100 ++++++++++++++++++++ indra/llcommon/lltracesampler.cpp | 167 ---------------------------------- indra/llcommon/lltracesampler.h | 100 -------------------- indra/llui/llstatbar.cpp | 20 ++-- indra/llui/llstatgraph.cpp | 8 +- indra/newview/llappviewer.cpp | 2 +- indra/newview/llviewerstats.cpp | 3 +- indra/newview/llviewerstats.h | 7 +- indra/newview/llviewertexturelist.cpp | 4 +- 17 files changed, 419 insertions(+), 427 deletions(-) create mode 100644 indra/llcommon/lltracerecording.cpp create mode 100644 indra/llcommon/lltracerecording.h delete mode 100644 indra/llcommon/lltracesampler.cpp delete mode 100644 indra/llcommon/lltracesampler.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index e10dbb3e4d..1ccee23e1e 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -101,7 +101,7 @@ set(llcommon_SOURCE_FILES llthreadsafequeue.cpp lltimer.cpp lltrace.cpp - lltracesampler.cpp + lltracerecording.cpp lluri.cpp lluuid.cpp llworkerthread.cpp @@ -244,7 +244,7 @@ set(llcommon_HEADER_FILES llthreadsafequeue.h lltimer.h lltrace.h - lltracesampler.h + lltracerecording.h lltreeiterators.h lltypeinfolookup.h lluri.h diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d23b70690d..1db3aa9e89 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -486,29 +486,6 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset) // bool LLThreadLocalPointerBase::sInitialized = false; -LLThreadLocalPointerBase::LLThreadLocalPointerBase() -: mThreadKey(NULL) -{ - if (sInitialized) - { - initStorage(); - } -} - -LLThreadLocalPointerBase::LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) -: mThreadKey(NULL) -{ - if (sInitialized) - { - initStorage(); - } -} - -LLThreadLocalPointerBase::~LLThreadLocalPointerBase() -{ - destroyStorage(); -} - void LLThreadLocalPointerBase::set( void* value ) { llassert(sInitialized && mThreadKey); diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 6efb44a663..821274aeb3 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -261,9 +261,28 @@ public: class LLThreadLocalPointerBase : LLInstanceTracker<LLThreadLocalPointerBase> { public: - LLThreadLocalPointerBase(); - LLThreadLocalPointerBase(const LLThreadLocalPointerBase& other); - ~LLThreadLocalPointerBase(); + LLThreadLocalPointerBase() + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + ~LLThreadLocalPointerBase() + { + destroyStorage(); + } static void initAllThreadLocalStorage(); static void destroyAllThreadLocalStorage(); @@ -312,7 +331,6 @@ class LLThreadLocalPointer : public LLThreadLocalPointerBase public: LLThreadLocalPointer() - : LLThreadLocalPointerBase() {} explicit LLThreadLocalPointer(T* value) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 9aa449d037..6e2a2b140f 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -112,7 +112,7 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(F32 max_time_ms) { - LLTrace::get_thread_trace()->pushToMaster(); + LLTrace::get_thread_recorder()->pushToMaster(); if (!mStarted) { diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index c705e5103b..6723e427f5 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -85,7 +85,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - LLTrace::ThreadTrace* thread_trace = new LLTrace::SlaveThreadTrace(); + LLTrace::ThreadRecorder* thread_recorder = new LLTrace::SlaveThreadRecorder(); #if !LL_DARWIN sThreadIndex = threadp->mID; @@ -99,7 +99,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap // We're done with the run function, this thread is done executing now. threadp->mStatus = STOPPED; - delete thread_trace; + delete thread_recorder; return NULL; } diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 04817fd4f4..6b4c3aeb06 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -26,28 +26,28 @@ #include "linden_common.h" #include "lltrace.h" -#include "lltracesampler.h" +#include "lltracerecording.h" namespace LLTrace { -static MasterThreadTrace* gMasterThreadTrace = NULL; +static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { - gMasterThreadTrace = new MasterThreadTrace(); + gMasterThreadRecorder = new MasterThreadRecorder(); } void cleanup() { - delete gMasterThreadTrace; - gMasterThreadTrace = NULL; + delete gMasterThreadRecorder; + gMasterThreadRecorder = NULL; } -LLThreadLocalPointer<ThreadTrace>& get_thread_trace() +LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() { - static LLThreadLocalPointer<ThreadTrace> s_trace_data; - return s_trace_data; + static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; + return s_thread_recorder; } @@ -55,164 +55,161 @@ BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; -MasterThreadTrace& getMasterThreadTrace() +MasterThreadRecorder& getMasterThreadRecorder() { - llassert(gMasterThreadTrace != NULL); - return *gMasterThreadTrace; + llassert(gMasterThreadRecorder != NULL); + return *gMasterThreadRecorder; } /////////////////////////////////////////////////////////////////////// -// MasterThreadTrace +// ThreadRecorder /////////////////////////////////////////////////////////////////////// -ThreadTrace::ThreadTrace() +ThreadRecorder::ThreadRecorder() { - get_thread_trace() = this; - mPrimarySampler.makePrimary(); - mTotalSampler.start(); + get_thread_recorder() = this; + mPrimaryRecording.makePrimary(); + mFullRecording.start(); } -ThreadTrace::ThreadTrace( const ThreadTrace& other ) -: mPrimarySampler(other.mPrimarySampler), - mTotalSampler(other.mTotalSampler) +ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) +: mPrimaryRecording(other.mPrimaryRecording), + mFullRecording(other.mFullRecording) { - get_thread_trace() = this; - mPrimarySampler.makePrimary(); - mTotalSampler.start(); + get_thread_recorder() = this; + mPrimaryRecording.makePrimary(); + mFullRecording.start(); } -ThreadTrace::~ThreadTrace() +ThreadRecorder::~ThreadRecorder() { - get_thread_trace() = NULL; + get_thread_recorder() = NULL; } -//TODO: remove this and use llviewerstats sampler -Sampler* ThreadTrace::getPrimarySampler() +//TODO: remove this and use llviewerstats recording +Recording* ThreadRecorder::getPrimaryRecording() { - return &mPrimarySampler; + return &mPrimaryRecording; } -void ThreadTrace::activate( Sampler* sampler ) +void ThreadRecorder::activate( Recording* recorder ) { - for (std::list<Sampler*>::iterator it = mActiveSamplers.begin(), end_it = mActiveSamplers.end(); + for (std::list<Recording*>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); it != end_it; ++it) { - (*it)->mMeasurements.write()->mergeSamples(*mPrimarySampler.mMeasurements); + (*it)->mMeasurements.write()->mergeSamples(*mPrimaryRecording.mMeasurements); } - mPrimarySampler.mMeasurements.write()->reset(); + mPrimaryRecording.mMeasurements.write()->reset(); - sampler->initDeltas(mPrimarySampler); + recorder->initDeltas(mPrimaryRecording); - mActiveSamplers.push_front(sampler); + mActiveRecordings.push_front(recorder); } //TODO: consider merging results down the list to one past the buffered item. // this would require 2 buffers per sampler, to separate current total from running total -void ThreadTrace::deactivate( Sampler* sampler ) +void ThreadRecorder::deactivate( Recording* recorder ) { - sampler->mergeDeltas(mPrimarySampler); + recorder->mergeDeltas(mPrimaryRecording); // TODO: replace with intrusive list - std::list<Sampler*>::iterator found_it = std::find(mActiveSamplers.begin(), mActiveSamplers.end(), sampler); - if (found_it != mActiveSamplers.end()) + std::list<Recording*>::iterator found_it = std::find(mActiveRecordings.begin(), mActiveRecordings.end(), recorder); + if (found_it != mActiveRecordings.end()) { - mActiveSamplers.erase(found_it); + mActiveRecordings.erase(found_it); } } /////////////////////////////////////////////////////////////////////// -// SlaveThreadTrace +// SlaveThreadRecorder /////////////////////////////////////////////////////////////////////// -SlaveThreadTrace::SlaveThreadTrace() -: ThreadTrace(getMasterThreadTrace()) +SlaveThreadRecorder::SlaveThreadRecorder() +: ThreadRecorder(getMasterThreadRecorder()) { - getMasterThreadTrace().addSlaveThread(this); + getMasterThreadRecorder().addSlaveThread(this); } -SlaveThreadTrace::~SlaveThreadTrace() +SlaveThreadRecorder::~SlaveThreadRecorder() { - getMasterThreadTrace().removeSlaveThread(this); + getMasterThreadRecorder().removeSlaveThread(this); } -void SlaveThreadTrace::pushToMaster() +void SlaveThreadRecorder::pushToMaster() { - mTotalSampler.stop(); + mFullRecording.stop(); { - LLMutexLock(getMasterThreadTrace().getSlaveListMutex()); - mSharedData.copyFrom(mTotalSampler); + LLMutexLock(getMasterThreadRecorder().getSlaveListMutex()); + mSharedData.copyFrom(mFullRecording); } - mTotalSampler.start(); + mFullRecording.start(); } -void SlaveThreadTrace::SharedData::copyFrom( const Sampler& source ) +void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) { - LLMutexLock lock(&mSamplerMutex); - mSampler.mergeSamples(source); + LLMutexLock lock(&mRecorderMutex); + mRecorder.mergeSamples(source); } -void SlaveThreadTrace::SharedData::copyTo( Sampler& sink ) +void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) { - LLMutexLock lock(&mSamplerMutex); - sink.mergeSamples(mSampler); + LLMutexLock lock(&mRecorderMutex); + sink.mergeSamples(mRecorder); } - - - /////////////////////////////////////////////////////////////////////// -// MasterThreadTrace +// MasterThreadRecorder /////////////////////////////////////////////////////////////////////// -void MasterThreadTrace::pullFromSlaveThreads() +void MasterThreadRecorder::pullFromSlaveThreads() { LLMutexLock lock(&mSlaveListMutex); - for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); it != end_it; ++it) { - (*it)->mSlaveTrace->mSharedData.copyTo((*it)->mSamplerStorage); + (*it)->mRecorder->mSharedData.copyTo((*it)->mSlaveRecording); } } -void MasterThreadTrace::addSlaveThread( class SlaveThreadTrace* child ) +void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadTraces.push_back(new SlaveThreadTraceProxy(child)); + mSlaveThreadRecorders.push_back(new SlaveThreadRecorderProxy(child)); } -void MasterThreadTrace::removeSlaveThread( class SlaveThreadTrace* child ) +void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) { LLMutexLock lock(&mSlaveListMutex); - for (slave_thread_trace_list_t::iterator it = mSlaveThreadTraces.begin(), end_it = mSlaveThreadTraces.end(); + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); it != end_it; ++it) { - if ((*it)->mSlaveTrace == child) + if ((*it)->mRecorder == child) { - mSlaveThreadTraces.erase(it); + mSlaveThreadRecorders.erase(it); break; } } } -void MasterThreadTrace::pushToMaster() +void MasterThreadRecorder::pushToMaster() {} -MasterThreadTrace::MasterThreadTrace() +MasterThreadRecorder::MasterThreadRecorder() {} /////////////////////////////////////////////////////////////////////// -// MasterThreadTrace::SlaveThreadTraceProxy +// MasterThreadRecorder::SlaveThreadTraceProxy /////////////////////////////////////////////////////////////////////// -MasterThreadTrace::SlaveThreadTraceProxy::SlaveThreadTraceProxy( class SlaveThreadTrace* trace) -: mSlaveTrace(trace) +MasterThreadRecorder::SlaveThreadRecorderProxy::SlaveThreadRecorderProxy( class SlaveThreadRecorder* recorder) +: mRecorder(recorder) {} } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 5ec1c821c3..c5356777ae 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -34,7 +34,7 @@ #include "llmemory.h" #include "lltimer.h" #include "llrefcount.h" -#include "lltracesampler.h" +#include "lltracerecording.h" #include <list> @@ -45,14 +45,14 @@ namespace LLTrace { - class Sampler; + class Recording; void init(); void cleanup(); - LLThreadLocalPointer<class ThreadTrace>& get_thread_trace(); + LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); - class LL_COMMON_API MasterThreadTrace& getMasterThreadTrace(); + class LL_COMMON_API MasterThreadRecorder& getMasterThreadRecorder(); // one per thread per type template<typename ACCUMULATOR> @@ -482,33 +482,33 @@ namespace LLTrace static Recorder::StackEntry sCurRecorder; }; - class LL_COMMON_API ThreadTrace + class LL_COMMON_API ThreadRecorder { public: - ThreadTrace(); - ThreadTrace(const ThreadTrace& other); + ThreadRecorder(); + ThreadRecorder(const ThreadRecorder& other); - virtual ~ThreadTrace(); + virtual ~ThreadRecorder(); - void activate(Sampler* sampler); - void deactivate(Sampler* sampler); + void activate(Recording* recording); + void deactivate(Recording* recording); virtual void pushToMaster() = 0; - Sampler* getPrimarySampler(); + Recording* getPrimaryRecording(); protected: - Sampler mPrimarySampler; - Sampler mTotalSampler; - std::list<Sampler*> mActiveSamplers; + Recording mPrimaryRecording; + Recording mFullRecording; + std::list<Recording*> mActiveRecordings; }; - class LL_COMMON_API MasterThreadTrace : public ThreadTrace + class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder { public: - MasterThreadTrace(); + MasterThreadRecorder(); - void addSlaveThread(class SlaveThreadTrace* child); - void removeSlaveThread(class SlaveThreadTrace* child); + void addSlaveThread(class SlaveThreadRecorder* child); + void removeSlaveThread(class SlaveThreadRecorder* child); /*virtual */ void pushToMaster(); @@ -518,41 +518,41 @@ namespace LLTrace LLMutex* getSlaveListMutex() { return &mSlaveListMutex; } private: - struct SlaveThreadTraceProxy + struct SlaveThreadRecorderProxy { - SlaveThreadTraceProxy(class SlaveThreadTrace* trace); + SlaveThreadRecorderProxy(class SlaveThreadRecorder* recorder); - class SlaveThreadTrace* mSlaveTrace; - Sampler mSamplerStorage; + class SlaveThreadRecorder* mRecorder; + Recording mSlaveRecording; private: //no need to copy these and then have to duplicate the storage - SlaveThreadTraceProxy(const SlaveThreadTraceProxy& other) {} + SlaveThreadRecorderProxy(const SlaveThreadRecorderProxy& other) {} }; - typedef std::list<SlaveThreadTraceProxy*> slave_thread_trace_list_t; + typedef std::list<SlaveThreadRecorderProxy*> slave_thread_recorder_list_t; - slave_thread_trace_list_t mSlaveThreadTraces; + slave_thread_recorder_list_t mSlaveThreadRecorders; LLMutex mSlaveListMutex; }; - class LL_COMMON_API SlaveThreadTrace : public ThreadTrace + class LL_COMMON_API SlaveThreadRecorder : public ThreadRecorder { public: - SlaveThreadTrace(); - ~SlaveThreadTrace(); + SlaveThreadRecorder(); + ~SlaveThreadRecorder(); // call this periodically to gather stats data for master thread to consume /*virtual*/ void pushToMaster(); - MasterThreadTrace* mMaster; + MasterThreadRecorder* mMaster; class SharedData { public: - void copyFrom(const Sampler& source); - void copyTo(Sampler& sink); + void copyFrom(const Recording& source); + void copyTo(Recording& sink); private: - LLMutex mSamplerMutex; - Sampler mSampler; + LLMutex mRecorderMutex; + Recording mRecorder; }; SharedData mSharedData; }; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp new file mode 100644 index 0000000000..a792d40f9d --- /dev/null +++ b/indra/llcommon/lltracerecording.cpp @@ -0,0 +1,167 @@ +/** + * @file lltracesampler.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltracerecording.h" +#include "lltrace.h" +#include "llthread.h" + +namespace LLTrace +{ + +/////////////////////////////////////////////////////////////////////// +// Recording +/////////////////////////////////////////////////////////////////////// + +Recording::Recording() +: mElapsedSeconds(0), + mIsStarted(false), + mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()), + mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), + mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), + mStackTimers(new AccumulatorBuffer<TimerAccumulator>()), + mStackTimersStart(new AccumulatorBuffer<TimerAccumulator>()) +{ +} + +Recording::~Recording() +{ +} + +void Recording::start() +{ + reset(); + resume(); +} + +void Recording::reset() +{ + mRates.write()->reset(); + mMeasurements.write()->reset(); + mStackTimers.write()->reset(); + + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + +void Recording::resume() +{ + if (!mIsStarted) + { + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); + mIsStarted = true; + } +} + +void Recording::stop() +{ + if (mIsStarted) + { + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); + mIsStarted = false; + } +} + + +void Recording::makePrimary() +{ + mRates.write()->makePrimary(); + mMeasurements.write()->makePrimary(); + mStackTimers.write()->makePrimary(); +} + +bool Recording::isPrimary() +{ + return mRates->isPrimary(); +} + +void Recording::mergeSamples( const Recording& other ) +{ + mRates.write()->mergeSamples(*other.mRates); + mMeasurements.write()->mergeSamples(*other.mMeasurements); + mStackTimers.write()->mergeSamples(*other.mStackTimers); +} + +void Recording::initDeltas( const Recording& other ) +{ + mRatesStart.write()->copyFrom(*other.mRates); + mStackTimersStart.write()->copyFrom(*other.mStackTimers); +} + + +void Recording::mergeDeltas( const Recording& other ) +{ + mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); + mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); + mMeasurements.write()->mergeSamples(*other.mMeasurements); +} + + +F32 Recording::getSum( Rate<F32>& stat ) +{ + return stat.getAccumulator(mRates).getSum(); +} + +F32 Recording::getSum( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getSum(); +} + + +F32 Recording::getPerSec( Rate<F32>& stat ) +{ + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; +} + +F32 Recording::getMin( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F32 Recording::getMax( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F32 Recording::getMean( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F32 Recording::getStandardDeviation( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + + + + + + + +} diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h new file mode 100644 index 0000000000..83dc503ea6 --- /dev/null +++ b/indra/llcommon/lltracerecording.h @@ -0,0 +1,100 @@ +/** + * @file lltracerecording.h + * @brief Sampling object for collecting runtime statistics originating from lltrace. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTRACERECORDING_H +#define LL_LLTRACERECORDING_H + +#include "stdtypes.h" +#include "llpreprocessor.h" + +#include "llpointer.h" +#include "lltimer.h" + +namespace LLTrace +{ + template<typename T> class Rate; + template<typename T> class Measurement; + template<typename T> class AccumulatorBuffer; + template<typename T> class RateAccumulator; + template<typename T> class MeasurementAccumulator; + class TimerAccumulator; + + class LL_COMMON_API Recording + { + public: + Recording(); + + ~Recording(); + + void makePrimary(); + bool isPrimary(); + + void start(); + void stop(); + void resume(); + + void mergeSamples(const Recording& other); + void initDeltas(const Recording& other); + void mergeDeltas(const Recording& other); + + void reset(); + + bool isStarted() { return mIsStarted; } + + F32 getSum(Rate<F32>& stat); + F32 getPerSec(Rate<F32>& stat); + + F32 getSum(Measurement<F32>& stat); + F32 getMin(Measurement<F32>& stat); + F32 getMax(Measurement<F32>& stat); + F32 getMean(Measurement<F32>& stat); + F32 getStandardDeviation(Measurement<F32>& stat); + + F64 getSampleTime() { return mElapsedSeconds; } + + private: + friend class ThreadRecorder; + // returns data for current thread + class ThreadRecorder* getThreadRecorder(); + + LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRatesStart; + LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates; + LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; + LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimersStart; + LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; + + bool mIsStarted; + LLTimer mSamplingTimer; + F64 mElapsedSeconds; + }; + + class LL_COMMON_API PeriodicRecording + { + + }; +} + +#endif // LL_LLTRACERECORDING_H diff --git a/indra/llcommon/lltracesampler.cpp b/indra/llcommon/lltracesampler.cpp deleted file mode 100644 index 17e58b96e2..0000000000 --- a/indra/llcommon/lltracesampler.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @file lltracesampler.cpp - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "lltracesampler.h" -#include "lltrace.h" -#include "llthread.h" - -namespace LLTrace -{ - -/////////////////////////////////////////////////////////////////////// -// Sampler -/////////////////////////////////////////////////////////////////////// - -Sampler::Sampler() -: mElapsedSeconds(0), - mIsStarted(false), - mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()), - mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), - mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), - mStackTimers(new AccumulatorBuffer<TimerAccumulator>()), - mStackTimersStart(new AccumulatorBuffer<TimerAccumulator>()) -{ -} - -Sampler::~Sampler() -{ -} - -void Sampler::start() -{ - reset(); - resume(); -} - -void Sampler::reset() -{ - mRates.write()->reset(); - mMeasurements.write()->reset(); - mStackTimers.write()->reset(); - - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); -} - -void Sampler::resume() -{ - if (!mIsStarted) - { - mSamplingTimer.reset(); - LLTrace::get_thread_trace()->activate(this); - mIsStarted = true; - } -} - -void Sampler::stop() -{ - if (mIsStarted) - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_trace()->deactivate(this); - mIsStarted = false; - } -} - - -void Sampler::makePrimary() -{ - mRates.write()->makePrimary(); - mMeasurements.write()->makePrimary(); - mStackTimers.write()->makePrimary(); -} - -bool Sampler::isPrimary() -{ - return mRates->isPrimary(); -} - -void Sampler::mergeSamples( const Sampler& other ) -{ - mRates.write()->mergeSamples(*other.mRates); - mMeasurements.write()->mergeSamples(*other.mMeasurements); - mStackTimers.write()->mergeSamples(*other.mStackTimers); -} - -void Sampler::initDeltas( const Sampler& other ) -{ - mRatesStart.write()->copyFrom(*other.mRates); - mStackTimersStart.write()->copyFrom(*other.mStackTimers); -} - - -void Sampler::mergeDeltas( const Sampler& other ) -{ - mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); - mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); - mMeasurements.write()->mergeSamples(*other.mMeasurements); -} - - -F32 Sampler::getSum( Rate<F32>& stat ) -{ - return stat.getAccumulator(mRates).getSum(); -} - -F32 Sampler::getSum( Measurement<F32>& stat ) -{ - return stat.getAccumulator(mMeasurements).getSum(); -} - - -F32 Sampler::getPerSec( Rate<F32>& stat ) -{ - return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; -} - -F32 Sampler::getMin( Measurement<F32>& stat ) -{ - return stat.getAccumulator(mMeasurements).getMin(); -} - -F32 Sampler::getMax( Measurement<F32>& stat ) -{ - return stat.getAccumulator(mMeasurements).getMax(); -} - -F32 Sampler::getMean( Measurement<F32>& stat ) -{ - return stat.getAccumulator(mMeasurements).getMean(); -} - -F32 Sampler::getStandardDeviation( Measurement<F32>& stat ) -{ - return stat.getAccumulator(mMeasurements).getStandardDeviation(); -} - - - - - - - -} diff --git a/indra/llcommon/lltracesampler.h b/indra/llcommon/lltracesampler.h deleted file mode 100644 index e3498fb39f..0000000000 --- a/indra/llcommon/lltracesampler.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file lltracesampler.h - * @brief Sampling object for collecting runtime statistics originating from lltrace. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLTRACESAMPLER_H -#define LL_LLTRACESAMPLER_H - -#include "stdtypes.h" -#include "llpreprocessor.h" - -#include "llpointer.h" -#include "lltimer.h" - -namespace LLTrace -{ - template<typename T> class Rate; - template<typename T> class Measurement; - template<typename T> class AccumulatorBuffer; - template<typename T> class RateAccumulator; - template<typename T> class MeasurementAccumulator; - class TimerAccumulator; - - class LL_COMMON_API Sampler - { - public: - Sampler(); - - ~Sampler(); - - void makePrimary(); - bool isPrimary(); - - void start(); - void stop(); - void resume(); - - void mergeSamples(const Sampler& other); - void initDeltas(const Sampler& other); - void mergeDeltas(const Sampler& other); - - void reset(); - - bool isStarted() { return mIsStarted; } - - F32 getSum(Rate<F32>& stat); - F32 getPerSec(Rate<F32>& stat); - - F32 getSum(Measurement<F32>& stat); - F32 getMin(Measurement<F32>& stat); - F32 getMax(Measurement<F32>& stat); - F32 getMean(Measurement<F32>& stat); - F32 getStandardDeviation(Measurement<F32>& stat); - - F64 getSampleTime() { return mElapsedSeconds; } - - private: - friend class ThreadTrace; - // returns data for current thread - class ThreadTrace* getThreadTrace(); - - LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRatesStart; - LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates; - LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; - LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimersStart; - LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; - - bool mIsStarted; - LLTimer mSamplingTimer; - F64 mElapsedSeconds; - }; - - class LL_COMMON_API PeriodicSampler - { - - }; -} - -#endif // LL_LLTRACESAMPLER_H diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 1f8be3da62..bc9603804b 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -36,7 +36,7 @@ #include "llstat.h" #include "lluictrlfactory.h" -#include "lltracesampler.h" +#include "lltracerecording.h" /////////////////////////////////////////////////////////////////////////////////// @@ -111,20 +111,20 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); + LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); if (mPerSec) { - current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); - //min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); - //max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); - //mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + current = recording->getSum(*mFloatStatp) / recording->getSampleTime(); + //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); + //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); + //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); } else { - current = sampler->getSum(*mFloatStatp); - //min = sampler->getMin(*mFloatStatp); - //max = sampler->getMax(*mFloatStatp); - //mean = sampler->getMean(*mFloatStatp); + current = recording->getSum(*mFloatStatp); + //min = recording->getMin(*mFloatStatp); + //max = recording->getMax(*mFloatStatp); + //mean = recording->getMean(*mFloatStatp); } } diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index e0d7623999..aed9e4ec93 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -35,7 +35,7 @@ #include "llstat.h" #include "llgl.h" #include "llglheaders.h" -#include "lltracesampler.h" +#include "lltracerecording.h" //#include "llviewercontrol.h" /////////////////////////////////////////////////////////////////////////////////// @@ -85,15 +85,15 @@ void LLStatGraph::draw() } else if (mF32Statp) { - LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); + LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); if (mPerSec) { - mValue = sampler->getSum(*mF32Statp) / sampler->getSampleTime(); + mValue = recording->getSum(*mF32Statp) / recording->getSampleTime(); } else { - mValue = sampler->getSum(*mF32Statp); + mValue = recording->getSum(*mF32Statp); } } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 0bb87dfa6c..22f3cce9e8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop() { LLFastTimer _(FTM_FRAME); LLFastTimer::nextFrame(); - LLTrace::getMasterThreadTrace().pullFromSlaveThreads(); + LLTrace::getMasterThreadRecorder().pullFromSlaveThreads(); //clear call stack records llclearcallstacks; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index e2b09a1902..a6e9643edd 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -276,12 +276,11 @@ LLViewerStats::LLViewerStats() : } mAgentPositionSnaps.reset(); - mSampler->start(); + mRecording.start(); } LLViewerStats::~LLViewerStats() { - delete mSampler; } void LLViewerStats::resetStats() diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 9e809dd08c..ca5f6c6821 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -29,7 +29,8 @@ #include "llstat.h" #include "lltextureinfo.h" -#include "lltracesampler.h" +#include "lltracerecording.h" +#include "lltrace.h" extern LLTrace::Rate<F32> STAT_KBIT, STAT_LAYERS_KBIT, @@ -297,11 +298,11 @@ public: static void recordPhaseStat(const std::string& phase_name, F32 value); }; - LLTrace::Sampler* getSampler() { return mSampler; } + LLTrace::Recording& getRecording() { return mRecording; } private: F64 mStats[ST_COUNT]; - LLTrace::Sampler* mSampler; + LLTrace::Recording mRecording; F64 mLastTimeDiff; // used for time stat updates }; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 21a83b1676..4e62cbd714 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -622,9 +622,9 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLTrace::Sampler* sampler = LLTrace::getThreadTrace()->getPrimarySampler(); + LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); - LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime()); + LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(STAT_TEXTURE_KBIT)); LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); -- cgit v1.2.3 From 7196619b4a0823a332e10b7f98464a1649e0dfd2 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 2 Oct 2012 17:14:12 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible implemented minimal merging logic made recordings ligher weight by moving live tracking data into threadrecorder --- indra/llcommon/lltrace.cpp | 78 ++++++++++++++++++++++++++----------- indra/llcommon/lltrace.h | 14 ++++++- indra/llcommon/lltracerecording.cpp | 24 +++--------- indra/llcommon/lltracerecording.h | 5 +-- 4 files changed, 75 insertions(+), 46 deletions(-) diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 6b4c3aeb06..6d928721de 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -66,18 +66,17 @@ MasterThreadRecorder& getMasterThreadRecorder() /////////////////////////////////////////////////////////////////////// ThreadRecorder::ThreadRecorder() +: mPrimaryRecording(NULL) { get_thread_recorder() = this; - mPrimaryRecording.makePrimary(); mFullRecording.start(); } ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) -: mPrimaryRecording(other.mPrimaryRecording), - mFullRecording(other.mFullRecording) +: mFullRecording(other.mFullRecording), + mPrimaryRecording(NULL) { get_thread_recorder() = this; - mPrimaryRecording.makePrimary(); mFullRecording.start(); } @@ -89,39 +88,74 @@ ThreadRecorder::~ThreadRecorder() //TODO: remove this and use llviewerstats recording Recording* ThreadRecorder::getPrimaryRecording() { - return &mPrimaryRecording; + return mPrimaryRecording; } -void ThreadRecorder::activate( Recording* recorder ) +void ThreadRecorder::activate( Recording* recording ) { - for (std::list<Recording*>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); + mActiveRecordings.push_front(ActiveRecording(mPrimaryRecording, recording)); + mActiveRecordings.front().mBaseline.makePrimary(); + mPrimaryRecording = &mActiveRecordings.front().mBaseline; +} + +//TODO: consider merging results down the list to one past the buffered item. +// this would require 2 buffers per sampler, to separate current total from running total + +void ThreadRecorder::deactivate( Recording* recording ) +{ + for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); it != end_it; ++it) { - (*it)->mMeasurements.write()->mergeSamples(*mPrimaryRecording.mMeasurements); - } - mPrimaryRecording.mMeasurements.write()->reset(); + std::list<ActiveRecording>::iterator next_it = it; + if (++next_it != mActiveRecordings.end()) + { + next_it->mergeMeasurements((*it)); + } - recorder->initDeltas(mPrimaryRecording); + it->flushAccumulators(mPrimaryRecording); - mActiveRecordings.push_front(recorder); + if (it->mTargetRecording == recording) + { + if (next_it != mActiveRecordings.end()) + { + next_it->mBaseline.makePrimary(); + mPrimaryRecording = &next_it->mBaseline; + } + mActiveRecordings.erase(it); + break; + } + } } -//TODO: consider merging results down the list to one past the buffered item. -// this would require 2 buffers per sampler, to separate current total from running total - -void ThreadRecorder::deactivate( Recording* recorder ) +ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target ) +: mTargetRecording(target) { - recorder->mergeDeltas(mPrimaryRecording); - - // TODO: replace with intrusive list - std::list<Recording*>::iterator found_it = std::find(mActiveRecordings.begin(), mActiveRecordings.end(), recorder); - if (found_it != mActiveRecordings.end()) + // take snapshots of current values rates and timers + if (source) { - mActiveRecordings.erase(found_it); + mBaseline.mRates.write()->copyFrom(*source->mRates); + mBaseline.mStackTimers.write()->copyFrom(*source->mStackTimers); } } +void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other) +{ + mBaseline.mMeasurements.write()->mergeSamples(*other.mBaseline.mMeasurements); +} + +void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current) +{ + // accumulate statistics-like measurements + mTargetRecording->mMeasurements.write()->mergeSamples(*mBaseline.mMeasurements); + // for rate-like measurements, merge total change since baseline + mTargetRecording->mRates.write()->mergeDeltas(*mBaseline.mRates, *current->mRates); + mTargetRecording->mStackTimers.write()->mergeDeltas(*mBaseline.mStackTimers, *current->mStackTimers); + // reset baselines + mBaseline.mRates.write()->copyFrom(*current->mRates); + mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers); +} + /////////////////////////////////////////////////////////////////////// // SlaveThreadRecorder /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index c5356777ae..39de79e4c1 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -497,9 +497,19 @@ namespace LLTrace Recording* getPrimaryRecording(); protected: - Recording mPrimaryRecording; + struct ActiveRecording + { + ActiveRecording(Recording* source, Recording* target); + + Recording* mTargetRecording; + Recording mBaseline; + + void mergeMeasurements(ActiveRecording& other); + void flushAccumulators(Recording* current); + }; + Recording* mPrimaryRecording; Recording mFullRecording; - std::list<Recording*> mActiveRecordings; + std::list<ActiveRecording> mActiveRecordings; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a792d40f9d..95cdb44e4b 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,17 +39,13 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), mIsStarted(false), - mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()), mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), - mStackTimers(new AccumulatorBuffer<TimerAccumulator>()), - mStackTimersStart(new AccumulatorBuffer<TimerAccumulator>()) -{ -} + mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) +{} Recording::~Recording() -{ -} +{} void Recording::start() { @@ -107,18 +103,10 @@ void Recording::mergeSamples( const Recording& other ) mStackTimers.write()->mergeSamples(*other.mStackTimers); } -void Recording::initDeltas( const Recording& other ) +void Recording::mergeDeltas(const Recording& baseline, const Recording& target) { - mRatesStart.write()->copyFrom(*other.mRates); - mStackTimersStart.write()->copyFrom(*other.mStackTimers); -} - - -void Recording::mergeDeltas( const Recording& other ) -{ - mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); - mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); - mMeasurements.write()->mergeSamples(*other.mMeasurements); + mRates.write()->mergeDeltas(*baseline.mRates, *target.mRates); + mStackTimers.write()->mergeDeltas(*baseline.mStackTimers, *target.mStackTimers); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 83dc503ea6..0a54e4cedf 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -57,8 +57,7 @@ namespace LLTrace void resume(); void mergeSamples(const Recording& other); - void initDeltas(const Recording& other); - void mergeDeltas(const Recording& other); + void mergeDeltas(const Recording& baseline, const Recording& target); void reset(); @@ -80,10 +79,8 @@ namespace LLTrace // returns data for current thread class ThreadRecorder* getThreadRecorder(); - LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRatesStart; LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates; LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; - LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimersStart; LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; bool mIsStarted; -- cgit v1.2.3 From 8f5e83789254d19a1a31737b0d7515cd7e967b26 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 3 Oct 2012 19:32:59 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system SH-3403 FIX implement unit conversion LLUnit implements unit tracking and conversion added support for LLUnit to LLTrace duplicated most llstats into LLTrace equivalents --- indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/lltrace.h | 62 ++++++++-- indra/llcommon/lltracerecording.h | 18 +-- indra/llcommon/llunit.h | 226 ++++++++++++++++++++++++++++++++++ indra/newview/llstatusbar.cpp | 2 +- indra/newview/llviewerstats.cpp | 131 ++++++++++++++++++-- indra/newview/llviewerstats.h | 120 +++++++++++++++++- indra/newview/llviewertexturelist.cpp | 2 +- indra/newview/llworld.cpp | 3 +- 9 files changed, 529 insertions(+), 36 deletions(-) create mode 100644 indra/llcommon/llunit.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 1ccee23e1e..471558ea01 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -247,6 +247,7 @@ set(llcommon_HEADER_FILES lltracerecording.h lltreeiterators.h lltypeinfolookup.h + llunit.h lluri.h lluuid.h lluuidhashmap.h diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 39de79e4c1..6a889f74df 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -35,6 +35,7 @@ #include "lltimer.h" #include "llrefcount.h" #include "lltracerecording.h" +#include "llunit.h" #include <list> @@ -42,11 +43,8 @@ #define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) #define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); - namespace LLTrace { - class Recording; - void init(); void cleanup(); @@ -325,10 +323,10 @@ namespace LLTrace U32 mNumSamples; }; - template <typename T> + template <typename T, typename IS_UNIT = void> class LL_COMMON_API Measurement : public TraceType<MeasurementAccumulator<T> >, - public LLInstanceTracker<Measurement<T>, std::string> + public LLInstanceTracker<Measurement<T, IS_UNIT>, std::string> { public: Measurement(const std::string& name) @@ -343,13 +341,37 @@ namespace LLTrace }; template <typename T> + class LL_COMMON_API Measurement <T, typename T::is_unit_t> + : public Measurement<typename T::value_t> + { + public: + typedef Measurement<typename T::value_t> base_measurement_t; + Measurement(const std::string& name) + : Measurement<typename T::value_t>(name) + {} + + template<typename UNIT_T> + void sample(UNIT_T value) + { + base_measurement_t::sample(value.get()); + } + + template<typename UNIT_T> + typename T::value_t get() + { + UNIT_T value(*this); + return value.get(); + } + }; + + template <typename T, typename IS_UNIT = void> class LL_COMMON_API Rate - : public TraceType<RateAccumulator<T> >, + : public TraceType<RateAccumulator<T> >, public LLInstanceTracker<Rate<T>, std::string> { public: Rate(const std::string& name) - : TraceType(name), + : TraceType(name), LLInstanceTracker(name) {} @@ -359,6 +381,30 @@ namespace LLTrace } }; + template <typename T> + class LL_COMMON_API Rate <T, typename T::is_unit_t> + : public Rate<typename T::value_t> + { + public: + Rate(const std::string& name) + : Rate<typename T::value_t>(name) + {} + + template<typename UNIT_T> + void add(UNIT_T value) + { + getPrimaryAccumulator().add(value.get()); + } + + template<typename UNIT_T> + typename T::value_t get() + { + UNIT_T value(*this); + return value.get(); + } + + }; + class LL_COMMON_API TimerAccumulator { public: @@ -482,6 +528,8 @@ namespace LLTrace static Recorder::StackEntry sCurRecorder; }; + class Recording; + class LL_COMMON_API ThreadRecorder { public: diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 0a54e4cedf..4d5793014f 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -35,8 +35,8 @@ namespace LLTrace { - template<typename T> class Rate; - template<typename T> class Measurement; + template<typename T, typename IS_UNIT> class Rate; + template<typename T, typename IS_UNIT> class Measurement; template<typename T> class AccumulatorBuffer; template<typename T> class RateAccumulator; template<typename T> class MeasurementAccumulator; @@ -63,14 +63,14 @@ namespace LLTrace bool isStarted() { return mIsStarted; } - F32 getSum(Rate<F32>& stat); - F32 getPerSec(Rate<F32>& stat); + F32 getSum(Rate<F32, void>& stat); + F32 getPerSec(Rate<F32, void>& stat); - F32 getSum(Measurement<F32>& stat); - F32 getMin(Measurement<F32>& stat); - F32 getMax(Measurement<F32>& stat); - F32 getMean(Measurement<F32>& stat); - F32 getStandardDeviation(Measurement<F32>& stat); + F32 getSum(Measurement<F32, void>& stat); + F32 getMin(Measurement<F32, void>& stat); + F32 getMax(Measurement<F32, void>& stat); + F32 getMean(Measurement<F32, void>& stat); + F32 getStandardDeviation(Measurement<F32, void>& stat); F64 getSampleTime() { return mElapsedSeconds; } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h new file mode 100644 index 0000000000..9d78df7cae --- /dev/null +++ b/indra/llcommon/llunit.h @@ -0,0 +1,226 @@ +/** + * @file llunit.h + * @brief Unit conversion classes + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLUNIT_H +#define LL_LLUNIT_H + +#include "stdtypes.h" +#include "llpreprocessor.h" + +template<typename BASE_UNIT, typename DERIVED_UNIT = BASE_UNIT> +struct LLUnit : public BASE_UNIT +{ + typedef LLUnit<BASE_UNIT, DERIVED_UNIT> unit_t; + typedef typename BASE_UNIT::value_t value_t; + typedef void is_unit_t; + + LLUnit() + {} + + explicit LLUnit(value_t value) + : BASE_UNIT(convertToBase(value)) + {} + + operator value_t() { return get(); } + + value_t get() const + { + return convertToDerived(mValue); + } + + static value_t convertToBase(value_t derived_value) + { + return (value_t)((F32)derived_value * DERIVED_UNIT::conversionToBaseFactor()); + } + + static value_t convertToDerived(value_t base_value) + { + return (value_t)((F32)base_value / DERIVED_UNIT::conversionToBaseFactor()); + } + +}; + +template<typename T> +struct LLUnit<T, T> +{ + typedef LLUnit<T, T> unit_t; + typedef T value_t; + typedef void is_unit_t; + + LLUnit() + : mValue() + {} + + explicit LLUnit(T value) + : mValue(value) + {} + + unit_t& operator=(T value) + { + setBaseValue(value); + return *this; + } + + value_t get() { return mValue; } + + static value_t convertToBase(value_t derived_value) + { + return (value_t)1; + } + + static value_t convertToDerived(value_t base_value) + { + return (value_t)1; + } + + unit_t operator + (const unit_t other) const + { + return unit_t(mValue + other.mValue); + } + + void operator += (const unit_t other) + { + mValue += other.mValue; + } + + unit_t operator - (const unit_t other) const + { + return unit_t(mValue - other.mValue); + } + + void operator -= (const unit_t other) + { + mValue -= other.mValue; + } + + unit_t operator * (value_t multiplicand) const + { + return unit_t(mValue * multiplicand); + } + + void operator *= (value_t multiplicand) + { + mValue *= multiplicand; + } + + unit_t operator / (value_t divisor) const + { + return unit_t(mValue / divisor); + } + + void operator /= (value_t divisor) + { + mValue /= divisor; + } + +protected: + void setBaseValue(T value) + { + mValue = value; + } + + T mValue; +}; + +#define LL_DECLARE_BASE_UNIT(unit_name) \ + template<typename STORAGE_TYPE> \ + struct unit_name : public LLUnit<STORAGE_TYPE> \ + { \ + unit_name(STORAGE_TYPE value) \ + : LLUnit(value) \ + {} \ + \ + unit_name() \ + {} \ + \ + template <typename T> \ + unit_name(const LLUnit<unit_name, T>& other) \ + { \ + setBaseValue(other.unit_name::get()); \ + } \ + \ + using LLUnit<STORAGE_TYPE>::operator +; \ + using LLUnit<STORAGE_TYPE>::operator +=; \ + using LLUnit<STORAGE_TYPE>::operator -; \ + using LLUnit<STORAGE_TYPE>::operator -=; \ + using LLUnit<STORAGE_TYPE>::operator *; \ + using LLUnit<STORAGE_TYPE>::operator *=; \ + using LLUnit<STORAGE_TYPE>::operator /; \ + using LLUnit<STORAGE_TYPE>::operator /=; \ + }; + +#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ + template<typename STORAGE_TYPE> \ + struct derived_unit : public LLUnit<base_unit<STORAGE_TYPE>, derived_unit<STORAGE_TYPE> > \ + { \ + derived_unit(value_t value) \ + : LLUnit(value) \ + {} \ + \ + derived_unit() \ + {} \ + \ + template <typename T> \ + derived_unit(const LLUnit<base_unit<STORAGE_TYPE>, T>& other) \ + { \ + setBaseValue(other.base_unit<STORAGE_TYPE>::get()); \ + } \ + \ + static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ + \ + using LLUnit<STORAGE_TYPE>::operator +; \ + using LLUnit<STORAGE_TYPE>::operator +=; \ + using LLUnit<STORAGE_TYPE>::operator -; \ + using LLUnit<STORAGE_TYPE>::operator -=; \ + using LLUnit<STORAGE_TYPE>::operator *; \ + using LLUnit<STORAGE_TYPE>::operator *=; \ + using LLUnit<STORAGE_TYPE>::operator /; \ + using LLUnit<STORAGE_TYPE>::operator /=; \ + }; + +namespace LLUnits +{ + LL_DECLARE_BASE_UNIT(Bytes); + LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); + LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); + LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); + LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.f / 8.f)); + LL_DECLARE_DERIVED_UNIT(Bytes, Kilobit, (1024 / 8)); + LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); + LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); + + LL_DECLARE_BASE_UNIT(Seconds); + LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); + LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); + LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); + LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); + LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.f / 1000.f)); + LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.f / (1000000.f))); + LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.f / (1000000000.f))); + +} + +#endif // LL_LLUNIT_H diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index ab97d6465a..6f2a0de894 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild() sgp.rect(r); sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); sgp.mouse_opaque(false); - sgp.stat.rate_stat(&STAT_KBIT); + sgp.stat.rate_stat(&LLStatViewer::KBIT); sgp.units("Kbps"); sgp.precision(0); mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index a6e9643edd..954fa24eaa 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -61,21 +61,128 @@ #include "llviewernetwork.h" #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived +namespace LLStatViewer +{ -LLTrace::Rate<F32> STAT_KBIT("kbitstat"), - STAT_LAYERS_KBIT("layerskbitstat"), - STAT_OBJECT_KBIT("objectkbitstat"), - STAT_ASSET_KBIT("assetkbitstat"), - STAT_TEXTURE_KBIT("texturekbitstat"); - +LLTrace::Rate<F32> FPS("fpsstat"), + PACKETS_IN("packetsinstat"), + PACKETS_LOST("packetsloststat"), + PACKETS_OUT("packetsoutstat"), + TEXTURE_PACKETS("texturepacketsstat"), + TRIANGLES_DRAWN("trianglesdrawnstat"), + CHAT_COUNT("chatcount"), + IM_COUNT("imcount"), + OBJECT_CREATE("objectcreate"), + OBJECT_REZ("objectrez"), + LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay"), + LOGIN_TIMEOUTS("logintimeouts"), + FAILED_DOWNLOADS("faileddownloads"), + LSL_SAVES("lslsaves"), + ANIMATION_UPLOADS("animationuploads"), + FLY("fly"), + TELEPORT("teleport"), + DELETE_OBJECT("deleteobject"), + SNAPSHOT("snapshot"), + UPLOAD_SOUND("uploadsound"), + UPLOAD_TEXTURE("uploadtexture"), + EDIT_TEXTURE("edittexture"), + KILLED("killed"), + FRAMETIME_DOUBLED("frametimedoubled"), + TEX_BAKES("texbakes"), + TEX_REBAKES("texrebakes"); +LLTrace::Rate<LLUnits::Bytes<F32> > KBIT("kbitstat"), + LAYERS_KBIT("layerskbitstat"), + OBJECT_KBIT("objectkbitstat"), + ASSET_KBIT("assetkbitstat"), + TEXTURE_KBIT("texturekbitstat"), + ACTUAL_IN_KBIT("actualinkbit"), + ACTUAL_OUT_KBIT("actualoutkbit"); + +LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittimr"), + TOOLBOX_TIME("toolboxtime"), + MOUSELOOK_TIME("mouselooktime"), + FPS_10_TIME("fps10time"), + FPS_8_TIME("fps8time"), + FPS_2_TIME("fps2time"), + SIM_20_FPS_TIME("sim20fpstime"), + SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime"), + LOSS_5_PERCENT_TIME("loss5percenttime"); + +LLTrace::Measurement<F32> SIM_TIME_DILATION("simtimedilation"), + SIM_FPS("simfps"), + SIM_PHYSICS_FPS("simphysicsfps"), + SIM_AGENT_UPS("simagentups"), + SIM_SCRIPT_EPS("simscripteps"), + SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"), + SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"), + SIM_MAIN_AGENTS("simmainagents"), + SIM_CHILD_AGENTS("simchildagents"), + SIM_OBJECTS("simobjects"), + SIM_ACTIVE_OBJECTS("simactiveobjects"), + SIM_ACTIVE_SCRIPTS("simactivescripts"), + SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"), + SIM_IN_PACKETS_PER_SEC("siminpps"), + SIM_OUT_PACKETS_PER_SEC("simoutpps"), + SIM_PENDING_DOWNLOADS("simpendingdownloads"), + SIM_PENDING_UPLOADS("simpendinguploads"), + SIM_PENING_LOCAL_UPLOADS("simpendinglocaluploads"), + SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"), + SIM_PHYSICS_LOD_TASKS("physicslodtasks"), + NUM_IMAGES("numimagesstat"), + NUM_RAW_IMAGES("numrawimagesstat"), + NUM_OBJECTS("numobjectsstat"), + NUM_ACTIVE_OBJECTS("numactiveobjectsstat"), + NUM_NEW_OBJECTS("numnewobjectsstat"), + NUM_SIZE_CULLED("numsizeculledstat"), + NUM_VIS_CULLED("numvisculledstat"), + ENABLE_VBO("enablevbo"), + DELTA_BANDWIDTH("deltabandwidth"), + MAX_BANDWIDTH("maxbandwidth"), + LIGHTING_DETAIL("lightingdetail"), + VISIBLE_AVATARS("visibleavatars"), + SHADER_OBJECTS("shaderobjects"), + DRAW_DISTANCE("drawdistance"), + CHAT_BUBBLES("chatbubbles"), + WINDOW_WIDTH("windowwidth"), + WINDOW_HEIGHT("windowheight"); + +LLTrace::Measurement<LLUnits::Bytes<F32> > SIM_UNACKED_BYTES("simtotalunackedbytes"), + SIM_PHYSICS_MEM("physicsmemoryallocated"), + GL_TEX_MEM("gltexmemstat"), + GL_BOUND_MEM("glboundmemstat"), + RAW_MEM("rawmemstat"), + FORMATTED_MEM("formattedmemstat"); + + +LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec"), + SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"), + SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"), + SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"), + SIM_AI_TIME("simsimaistepmsec"), + SIM_AGENTS_TIME("simagentmsec"), + SIM_IMAGES_TIME("simimagesmsec"), + SIM_SCRIPTS_TIME("simscriptmsec"), + SIM_SPARE_TIME("simsparemsec"), + SIM_SLEEP_TIME("simsleepmsec"), + SIM_PUMP_IO_TIME("simpumpiomsec"), + SIM_PING("simpingstat"), + LOGIN_SECONDS("loginseconds"), + REGION_CROSSING_TIME("regioncrossingtime"), + FRAME_STACKTIME("framestacktime"), + UPDATE_STACKTIME("updatestacktime"), + NETWORK_STACKTIME("networkstacktime"), + IMAGE_STACKTIME("imagestacktime"), + REBUILD_STACKTIME("rebuildstacktime"), + RENDER_STACKTIME("renderstacktime"); +} class StatAttributes { public: StatAttributes(const char* name, const BOOL enabled) - : mName(name), - mEnabled(enabled) + : mName(name), + mEnabled(enabled) { } @@ -465,12 +572,12 @@ void update_statistics() stats.mFPSStat.addValue(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - STAT_LAYERS_KBIT.add(layer_bits/1024.f); + LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - STAT_OBJECT_KBIT.add(gObjectBits/1024.f); + LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); - STAT_ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); + LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -508,7 +615,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - STAT_TEXTURE_KBIT.add(LLViewerTextureList::sTextureBits/1024.f); + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(LLViewerTextureList::sTextureBits); //stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index ca5f6c6821..af2e915994 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -32,11 +32,121 @@ #include "lltracerecording.h" #include "lltrace.h" -extern LLTrace::Rate<F32> STAT_KBIT, - STAT_LAYERS_KBIT, - STAT_OBJECT_KBIT, - STAT_ASSET_KBIT, - STAT_TEXTURE_KBIT; +namespace LLStatViewer +{ +extern LLTrace::Rate<F32> FPS, + PACKETS_IN, + PACKETS_LOST, + PACKETS_OUT, + TEXTURE_PACKETS, + TRIANGLES_DRAWN, + CHAT_COUNT, + IM_COUNT, + OBJECT_CREATE, + OBJECT_REZ, + LOADING_WEARABLES_LONG_DELAY, + LOGIN_TIMEOUTS, + FAILED_DOWNLOADS, + LSL_SAVES, + ANIMATION_UPLOADS, + FLY, + TELEPORT, + DELETE_OBJECT, + SNAPSHOT, + UPLOAD_SOUND, + UPLOAD_TEXTURE, + EDIT_TEXTURE, + KILLED, + FRAMETIME_DOUBLED, + TEX_BAKES, + TEX_REBAKES; + + +extern LLTrace::Rate<LLUnits::Bytes<F32> > KBIT, + LAYERS_KBIT, + OBJECT_KBIT, + ASSET_KBIT, + TEXTURE_KBIT, + ACTUAL_IN_KBIT, + ACTUAL_OUT_KBIT; + +extern LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME, + TOOLBOX_TIME, + MOUSELOOK_TIME, + FPS_10_TIME, + FPS_8_TIME, + FPS_2_TIME, + SIM_20_FPS_TIME, + SIM_PHYSICS_20_FPS_TIME, + LOSS_5_PERCENT_TIME; + +extern LLTrace::Measurement<F32> SIM_TIME_DILATION, + SIM_FPS, + SIM_PHYSICS_FPS, + SIM_AGENT_UPS, + SIM_SCRIPT_EPS, + SIM_SKIPPED_SILHOUETTE, + SIM_SKIPPED_CHARACTERS_PERCENTAGE, + SIM_MAIN_AGENTS, + SIM_CHILD_AGENTS, + SIM_OBJECTS, + SIM_ACTIVE_OBJECTS, + SIM_ACTIVE_SCRIPTS, + SIM_PERCENTAGE_SCRIPTS_RUN, + SIM_IN_PACKETS_PER_SEC, + SIM_OUT_PACKETS_PER_SEC, + SIM_PENDING_DOWNLOADS, + SIM_PENDING_UPLOADS, + SIM_PENING_LOCAL_UPLOADS, + SIM_PHYSICS_PINNED_TASKS, + SIM_PHYSICS_LOD_TASKS, + NUM_IMAGES, + NUM_RAW_IMAGES, + NUM_OBJECTS, + NUM_ACTIVE_OBJECTS, + NUM_NEW_OBJECTS, + NUM_SIZE_CULLED, + NUM_VIS_CULLED, + ENABLE_VBO, + DELTA_BANDWIDTH, + MAX_BANDWIDTH, + LIGHTING_DETAIL, + VISIBLE_AVATARS, + SHADER_OBJECTS, + DRAW_DISTANCE, + CHAT_BUBBLES, + WINDOW_WIDTH, + WINDOW_HEIGHT; + +extern LLTrace::Measurement<LLUnits::Bytes<F32> > SIM_UNACKED_BYTES, + SIM_PHYSICS_MEM, + GL_TEX_MEM, + GL_BOUND_MEM, + RAW_MEM, + FORMATTED_MEM; + + +extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME, + SIM_PHYSICS_STEP_TIME, + SIM_PHYSICS_SHAPE_UPDATE_TIME, + SIM_PHYSICS_OTHER_TIME, + SIM_AI_TIME, + SIM_AGENTS_TIME, + SIM_IMAGES_TIME, + SIM_SCRIPTS_TIME, + SIM_SPARE_TIME, + SIM_SLEEP_TIME, + SIM_PUMP_IO_TIME, + SIM_PING, + LOGIN_SECONDS, + REGION_CROSSING_TIME, + FRAME_STACKTIME, + UPDATE_STACKTIME, + NETWORK_STACKTIME, + IMAGE_STACKTIME, + REBUILD_STACKTIME, + RENDER_STACKTIME; +} class LLViewerStats : public LLSingleton<LLViewerStats> { diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 4e62cbd714..de3dd3c1c6 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -624,7 +624,7 @@ void LLViewerTextureList::updateImages(F32 max_time) LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); - LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(STAT_TEXTURE_KBIT)); + LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT)); LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 1e8665e229..bf2a58f107 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -702,9 +702,10 @@ void LLWorld::updateNetStats() S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); + LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - STAT_KBIT.add(bits/1024.f); + LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); -- cgit v1.2.3 From 3960fdf9e01619ddfd7903bcdd8d894f432752d0 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 4 Oct 2012 23:11:57 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible moved threadrecorder classes into separate file added Count trace type, which tracks value increases and decreases and can report churn as well as overall growth rate --- indra/llcommon/CMakeLists.txt | 2 + indra/llcommon/lltrace.cpp | 195 +-------------------------- indra/llcommon/lltrace.h | 143 +++++--------------- indra/llcommon/lltracerecording.cpp | 54 ++++++-- indra/llcommon/lltracerecording.h | 30 +++-- indra/llcommon/lltracethreadrecorder.cpp | 219 +++++++++++++++++++++++++++++++ indra/llcommon/lltracethreadrecorder.h | 124 +++++++++++++++++ 7 files changed, 450 insertions(+), 317 deletions(-) create mode 100644 indra/llcommon/lltracethreadrecorder.cpp create mode 100644 indra/llcommon/lltracethreadrecorder.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 471558ea01..c0e9266aa9 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -102,6 +102,7 @@ set(llcommon_SOURCE_FILES lltimer.cpp lltrace.cpp lltracerecording.cpp + lltracethreadrecorder.cpp lluri.cpp lluuid.cpp llworkerthread.cpp @@ -245,6 +246,7 @@ set(llcommon_HEADER_FILES lltimer.h lltrace.h lltracerecording.h + lltracethreadrecorder.h lltreeiterators.h lltypeinfolookup.h llunit.h diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 6d928721de..2b1c8d8ce8 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -44,206 +44,19 @@ void cleanup() gMasterThreadRecorder = NULL; } -LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() -{ - static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; - return s_thread_recorder; - -} - -BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; - - - MasterThreadRecorder& getMasterThreadRecorder() { llassert(gMasterThreadRecorder != NULL); return *gMasterThreadRecorder; } -/////////////////////////////////////////////////////////////////////// -// ThreadRecorder -/////////////////////////////////////////////////////////////////////// - -ThreadRecorder::ThreadRecorder() -: mPrimaryRecording(NULL) -{ - get_thread_recorder() = this; - mFullRecording.start(); -} - -ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) -: mFullRecording(other.mFullRecording), - mPrimaryRecording(NULL) -{ - get_thread_recorder() = this; - mFullRecording.start(); -} - -ThreadRecorder::~ThreadRecorder() -{ - get_thread_recorder() = NULL; -} - -//TODO: remove this and use llviewerstats recording -Recording* ThreadRecorder::getPrimaryRecording() -{ - return mPrimaryRecording; -} - -void ThreadRecorder::activate( Recording* recording ) -{ - mActiveRecordings.push_front(ActiveRecording(mPrimaryRecording, recording)); - mActiveRecordings.front().mBaseline.makePrimary(); - mPrimaryRecording = &mActiveRecordings.front().mBaseline; -} - -//TODO: consider merging results down the list to one past the buffered item. -// this would require 2 buffers per sampler, to separate current total from running total - -void ThreadRecorder::deactivate( Recording* recording ) -{ - for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); - it != end_it; - ++it) - { - std::list<ActiveRecording>::iterator next_it = it; - if (++next_it != mActiveRecordings.end()) - { - next_it->mergeMeasurements((*it)); - } - - it->flushAccumulators(mPrimaryRecording); - - if (it->mTargetRecording == recording) - { - if (next_it != mActiveRecordings.end()) - { - next_it->mBaseline.makePrimary(); - mPrimaryRecording = &next_it->mBaseline; - } - mActiveRecordings.erase(it); - break; - } - } -} - -ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target ) -: mTargetRecording(target) -{ - // take snapshots of current values rates and timers - if (source) - { - mBaseline.mRates.write()->copyFrom(*source->mRates); - mBaseline.mStackTimers.write()->copyFrom(*source->mStackTimers); - } -} - -void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other) -{ - mBaseline.mMeasurements.write()->mergeSamples(*other.mBaseline.mMeasurements); -} - -void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current) -{ - // accumulate statistics-like measurements - mTargetRecording->mMeasurements.write()->mergeSamples(*mBaseline.mMeasurements); - // for rate-like measurements, merge total change since baseline - mTargetRecording->mRates.write()->mergeDeltas(*mBaseline.mRates, *current->mRates); - mTargetRecording->mStackTimers.write()->mergeDeltas(*mBaseline.mStackTimers, *current->mStackTimers); - // reset baselines - mBaseline.mRates.write()->copyFrom(*current->mRates); - mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers); -} - -/////////////////////////////////////////////////////////////////////// -// SlaveThreadRecorder -/////////////////////////////////////////////////////////////////////// - -SlaveThreadRecorder::SlaveThreadRecorder() -: ThreadRecorder(getMasterThreadRecorder()) -{ - getMasterThreadRecorder().addSlaveThread(this); -} - -SlaveThreadRecorder::~SlaveThreadRecorder() -{ - getMasterThreadRecorder().removeSlaveThread(this); -} - -void SlaveThreadRecorder::pushToMaster() -{ - mFullRecording.stop(); - { - LLMutexLock(getMasterThreadRecorder().getSlaveListMutex()); - mSharedData.copyFrom(mFullRecording); - } - mFullRecording.start(); -} - -void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) -{ - LLMutexLock lock(&mRecorderMutex); - mRecorder.mergeSamples(source); -} - -void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) -{ - LLMutexLock lock(&mRecorderMutex); - sink.mergeSamples(mRecorder); -} - -/////////////////////////////////////////////////////////////////////// -// MasterThreadRecorder -/////////////////////////////////////////////////////////////////////// - -void MasterThreadRecorder::pullFromSlaveThreads() -{ - LLMutexLock lock(&mSlaveListMutex); - - for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); - it != end_it; - ++it) - { - (*it)->mRecorder->mSharedData.copyTo((*it)->mSlaveRecording); - } -} - -void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child ) -{ - LLMutexLock lock(&mSlaveListMutex); - - mSlaveThreadRecorders.push_back(new SlaveThreadRecorderProxy(child)); -} - -void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) +LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() { - LLMutexLock lock(&mSlaveListMutex); + static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; + return s_thread_recorder; - for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); - it != end_it; - ++it) - { - if ((*it)->mRecorder == child) - { - mSlaveThreadRecorders.erase(it); - break; - } - } } -void MasterThreadRecorder::pushToMaster() -{} - -MasterThreadRecorder::MasterThreadRecorder() -{} - -/////////////////////////////////////////////////////////////////////// -// MasterThreadRecorder::SlaveThreadTraceProxy -/////////////////////////////////////////////////////////////////////// - -MasterThreadRecorder::SlaveThreadRecorderProxy::SlaveThreadRecorderProxy( class SlaveThreadRecorder* recorder) -: mRecorder(recorder) -{} +BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 6a889f74df..d83ea77363 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -30,11 +30,10 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "llmutex.h" #include "llmemory.h" -#include "lltimer.h" #include "llrefcount.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" #include "llunit.h" #include <list> @@ -171,7 +170,7 @@ namespace LLTrace template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; template<typename ACCUMULATOR> - class LL_COMMON_API TraceType + class LL_COMMON_API TraceType { public: TraceType(const std::string& name) @@ -186,6 +185,7 @@ namespace LLTrace } ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) { return (*buffer)[mAccumulatorIndex]; } + const ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) const { return (*buffer)[mAccumulatorIndex]; } protected: std::string mName; @@ -265,11 +265,11 @@ namespace LLTrace mMax = 0; } - T getSum() { return mSum; } - T getMin() { return mMin; } - T getMax() { return mMax; } - F32 getMean() { return mMean; } - F32 getStandardDeviation() { return mStandardDeviation; } + T getSum() const { return mSum; } + T getMin() const { return mMin; } + T getMax() const { return mMax; } + F32 getMean() const { return mMean; } + F32 getStandardDeviation() const { return mStandardDeviation; } private: T mSum, @@ -315,7 +315,7 @@ namespace LLTrace mSum = 0; } - T getSum() { return mSum; } + T getSum() const { return mSum; } private: T mSum; @@ -355,13 +355,6 @@ namespace LLTrace { base_measurement_t::sample(value.get()); } - - template<typename UNIT_T> - typename T::value_t get() - { - UNIT_T value(*this); - return value.get(); - } }; template <typename T, typename IS_UNIT = void> @@ -395,14 +388,35 @@ namespace LLTrace { getPrimaryAccumulator().add(value.get()); } + }; - template<typename UNIT_T> - typename T::value_t get() + template <typename T> + class LL_COMMON_API Count + { + public: + Count(const std::string& name) + : mIncrease(name + "_increase"), + mDecrease(name + "_decrease"), + mTotal(name) + {} + + void count(T value) { - UNIT_T value(*this); - return value.get(); + if (value < 0) + { + mDecrease.add(value * -1); + } + else + { + mIncrease.add(value); + } + mTotal.add(value); } - + private: + friend class LLTrace::Recording; + Rate<T> mIncrease; + Rate<T> mDecrease; + Rate<T> mTotal; }; class LL_COMMON_API TimerAccumulator @@ -527,93 +541,6 @@ namespace LLTrace static Recorder::StackEntry sCurRecorder; }; - - class Recording; - - class LL_COMMON_API ThreadRecorder - { - public: - ThreadRecorder(); - ThreadRecorder(const ThreadRecorder& other); - - virtual ~ThreadRecorder(); - - void activate(Recording* recording); - void deactivate(Recording* recording); - - virtual void pushToMaster() = 0; - - Recording* getPrimaryRecording(); - protected: - struct ActiveRecording - { - ActiveRecording(Recording* source, Recording* target); - - Recording* mTargetRecording; - Recording mBaseline; - - void mergeMeasurements(ActiveRecording& other); - void flushAccumulators(Recording* current); - }; - Recording* mPrimaryRecording; - Recording mFullRecording; - std::list<ActiveRecording> mActiveRecordings; - }; - - class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder - { - public: - MasterThreadRecorder(); - - void addSlaveThread(class SlaveThreadRecorder* child); - void removeSlaveThread(class SlaveThreadRecorder* child); - - /*virtual */ void pushToMaster(); - - // call this periodically to gather stats data from slave threads - void pullFromSlaveThreads(); - - LLMutex* getSlaveListMutex() { return &mSlaveListMutex; } - - private: - struct SlaveThreadRecorderProxy - { - SlaveThreadRecorderProxy(class SlaveThreadRecorder* recorder); - - class SlaveThreadRecorder* mRecorder; - Recording mSlaveRecording; - private: - //no need to copy these and then have to duplicate the storage - SlaveThreadRecorderProxy(const SlaveThreadRecorderProxy& other) {} - }; - typedef std::list<SlaveThreadRecorderProxy*> slave_thread_recorder_list_t; - - slave_thread_recorder_list_t mSlaveThreadRecorders; - LLMutex mSlaveListMutex; - }; - - class LL_COMMON_API SlaveThreadRecorder : public ThreadRecorder - { - public: - SlaveThreadRecorder(); - ~SlaveThreadRecorder(); - - // call this periodically to gather stats data for master thread to consume - /*virtual*/ void pushToMaster(); - - MasterThreadRecorder* mMaster; - - class SharedData - { - public: - void copyFrom(const Recording& source); - void copyTo(Recording& sink); - private: - LLMutex mRecorderMutex; - Recording mRecorder; - }; - SharedData mSharedData; - }; } #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 95cdb44e4b..e4cff551f9 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -110,46 +110,80 @@ void Recording::mergeDeltas(const Recording& baseline, const Recording& target) } -F32 Recording::getSum( Rate<F32>& stat ) +F32 Recording::getSum(const Rate<F32>& stat) { return stat.getAccumulator(mRates).getSum(); } -F32 Recording::getSum( Measurement<F32>& stat ) +F32 Recording::getPerSec(const Rate<F32>& stat) { - return stat.getAccumulator(mMeasurements).getSum(); + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; } - -F32 Recording::getPerSec( Rate<F32>& stat ) +F32 Recording::getSum(const Measurement<F32>& stat) { - return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; + return stat.getAccumulator(mMeasurements).getSum(); } -F32 Recording::getMin( Measurement<F32>& stat ) +F32 Recording::getMin(const Measurement<F32>& stat) { return stat.getAccumulator(mMeasurements).getMin(); } -F32 Recording::getMax( Measurement<F32>& stat ) +F32 Recording::getMax(const Measurement<F32>& stat) { return stat.getAccumulator(mMeasurements).getMax(); } -F32 Recording::getMean( Measurement<F32>& stat ) +F32 Recording::getMean(const Measurement<F32>& stat) { return stat.getAccumulator(mMeasurements).getMean(); } -F32 Recording::getStandardDeviation( Measurement<F32>& stat ) +F32 Recording::getStandardDeviation(const Measurement<F32>& stat) { return stat.getAccumulator(mMeasurements).getStandardDeviation(); } +F32 Recording::getSum(const Count<F32>& stat) +{ + return getSum(stat.mTotal); +} + +F32 Recording::getPerSec(const Count<F32>& stat) +{ + return getPerSec(stat.mTotal); +} + +F32 Recording::getIncrease(const Count<F32>& stat) +{ + return getSum(stat.mIncrease); +} + +F32 Recording::getIncreasePerSec(const Count<F32>& stat) +{ + return getPerSec(stat.mIncrease); +} +F32 Recording::getDecrease(const Count<F32>& stat) +{ + return getSum(stat.mDecrease); +} +F32 Recording::getDecreasePerSec(const Count<F32>& stat) +{ + return getPerSec(stat.mDecrease); +} +F32 Recording::getChurn(const Count<F32>& stat) +{ + return getIncrease(stat) + getDecrease(stat); +} +F32 Recording::getChurnPerSec(const Count<F32>& stat) +{ + return getIncreasePerSec(stat) + getDecreasePerSec(stat); +} } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 4d5793014f..f9bc6b61b2 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -37,6 +37,7 @@ namespace LLTrace { template<typename T, typename IS_UNIT> class Rate; template<typename T, typename IS_UNIT> class Measurement; + template<typename T> class Count; template<typename T> class AccumulatorBuffer; template<typename T> class RateAccumulator; template<typename T> class MeasurementAccumulator; @@ -63,14 +64,27 @@ namespace LLTrace bool isStarted() { return mIsStarted; } - F32 getSum(Rate<F32, void>& stat); - F32 getPerSec(Rate<F32, void>& stat); - - F32 getSum(Measurement<F32, void>& stat); - F32 getMin(Measurement<F32, void>& stat); - F32 getMax(Measurement<F32, void>& stat); - F32 getMean(Measurement<F32, void>& stat); - F32 getStandardDeviation(Measurement<F32, void>& stat); + // Rate accessors + F32 getSum(const Rate<F32, void>& stat); + F32 getPerSec(const Rate<F32, void>& stat); + + // Measurement accessors + F32 getSum(const Measurement<F32, void>& stat); + F32 getPerSec(const Measurement<F32, void>& stat); + F32 getMin(const Measurement<F32, void>& stat); + F32 getMax(const Measurement<F32, void>& stat); + F32 getMean(const Measurement<F32, void>& stat); + F32 getStandardDeviation(const Measurement<F32, void>& stat); + + // Count accessors + F32 getSum(const Count<F32>& stat); + F32 getPerSec(const Count<F32>& stat); + F32 getIncrease(const Count<F32>& stat); + F32 getIncreasePerSec(const Count<F32>& stat); + F32 getDecrease(const Count<F32>& stat); + F32 getDecreasePerSec(const Count<F32>& stat); + F32 getChurn(const Count<F32>& stat); + F32 getChurnPerSec(const Count<F32>& stat); F64 getSampleTime() { return mElapsedSeconds; } diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp new file mode 100644 index 0000000000..9115a52fd1 --- /dev/null +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -0,0 +1,219 @@ +/** + * @file lltracethreadrecorder.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltrace.h" + +namespace LLTrace +{ + + +/////////////////////////////////////////////////////////////////////// +// ThreadRecorder +/////////////////////////////////////////////////////////////////////// + +ThreadRecorder::ThreadRecorder() +: mPrimaryRecording(NULL) +{ + get_thread_recorder() = this; + mFullRecording.start(); +} + +ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) +: mFullRecording(other.mFullRecording), + mPrimaryRecording(NULL) +{ + get_thread_recorder() = this; + mFullRecording.start(); +} + +ThreadRecorder::~ThreadRecorder() +{ + get_thread_recorder() = NULL; +} + +//TODO: remove this and use llviewerstats recording +Recording* ThreadRecorder::getPrimaryRecording() +{ + return mPrimaryRecording; +} + +void ThreadRecorder::activate( Recording* recording ) +{ + mActiveRecordings.push_front(ActiveRecording(mPrimaryRecording, recording)); + mActiveRecordings.front().mBaseline.makePrimary(); + mPrimaryRecording = &mActiveRecordings.front().mBaseline; +} + +//TODO: consider merging results down the list to one past the buffered item. +// this would require 2 buffers per sampler, to separate current total from running total + +void ThreadRecorder::deactivate( Recording* recording ) +{ + for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); + it != end_it; + ++it) + { + std::list<ActiveRecording>::iterator next_it = it; + if (++next_it != mActiveRecordings.end()) + { + next_it->mergeMeasurements((*it)); + } + + it->flushAccumulators(mPrimaryRecording); + + if (it->mTargetRecording == recording) + { + if (next_it != mActiveRecordings.end()) + { + next_it->mBaseline.makePrimary(); + mPrimaryRecording = &next_it->mBaseline; + } + mActiveRecordings.erase(it); + break; + } + } +} + +ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target ) +: mTargetRecording(target) +{ + // take snapshots of current values rates and timers + if (source) + { + mBaseline.mRates.write()->copyFrom(*source->mRates); + mBaseline.mStackTimers.write()->copyFrom(*source->mStackTimers); + } +} + +void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other) +{ + mBaseline.mMeasurements.write()->mergeSamples(*other.mBaseline.mMeasurements); +} + +void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current) +{ + // accumulate statistics-like measurements + mTargetRecording->mMeasurements.write()->mergeSamples(*mBaseline.mMeasurements); + // for rate-like measurements, merge total change since baseline + mTargetRecording->mRates.write()->mergeDeltas(*mBaseline.mRates, *current->mRates); + mTargetRecording->mStackTimers.write()->mergeDeltas(*mBaseline.mStackTimers, *current->mStackTimers); + // reset baselines + mBaseline.mRates.write()->copyFrom(*current->mRates); + mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers); +} + +/////////////////////////////////////////////////////////////////////// +// SlaveThreadRecorder +/////////////////////////////////////////////////////////////////////// + +SlaveThreadRecorder::SlaveThreadRecorder() +: ThreadRecorder(getMasterThreadRecorder()) +{ + getMasterThreadRecorder().addSlaveThread(this); +} + +SlaveThreadRecorder::~SlaveThreadRecorder() +{ + getMasterThreadRecorder().removeSlaveThread(this); +} + +void SlaveThreadRecorder::pushToMaster() +{ + mFullRecording.stop(); + { + LLMutexLock(getMasterThreadRecorder().getSlaveListMutex()); + mSharedData.copyFrom(mFullRecording); + } + mFullRecording.start(); +} + +void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) +{ + LLMutexLock lock(&mRecorderMutex); + mRecorder.mergeSamples(source); +} + +void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) +{ + LLMutexLock lock(&mRecorderMutex); + sink.mergeSamples(mRecorder); +} + +/////////////////////////////////////////////////////////////////////// +// MasterThreadRecorder +/////////////////////////////////////////////////////////////////////// + +void MasterThreadRecorder::pullFromSlaveThreads() +{ + LLMutexLock lock(&mSlaveListMutex); + + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); + it != end_it; + ++it) + { + (*it)->mRecorder->mSharedData.copyTo((*it)->mSlaveRecording); + } +} + +void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child ) +{ + LLMutexLock lock(&mSlaveListMutex); + + mSlaveThreadRecorders.push_back(new SlaveThreadRecorderProxy(child)); +} + +void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) +{ + LLMutexLock lock(&mSlaveListMutex); + + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); + it != end_it; + ++it) + { + if ((*it)->mRecorder == child) + { + mSlaveThreadRecorders.erase(it); + break; + } + } +} + +void MasterThreadRecorder::pushToMaster() +{} + +MasterThreadRecorder::MasterThreadRecorder() +{} + +/////////////////////////////////////////////////////////////////////// +// MasterThreadRecorder::SlaveThreadTraceProxy +/////////////////////////////////////////////////////////////////////// + +MasterThreadRecorder::SlaveThreadRecorderProxy::SlaveThreadRecorderProxy( class SlaveThreadRecorder* recorder) +: mRecorder(recorder) +{} + +} diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h new file mode 100644 index 0000000000..40441d0447 --- /dev/null +++ b/indra/llcommon/lltracethreadrecorder.h @@ -0,0 +1,124 @@ +/** + * @file lltrace.h + * @brief Runtime statistics accumulation. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTRACETHREADRECORDER_H +#define LL_LLTRACETHREADRECORDER_H + +#include "stdtypes.h" +#include "llpreprocessor.h" + +#include "llmutex.h" +#include "lltracerecording.h" + +namespace LLTrace +{ + class LL_COMMON_API ThreadRecorder + { + public: + ThreadRecorder(); + ThreadRecorder(const ThreadRecorder& other); + + virtual ~ThreadRecorder(); + + void activate(Recording* recording); + void deactivate(Recording* recording); + + virtual void pushToMaster() = 0; + + Recording* getPrimaryRecording(); + protected: + struct ActiveRecording + { + ActiveRecording(Recording* source, Recording* target); + + Recording* mTargetRecording; + Recording mBaseline; + + void mergeMeasurements(ActiveRecording& other); + void flushAccumulators(Recording* current); + }; + Recording* mPrimaryRecording; + Recording mFullRecording; + std::list<ActiveRecording> mActiveRecordings; + }; + + class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder + { + public: + MasterThreadRecorder(); + + void addSlaveThread(class SlaveThreadRecorder* child); + void removeSlaveThread(class SlaveThreadRecorder* child); + + /*virtual */ void pushToMaster(); + + // call this periodically to gather stats data from slave threads + void pullFromSlaveThreads(); + + LLMutex* getSlaveListMutex() { return &mSlaveListMutex; } + + private: + struct SlaveThreadRecorderProxy + { + SlaveThreadRecorderProxy(class SlaveThreadRecorder* recorder); + + class SlaveThreadRecorder* mRecorder; + Recording mSlaveRecording; + private: + //no need to copy these and then have to duplicate the storage + SlaveThreadRecorderProxy(const SlaveThreadRecorderProxy& other) {} + }; + typedef std::list<SlaveThreadRecorderProxy*> slave_thread_recorder_list_t; + + slave_thread_recorder_list_t mSlaveThreadRecorders; + LLMutex mSlaveListMutex; + }; + + class LL_COMMON_API SlaveThreadRecorder : public ThreadRecorder + { + public: + SlaveThreadRecorder(); + ~SlaveThreadRecorder(); + + // call this periodically to gather stats data for master thread to consume + /*virtual*/ void pushToMaster(); + + MasterThreadRecorder* mMaster; + + class SharedData + { + public: + void copyFrom(const Recording& source); + void copyTo(Recording& sink); + private: + LLMutex mRecorderMutex; + Recording mRecorder; + }; + SharedData mSharedData; + }; +} + +#endif // LL_LLTRACETHREADRECORDER_H -- cgit v1.2.3 From 4dce574a8d604a501ec3c12eef3f5d03ee188473 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 5 Oct 2012 10:51:38 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system added update() method to trace recorders to allow mid-collection snapshots --- indra/llcommon/lltracerecording.cpp | 6 ++++++ indra/llcommon/lltracerecording.h | 1 + indra/llcommon/lltracethreadrecorder.cpp | 19 +++++++++++++------ indra/llcommon/lltracethreadrecorder.h | 3 +++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e4cff551f9..c44cc8a8a7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -63,6 +63,12 @@ void Recording::reset() mSamplingTimer.reset(); } +void Recording::update() +{ + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); +} + void Recording::resume() { if (!mIsStarted) diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f9bc6b61b2..4d53cd9600 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -61,6 +61,7 @@ namespace LLTrace void mergeDeltas(const Recording& baseline, const Recording& target); void reset(); + void update(); bool isStarted() { return mIsStarted; } diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 9115a52fd1..b2c6fe3b80 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -68,10 +68,7 @@ void ThreadRecorder::activate( Recording* recording ) mPrimaryRecording = &mActiveRecordings.front().mBaseline; } -//TODO: consider merging results down the list to one past the buffered item. -// this would require 2 buffers per sampler, to separate current total from running total - -void ThreadRecorder::deactivate( Recording* recording ) +std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Recording* recording ) { for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); it != end_it; @@ -92,10 +89,20 @@ void ThreadRecorder::deactivate( Recording* recording ) next_it->mBaseline.makePrimary(); mPrimaryRecording = &next_it->mBaseline; } - mActiveRecordings.erase(it); - break; + return it; } } + + return mActiveRecordings.end(); +} + +void ThreadRecorder::deactivate( Recording* recording ) +{ + std::list<ActiveRecording>::iterator it = update(recording); + if (it != mActiveRecordings.end()) + { + mActiveRecordings.erase(it); + } } ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target ) diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 40441d0447..42230087c0 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -37,6 +37,8 @@ namespace LLTrace { class LL_COMMON_API ThreadRecorder { + protected: + struct ActiveRecording; public: ThreadRecorder(); ThreadRecorder(const ThreadRecorder& other); @@ -44,6 +46,7 @@ namespace LLTrace virtual ~ThreadRecorder(); void activate(Recording* recording); + std::list<struct ActiveRecording>::iterator update(Recording* recording); void deactivate(Recording* recording); virtual void pushToMaster() = 0; -- cgit v1.2.3 From 960f8764ad2407add941bc8650b295f1e77beb19 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 5 Oct 2012 11:44:36 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system added update() method to trace recorders to allow mid-collection snapshots --- indra/llcommon/lltracerecording.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c44cc8a8a7..f0b17ef100 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -65,8 +65,12 @@ void Recording::reset() void Recording::update() { - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); + if (mIsStarted) + { + LLTrace::get_thread_recorder()->update(this); + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); + } } void Recording::resume() -- cgit v1.2.3 From aff9654c1115b4a74fc3ee8f9ca2c2ffa07f8d73 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 9 Oct 2012 18:02:47 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible added PeriodicRecorder class for frame by frame stats accumulation --- indra/llcommon/lltrace.h | 4 +- indra/llcommon/lltracerecording.cpp | 35 ++--- indra/llcommon/lltracerecording.h | 247 ++++++++++++++++++++++++++++++++++-- indra/llcommon/llunit.h | 12 +- 4 files changed, 261 insertions(+), 37 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index d83ea77363..e655a3582e 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -353,7 +353,7 @@ namespace LLTrace template<typename UNIT_T> void sample(UNIT_T value) { - base_measurement_t::sample(value.get()); + base_measurement_t::sample(value.value()); } }; @@ -386,7 +386,7 @@ namespace LLTrace template<typename UNIT_T> void add(UNIT_T value) { - getPrimaryAccumulator().add(value.get()); + getPrimaryAccumulator().add(value.value()); } }; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e4cff551f9..7cd6280f03 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -38,7 +38,6 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mIsStarted(false), mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) @@ -47,13 +46,7 @@ Recording::Recording() Recording::~Recording() {} -void Recording::start() -{ - reset(); - resume(); -} - -void Recording::reset() +void Recording::handleReset() { mRates.write()->reset(); mMeasurements.write()->reset(); @@ -63,24 +56,22 @@ void Recording::reset() mSamplingTimer.reset(); } -void Recording::resume() +void Recording::handleStart() +{ + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); +} + +void Recording::handleStop() { - if (!mIsStarted) - { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); - mIsStarted = true; - } + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); } -void Recording::stop() +void Recording::handleSplitTo(Recording& other) { - if (mIsStarted) - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - mIsStarted = false; - } + stop(); + other.restart(); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f9bc6b61b2..080007ba00 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -33,6 +33,147 @@ #include "llpointer.h" #include "lltimer.h" +template<typename DERIVED> +class LL_COMMON_API LLVCRControlsMixinInterface +{ +public: + virtual ~LLVCRControlsMixinInterface() {} + // trigger data accumulation (without reset) + virtual void handleStart() = 0; + // stop data accumulation, should put object in queryable state + virtual void handleStop() = 0; + // clear accumulated values, can be called while started + virtual void handleReset() = 0; + // atomically stop this object while starting the other + // no data can be missed in between stop and start + virtual void handleSplitTo(DERIVED& other) = 0; +}; + +template<typename DERIVED> +class LL_COMMON_API LLVCRControlsMixin +: private LLVCRControlsMixinInterface<DERIVED> +{ +public: + enum EPlayState + { + STOPPED, + PAUSED, + STARTED + }; + + void start() + { + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; + } + + void stop() + { + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + handleStop(); + break; + case STARTED: + break; + } + mPlayState = STOPPED; + } + + void pause() + { + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + break; + case STARTED: + handleStop(); + break; + } + mPlayState = PAUSED; + } + + void resume() + { + switch (mPlayState) + { + case STOPPED: + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + break; + } + mPlayState = STARTED; + } + + void restart() + { + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleReset(); + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; + } + + void reset() + { + handleReset(); + } + + void splitTo(DERIVED& other) + { + onSplitTo(other); + } + + void splitFrom(DERIVED& other) + { + other.onSplitTo(*this); + } + + bool isStarted() { return mPlayState == STARTED; } + bool isPaused() { return mPlayState == PAUSED; } + bool isStopped() { return mPlayState == STOPPED; } + EPlayState getPlayState() { return mPlayState; } + +protected: + + LLVCRControlsMixin() + : mPlayState(STOPPED) + {} + +private: + EPlayState mPlayState; +}; + namespace LLTrace { template<typename T, typename IS_UNIT> class Rate; @@ -43,7 +184,7 @@ namespace LLTrace template<typename T> class MeasurementAccumulator; class TimerAccumulator; - class LL_COMMON_API Recording + class LL_COMMON_API Recording : public LLVCRControlsMixin<Recording> { public: Recording(); @@ -53,16 +194,9 @@ namespace LLTrace void makePrimary(); bool isPrimary(); - void start(); - void stop(); - void resume(); - void mergeSamples(const Recording& other); void mergeDeltas(const Recording& baseline, const Recording& target); - void reset(); - - bool isStarted() { return mIsStarted; } // Rate accessors F32 getSum(const Rate<F32, void>& stat); @@ -89,6 +223,14 @@ namespace LLTrace F64 getSampleTime() { return mElapsedSeconds; } private: + friend class PeriodicRecording; + // implementation for LLVCRControlsMixin + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); + /*virtual*/ void handleSplitTo(Recording& other); + + friend class ThreadRecorder; // returns data for current thread class ThreadRecorder* getThreadRecorder(); @@ -97,14 +239,99 @@ namespace LLTrace LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; - bool mIsStarted; LLTimer mSamplingTimer; F64 mElapsedSeconds; }; - class LL_COMMON_API PeriodicRecording + class LL_COMMON_API PeriodicRecording + : public LLVCRControlsMixin<PeriodicRecording> { + public: + PeriodicRecording(S32 num_periods) + : mNumPeriods(num_periods), + mCurPeriod(0), + mTotalValid(false), + mRecordingPeriods(new Recording[num_periods]) + { + llassert(mNumPeriods > 0); + } + + ~PeriodicRecording() + { + delete[] mRecordingPeriods; + } + + void nextPeriod() + { + EPlayState play_state = getPlayState(); + getCurRecordingPeriod().stop(); + mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + switch(play_state) + { + case STOPPED: + break; + case PAUSED: + getCurRecordingPeriod().pause(); + break; + case STARTED: + getCurRecordingPeriod().start(); + break; + } + // new period, need to recalculate total + mTotalValid = false; + } + + Recording& getCurRecordingPeriod() + { + return mRecordingPeriods[mCurPeriod]; + } + + const Recording& getCurRecordingPeriod() const + { + return mRecordingPeriods[mCurPeriod]; + } + + Recording& getTotalRecording() + { + if (!mTotalValid) + { + mTotalRecording.reset(); + for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) + { + mTotalRecording.mergeSamples(mRecordingPeriods[i]); + } + } + mTotalValid = true; + return mTotalRecording; + } + + private: + // implementation for LLVCRControlsMixin + /*virtual*/ void handleStart() + { + getCurRecordingPeriod().handleStart(); + } + + /*virtual*/ void handleStop() + { + getCurRecordingPeriod().handleStop(); + } + + /*virtual*/ void handleReset() + { + getCurRecordingPeriod().handleReset(); + } + + /*virtual*/ void handleSplitTo(PeriodicRecording& other) + { + getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); + } + Recording* mRecordingPeriods; + Recording mTotalRecording; + bool mTotalValid; + S32 mNumPeriods, + mCurPeriod; }; } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 9d78df7cae..52b837fdc3 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -44,13 +44,19 @@ struct LLUnit : public BASE_UNIT : BASE_UNIT(convertToBase(value)) {} - operator value_t() { return get(); } + operator value_t() { return value(); } - value_t get() const + value_t value() const { return convertToDerived(mValue); } + template<typename CONVERTED_TYPE> + value_t value() const + { + return CONVERTED_TYPE(*this).value(); + } + static value_t convertToBase(value_t derived_value) { return (value_t)((F32)derived_value * DERIVED_UNIT::conversionToBaseFactor()); @@ -84,7 +90,7 @@ struct LLUnit<T, T> return *this; } - value_t get() { return mValue; } + value_t value() { return mValue; } static value_t convertToBase(value_t derived_value) { -- cgit v1.2.3 From 8bb0a6ef737cb40c8f64f37fe64ecc7f6a87ae18 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 9 Oct 2012 18:07:31 -0700 Subject: post merge cleanup --- indra/llcommon/lltracerecording.cpp | 32 ++++++++++++++++---------------- indra/llcommon/lltracerecording.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 93d2136e7f..d931c4ed29 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,16 @@ Recording::Recording() Recording::~Recording() {} +void Recording::update() +{ + if (isStarted()) + { + LLTrace::get_thread_recorder()->update(this); + mElapsedSeconds = 0.0; + mSamplingTimer.reset(); + } +} + void Recording::handleReset() { mRates.write()->reset(); @@ -56,27 +66,17 @@ void Recording::handleReset() mSamplingTimer.reset(); } -void Recording::update() -{ - if (mIsStarted) - { - LLTrace::get_thread_recorder()->update(this); - mElapsedSeconds = 0.0; - mSamplingTimer.reset(); - } -} - void Recording::handleStart() { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); } void Recording::handleStop() - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - } +{ + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); +} void Recording::handleSplitTo(Recording& other) { diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 6e5f118cf6..092dc7ff2c 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -254,7 +254,7 @@ namespace LLTrace mCurPeriod(0), mTotalValid(false), mRecordingPeriods(new Recording[num_periods]) - { + { llassert(mNumPeriods > 0); } -- cgit v1.2.3 From 05510799e5a69eafcc919e72d25cf5b89c9274cf Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 9 Oct 2012 22:18:07 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible renamed mergeSamples to mergeRecording --- indra/llcommon/lltracerecording.cpp | 2 +- indra/llcommon/lltracerecording.h | 4 ++-- indra/llcommon/lltracethreadrecorder.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index d931c4ed29..9a08770bd7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -97,7 +97,7 @@ bool Recording::isPrimary() return mRates->isPrimary(); } -void Recording::mergeSamples( const Recording& other ) +void Recording::mergeRecording( const Recording& other ) { mRates.write()->mergeSamples(*other.mRates); mMeasurements.write()->mergeSamples(*other.mMeasurements); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 092dc7ff2c..4399a65cfb 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -194,7 +194,7 @@ namespace LLTrace void makePrimary(); bool isPrimary(); - void mergeSamples(const Recording& other); + void mergeRecording(const Recording& other); void mergeDeltas(const Recording& baseline, const Recording& target); void reset(); @@ -300,7 +300,7 @@ namespace LLTrace mTotalRecording.reset(); for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) { - mTotalRecording.mergeSamples(mRecordingPeriods[i]); + mTotalRecording.mergeRecording(mRecordingPeriods[i]); } } mTotalValid = true; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index b2c6fe3b80..4d020f5650 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -161,13 +161,13 @@ void SlaveThreadRecorder::pushToMaster() void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) { LLMutexLock lock(&mRecorderMutex); - mRecorder.mergeSamples(source); + mRecorder.mergeRecording(source); } void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) { LLMutexLock lock(&mRecorderMutex); - sink.mergeSamples(mRecorder); + sink.mergeRecording(mRecorder); } /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 74ac0182ec8f7a0f6d0ea89f5814f0998ab90b62 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 10 Oct 2012 19:25:56 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed units conversion so that trace getters return convertable units removed circular dependencies from lltrace* converted more stats to lltrace --- indra/llcommon/llqueuedthread.cpp | 2 +- indra/llcommon/llthread.cpp | 1 + indra/llcommon/lltrace.cpp | 1 + indra/llcommon/lltrace.h | 88 +++++--- indra/llcommon/lltracerecording.cpp | 96 +-------- indra/llcommon/lltracerecording.h | 145 ++++++++++--- indra/llcommon/lltracethreadrecorder.cpp | 14 +- indra/llcommon/llunit.h | 176 +++++++++------- indra/llui/llstatbar.cpp | 1 + indra/llui/llstatgraph.cpp | 1 + indra/newview/lltexturefetch.cpp | 3 +- indra/newview/llviewermessage.cpp | 13 +- indra/newview/llviewerstats.cpp | 349 ++++++++++--------------------- indra/newview/llviewerstats.h | 9 +- indra/newview/llviewertexturelist.cpp | 14 +- indra/newview/llviewertexturelist.h | 3 - indra/newview/llviewerwindow.cpp | 7 +- indra/newview/llworld.cpp | 36 ++-- indra/newview/pipeline.cpp | 5 +- 19 files changed, 461 insertions(+), 503 deletions(-) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 6e2a2b140f..218f6dbcd0 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -28,7 +28,7 @@ #include "llstl.h" #include "lltimer.h" // ms_sleep() -#include "lltrace.h" +#include "lltracethreadrecorder.h" //============================================================================ diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 6723e427f5..cc661bab59 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -33,6 +33,7 @@ #include "lltimer.h" #include "lltrace.h" +#include "lltracethreadrecorder.h" #if LL_LINUX || LL_SOLARIS #include <sched.h> diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 2b1c8d8ce8..d5911ece25 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -27,6 +27,7 @@ #include "lltrace.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" namespace LLTrace { diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index d83ea77363..539a37ce31 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -32,9 +32,9 @@ #include "llmemory.h" #include "llrefcount.h" -#include "lltracerecording.h" -#include "lltracethreadrecorder.h" +//#include "lltracethreadrecorder.h" #include "llunit.h" +#include "llapr.h" #include <list> @@ -44,6 +44,8 @@ namespace LLTrace { + class Recording; + void init(); void cleanup(); @@ -89,23 +91,23 @@ namespace LLTrace return mStorage[index]; } - void mergeSamples(const AccumulatorBuffer<ACCUMULATOR>& other) + void addSamples(const AccumulatorBuffer<ACCUMULATOR>& other) { llassert(mNextStorageSlot == other.mNextStorageSlot); for (size_t i = 0; i < mNextStorageSlot; i++) { - mStorage[i].mergeSamples(other.mStorage[i]); + mStorage[i].addSamples(other.mStorage[i]); } } - void mergeDeltas(const AccumulatorBuffer<ACCUMULATOR>& start, const AccumulatorBuffer<ACCUMULATOR>& finish) + void addDeltas(const AccumulatorBuffer<ACCUMULATOR>& start, const AccumulatorBuffer<ACCUMULATOR>& finish) { llassert(mNextStorageSlot == start.mNextStorageSlot && mNextStorageSlot == finish.mNextStorageSlot); for (size_t i = 0; i < mNextStorageSlot; i++) { - mStorage[i].mergeDeltas(start.mStorage[i], finish.mStorage[i]); + mStorage[i].addDeltas(start.mStorage[i], finish.mStorage[i]); } } @@ -173,8 +175,9 @@ namespace LLTrace class LL_COMMON_API TraceType { public: - TraceType(const std::string& name) - : mName(name) + TraceType(const char* name, const char* description = NULL) + : mName(name), + mDescription(description ? description : "") { mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } @@ -189,6 +192,7 @@ namespace LLTrace protected: std::string mName; + std::string mDescription; size_t mAccumulatorIndex; }; @@ -201,6 +205,8 @@ namespace LLTrace : mSum(0), mMin(0), mMax(0), + mMean(0), + mVarianceSum(0), mNumSamples(0) {} @@ -218,10 +224,11 @@ namespace LLTrace } F32 old_mean = mMean; mMean += ((F32)value - old_mean) / (F32)mNumSamples; - mStandardDeviation += ((F32)value - old_mean) * ((F32)value - mMean); + mVarianceSum += ((F32)value - old_mean) * ((F32)value - mMean); + mLastValue = value; } - void mergeSamples(const MeasurementAccumulator<T>& other) + void addSamples(const MeasurementAccumulator<T>& other) { mSum += other.mSum; if (other.mMin < mMin) @@ -240,19 +247,20 @@ namespace LLTrace n_2 = (F32)other.mNumSamples; F32 m_1 = mMean, m_2 = other.mMean; - F32 sd_1 = mStandardDeviation, - sd_2 = other.mStandardDeviation; + F32 sd_1 = getStandardDeviation(), + sd_2 = other.getStandardDeviation(); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F32 variance = ((((n_1 - 1.f) * sd_1 * sd_1) - + ((n_2 - 1.f) * sd_2 * sd_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); - mStandardDeviation = sqrtf(variance); + mVarianceSum = (F32)mNumSamples + * ((((n_1 - 1.f) * sd_1 * sd_1) + + ((n_2 - 1.f) * sd_2 * sd_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + mLastValue = other.mLastValue; } - void mergeDeltas(const MeasurementAccumulator<T>& start, const MeasurementAccumulator<T>& finish) + void addDeltas(const MeasurementAccumulator<T>& start, const MeasurementAccumulator<T>& finish) { llerrs << "Delta merge invalid for measurement accumulators" << llendl; } @@ -268,16 +276,18 @@ namespace LLTrace T getSum() const { return mSum; } T getMin() const { return mMin; } T getMax() const { return mMax; } + T getLastValue() const { return mLastValue; } F32 getMean() const { return mMean; } - F32 getStandardDeviation() const { return mStandardDeviation; } + F32 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } private: T mSum, mMin, - mMax; + mMax, + mLastValue; F32 mMean, - mStandardDeviation; + mVarianceSum; U32 mNumSamples; }; @@ -297,13 +307,13 @@ namespace LLTrace mSum += value; } - void mergeSamples(const RateAccumulator<T>& other) + void addSamples(const RateAccumulator<T>& other) { mSum += other.mSum; mNumSamples += other.mNumSamples; } - void mergeDeltas(const RateAccumulator<T>& start, const RateAccumulator<T>& finish) + void addDeltas(const RateAccumulator<T>& start, const RateAccumulator<T>& finish) { mSum += finish.mSum - start.mSum; mNumSamples += finish.mNumSamples - start.mNumSamples; @@ -329,7 +339,10 @@ namespace LLTrace public LLInstanceTracker<Measurement<T, IS_UNIT>, std::string> { public: - Measurement(const std::string& name) + typedef T storage_t; + typedef T base_unit_t; + + Measurement(const char* name, const char* description = NULL) : TraceType(name), LLInstanceTracker(name) {} @@ -345,8 +358,11 @@ namespace LLTrace : public Measurement<typename T::value_t> { public: + typedef typename T::storage_t storage_t; + typedef typename T::base_unit_t base_unit_t; + typedef Measurement<typename T::value_t> base_measurement_t; - Measurement(const std::string& name) + Measurement(const char* name, const char* description = NULL) : Measurement<typename T::value_t>(name) {} @@ -363,7 +379,10 @@ namespace LLTrace public LLInstanceTracker<Rate<T>, std::string> { public: - Rate(const std::string& name) + typedef T storage_t; + typedef T base_unit_t; + + Rate(const char* name, const char* description = NULL) : TraceType(name), LLInstanceTracker(name) {} @@ -379,7 +398,10 @@ namespace LLTrace : public Rate<typename T::value_t> { public: - Rate(const std::string& name) + typedef typename T::storage_t storage_t; + typedef typename T::base_unit_t base_unit_t; + + Rate(const char* name, const char* description = NULL) : Rate<typename T::value_t>(name) {} @@ -394,7 +416,9 @@ namespace LLTrace class LL_COMMON_API Count { public: - Count(const std::string& name) + typedef typename Rate<T>::base_unit_t base_unit_t; + + Count(const char* name) : mIncrease(name + "_increase"), mDecrease(name + "_decrease"), mTotal(name) @@ -413,7 +437,7 @@ namespace LLTrace mTotal.add(value); } private: - friend class LLTrace::Recording; + friend LLTrace::Recording; Rate<T> mIncrease; Rate<T> mDecrease; Rate<T> mTotal; @@ -433,14 +457,14 @@ namespace LLTrace bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame std::vector<TimerAccumulator*> mChildren; // currently assumed child timers - void mergeSamples(const TimerAccumulator& other) + void addSamples(const TimerAccumulator& other) { mTotalTimeCounter += other.mTotalTimeCounter; mChildTimeCounter += other.mChildTimeCounter; mCalls += other.mCalls; } - void mergeDeltas(const TimerAccumulator& start, const TimerAccumulator& finish) + void addDeltas(const TimerAccumulator& start, const TimerAccumulator& finish) { mTotalTimeCounter += finish.mTotalTimeCounter - start.mTotalTimeCounter; mChildTimeCounter += finish.mChildTimeCounter - start.mChildTimeCounter; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f0b17ef100..e20bf797e7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -25,8 +25,9 @@ #include "linden_common.h" -#include "lltracerecording.h" #include "lltrace.h" +#include "lltracerecording.h" +#include "lltracethreadrecorder.h" #include "llthread.h" namespace LLTrace @@ -101,99 +102,22 @@ void Recording::makePrimary() mStackTimers.write()->makePrimary(); } -bool Recording::isPrimary() +bool Recording::isPrimary() const { return mRates->isPrimary(); } -void Recording::mergeSamples( const Recording& other ) +void Recording::addSamples( const Recording& other ) { - mRates.write()->mergeSamples(*other.mRates); - mMeasurements.write()->mergeSamples(*other.mMeasurements); - mStackTimers.write()->mergeSamples(*other.mStackTimers); + mRates.write()->addSamples(*other.mRates); + mMeasurements.write()->addSamples(*other.mMeasurements); + mStackTimers.write()->addSamples(*other.mStackTimers); } -void Recording::mergeDeltas(const Recording& baseline, const Recording& target) +void Recording::addDeltas(const Recording& baseline, const Recording& target) { - mRates.write()->mergeDeltas(*baseline.mRates, *target.mRates); - mStackTimers.write()->mergeDeltas(*baseline.mStackTimers, *target.mStackTimers); + mRates.write()->addDeltas(*baseline.mRates, *target.mRates); + mStackTimers.write()->addDeltas(*baseline.mStackTimers, *target.mStackTimers); } - -F32 Recording::getSum(const Rate<F32>& stat) -{ - return stat.getAccumulator(mRates).getSum(); -} - -F32 Recording::getPerSec(const Rate<F32>& stat) -{ - return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; -} - -F32 Recording::getSum(const Measurement<F32>& stat) -{ - return stat.getAccumulator(mMeasurements).getSum(); -} - -F32 Recording::getMin(const Measurement<F32>& stat) -{ - return stat.getAccumulator(mMeasurements).getMin(); -} - -F32 Recording::getMax(const Measurement<F32>& stat) -{ - return stat.getAccumulator(mMeasurements).getMax(); -} - -F32 Recording::getMean(const Measurement<F32>& stat) -{ - return stat.getAccumulator(mMeasurements).getMean(); -} - -F32 Recording::getStandardDeviation(const Measurement<F32>& stat) -{ - return stat.getAccumulator(mMeasurements).getStandardDeviation(); -} - -F32 Recording::getSum(const Count<F32>& stat) -{ - return getSum(stat.mTotal); -} - -F32 Recording::getPerSec(const Count<F32>& stat) -{ - return getPerSec(stat.mTotal); -} - -F32 Recording::getIncrease(const Count<F32>& stat) -{ - return getSum(stat.mIncrease); -} - -F32 Recording::getIncreasePerSec(const Count<F32>& stat) -{ - return getPerSec(stat.mIncrease); -} - -F32 Recording::getDecrease(const Count<F32>& stat) -{ - return getSum(stat.mDecrease); -} - -F32 Recording::getDecreasePerSec(const Count<F32>& stat) -{ - return getPerSec(stat.mDecrease); -} - -F32 Recording::getChurn(const Count<F32>& stat) -{ - return getIncrease(stat) + getDecrease(stat); -} - -F32 Recording::getChurnPerSec(const Count<F32>& stat) -{ - return getIncreasePerSec(stat) + getDecreasePerSec(stat); -} - - } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 4d53cd9600..d0c2e754f5 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -32,16 +32,17 @@ #include "llpointer.h" #include "lltimer.h" +#include "lltrace.h" namespace LLTrace { - template<typename T, typename IS_UNIT> class Rate; - template<typename T, typename IS_UNIT> class Measurement; - template<typename T> class Count; - template<typename T> class AccumulatorBuffer; - template<typename T> class RateAccumulator; - template<typename T> class MeasurementAccumulator; - class TimerAccumulator; + //template<typename T, typename IS_UNIT> class Rate; + //template<typename T, typename IS_UNIT> class Measurement; + //template<typename T> class Count; + //template<typename T> class AccumulatorBuffer; + //template<typename T> class RateAccumulator; + //template<typename T> class MeasurementAccumulator; + //class TimerAccumulator; class LL_COMMON_API Recording { @@ -51,43 +52,125 @@ namespace LLTrace ~Recording(); void makePrimary(); - bool isPrimary(); + bool isPrimary() const; void start(); void stop(); void resume(); - - void mergeSamples(const Recording& other); - void mergeDeltas(const Recording& baseline, const Recording& target); - void reset(); void update(); + bool isStarted() const { return mIsStarted; } - bool isStarted() { return mIsStarted; } + void addSamples(const Recording& other); + void addDeltas(const Recording& baseline, const Recording& target); // Rate accessors - F32 getSum(const Rate<F32, void>& stat); - F32 getPerSec(const Rate<F32, void>& stat); + template <typename T, typename IS_UNIT> + typename Rate<T, IS_UNIT>::base_unit_t getSum(const Rate<T, IS_UNIT>& stat) const + { + return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mRates).getSum(); + } + + template <typename T, typename IS_UNIT> + typename Rate<T, IS_UNIT>::base_unit_t getPerSec(const Rate<T, IS_UNIT>& stat) const + { + return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mRates).getSum() / mElapsedSeconds; + } // Measurement accessors - F32 getSum(const Measurement<F32, void>& stat); - F32 getPerSec(const Measurement<F32, void>& stat); - F32 getMin(const Measurement<F32, void>& stat); - F32 getMax(const Measurement<F32, void>& stat); - F32 getMean(const Measurement<F32, void>& stat); - F32 getStandardDeviation(const Measurement<F32, void>& stat); + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getSum(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum(); + + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getPerSec(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getMin(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMin(); + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getMax(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMax(); + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getMean(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMean(); + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getStandardDeviation(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getStandardDeviation(); + } + + template <typename T, typename IS_UNIT> + typename Measurement<T, IS_UNIT>::base_unit_t getLastValue(const Measurement<T, IS_UNIT>& stat) const + { + return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getLastValue(); + } // Count accessors - F32 getSum(const Count<F32>& stat); - F32 getPerSec(const Count<F32>& stat); - F32 getIncrease(const Count<F32>& stat); - F32 getIncreasePerSec(const Count<F32>& stat); - F32 getDecrease(const Count<F32>& stat); - F32 getDecreasePerSec(const Count<F32>& stat); - F32 getChurn(const Count<F32>& stat); - F32 getChurnPerSec(const Count<F32>& stat); - - F64 getSampleTime() { return mElapsedSeconds; } + template <typename T> + typename Count<T>::base_unit_t getSum(const Count<T>& stat) const + { + return getSum(stat.mTotal); + } + + template <typename T> + typename Count<T>::base_unit_t getPerSec(const Count<T>& stat) const + { + return getPerSec(stat.mTotal); + } + + template <typename T> + typename Count<T>::base_unit_t getIncrease(const Count<T>& stat) const + { + return getPerSec(stat.mTotal); + } + + template <typename T> + typename Count<T>::base_unit_t getIncreasePerSec(const Count<T>& stat) const + { + return getPerSec(stat.mIncrease); + } + + template <typename T> + typename Count<T>::base_unit_t getDecrease(const Count<T>& stat) const + { + return getPerSec(stat.mDecrease); + } + + template <typename T> + typename Count<T>::base_unit_t getDecreasePerSec(const Count<T>& stat) const + { + return getPerSec(stat.mDecrease); + } + + template <typename T> + typename Count<T>::base_unit_t getChurn(const Count<T>& stat) const + { + return getIncrease(stat) + getDecrease(stat); + } + + template <typename T> + typename Count<T>::base_unit_t getChurnPerSec(const Count<T>& stat) const + { + return getIncreasePerSec(stat) + getDecreasePerSec(stat); + } + + F64 getSampleTime() const { return mElapsedSeconds; } private: friend class ThreadRecorder; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index b2c6fe3b80..78833835c2 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -25,7 +25,7 @@ #include "linden_common.h" -#include "lltrace.h" +#include "lltracethreadrecorder.h" namespace LLTrace { @@ -118,16 +118,16 @@ ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other) { - mBaseline.mMeasurements.write()->mergeSamples(*other.mBaseline.mMeasurements); + mBaseline.mMeasurements.write()->addSamples(*other.mBaseline.mMeasurements); } void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current) { // accumulate statistics-like measurements - mTargetRecording->mMeasurements.write()->mergeSamples(*mBaseline.mMeasurements); + mTargetRecording->mMeasurements.write()->addSamples(*mBaseline.mMeasurements); // for rate-like measurements, merge total change since baseline - mTargetRecording->mRates.write()->mergeDeltas(*mBaseline.mRates, *current->mRates); - mTargetRecording->mStackTimers.write()->mergeDeltas(*mBaseline.mStackTimers, *current->mStackTimers); + mTargetRecording->mRates.write()->addDeltas(*mBaseline.mRates, *current->mRates); + mTargetRecording->mStackTimers.write()->addDeltas(*mBaseline.mStackTimers, *current->mStackTimers); // reset baselines mBaseline.mRates.write()->copyFrom(*current->mRates); mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers); @@ -161,13 +161,13 @@ void SlaveThreadRecorder::pushToMaster() void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) { LLMutexLock lock(&mRecorderMutex); - mRecorder.mergeSamples(source); + mRecorder.addSamples(source); } void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) { LLMutexLock lock(&mRecorderMutex); - sink.mergeSamples(mRecorder); + sink.addSamples(mRecorder); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 9d78df7cae..4663070c42 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -30,21 +30,24 @@ #include "stdtypes.h" #include "llpreprocessor.h" -template<typename BASE_UNIT, typename DERIVED_UNIT = BASE_UNIT> -struct LLUnit : public BASE_UNIT +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT = BASE_UNIT> +struct LLUnitType : public BASE_UNIT { - typedef LLUnit<BASE_UNIT, DERIVED_UNIT> unit_t; + typedef DERIVED_UNIT unit_t; typedef typename BASE_UNIT::value_t value_t; typedef void is_unit_t; - LLUnit() + LLUnitType() {} - explicit LLUnit(value_t value) + explicit LLUnitType(value_t value) : BASE_UNIT(convertToBase(value)) {} - operator value_t() { return get(); } + operator unit_t& () + { + return static_cast<unit_t&>(*this); + } value_t get() const { @@ -53,47 +56,72 @@ struct LLUnit : public BASE_UNIT static value_t convertToBase(value_t derived_value) { - return (value_t)((F32)derived_value * DERIVED_UNIT::conversionToBaseFactor()); + return (value_t)((F32)derived_value * unit_t::conversionToBaseFactor()); } static value_t convertToDerived(value_t base_value) { - return (value_t)((F32)base_value / DERIVED_UNIT::conversionToBaseFactor()); + return (value_t)((F32)base_value / unit_t::conversionToBaseFactor()); + } + + unit_t operator + (const unit_t other) const + { + return unit_t(mValue + other.mValue); + } + + unit_t operator - (const unit_t other) const + { + return unit_t(mValue - other.mValue); + } + + unit_t operator * (value_t multiplicand) const + { + return unit_t(mValue * multiplicand); + } + + unit_t operator / (value_t divisor) const + { + return unit_t(mValue / divisor); } }; -template<typename T> -struct LLUnit<T, T> +template<typename STORAGE_TYPE, typename T> +struct LLUnitType<STORAGE_TYPE, T, T> { - typedef LLUnit<T, T> unit_t; - typedef T value_t; + typedef T unit_t; + typedef typename STORAGE_TYPE value_t; typedef void is_unit_t; - LLUnit() + LLUnitType() : mValue() {} - explicit LLUnit(T value) + explicit LLUnitType(value_t value) : mValue(value) {} - unit_t& operator=(T value) + unit_t& operator=(value_t value) { setBaseValue(value); return *this; } + operator unit_t& () + { + return static_cast<unit_t&>(*this); + } + value_t get() { return mValue; } static value_t convertToBase(value_t derived_value) { - return (value_t)1; + return (value_t)derived_value; } static value_t convertToDerived(value_t base_value) { - return (value_t)1; + return (value_t)base_value; } unit_t operator + (const unit_t other) const @@ -137,68 +165,74 @@ struct LLUnit<T, T> } protected: - void setBaseValue(T value) + void setBaseValue(value_t value) { mValue = value; } - T mValue; + value_t mValue; }; -#define LL_DECLARE_BASE_UNIT(unit_name) \ - template<typename STORAGE_TYPE> \ - struct unit_name : public LLUnit<STORAGE_TYPE> \ - { \ - unit_name(STORAGE_TYPE value) \ - : LLUnit(value) \ - {} \ - \ - unit_name() \ - {} \ - \ - template <typename T> \ - unit_name(const LLUnit<unit_name, T>& other) \ - { \ - setBaseValue(other.unit_name::get()); \ - } \ - \ - using LLUnit<STORAGE_TYPE>::operator +; \ - using LLUnit<STORAGE_TYPE>::operator +=; \ - using LLUnit<STORAGE_TYPE>::operator -; \ - using LLUnit<STORAGE_TYPE>::operator -=; \ - using LLUnit<STORAGE_TYPE>::operator *; \ - using LLUnit<STORAGE_TYPE>::operator *=; \ - using LLUnit<STORAGE_TYPE>::operator /; \ - using LLUnit<STORAGE_TYPE>::operator /=; \ +#define LL_DECLARE_BASE_UNIT(unit_name) \ + template<typename STORAGE_TYPE> \ + struct unit_name : public LLUnitType<STORAGE_TYPE, unit_name<STORAGE_TYPE> > \ + { \ + typedef unit_name<STORAGE_TYPE> base_unit_t; \ + typedef STORAGE_TYPE storage_t; \ + \ + unit_name(STORAGE_TYPE value) \ + : LLUnitType(value) \ + {} \ + \ + unit_name() \ + {} \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + unit_name(const LLUnitType<SOURCE_STORAGE_TYPE, unit_name, SOURCE_TYPE>& source) \ + { \ + setBaseValue(source.unit_t::get()); \ + } \ + \ + using LLUnitType::operator +; \ + using LLUnitType::operator +=; \ + using LLUnitType::operator -; \ + using LLUnitType::operator -=; \ + using LLUnitType::operator *; \ + using LLUnitType::operator *=; \ + using LLUnitType::operator /; \ + using LLUnitType::operator /=; \ }; -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - template<typename STORAGE_TYPE> \ - struct derived_unit : public LLUnit<base_unit<STORAGE_TYPE>, derived_unit<STORAGE_TYPE> > \ - { \ - derived_unit(value_t value) \ - : LLUnit(value) \ - {} \ - \ - derived_unit() \ - {} \ - \ - template <typename T> \ - derived_unit(const LLUnit<base_unit<STORAGE_TYPE>, T>& other) \ - { \ - setBaseValue(other.base_unit<STORAGE_TYPE>::get()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - using LLUnit<STORAGE_TYPE>::operator +; \ - using LLUnit<STORAGE_TYPE>::operator +=; \ - using LLUnit<STORAGE_TYPE>::operator -; \ - using LLUnit<STORAGE_TYPE>::operator -=; \ - using LLUnit<STORAGE_TYPE>::operator *; \ - using LLUnit<STORAGE_TYPE>::operator *=; \ - using LLUnit<STORAGE_TYPE>::operator /; \ - using LLUnit<STORAGE_TYPE>::operator /=; \ +#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ + template<typename STORAGE_TYPE> \ + struct derived_unit : public LLUnitType<STORAGE_TYPE, base_unit<STORAGE_TYPE>, derived_unit<STORAGE_TYPE> > \ + { \ + typedef base_unit<STORAGE_TYPE> base_unit_t; \ + typedef STORAGE_TYPE storage_t; \ + \ + derived_unit(value_t value) \ + : LLUnitType(value) \ + {} \ + \ + derived_unit() \ + {} \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + derived_unit(const LLUnitType<SOURCE_STORAGE_TYPE, base_unit<STORAGE_TYPE>, SOURCE_TYPE>& source) \ + { \ + setBaseValue(source.base_unit_t::get()); \ + } \ + \ + static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ + \ + using LLUnitType::operator +; \ + using LLUnitType::operator +=; \ + using LLUnitType::operator -; \ + using LLUnitType::operator -=; \ + using LLUnitType::operator *; \ + using LLUnitType::operator *=; \ + using LLUnitType::operator /; \ + using LLUnitType::operator /=; \ }; namespace LLUnits diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index bc9603804b..4cbf695059 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -37,6 +37,7 @@ #include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" /////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index aed9e4ec93..1d4527aaa3 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -36,6 +36,7 @@ #include "llgl.h" #include "llglheaders.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" //#include "llviewercontrol.h" /////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index e7538d685d..2ce5f95b54 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2316,7 +2316,8 @@ S32 LLTextureFetch::update(F32 max_time_ms) if(mCurlGetRequest) { - gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(mCurlGetRequest->getTotalReceivedBits()); + //gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); } if(mFetchDebugger) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 85ea543838..79ed093382 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4756,18 +4756,23 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) switch (stat_id) { case LL_SIM_STAT_TIME_DILATION: - LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value); + LLStatViewer::SIM_TIME_DILATION.sample(stat_value); + //LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value); break; case LL_SIM_STAT_FPS: - LLViewerStats::getInstance()->mSimFPS.addValue(stat_value); + LLStatViewer::SIM_FPS.sample(stat_value); + //LLViewerStats::getInstance()->mSimFPS.addValue(stat_value); break; case LL_SIM_STAT_PHYSFPS: - LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value); + LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value); + //LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value); break; case LL_SIM_STAT_AGENTUPS: - LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); + LLStatViewer::SIM_AGENT_UPS.sample(stat_value); + //LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); break; case LL_SIM_STAT_FRAMEMS: + //LLStatViewer::SIM_.sample(stat_value); LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value); break; case LL_SIM_STAT_NETMS: diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 954fa24eaa..2737d24674 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,32 +64,32 @@ namespace LLStatViewer { -LLTrace::Rate<F32> FPS("fpsstat"), - PACKETS_IN("packetsinstat"), - PACKETS_LOST("packetsloststat"), - PACKETS_OUT("packetsoutstat"), - TEXTURE_PACKETS("texturepacketsstat"), - TRIANGLES_DRAWN("trianglesdrawnstat"), - CHAT_COUNT("chatcount"), - IM_COUNT("imcount"), - OBJECT_CREATE("objectcreate"), - OBJECT_REZ("objectrez"), - LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay"), - LOGIN_TIMEOUTS("logintimeouts"), - FAILED_DOWNLOADS("faileddownloads"), - LSL_SAVES("lslsaves"), - ANIMATION_UPLOADS("animationuploads"), - FLY("fly"), - TELEPORT("teleport"), - DELETE_OBJECT("deleteobject"), - SNAPSHOT("snapshot"), - UPLOAD_SOUND("uploadsound"), - UPLOAD_TEXTURE("uploadtexture"), - EDIT_TEXTURE("edittexture"), - KILLED("killed"), - FRAMETIME_DOUBLED("frametimedoubled"), - TEX_BAKES("texbakes"), - TEX_REBAKES("texrebakes"); +LLTrace::Rate<F32> FPS("fpsstat"), + PACKETS_IN("packetsinstat"), + PACKETS_LOST("packetsloststat"), + PACKETS_OUT("packetsoutstat"), + TEXTURE_PACKETS("texturepacketsstat"), + TRIANGLES_DRAWN("trianglesdrawnstat"), + CHAT_COUNT("chatcount", "Chat messages sent"), + IM_COUNT("imcount", "IMs sent"), + OBJECT_CREATE("objectcreate"), + OBJECT_REZ("objectrez", "Object rez count"), + LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"), + LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"), + FAILED_DOWNLOADS("faileddownloads", "Number of times LLAssetStorage::getAssetData() has failed"), + LSL_SAVES("lslsaves", "Number of times user has saved a script"), + ANIMATION_UPLOADS("animationuploads", "Animations uploaded"), + FLY("fly", "Fly count"), + TELEPORT("teleport", "Teleport count"), + DELETE_OBJECT("deleteobject", "Objects deleted"), + SNAPSHOT("snapshot", "Snapshots taken"), + UPLOAD_SOUND("uploadsound", "Sounds uploaded"), + UPLOAD_TEXTURE("uploadtexture", "Textures uploaded"), + EDIT_TEXTURE("edittexture", "Changes to textures on objects"), + KILLED("killed", "Number of times killed"), + FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"), + TEX_BAKES("texbakes"), + TEX_REBAKES("texrebakes"); LLTrace::Rate<LLUnits::Bytes<F32> > KBIT("kbitstat"), LAYERS_KBIT("layerskbitstat"), OBJECT_KBIT("objectkbitstat"), @@ -98,53 +98,54 @@ LLTrace::Rate<LLUnits::Bytes<F32> > KBIT("kbitstat"), ACTUAL_IN_KBIT("actualinkbit"), ACTUAL_OUT_KBIT("actualoutkbit"); -LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittimr"), - TOOLBOX_TIME("toolboxtime"), - MOUSELOOK_TIME("mouselooktime"), - FPS_10_TIME("fps10time"), - FPS_8_TIME("fps8time"), - FPS_2_TIME("fps2time"), - SIM_20_FPS_TIME("sim20fpstime"), - SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime"), - LOSS_5_PERCENT_TIME("loss5percenttime"); - -LLTrace::Measurement<F32> SIM_TIME_DILATION("simtimedilation"), - SIM_FPS("simfps"), - SIM_PHYSICS_FPS("simphysicsfps"), - SIM_AGENT_UPS("simagentups"), - SIM_SCRIPT_EPS("simscripteps"), - SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"), - SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"), - SIM_MAIN_AGENTS("simmainagents"), - SIM_CHILD_AGENTS("simchildagents"), - SIM_OBJECTS("simobjects"), - SIM_ACTIVE_OBJECTS("simactiveobjects"), - SIM_ACTIVE_SCRIPTS("simactivescripts"), - SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"), - SIM_IN_PACKETS_PER_SEC("siminpps"), - SIM_OUT_PACKETS_PER_SEC("simoutpps"), - SIM_PENDING_DOWNLOADS("simpendingdownloads"), - SIM_PENDING_UPLOADS("simpendinguploads"), - SIM_PENING_LOCAL_UPLOADS("simpendinglocaluploads"), - SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"), - SIM_PHYSICS_LOD_TASKS("physicslodtasks"), - NUM_IMAGES("numimagesstat"), - NUM_RAW_IMAGES("numrawimagesstat"), - NUM_OBJECTS("numobjectsstat"), - NUM_ACTIVE_OBJECTS("numactiveobjectsstat"), - NUM_NEW_OBJECTS("numnewobjectsstat"), - NUM_SIZE_CULLED("numsizeculledstat"), - NUM_VIS_CULLED("numvisculledstat"), - ENABLE_VBO("enablevbo"), - DELTA_BANDWIDTH("deltabandwidth"), - MAX_BANDWIDTH("maxbandwidth"), - LIGHTING_DETAIL("lightingdetail"), - VISIBLE_AVATARS("visibleavatars"), - SHADER_OBJECTS("shaderobjects"), - DRAW_DISTANCE("drawdistance"), - CHAT_BUBBLES("chatbubbles"), - WINDOW_WIDTH("windowwidth"), - WINDOW_HEIGHT("windowheight"); +LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), + TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), + MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"), + FPS_10_TIME("fps10time", "Seconds below 10 FPS"), + FPS_8_TIME("fps8time", "Seconds below 8 FPS"), + FPS_2_TIME("fps2time", "Seconds below 2 FPS"), + SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"), + SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"), + LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%"); + +LLTrace::Measurement<F32> SIM_TIME_DILATION("simtimedilation"), + SIM_FPS("simfps"), + SIM_PHYSICS_FPS("simphysicsfps"), + SIM_AGENT_UPS("simagentups"), + SIM_SCRIPT_EPS("simscripteps"), + SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"), + SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"), + SIM_MAIN_AGENTS("simmainagents"), + SIM_CHILD_AGENTS("simchildagents"), + SIM_OBJECTS("simobjects"), + SIM_ACTIVE_OBJECTS("simactiveobjects"), + SIM_ACTIVE_SCRIPTS("simactivescripts"), + SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"), + SIM_IN_PACKETS_PER_SEC("siminpps"), + SIM_OUT_PACKETS_PER_SEC("simoutpps"), + SIM_PENDING_DOWNLOADS("simpendingdownloads"), + SIM_PENDING_UPLOADS("simpendinguploads"), + SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads"), + SIM_PENDING_VFS_OPERATIONS("vfspendingoperations"), + SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"), + SIM_PHYSICS_LOD_TASKS("physicslodtasks"), + NUM_IMAGES("numimagesstat"), + NUM_RAW_IMAGES("numrawimagesstat"), + NUM_OBJECTS("numobjectsstat"), + NUM_ACTIVE_OBJECTS("numactiveobjectsstat"), + NUM_NEW_OBJECTS("numnewobjectsstat"), + NUM_SIZE_CULLED("numsizeculledstat"), + NUM_VIS_CULLED("numvisculledstat"), + ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"), + DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), + MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"), + LIGHTING_DETAIL("lightingdetail", "Lighting Detail"), + VISIBLE_AVATARS("visibleavatars", "Visible Avatars"), + SHADER_OBJECTS("shaderobjects", "Object Shaders"), + DRAW_DISTANCE("drawdistance", "Draw Distance"), + CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"), + WINDOW_WIDTH("windowwidth", "Window width"), + WINDOW_HEIGHT("windowheight", "Window height"); LLTrace::Measurement<LLUnits::Bytes<F32> > SIM_UNACKED_BYTES("simtotalunackedbytes"), SIM_PHYSICS_MEM("physicsmemoryallocated"), @@ -166,14 +167,16 @@ LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec SIM_SLEEP_TIME("simsleepmsec"), SIM_PUMP_IO_TIME("simpumpiomsec"), SIM_PING("simpingstat"), - LOGIN_SECONDS("loginseconds"), - REGION_CROSSING_TIME("regioncrossingtime"), - FRAME_STACKTIME("framestacktime"), - UPDATE_STACKTIME("updatestacktime"), - NETWORK_STACKTIME("networkstacktime"), - IMAGE_STACKTIME("imagestacktime"), - REBUILD_STACKTIME("rebuildstacktime"), - RENDER_STACKTIME("renderstacktime"); + FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), + FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), + LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), + REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), + FRAME_STACKTIME("framestacktime", "FRAME_SECS"), + UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"), + NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"), + IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"), + REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"), + RENDER_STACKTIME("renderstacktime", "RENDER_SECS"); } class StatAttributes @@ -190,139 +193,18 @@ public: BOOL mEnabled; }; -const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] = -{ - // ST_VERSION - StatAttributes("Version", TRUE), - // ST_AVATAR_EDIT_SECONDS - StatAttributes("Seconds in Edit Appearence", FALSE), - // ST_TOOLBOX_SECONDS - StatAttributes("Seconds using Toolbox", FALSE), - // ST_CHAT_COUNT - StatAttributes("Chat messages sent", FALSE), - // ST_IM_COUNT - StatAttributes("IMs sent", FALSE), - // ST_FULLSCREEN_BOOL - StatAttributes("Fullscreen mode", FALSE), - // ST_RELEASE_COUNT - StatAttributes("Object release count", FALSE), - // ST_CREATE_COUNT - StatAttributes("Object create count", FALSE), - // ST_REZ_COUNT - StatAttributes("Object rez count", FALSE), - // ST_FPS_10_SECONDS - StatAttributes("Seconds below 10 FPS", FALSE), - // ST_FPS_2_SECONDS - StatAttributes("Seconds below 2 FPS", FALSE), - // ST_MOUSELOOK_SECONDS - StatAttributes("Seconds in Mouselook", FALSE), - // ST_FLY_COUNT - StatAttributes("Fly count", FALSE), - // ST_TELEPORT_COUNT - StatAttributes("Teleport count", FALSE), - // ST_OBJECT_DELETE_COUNT - StatAttributes("Objects deleted", FALSE), - // ST_SNAPSHOT_COUNT - StatAttributes("Snapshots taken", FALSE), - // ST_UPLOAD_SOUND_COUNT - StatAttributes("Sounds uploaded", FALSE), - // ST_UPLOAD_TEXTURE_COUNT - StatAttributes("Textures uploaded", FALSE), - // ST_EDIT_TEXTURE_COUNT - StatAttributes("Changes to textures on objects", FALSE), - // ST_KILLED_COUNT - StatAttributes("Number of times killed", FALSE), - // ST_FRAMETIME_JITTER - StatAttributes("Average delta between successive frame times", FALSE), - // ST_FRAMETIME_SLEW - StatAttributes("Average delta between frame time and mean", FALSE), - // ST_INVENTORY_TOO_LONG - StatAttributes("Inventory took too long to load", FALSE), - // ST_WEARABLES_TOO_LONG - StatAttributes("Wearables took too long to load", FALSE), - // ST_LOGIN_SECONDS - StatAttributes("Time between LoginRequest and LoginReply", FALSE), - // ST_LOGIN_TIMEOUT_COUNT - StatAttributes("Number of login attempts that timed out", FALSE), - // ST_HAS_BAD_TIMER - StatAttributes("Known bad timer if != 0.0", FALSE), - // ST_DOWNLOAD_FAILED - StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE), - // ST_LSL_SAVE_COUNT - StatAttributes("Number of times user has saved a script", FALSE), - // ST_UPLOAD_ANIM_COUNT - StatAttributes("Animations uploaded", FALSE), - // ST_FPS_8_SECONDS - StatAttributes("Seconds below 8 FPS", FALSE), - // ST_SIM_FPS_20_SECONDS - StatAttributes("Seconds with sim FPS below 20", FALSE), - // ST_PHYS_FPS_20_SECONDS - StatAttributes("Seconds with physics FPS below 20", FALSE), - // ST_LOSS_05_SECONDS - StatAttributes("Seconds with packet loss > 5%", FALSE), - // ST_FPS_DROP_50_RATIO - StatAttributes("Ratio of frames 2x longer than previous", FALSE), - // ST_ENABLE_VBO - StatAttributes("Vertex Buffers Enabled", TRUE), - // ST_DELTA_BANDWIDTH - StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE), - // ST_MAX_BANDWIDTH - StatAttributes("Max bandwidth setting", FALSE), - // ST_LIGHTING_DETAIL - StatAttributes("Lighting Detail", FALSE), - // ST_VISIBLE_AVATARS - StatAttributes("Visible Avatars", FALSE), - // ST_SHADER_OJECTS - StatAttributes("Object Shaders", FALSE), - // ST_SHADER_ENVIRONMENT - StatAttributes("Environment Shaders", FALSE), - // ST_VISIBLE_DRAW_DIST - StatAttributes("Draw Distance", FALSE), - // ST_VISIBLE_CHAT_BUBBLES - StatAttributes("Chat Bubbles Enabled", FALSE), - // ST_SHADER_AVATAR - StatAttributes("Avatar Shaders", FALSE), - // ST_FRAME_SECS - StatAttributes("FRAME_SECS", FALSE), - // ST_UPDATE_SECS - StatAttributes("UPDATE_SECS", FALSE), - // ST_NETWORK_SECS - StatAttributes("NETWORK_SECS", FALSE), - // ST_IMAGE_SECS - StatAttributes("IMAGE_SECS", FALSE), - // ST_REBUILD_SECS - StatAttributes("REBUILD_SECS", FALSE), - // ST_RENDER_SECS - StatAttributes("RENDER_SECS", FALSE), - // ST_CROSSING_AVG - StatAttributes("CROSSING_AVG", FALSE), - // ST_CROSSING_MAX - StatAttributes("CROSSING_MAX", FALSE), - // ST_LIBXUL_WIDGET_USED - StatAttributes("LibXUL Widget used", FALSE), // Unused - // ST_WINDOW_WIDTH - StatAttributes("Window width", FALSE), - // ST_WINDOW_HEIGHT - StatAttributes("Window height", FALSE), - // ST_TEX_BAKES - StatAttributes("Texture Bakes", FALSE), - // ST_TEX_REBAKES - StatAttributes("Texture Rebakes", FALSE) - -}; - LLViewerStats::LLViewerStats() : - mVFSPendingOperations("vfspendingoperations"), - mFPSStat("fpsstat"), - mPacketsInStat("packetsinstat"), - mPacketsLostStat("packetsloststat"), - mPacketsOutStat("packetsoutstat"), - mPacketsLostPercentStat("packetslostpercentstat"), - mTexturePacketsStat("texturepacketsstat"), - mActualInKBitStat("actualinkbitstat"), - mActualOutKBitStat("actualoutkbitstat"), - mTrianglesDrawnStat("trianglesdrawnstat"), - mSimTimeDilation("simtimedilation"), + //mVFSPendingOperations("vfspendingoperations"), + //mFPSStat("fpsstat"), + //mPacketsInStat("packetsinstat"), + //mPacketsLostStat("packetsloststat"), + //mPacketsOutStat("packetsoutstat"), + //mPacketsLostPercentStat("packetslostpercentstat"), + //mTexturePacketsStat("texturepacketsstat"), + //mActualInKBitStat("actualinkbitstat"), + //mActualOutKBitStat("actualoutkbitstat"), + //mTrianglesDrawnStat("trianglesdrawnstat"), + //mSimTimeDilation("simtimedilation"), mSimFPS("simfps"), mSimPhysicsFPS("simphysicsfps"), mSimAgentUPS("simagentups"), @@ -393,13 +275,14 @@ LLViewerStats::~LLViewerStats() void LLViewerStats::resetStats() { LLViewerStats& stats = LLViewerStats::instance(); - stats.mVFSPendingOperations.reset(); - stats.mPacketsInStat.reset(); - stats.mPacketsLostStat.reset(); - stats.mPacketsOutStat.reset(); - stats.mFPSStat.reset(); - stats.mTexturePacketsStat.reset(); - stats.mAgentPositionSnaps.reset(); + stats.mRecording.reset(); + //stats.mVFSPendingOperations.reset(); + //stats.mPacketsInStat.reset(); + //stats.mPacketsLostStat.reset(); + //stats.mPacketsOutStat.reset(); + //stats.mFPSStat.reset(); + //stats.mTexturePacketsStat.reset(); + //stats.mAgentPositionSnaps.reset(); } @@ -484,16 +367,9 @@ void LLViewerStats::addToMessage(LLSD &body) const { LLSD &misc = body["misc"]; - for (S32 i = 0; i < ST_COUNT; i++) - { - if (STAT_INFO[i].mEnabled) - { - // TODO: send timer value so dataserver can normalize - misc[STAT_INFO[i].mName] = mStats[i]; - llinfos << "STAT: " << STAT_INFO[i].mName << ": " << mStats[i] - << llendl; - } - } + misc["Version"] = TRUE; + //TODO RN: get last value, not mean + misc["Vertex Buffers Enabled"] = mRecording.getMean(LLStatViewer::ENABLE_VBO); body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD(); llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() @@ -570,13 +446,15 @@ void update_statistics() stats.mSimPingStat.addValue(10000); } - stats.mFPSStat.addValue(1); + //stats.mFPSStat.addValue(1); + LLStatViewer::FPS.add(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); - stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); + //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); + LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -615,12 +493,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(LLViewerTextureList::sTextureBits); - //stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f); - stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets); - gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8; - LLViewerTextureList::sTextureBits = 0; - LLViewerTextureList::sTexturePackets = 0; + gTotalTextureBytes = LLUnits::Bytes<F32>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).get();//LLViewerTextureList::sTextureBits / 8; texture_stats_timer.reset(); } } diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index af2e915994..a14518f536 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -1,5 +1,5 @@ /** - * @file llviewerstats.h + * @file llviewerim_peningtats.h * @brief LLViewerStats class header file * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ @@ -97,7 +97,8 @@ extern LLTrace::Measurement<F32> SIM_TIME_DILATION, SIM_OUT_PACKETS_PER_SEC, SIM_PENDING_DOWNLOADS, SIM_PENDING_UPLOADS, - SIM_PENING_LOCAL_UPLOADS, + SIM_PENDING_LOCAL_UPLOADS, + SIM_PENDING_VFS_OPERATIONS, SIM_PHYSICS_PINNED_TASKS, SIM_PHYSICS_LOD_TASKS, NUM_IMAGES, @@ -138,6 +139,8 @@ extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME, SIM_SLEEP_TIME, SIM_PUMP_IO_TIME, SIM_PING, + FRAMETIME_JITTER, + FRAMETIME_SLEW, LOGIN_SECONDS, REGION_CROSSING_TIME, FRAME_STACKTIME, @@ -409,10 +412,12 @@ public: }; LLTrace::Recording& getRecording() { return mRecording; } + LLTrace::Recording& getFrameRecording() { return mFrameRecording; } private: F64 mStats[ST_COUNT]; LLTrace::Recording mRecording; + LLTrace::Recording mFrameRecording; F64 mLastTimeDiff; // used for time stat updates }; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index de3dd3c1c6..b22c0c797e 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -58,14 +58,13 @@ #include "pipeline.h" #include "llappviewer.h" #include "llxuiparser.h" +#include "lltracethreadrecorder.h" #include "llviewerdisplay.h" //////////////////////////////////////////////////////////////////////////// void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; -U32 LLViewerTextureList::sTextureBits = 0; -U32 LLViewerTextureList::sTexturePackets = 0; S32 LLViewerTextureList::sNumImages = 0; LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE); LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE); @@ -624,7 +623,7 @@ void LLViewerTextureList::updateImages(F32 max_time) LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); - LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT)); + LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT).get()); LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); @@ -1326,8 +1325,8 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } - gTextureList.sTextureBits += received_size * 8; - gTextureList.sTexturePackets++; + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size); + LLStatViewer::TEXTURE_PACKETS.add(1); U8 codec; U16 packets; @@ -1399,8 +1398,9 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } - gTextureList.sTextureBits += received_size * 8; - gTextureList.sTexturePackets++; + + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size); + LLStatViewer::TEXTURE_PACKETS.add(1); //llprintline("Start decode, image header..."); msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id); diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 3dda973d3f..ab6f009e28 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -201,9 +201,6 @@ private: LLFrameTimer mForceDecodeTimer; public: - static U32 sTextureBits; - static U32 sTexturePackets; - static LLStat sNumImagesStat; static LLStat sNumRawImagesStat; static LLStat sGLTexMemStat; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8b50e56fb3..4ad7c49d4b 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1402,10 +1402,11 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S FillRect(hdc, &wnd_rect, CreateSolidBrush(RGB(255, 255, 255))); std::string temp_str; + LLTrace::Recording& recording = LLViewerStats::instance().getRecording(); temp_str = llformat( "FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ - LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(), - LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), - LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); + recording.getPerSec(LLStatViewer::FPS), //mFPSStat.getMeanPerSec(), + recording.getMean(LLStatViewer::SIM_PHYSICS_FPS), //LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), + recording.getMean(LLStatViewer::SIM_TIME_DILATION)); //LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); S32 len = temp_str.length(); TextOutA(hdc, 0, 0, temp_str.c_str(), len); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index bf2a58f107..056132c165 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -703,21 +703,26 @@ void LLWorld::updateNetStats() S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); - LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); - LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); + LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits<F32> >(actual_in_bits); + LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits<F32> >(actual_out_bits); + //LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); + //LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); - LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); - LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); - LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); - if (packets_in) - { - LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); - } - else - { - LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f); - } + LLStatViewer::PACKETS_IN.add(packets_in); + LLStatViewer::PACKETS_OUT.add(packets_out); + LLStatViewer::PACKETS_LOST.add(packets_lost); + //LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); + //LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); + //LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); + //if (packets_in) + //{ + // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); + //} + //else + //{ + // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f); + //} mLastPacketsIn = gMessageSystem->mPacketsIn; mLastPacketsOut = gMessageSystem->mPacketsOut; @@ -1129,6 +1134,7 @@ void send_agent_pause() } gObjectList.mWasPaused = TRUE; + LLViewerStats::instance().getRecording().stop(); } @@ -1158,8 +1164,8 @@ void send_agent_resume() gMessageSystem->sendReliable(regionp->getHost()); } - // Reset the FPS counter to avoid an invalid fps - LLViewerStats::getInstance()->mFPSStat.reset(); + // Resume data collection to ignore invalid rates + LLViewerStats::instance().getRecording().resume();//getInstance()->mFPSStat.reset(); LLAppViewer::instance()->resumeMainloopTimeout(); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 86791a37fb..4582de805f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -488,7 +488,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_GLOW); - LLViewerStats::getInstance()->mTrianglesDrawnStat.reset(); + //LLViewerStats::getInstance()->mTrianglesDrawnStat.reset(); resetFrameStats(); for (U32 i = 0; i < NUM_RENDER_TYPES; ++i) @@ -1768,7 +1768,8 @@ void LLPipeline::resetFrameStats() { assertInitialized(); - LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f); + LLStatViewer::TRIANGLES_DRAWN.add(mTrianglesDrawn); + //LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f); if (mBatchCount > 0) { -- cgit v1.2.3 From 0f58ca02cdec62711eadb82ba28fcff08faef2ee Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 12 Oct 2012 00:20:19 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible cleaned up accumulator merging logic introduced frame recording to LLTrace directly instead of going through LLViewerStats moved consumer code over to frame recording instead of whatever the current active recording was --- indra/llcommon/lltrace.h | 49 +++--- indra/llcommon/lltracerecording.cpp | 214 ++++++++++++++++++++++++-- indra/llcommon/lltracerecording.h | 251 +++++++++---------------------- indra/llcommon/lltracethreadrecorder.cpp | 73 ++++----- indra/llcommon/lltracethreadrecorder.h | 7 +- indra/llui/llstatbar.cpp | 7 +- indra/llui/llstatbar.h | 35 +++-- indra/llui/llstatgraph.cpp | 6 +- indra/newview/llviewerstats.cpp | 2 + indra/newview/llviewerstats.h | 8 +- indra/newview/llviewertexturelist.cpp | 6 +- 11 files changed, 355 insertions(+), 303 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index a6334e176b..0c618a2f4b 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -101,16 +101,6 @@ namespace LLTrace } } - void addDeltas(const AccumulatorBuffer<ACCUMULATOR>& start, const AccumulatorBuffer<ACCUMULATOR>& finish) - { - llassert(mNextStorageSlot == start.mNextStorageSlot && mNextStorageSlot == finish.mNextStorageSlot); - - for (size_t i = 0; i < mNextStorageSlot; i++) - { - mStorage[i].addDeltas(start.mStorage[i], finish.mStorage[i]); - } - } - void copyFrom(const AccumulatorBuffer<ACCUMULATOR>& other) { for (size_t i = 0; i < mNextStorageSlot; i++) @@ -203,11 +193,12 @@ namespace LLTrace public: MeasurementAccumulator() : mSum(0), - mMin(0), - mMax(0), + mMin(std::numeric_limits<T>::max()), + mMax(std::numeric_limits<T>::min()), mMean(0), mVarianceSum(0), - mNumSamples(0) + mNumSamples(0), + mLastValue(0) {} LL_FORCE_INLINE void sample(T value) @@ -251,20 +242,27 @@ namespace LLTrace sd_2 = other.getStandardDeviation(); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - mVarianceSum = (F32)mNumSamples + if (n_1 == 0) + { + mVarianceSum = other.mVarianceSum; + } + else if (n_2 == 0) + { + // don't touch variance + // mVarianceSum = mVarianceSum; + } + else + { + mVarianceSum = (F32)mNumSamples * ((((n_1 - 1.f) * sd_1 * sd_1) + ((n_2 - 1.f) * sd_2 * sd_2) + (((n_1 * n_2) / (n_1 + n_2)) * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) / (n_1 + n_2 - 1.f)); + } mLastValue = other.mLastValue; } - void addDeltas(const MeasurementAccumulator<T>& start, const MeasurementAccumulator<T>& finish) - { - llerrs << "Delta merge invalid for measurement accumulators" << llendl; - } - void reset() { mNumSamples = 0; @@ -313,12 +311,6 @@ namespace LLTrace mNumSamples += other.mNumSamples; } - void addDeltas(const RateAccumulator<T>& start, const RateAccumulator<T>& finish) - { - mSum += finish.mSum - start.mSum; - mNumSamples += finish.mNumSamples - start.mNumSamples; - } - void reset() { mNumSamples = 0; @@ -464,13 +456,6 @@ namespace LLTrace mCalls += other.mCalls; } - void addDeltas(const TimerAccumulator& start, const TimerAccumulator& finish) - { - mTotalTimeCounter += finish.mTotalTimeCounter - start.mTotalTimeCounter; - mChildTimeCounter += finish.mChildTimeCounter - start.mChildTimeCounter; - mCalls += finish.mCalls - start.mCalls; - } - void reset() { mTotalTimeCounter = 0; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0883930319..5d7b231b7d 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -68,16 +68,16 @@ void Recording::handleReset() } void Recording::handleStart() - { - mSamplingTimer.reset(); - LLTrace::get_thread_recorder()->activate(this); +{ + mSamplingTimer.reset(); + LLTrace::get_thread_recorder()->activate(this); } void Recording::handleStop() - { - mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - LLTrace::get_thread_recorder()->deactivate(this); - } +{ + mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::get_thread_recorder()->deactivate(this); +} void Recording::handleSplitTo(Recording& other) { @@ -105,10 +105,204 @@ void Recording::mergeRecording( const Recording& other ) mStackTimers.write()->addSamples(*other.mStackTimers); } -void Recording::mergeRecordingDelta(const Recording& baseline, const Recording& target) +/////////////////////////////////////////////////////////////////////// +// Recording +/////////////////////////////////////////////////////////////////////// + +PeriodicRecording::PeriodicRecording( S32 num_periods ) +: mNumPeriods(num_periods), + mCurPeriod(0), + mTotalValid(false), + mRecordingPeriods( new Recording[num_periods]) +{ + llassert(mNumPeriods > 0); +} + +PeriodicRecording::~PeriodicRecording() +{ + delete[] mRecordingPeriods; +} + + +void PeriodicRecording::nextPeriod() +{ + EPlayState play_state = getPlayState(); + getCurRecordingPeriod().stop(); + mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + switch(play_state) + { + case STOPPED: + break; + case PAUSED: + getCurRecordingPeriod().pause(); + break; + case STARTED: + getCurRecordingPeriod().start(); + break; + } + // new period, need to recalculate total + mTotalValid = false; +} + +Recording& PeriodicRecording::getTotalRecording() +{ + if (!mTotalValid) + { + mTotalRecording.reset(); + for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) + { + mTotalRecording.mergeRecording(mRecordingPeriods[i]); + } + } + mTotalValid = true; + return mTotalRecording; +} + +void PeriodicRecording::handleStart() +{ + getCurRecordingPeriod().handleStart(); +} + +void PeriodicRecording::handleStop() +{ + getCurRecordingPeriod().handleStop(); +} + +void PeriodicRecording::handleReset() +{ + getCurRecordingPeriod().handleReset(); +} + +void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) +{ + getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); +} + +/////////////////////////////////////////////////////////////////////// +// ExtendableRecording +/////////////////////////////////////////////////////////////////////// + +void ExtendableRecording::extend() { - mRates.write()->addDeltas(*baseline.mRates, *target.mRates); - mStackTimers.write()->addDeltas(*baseline.mStackTimers, *target.mStackTimers); + mAcceptedRecording.mergeRecording(mPotentialRecording); + mPotentialRecording.reset(); } +void ExtendableRecording::handleStart() +{ + mPotentialRecording.handleStart(); +} + +void ExtendableRecording::handleStop() +{ + mPotentialRecording.handleStop(); +} + +void ExtendableRecording::handleReset() +{ + mAcceptedRecording.handleReset(); + mPotentialRecording.handleReset(); +} + +void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) +{ + mPotentialRecording.handleSplitTo(other.mPotentialRecording); +} + +PeriodicRecording& get_frame_recording() +{ + static PeriodicRecording sRecording(64); + sRecording.start(); + return sRecording; +} + +} + +void LLVCRControlsMixinCommon::start() +{ + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::stop() +{ + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + handleStop(); + break; + case STARTED: + handleStop(); + break; + } + mPlayState = STOPPED; +} + +void LLVCRControlsMixinCommon::pause() +{ + switch (mPlayState) + { + case STOPPED: + break; + case PAUSED: + break; + case STARTED: + handleStop(); + break; + } + mPlayState = PAUSED; +} + +void LLVCRControlsMixinCommon::resume() +{ + switch (mPlayState) + { + case STOPPED: + handleStart(); + break; + case PAUSED: + handleStart(); + break; + case STARTED: + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::restart() +{ + switch (mPlayState) + { + case STOPPED: + handleReset(); + handleStart(); + break; + case PAUSED: + handleReset(); + handleStart(); + break; + case STARTED: + handleReset(); + break; + } + mPlayState = STARTED; +} + +void LLVCRControlsMixinCommon::reset() +{ + handleReset(); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 0a1a02fa02..924a7bffd5 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -34,27 +34,11 @@ #include "lltimer.h" #include "lltrace.h" -template<typename DERIVED> -class LL_COMMON_API LLVCRControlsMixinInterface +class LL_COMMON_API LLVCRControlsMixinCommon { public: - virtual ~LLVCRControlsMixinInterface() {} - // trigger data accumulation (without reset) - virtual void handleStart() = 0; - // stop data accumulation, should put object in queryable state - virtual void handleStop() = 0; - // clear accumulated values, can be called while started - virtual void handleReset() = 0; - // atomically stop this object while starting the other - // no data can be missed in between stop and start - virtual void handleSplitTo(DERIVED& other) = 0; -}; + virtual ~LLVCRControlsMixinCommon() {} -template<typename DERIVED> -class LL_COMMON_API LLVCRControlsMixin -: private LLVCRControlsMixinInterface<DERIVED> -{ -public: enum EPlayState { STOPPED, @@ -62,94 +46,39 @@ public: STARTED }; - void start() - { - switch (mPlayState) - { - case STOPPED: - handleReset(); - handleStart(); - break; - case PAUSED: - handleStart(); - break; - case STARTED: - handleReset(); - break; - } - mPlayState = STARTED; - } + void start(); + void stop(); + void pause(); + void resume(); + void restart(); + void reset(); - void stop() - { - switch (mPlayState) - { - case STOPPED: - break; - case PAUSED: - handleStop(); - break; - case STARTED: - break; - } - mPlayState = STOPPED; - } - - void pause() - { - switch (mPlayState) - { - case STOPPED: - break; - case PAUSED: - break; - case STARTED: - handleStop(); - break; - } - mPlayState = PAUSED; - } + bool isStarted() { return mPlayState == STARTED; } + bool isPaused() { return mPlayState == PAUSED; } + bool isStopped() { return mPlayState == STOPPED; } + EPlayState getPlayState() { return mPlayState; } - void resume() - { - switch (mPlayState) - { - case STOPPED: - handleStart(); - break; - case PAUSED: - handleStart(); - break; - case STARTED: - break; - } - mPlayState = STARTED; - } +protected: + LLVCRControlsMixinCommon() + : mPlayState(STOPPED) + {} - void restart() - { - switch (mPlayState) - { - case STOPPED: - handleReset(); - handleStart(); - break; - case PAUSED: - handleReset(); - handleStart(); - break; - case STARTED: - handleReset(); - break; - } - mPlayState = STARTED; - } +private: + // trigger data accumulation (without reset) + virtual void handleStart() = 0; + // stop data accumulation, should put object in queryable state + virtual void handleStop() = 0; + // clear accumulated values, can be called while started + virtual void handleReset() = 0; - void reset() - { - handleReset(); - } + EPlayState mPlayState; +}; +template<typename DERIVED> +class LLVCRControlsMixin +: public LLVCRControlsMixinCommon +{ +public: void splitTo(DERIVED& other) { onSplitTo(other); @@ -159,32 +88,15 @@ public: { other.onSplitTo(*this); } - - bool isStarted() { return mPlayState == STARTED; } - bool isPaused() { return mPlayState == PAUSED; } - bool isStopped() { return mPlayState == STOPPED; } - EPlayState getPlayState() { return mPlayState; } - -protected: - - LLVCRControlsMixin() - : mPlayState(STOPPED) - {} - private: - EPlayState mPlayState; + // atomically stop this object while starting the other + // no data can be missed in between stop and start + virtual void handleSplitTo(DERIVED& other) = 0; + }; namespace LLTrace { - //template<typename T, typename IS_UNIT> class Rate; - //template<typename T, typename IS_UNIT> class Measurement; - //template<typename T> class Count; - //template<typename T> class AccumulatorBuffer; - //template<typename T> class RateAccumulator; - //template<typename T> class MeasurementAccumulator; - //class TimerAccumulator; - class LL_COMMON_API Recording : public LLVCRControlsMixin<Recording> { public: @@ -196,7 +108,6 @@ namespace LLTrace bool isPrimary() const; void mergeRecording(const Recording& other); - void mergeRecordingDelta(const Recording& baseline, const Recording& target); void update(); @@ -308,15 +219,13 @@ namespace LLTrace F64 getSampleTime() const { return mElapsedSeconds; } - private: - friend class PeriodicRecording; // implementation for LLVCRControlsMixin /*virtual*/ void handleStart(); /*virtual*/ void handleStop(); /*virtual*/ void handleReset(); /*virtual*/ void handleSplitTo(Recording& other); - + private: friend class ThreadRecorder; // returns data for current thread class ThreadRecorder* getThreadRecorder(); @@ -333,38 +242,19 @@ namespace LLTrace : public LLVCRControlsMixin<PeriodicRecording> { public: - PeriodicRecording(S32 num_periods) - : mNumPeriods(num_periods), - mCurPeriod(0), - mTotalValid(false), - mRecordingPeriods(new Recording[num_periods]) - { - llassert(mNumPeriods > 0); - } + PeriodicRecording(S32 num_periods); + ~PeriodicRecording(); + + void nextPeriod(); - ~PeriodicRecording() + Recording& getLastRecordingPeriod() { - delete[] mRecordingPeriods; + return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; } - void nextPeriod() + const Recording& getLastRecordingPeriod() const { - EPlayState play_state = getPlayState(); - getCurRecordingPeriod().stop(); - mCurPeriod = (mCurPeriod + 1) % mNumPeriods; - switch(play_state) - { - case STOPPED: - break; - case PAUSED: - getCurRecordingPeriod().pause(); - break; - case STARTED: - getCurRecordingPeriod().start(); - break; - } - // new period, need to recalculate total - mTotalValid = false; + return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; } Recording& getCurRecordingPeriod() @@ -377,41 +267,16 @@ namespace LLTrace return mRecordingPeriods[mCurPeriod]; } - Recording& getTotalRecording() - { - if (!mTotalValid) - { - mTotalRecording.reset(); - for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) - { - mTotalRecording.mergeRecording(mRecordingPeriods[i]); - } - } - mTotalValid = true; - return mTotalRecording; - } + Recording& getTotalRecording(); private: - // implementation for LLVCRControlsMixin - /*virtual*/ void handleStart() - { - getCurRecordingPeriod().handleStart(); - } - - /*virtual*/ void handleStop() - { - getCurRecordingPeriod().handleStop(); - } - /*virtual*/ void handleReset() - { - getCurRecordingPeriod().handleReset(); - } + // implementation for LLVCRControlsMixin + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); - /*virtual*/ void handleSplitTo(PeriodicRecording& other) - { - getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); - } + /*virtual*/ void handleSplitTo(PeriodicRecording& other); Recording* mRecordingPeriods; Recording mTotalRecording; @@ -419,6 +284,24 @@ namespace LLTrace S32 mNumPeriods, mCurPeriod; }; + + PeriodicRecording& get_frame_recording(); + + class ExtendableRecording + : public LLVCRControlsMixin<ExtendableRecording> + { + void extend(); + + private: + // implementation for LLVCRControlsMixin + /*virtual*/ void handleStart(); + /*virtual*/ void handleStop(); + /*virtual*/ void handleReset(); + /*virtual*/ void handleSplitTo(ExtendableRecording& other); + + Recording mAcceptedRecording; + Recording mPotentialRecording; + }; } #endif // LL_LLTRACERECORDING_H diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 3acd06d553..48aa1a42f2 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -36,15 +36,13 @@ namespace LLTrace /////////////////////////////////////////////////////////////////////// ThreadRecorder::ThreadRecorder() -: mPrimaryRecording(NULL) { get_thread_recorder() = this; mFullRecording.start(); } ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) -: mFullRecording(other.mFullRecording), - mPrimaryRecording(NULL) +: mFullRecording(other.mFullRecording) { get_thread_recorder() = this; mFullRecording.start(); @@ -55,45 +53,40 @@ ThreadRecorder::~ThreadRecorder() get_thread_recorder() = NULL; } -//TODO: remove this and use llviewerstats recording -Recording* ThreadRecorder::getPrimaryRecording() -{ - return mPrimaryRecording; -} - void ThreadRecorder::activate( Recording* recording ) { - mActiveRecordings.push_front(ActiveRecording(mPrimaryRecording, recording)); + mActiveRecordings.push_front(ActiveRecording(recording)); mActiveRecordings.front().mBaseline.makePrimary(); - mPrimaryRecording = &mActiveRecordings.front().mBaseline; } std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Recording* recording ) { - for (std::list<ActiveRecording>::iterator it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); + std::list<ActiveRecording>::iterator it, end_it; + for (it = mActiveRecordings.begin(), end_it = mActiveRecordings.end(); it != end_it; ++it) { std::list<ActiveRecording>::iterator next_it = it; - if (++next_it != mActiveRecordings.end()) + ++next_it; + + // if we have another recording further down in the stack... + if (next_it != mActiveRecordings.end()) { - next_it->mergeMeasurements((*it)); + // ...push our gathered data down to it + next_it->mBaseline.mergeRecording(it->mBaseline); } - it->flushAccumulators(mPrimaryRecording); + // copy accumulated measurements into result buffer and clear accumulator (mBaseline) + it->moveBaselineToTarget(); if (it->mTargetRecording == recording) { - if (next_it != mActiveRecordings.end()) - { - next_it->mBaseline.makePrimary(); - mPrimaryRecording = &next_it->mBaseline; - } - return it; + // found the recording, so return it + break; } } - return mActiveRecordings.end(); + return it; } void ThreadRecorder::deactivate( Recording* recording ) @@ -101,38 +94,34 @@ void ThreadRecorder::deactivate( Recording* recording ) std::list<ActiveRecording>::iterator it = update(recording); if (it != mActiveRecordings.end()) { + // and if we've found the recording we wanted to update + std::list<ActiveRecording>::iterator next_it = it; + ++next_it; + if (next_it != mActiveRecordings.end()) + { + next_it->mTargetRecording->makePrimary(); + } + mActiveRecordings.erase(it); } } -ThreadRecorder::ActiveRecording::ActiveRecording( Recording* source, Recording* target ) +ThreadRecorder::ActiveRecording::ActiveRecording( Recording* target ) : mTargetRecording(target) { - // take snapshots of current values rates and timers - if (source) - { - mBaseline.mRates.write()->copyFrom(*source->mRates); - mBaseline.mStackTimers.write()->copyFrom(*source->mStackTimers); - } } -void ThreadRecorder::ActiveRecording::mergeMeasurements(ThreadRecorder::ActiveRecording& other) +void ThreadRecorder::ActiveRecording::moveBaselineToTarget() { - mBaseline.mMeasurements.write()->addSamples(*other.mBaseline.mMeasurements); -} - -void ThreadRecorder::ActiveRecording::flushAccumulators(Recording* current) -{ - // accumulate statistics-like measurements mTargetRecording->mMeasurements.write()->addSamples(*mBaseline.mMeasurements); - // for rate-like measurements, merge total change since baseline - mTargetRecording->mRates.write()->addDeltas(*mBaseline.mRates, *current->mRates); - mTargetRecording->mStackTimers.write()->addDeltas(*mBaseline.mStackTimers, *current->mStackTimers); - // reset baselines - mBaseline.mRates.write()->copyFrom(*current->mRates); - mBaseline.mStackTimers.write()->copyFrom(*current->mStackTimers); + mTargetRecording->mRates.write()->addSamples(*mBaseline.mRates); + mTargetRecording->mStackTimers.write()->addSamples(*mBaseline.mStackTimers); + mBaseline.mMeasurements.write()->reset(); + mBaseline.mRates.write()->reset(); + mBaseline.mStackTimers.write()->reset(); } + /////////////////////////////////////////////////////////////////////// // SlaveThreadRecorder /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 42230087c0..678b1a89f0 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -51,19 +51,16 @@ namespace LLTrace virtual void pushToMaster() = 0; - Recording* getPrimaryRecording(); protected: struct ActiveRecording { - ActiveRecording(Recording* source, Recording* target); + ActiveRecording(Recording* target); Recording* mTargetRecording; Recording mBaseline; - void mergeMeasurements(ActiveRecording& other); - void flushAccumulators(Recording* current); + void moveBaselineToTarget(); }; - Recording* mPrimaryRecording; Recording mFullRecording; std::list<ActiveRecording> mActiveRecordings; }; diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 4cbf695059..b73007e107 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -37,7 +37,6 @@ #include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" -#include "lltracethreadrecorder.h" /////////////////////////////////////////////////////////////////////////////////// @@ -112,17 +111,17 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); if (mPerSec) { - current = recording->getSum(*mFloatStatp) / recording->getSampleTime(); + current = recording.getPerSec(*mFloatStatp); //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); } else { - current = recording->getSum(*mFloatStatp); + current = recording.getSum(*mFloatStatp); //min = recording->getMin(*mFloatStatp); //max = recording->getMax(*mFloatStatp); //mean = recording->getMean(*mFloatStatp); diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index c735e7045b..bfc49b9204 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -29,8 +29,7 @@ #include "llview.h" #include "llframetimer.h" -#include "lltrace.h" - +#include "lltracerecording.h" class LLStat; class LLStatBar : public LLView @@ -39,19 +38,24 @@ public: struct Params : public LLInitParam::Block<Params, LLView::Params> { - Optional<std::string> label; - Optional<std::string> unit_label; - Optional<F32> bar_min; - Optional<F32> bar_max; - Optional<F32> tick_spacing; - Optional<F32> label_spacing; - Optional<U32> precision; - Optional<F32> update_rate; - Optional<bool> show_per_sec; - Optional<bool> show_bar; - Optional<bool> show_history; - Optional<bool> show_mean; - Optional<std::string> stat; + Optional<std::string> label, + unit_label; + + Optional<F32> bar_min, + bar_max, + tick_spacing, + label_spacing, + update_rate; + + Optional<U32> precision; + + Optional<bool> show_per_sec, + show_bar, + show_history, + show_mean; + + Optional<std::string> stat; + Params() : label("label"), unit_label("unit_label"), @@ -92,6 +96,7 @@ private: BOOL mDisplayBar; // Display the bar graph. BOOL mDisplayHistory; BOOL mDisplayMean; // If true, display mean, if false, display current value + LLTrace::PeriodicRecording* mFrameRecording; LLStat* mStatp; LLTrace::Rate<F32>* mFloatStatp; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index 1d4527aaa3..21b55c7c5a 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -86,15 +86,15 @@ void LLStatGraph::draw() } else if (mF32Statp) { - LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); if (mPerSec) { - mValue = recording->getSum(*mF32Statp) / recording->getSampleTime(); + mValue = recording.getPerSec(*mF32Statp); } else { - mValue = recording->getSum(*mF32Statp); + mValue = recording.getSum(*mF32Statp); } } diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 11d9f5e1ec..bed2dffb14 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -497,6 +497,8 @@ void update_statistics() texture_stats_timer.reset(); } } + + LLTrace::get_frame_recording().nextPeriod(); } class ViewerStatsResponder : public LLHTTPClient::Responder diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index a14518f536..a164a28a59 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -412,14 +412,12 @@ public: }; LLTrace::Recording& getRecording() { return mRecording; } - LLTrace::Recording& getFrameRecording() { return mFrameRecording; } private: - F64 mStats[ST_COUNT]; - LLTrace::Recording mRecording; - LLTrace::Recording mFrameRecording; + F64 mStats[ST_COUNT]; + LLTrace::Recording mRecording; - F64 mLastTimeDiff; // used for time stat updates + F64 mLastTimeDiff; // used for time stat updates }; static const F32 SEND_STATS_PERIOD = 300.0f; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 81c45cfb84..af28ea36eb 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -58,7 +58,7 @@ #include "pipeline.h" #include "llappviewer.h" #include "llxuiparser.h" -#include "lltracethreadrecorder.h" +#include "lltracerecording.h" #include "llviewerdisplay.h" //////////////////////////////////////////////////////////////////////////// @@ -621,9 +621,9 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording(); - LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT).value()); + LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value()); LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); -- cgit v1.2.3 From 041dfccd1ea5b59c1b3c4e37e9a5495cad342c8f Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 12 Oct 2012 20:17:52 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system default to double precision now fixed unit conversion logic for LLUnit renamed LLTrace::Rate to LLTrace::Count and got rid of the old count as it was confusing some const correctness changes --- indra/llcommon/llpointer.h | 2 + indra/llcommon/lltrace.h | 93 ++++++++-------------- indra/llcommon/lltracerecording.cpp | 18 ++--- indra/llcommon/lltracerecording.h | 69 +++------------- indra/llcommon/lltracethreadrecorder.cpp | 4 +- indra/llcommon/llunit.h | 130 +++++++++++++++---------------- indra/llui/llstatbar.cpp | 25 +++--- indra/llui/llstatbar.h | 2 +- indra/llui/llstatgraph.cpp | 8 +- indra/llui/llstatgraph.h | 5 +- indra/newview/lltexturefetch.cpp | 2 +- indra/newview/llviewermessage.cpp | 1 - indra/newview/llviewerstats.cpp | 98 ++++++++++++----------- indra/newview/llviewerstats.h | 86 ++++++++++---------- indra/newview/llviewertexturelist.cpp | 4 +- indra/newview/llworld.cpp | 6 +- 16 files changed, 243 insertions(+), 310 deletions(-) diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 0fee4f0990..6a3bbeb768 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -207,7 +207,9 @@ public: using LLPointer<Type>::operator >; + operator Type*() { return mPointer; } operator const Type*() const { return mPointer; } + Type* operator->() { return mPointer; } const Type* operator->() const { return mPointer; } }; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 0c618a2f4b..221c226ad1 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -91,6 +91,11 @@ namespace LLTrace return mStorage[index]; } + LL_FORCE_INLINE const ACCUMULATOR& operator[](size_t index) const + { + return mStorage[index]; + } + void addSamples(const AccumulatorBuffer<ACCUMULATOR>& other) { llassert(mNextStorageSlot == other.mNextStorageSlot); @@ -178,7 +183,7 @@ namespace LLTrace } ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) { return (*buffer)[mAccumulatorIndex]; } - const ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) const { return (*buffer)[mAccumulatorIndex]; } + const ACCUMULATOR& getAccumulator(const AccumulatorBuffer<ACCUMULATOR>* buffer) const { return (*buffer)[mAccumulatorIndex]; } protected: std::string mName; @@ -213,9 +218,9 @@ namespace LLTrace { mMax = value; } - F32 old_mean = mMean; - mMean += ((F32)value - old_mean) / (F32)mNumSamples; - mVarianceSum += ((F32)value - old_mean) * ((F32)value - mMean); + F64 old_mean = mMean; + mMean += ((F64)value - old_mean) / (F64)mNumSamples; + mVarianceSum += ((F64)value - old_mean) * ((F64)value - mMean); mLastValue = value; } @@ -231,14 +236,14 @@ namespace LLTrace mMax = other.mMax; } mNumSamples += other.mNumSamples; - F32 weight = (F32)mNumSamples / (F32)(mNumSamples + other.mNumSamples); + F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); mMean = mMean * weight + other.mMean * (1.f - weight); - F32 n_1 = (F32)mNumSamples, - n_2 = (F32)other.mNumSamples; - F32 m_1 = mMean, + F64 n_1 = (F64)mNumSamples, + n_2 = (F64)other.mNumSamples; + F64 m_1 = mMean, m_2 = other.mMean; - F32 sd_1 = getStandardDeviation(), + F64 sd_1 = getStandardDeviation(), sd_2 = other.getStandardDeviation(); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm @@ -275,8 +280,8 @@ namespace LLTrace T getMin() const { return mMin; } T getMax() const { return mMax; } T getLastValue() const { return mLastValue; } - F32 getMean() const { return mMean; } - F32 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } + F64 getMean() const { return mMean; } + F64 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } private: T mSum, @@ -284,17 +289,17 @@ namespace LLTrace mMax, mLastValue; - F32 mMean, + F64 mMean, mVarianceSum; U32 mNumSamples; }; template<typename T> - class LL_COMMON_API RateAccumulator + class LL_COMMON_API CountAccumulator { public: - RateAccumulator() + CountAccumulator() : mSum(0), mNumSamples(0) {} @@ -305,7 +310,7 @@ namespace LLTrace mSum += value; } - void addSamples(const RateAccumulator<T>& other) + void addSamples(const CountAccumulator<T>& other) { mSum += other.mSum; mNumSamples += other.mNumSamples; @@ -325,7 +330,7 @@ namespace LLTrace U32 mNumSamples; }; - template <typename T, typename IS_UNIT = void> + template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Measurement : public TraceType<MeasurementAccumulator<T> >, public LLInstanceTracker<Measurement<T, IS_UNIT>, std::string> @@ -352,8 +357,8 @@ namespace LLTrace public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; - typedef Measurement<typename T::value_t> base_measurement_t; + Measurement(const char* name, const char* description = NULL) : Measurement<typename T::value_t>(name) {} @@ -361,20 +366,20 @@ namespace LLTrace template<typename UNIT_T> void sample(UNIT_T value) { - base_measurement_t::sample(value.value()); + base_measurement_t::sample(((T)value).value()); } }; - template <typename T, typename IS_UNIT = void> - class LL_COMMON_API Rate - : public TraceType<RateAccumulator<T> >, - public LLInstanceTracker<Rate<T>, std::string> + template <typename T = F64, typename IS_UNIT = void> + class LL_COMMON_API Count + : public TraceType<CountAccumulator<T> >, + public LLInstanceTracker<Count<T>, std::string> { public: typedef T storage_t; typedef T base_unit_t; - Rate(const char* name, const char* description = NULL) + Count(const char* name, const char* description = NULL) : TraceType(name), LLInstanceTracker(name) {} @@ -386,53 +391,23 @@ namespace LLTrace }; template <typename T> - class LL_COMMON_API Rate <T, typename T::is_unit_t> - : public Rate<typename T::value_t> + class LL_COMMON_API Count <T, typename T::is_unit_t> + : public Count<typename T::value_t> { public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; + typedef Count<typename T::value_t> base_count_t; - Rate(const char* name, const char* description = NULL) - : Rate<typename T::value_t>(name) + Count(const char* name, const char* description = NULL) + : Count<typename T::value_t>(name) {} template<typename UNIT_T> void add(UNIT_T value) { - getPrimaryAccumulator().add(value.value()); - } - }; - - template <typename T> - class LL_COMMON_API Count - { - public: - typedef typename Rate<T>::base_unit_t base_unit_t; - - Count(const char* name) - : mIncrease(name + "_increase"), - mDecrease(name + "_decrease"), - mTotal(name) - {} - - void count(T value) - { - if (value < 0) - { - mDecrease.add(value * -1); - } - else - { - mIncrease.add(value); - } - mTotal.add(value); + base_count_t::add(((T)value).value()); } - private: - friend LLTrace::Recording; - Rate<T> mIncrease; - Rate<T> mDecrease; - Rate<T> mTotal; }; class LL_COMMON_API TimerAccumulator diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5d7b231b7d..9a769ff344 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,8 +39,8 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), - mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), + mCounts(new AccumulatorBuffer<CountAccumulator<F64> >()), + mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) {} @@ -59,7 +59,7 @@ void Recording::update() void Recording::handleReset() { - mRates.write()->reset(); + mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); @@ -88,21 +88,22 @@ void Recording::handleSplitTo(Recording& other) void Recording::makePrimary() { - mRates.write()->makePrimary(); + mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); } bool Recording::isPrimary() const { - return mRates->isPrimary(); + return mCounts->isPrimary(); } void Recording::mergeRecording( const Recording& other ) { - mRates.write()->addSamples(*other.mRates); + mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); + mElapsedSeconds += other.mElapsedSeconds; } /////////////////////////////////////////////////////////////////////// @@ -149,9 +150,9 @@ Recording& PeriodicRecording::getTotalRecording() if (!mTotalValid) { mTotalRecording.reset(); - for (S32 i = (mCurPeriod + 1) % mNumPeriods; i < mCurPeriod; i++) + for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++) { - mTotalRecording.mergeRecording(mRecordingPeriods[i]); + mTotalRecording.mergeRecording(mRecordingPeriods[i % mNumPeriods]); } } mTotalValid = true; @@ -212,7 +213,6 @@ void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) PeriodicRecording& get_frame_recording() { static PeriodicRecording sRecording(64); - sRecording.start(); return sRecording; } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 924a7bffd5..d9ac8c327a 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -111,17 +111,17 @@ namespace LLTrace void update(); - // Rate accessors + // Count accessors template <typename T, typename IS_UNIT> - typename Rate<T, IS_UNIT>::base_unit_t getSum(const Rate<T, IS_UNIT>& stat) const + typename Count<T, IS_UNIT>::base_unit_t getSum(const Count<T, IS_UNIT>& stat) const { - return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mRates).getSum(); + return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mCounts).getSum(); } template <typename T, typename IS_UNIT> - typename Rate<T, IS_UNIT>::base_unit_t getPerSec(const Rate<T, IS_UNIT>& stat) const + typename Count<T, IS_UNIT>::base_unit_t getPerSec(const Count<T, IS_UNIT>& stat) const { - return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mRates).getSum() / mElapsedSeconds; + return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; } // Measurement accessors @@ -135,7 +135,7 @@ namespace LLTrace template <typename T, typename IS_UNIT> typename Measurement<T, IS_UNIT>::base_unit_t getPerSec(const Measurement<T, IS_UNIT>& stat) const { - return (typename Rate<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; + return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; } template <typename T, typename IS_UNIT> @@ -151,7 +151,7 @@ namespace LLTrace } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getMean(const Measurement<T, IS_UNIT>& stat) const + typename Measurement<T, IS_UNIT>::base_unit_t getMean(Measurement<T, IS_UNIT>& stat) const { return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMean(); } @@ -168,56 +168,7 @@ namespace LLTrace return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getLastValue(); } - // Count accessors - template <typename T> - typename Count<T>::base_unit_t getSum(const Count<T>& stat) const - { - return getSum(stat.mTotal); - } - - template <typename T> - typename Count<T>::base_unit_t getPerSec(const Count<T>& stat) const - { - return getPerSec(stat.mTotal); - } - - template <typename T> - typename Count<T>::base_unit_t getIncrease(const Count<T>& stat) const - { - return getPerSec(stat.mTotal); - } - - template <typename T> - typename Count<T>::base_unit_t getIncreasePerSec(const Count<T>& stat) const - { - return getPerSec(stat.mIncrease); - } - - template <typename T> - typename Count<T>::base_unit_t getDecrease(const Count<T>& stat) const - { - return getPerSec(stat.mDecrease); - } - - template <typename T> - typename Count<T>::base_unit_t getDecreasePerSec(const Count<T>& stat) const - { - return getPerSec(stat.mDecrease); - } - - template <typename T> - typename Count<T>::base_unit_t getChurn(const Count<T>& stat) const - { - return getIncrease(stat) + getDecrease(stat); - } - - template <typename T> - typename Count<T>::base_unit_t getChurnPerSec(const Count<T>& stat) const - { - return getIncreasePerSec(stat) + getDecreasePerSec(stat); - } - - F64 getSampleTime() const { return mElapsedSeconds; } + F64 getDuration() const { return mElapsedSeconds; } // implementation for LLVCRControlsMixin /*virtual*/ void handleStart(); @@ -230,8 +181,8 @@ namespace LLTrace // returns data for current thread class ThreadRecorder* getThreadRecorder(); - LLCopyOnWritePointer<AccumulatorBuffer<RateAccumulator<F32> > > mRates; - LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F32> > > mMeasurements; + LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > > mCounts; + LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurements; LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; LLTimer mSamplingTimer; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 48aa1a42f2..02dc55771b 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -114,10 +114,10 @@ ThreadRecorder::ActiveRecording::ActiveRecording( Recording* target ) void ThreadRecorder::ActiveRecording::moveBaselineToTarget() { mTargetRecording->mMeasurements.write()->addSamples(*mBaseline.mMeasurements); - mTargetRecording->mRates.write()->addSamples(*mBaseline.mRates); + mTargetRecording->mCounts.write()->addSamples(*mBaseline.mCounts); mTargetRecording->mStackTimers.write()->addSamples(*mBaseline.mStackTimers); mBaseline.mMeasurements.write()->reset(); - mBaseline.mRates.write()->reset(); + mBaseline.mCounts.write()->reset(); mBaseline.mStackTimers.write()->reset(); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 2664bd77e9..090e42607e 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -51,7 +51,7 @@ struct LLUnitType : public BASE_UNIT value_t value() const { - return convertToDerived(mValue); + return convertToDerived(mBaseValue); } template<typename CONVERTED_TYPE> @@ -72,22 +72,22 @@ struct LLUnitType : public BASE_UNIT unit_t operator + (const unit_t other) const { - return unit_t(mValue + other.mValue); + return unit_t(mBaseValue + other.mBaseValue); } unit_t operator - (const unit_t other) const { - return unit_t(mValue - other.mValue); + return unit_t(mBaseValue - other.mBaseValue); } unit_t operator * (value_t multiplicand) const { - return unit_t(mValue * multiplicand); + return unit_t(mBaseValue * multiplicand); } unit_t operator / (value_t divisor) const { - return unit_t(mValue / divisor); + return unit_t(mBaseValue / divisor); } }; @@ -100,11 +100,11 @@ struct LLUnitType<STORAGE_TYPE, T, T> typedef void is_unit_t; LLUnitType() - : mValue() + : mBaseValue() {} explicit LLUnitType(value_t value) - : mValue(value) + : mBaseValue(value) {} unit_t& operator=(value_t value) @@ -118,7 +118,7 @@ struct LLUnitType<STORAGE_TYPE, T, T> return static_cast<unit_t&>(*this); } - value_t value() { return mValue; } + value_t value() const { return mBaseValue; } static value_t convertToBase(value_t derived_value) { @@ -132,73 +132,73 @@ struct LLUnitType<STORAGE_TYPE, T, T> unit_t operator + (const unit_t other) const { - return unit_t(mValue + other.mValue); + return unit_t(mBaseValue + other.mBaseValue); } void operator += (const unit_t other) { - mValue += other.mValue; + mBaseValue += other.mBaseValue; } unit_t operator - (const unit_t other) const { - return unit_t(mValue - other.mValue); + return unit_t(mBaseValue - other.mBaseValue); } void operator -= (const unit_t other) { - mValue -= other.mValue; + mBaseValue -= other.mBaseValue; } unit_t operator * (value_t multiplicand) const { - return unit_t(mValue * multiplicand); + return unit_t(mBaseValue * multiplicand); } void operator *= (value_t multiplicand) { - mValue *= multiplicand; + mBaseValue *= multiplicand; } unit_t operator / (value_t divisor) const { - return unit_t(mValue / divisor); + return unit_t(mBaseValue / divisor); } void operator /= (value_t divisor) { - mValue /= divisor; + mBaseValue /= divisor; } protected: void setBaseValue(value_t value) { - mValue = value; + mBaseValue = value; } - value_t mValue; + value_t mBaseValue; }; -#define LL_DECLARE_BASE_UNIT(unit_name) \ - template<typename STORAGE_TYPE> \ - struct unit_name : public LLUnitType<STORAGE_TYPE, unit_name<STORAGE_TYPE> > \ - { \ - typedef unit_name<STORAGE_TYPE> base_unit_t; \ - typedef STORAGE_TYPE storage_t; \ +#define LL_DECLARE_BASE_UNIT(unit_name) \ + struct unit_name : public LLUnitType<F64, unit_name> \ + { \ + typedef unit_name base_unit_t; \ + typedef LLUnitType<F64, unit_name> unit_t; \ + typedef F64 storage_t; \ \ - unit_name(STORAGE_TYPE value) \ + unit_name(F64 value) \ : LLUnitType(value) \ - {} \ - \ - unit_name() \ - {} \ - \ + {} \ + \ + unit_name() \ + {} \ + \ template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ unit_name(const LLUnitType<SOURCE_STORAGE_TYPE, unit_name, SOURCE_TYPE>& source) \ - { \ - setBaseValue(source.unit_t::value()); \ - } \ - \ + { \ + setBaseValue((F64)source.unit_name::unit_t::value()); \ + } \ + \ using LLUnitType::operator +; \ using LLUnitType::operator +=; \ using LLUnitType::operator -; \ @@ -209,36 +209,36 @@ protected: using LLUnitType::operator /=; \ }; -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - template<typename STORAGE_TYPE> \ - struct derived_unit : public LLUnitType<STORAGE_TYPE, base_unit<STORAGE_TYPE>, derived_unit<STORAGE_TYPE> > \ - { \ - typedef base_unit<STORAGE_TYPE> base_unit_t; \ - typedef STORAGE_TYPE storage_t; \ - \ - derived_unit(value_t value) \ - : LLUnitType(value) \ - {} \ - \ - derived_unit() \ - {} \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - derived_unit(const LLUnitType<SOURCE_STORAGE_TYPE, base_unit<STORAGE_TYPE>, SOURCE_TYPE>& source) \ - { \ - setBaseValue(source.base_unit_t::value()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - using LLUnitType::operator +; \ - using LLUnitType::operator +=; \ - using LLUnitType::operator -; \ - using LLUnitType::operator -=; \ - using LLUnitType::operator *; \ - using LLUnitType::operator *=; \ - using LLUnitType::operator /; \ - using LLUnitType::operator /=; \ +#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ + struct derived_unit : public LLUnitType<F64, base_unit, derived_unit> \ + { \ + typedef base_unit base_unit_t; \ + typedef LLUnitType<F64, base_unit, derived_unit> unit_t; \ + typedef F64 storage_t; \ + \ + derived_unit(value_t value) \ + : LLUnitType(value) \ + {} \ + \ + derived_unit() \ + {} \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + derived_unit(const LLUnitType<SOURCE_STORAGE_TYPE, base_unit, SOURCE_TYPE>& source) \ + { \ + setBaseValue((F64)source.base_unit::unit_t::value()); \ + } \ + \ + static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ + \ + using LLUnitType::operator +; \ + using LLUnitType::operator +=; \ + using LLUnitType::operator -; \ + using LLUnitType::operator -=; \ + using LLUnitType::operator *; \ + using LLUnitType::operator *=; \ + using LLUnitType::operator /; \ + using LLUnitType::operator /=; \ }; namespace LLUnits @@ -248,7 +248,7 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.f / 8.f)); - LL_DECLARE_DERIVED_UNIT(Bytes, Kilobit, (1024 / 8)); + LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index b73007e107..c60e5431ae 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -47,7 +47,7 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), - mFloatStatp(LLTrace::Rate<F32>::getInstance(p.stat)), + mNewStatp(LLTrace::Count<>::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -109,22 +109,25 @@ void LLStatBar::draw() mean = mStatp->getMean(); } } - else if (mFloatStatp) + else if (mNewStatp) { - LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& windowed_frame_recording = frame_recording.getTotalRecording(); + if (mPerSec) { - current = recording.getPerSec(*mFloatStatp); - //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); - //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); - //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); + current = last_frame_recording.getPerSec(*mNewStatp); + //min = frame_window_recording.getMin(*mNewStatp) / frame_window_recording.getDuration(); + //max = frame_window_recording.getMax(*mNewStatp) / frame_window_recording.getDuration(); + mean = windowed_frame_recording.getPerSec(*mNewStatp);//frame_window_recording.getMean(*mNewStatp) / frame_window_recording.getDuration(); } else { - current = recording.getSum(*mFloatStatp); - //min = recording->getMin(*mFloatStatp); - //max = recording->getMax(*mFloatStatp); - //mean = recording->getMean(*mFloatStatp); + current = last_frame_recording.getSum(*mNewStatp); + //min = last_frame_recording.getMin(*mNewStatp); + //max = last_frame_recording.getMax(*mNewStatp); + mean = windowed_frame_recording.getSum(*mNewStatp); } } diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index bfc49b9204..e4b0c61c42 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -99,7 +99,7 @@ private: LLTrace::PeriodicRecording* mFrameRecording; LLStat* mStatp; - LLTrace::Rate<F32>* mFloatStatp; + LLTrace::Count<>* mNewStatp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index 21b55c7c5a..be3baeea76 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -49,7 +49,7 @@ LLStatGraph::LLStatGraph(const Params& p) mPrecision(p.precision), mValue(p.value), mStatp(p.stat.legacy_stat), - mF32Statp(p.stat.rate_stat) + mNewStatp(p.stat.rate_stat) { setToolTip(p.name()); @@ -84,17 +84,17 @@ void LLStatGraph::draw() mValue = mStatp->getMean(); } } - else if (mF32Statp) + else if (mNewStatp) { LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); if (mPerSec) { - mValue = recording.getPerSec(*mF32Statp); + mValue = recording.getPerSec(*mNewStatp); } else { - mValue = recording.getSum(*mF32Statp); + mValue = recording.getSum(*mNewStatp); } } diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 69fc36ea52..54a959f49e 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -60,7 +60,7 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { Alternative<LLStat*> legacy_stat; - Alternative<LLTrace::Rate<F32>* > rate_stat; + Alternative<LLTrace::Count<>* > rate_stat; }; struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -106,8 +106,7 @@ public: private: LLStat* mStatp; - LLTrace::Rate<F32>* mF32Statp; - LLTrace::Rate<S32>* mS32Statp; + LLTrace::Count<>* mNewStatp; BOOL mPerSec; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 2ce5f95b54..f2caa01644 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2316,7 +2316,7 @@ S32 LLTextureFetch::update(F32 max_time_ms) if(mCurlGetRequest) { - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(mCurlGetRequest->getTotalReceivedBits()); + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits>(mCurlGetRequest->getTotalReceivedBits()); //gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 79ed093382..ec7d91ec4f 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4772,7 +4772,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) //LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); break; case LL_SIM_STAT_FRAMEMS: - //LLStatViewer::SIM_.sample(stat_value); LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value); break; case LL_SIM_STAT_NETMS: diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index bed2dffb14..a3d04d655a 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -64,7 +64,7 @@ namespace LLStatViewer { -LLTrace::Rate<F32> FPS("fpsstat"), +LLTrace::Count<> FPS("fpsstat"), PACKETS_IN("packetsinstat"), PACKETS_LOST("packetsloststat"), PACKETS_OUT("packetsoutstat"), @@ -90,7 +90,7 @@ LLTrace::Rate<F32> FPS("fpsstat"), FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"), TEX_BAKES("texbakes"), TEX_REBAKES("texrebakes"); -LLTrace::Rate<LLUnits::Bytes<F32> > KBIT("kbitstat"), +LLTrace::Count<LLUnits::Kilobits> KBIT("kbitstat"), LAYERS_KBIT("layerskbitstat"), OBJECT_KBIT("objectkbitstat"), ASSET_KBIT("assetkbitstat"), @@ -98,17 +98,17 @@ LLTrace::Rate<LLUnits::Bytes<F32> > KBIT("kbitstat"), ACTUAL_IN_KBIT("actualinkbit"), ACTUAL_OUT_KBIT("actualoutkbit"); -LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), - TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), - MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"), - FPS_10_TIME("fps10time", "Seconds below 10 FPS"), - FPS_8_TIME("fps8time", "Seconds below 8 FPS"), - FPS_2_TIME("fps2time", "Seconds below 2 FPS"), - SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"), - SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"), - LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%"); - -LLTrace::Measurement<F32> SIM_TIME_DILATION("simtimedilation"), +LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), + TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), + MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"), + FPS_10_TIME("fps10time", "Seconds below 10 FPS"), + FPS_8_TIME("fps8time", "Seconds below 8 FPS"), + FPS_2_TIME("fps2time", "Seconds below 2 FPS"), + SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"), + SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"), + LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%"); + +LLTrace::Measurement<> SIM_TIME_DILATION("simtimedilation"), SIM_FPS("simfps"), SIM_PHYSICS_FPS("simphysicsfps"), SIM_AGENT_UPS("simagentups"), @@ -147,36 +147,36 @@ LLTrace::Measurement<F32> SIM_TIME_DILATION("simtimedilation"), WINDOW_WIDTH("windowwidth", "Window width"), WINDOW_HEIGHT("windowheight", "Window height"); -LLTrace::Measurement<LLUnits::Bytes<F32> > SIM_UNACKED_BYTES("simtotalunackedbytes"), - SIM_PHYSICS_MEM("physicsmemoryallocated"), - GL_TEX_MEM("gltexmemstat"), - GL_BOUND_MEM("glboundmemstat"), - RAW_MEM("rawmemstat"), - FORMATTED_MEM("formattedmemstat"); - - -LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec"), - SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"), - SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"), - SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"), - SIM_AI_TIME("simsimaistepmsec"), - SIM_AGENTS_TIME("simagentmsec"), - SIM_IMAGES_TIME("simimagesmsec"), - SIM_SCRIPTS_TIME("simscriptmsec"), - SIM_SPARE_TIME("simsparemsec"), - SIM_SLEEP_TIME("simsleepmsec"), - SIM_PUMP_IO_TIME("simpumpiomsec"), - SIM_PING("simpingstat"), - FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), - FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), - LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), - REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), - FRAME_STACKTIME("framestacktime", "FRAME_SECS"), - UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"), - NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"), - IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"), - REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"), - RENDER_STACKTIME("renderstacktime", "RENDER_SECS"); +LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), + SIM_PHYSICS_MEM("physicsmemoryallocated"), + GL_TEX_MEM("gltexmemstat"), + GL_BOUND_MEM("glboundmemstat"), + RAW_MEM("rawmemstat"), + FORMATTED_MEM("formattedmemstat"); + + +LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME("simsimphysicsmsec"), + SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"), + SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"), + SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"), + SIM_AI_TIME("simsimaistepmsec"), + SIM_AGENTS_TIME("simagentmsec"), + SIM_IMAGES_TIME("simimagesmsec"), + SIM_SCRIPTS_TIME("simscriptmsec"), + SIM_SPARE_TIME("simsparemsec"), + SIM_SLEEP_TIME("simsleepmsec"), + SIM_PUMP_IO_TIME("simpumpiomsec"), + SIM_PING("simpingstat"), + FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), + FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), + LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), + REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), + FRAME_STACKTIME("framestacktime", "FRAME_SECS"), + UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"), + NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"), + IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"), + REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"), + RENDER_STACKTIME("renderstacktime", "RENDER_SECS"); } class StatAttributes @@ -266,6 +266,7 @@ LLViewerStats::LLViewerStats() : mAgentPositionSnaps.reset(); mRecording.start(); + LLTrace::get_frame_recording().start(); } LLViewerStats::~LLViewerStats() @@ -437,25 +438,28 @@ void update_statistics() LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { + LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay()); stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { + LLUnits::Seconds i(10000); + LLStatViewer::SIM_PING.sample(i);//<LLUnits::Seconds<U32> >(10000); stats.mSimPingStat.addValue(10000); } //stats.mFPSStat.addValue(1); LLStatViewer::FPS.add(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits); + LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits>(layer_bits); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits); + LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); - LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); + LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -493,7 +497,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - gTotalTextureBytes = LLUnits::Bytes<F32>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); + gTotalTextureBytes = LLUnits::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); texture_stats_timer.reset(); } } diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index a164a28a59..5412294cf2 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -34,7 +34,7 @@ namespace LLStatViewer { -extern LLTrace::Rate<F32> FPS, +extern LLTrace::Count<> FPS, PACKETS_IN, PACKETS_LOST, PACKETS_OUT, @@ -62,7 +62,7 @@ extern LLTrace::Rate<F32> FPS, TEX_REBAKES; -extern LLTrace::Rate<LLUnits::Bytes<F32> > KBIT, +extern LLTrace::Count<LLUnits::Kilobits> KBIT, LAYERS_KBIT, OBJECT_KBIT, ASSET_KBIT, @@ -70,17 +70,17 @@ extern LLTrace::Rate<LLUnits::Bytes<F32> > KBIT, ACTUAL_IN_KBIT, ACTUAL_OUT_KBIT; -extern LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME, - TOOLBOX_TIME, - MOUSELOOK_TIME, - FPS_10_TIME, - FPS_8_TIME, - FPS_2_TIME, - SIM_20_FPS_TIME, - SIM_PHYSICS_20_FPS_TIME, - LOSS_5_PERCENT_TIME; - -extern LLTrace::Measurement<F32> SIM_TIME_DILATION, +extern LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME, + TOOLBOX_TIME, + MOUSELOOK_TIME, + FPS_10_TIME, + FPS_8_TIME, + FPS_2_TIME, + SIM_20_FPS_TIME, + SIM_PHYSICS_20_FPS_TIME, + LOSS_5_PERCENT_TIME; + +extern LLTrace::Measurement<> SIM_TIME_DILATION, SIM_FPS, SIM_PHYSICS_FPS, SIM_AGENT_UPS, @@ -119,36 +119,36 @@ extern LLTrace::Measurement<F32> SIM_TIME_DILATION, WINDOW_WIDTH, WINDOW_HEIGHT; -extern LLTrace::Measurement<LLUnits::Bytes<F32> > SIM_UNACKED_BYTES, - SIM_PHYSICS_MEM, - GL_TEX_MEM, - GL_BOUND_MEM, - RAW_MEM, - FORMATTED_MEM; - - -extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME, - SIM_PHYSICS_STEP_TIME, - SIM_PHYSICS_SHAPE_UPDATE_TIME, - SIM_PHYSICS_OTHER_TIME, - SIM_AI_TIME, - SIM_AGENTS_TIME, - SIM_IMAGES_TIME, - SIM_SCRIPTS_TIME, - SIM_SPARE_TIME, - SIM_SLEEP_TIME, - SIM_PUMP_IO_TIME, - SIM_PING, - FRAMETIME_JITTER, - FRAMETIME_SLEW, - LOGIN_SECONDS, - REGION_CROSSING_TIME, - FRAME_STACKTIME, - UPDATE_STACKTIME, - NETWORK_STACKTIME, - IMAGE_STACKTIME, - REBUILD_STACKTIME, - RENDER_STACKTIME; +extern LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES, + SIM_PHYSICS_MEM, + GL_TEX_MEM, + GL_BOUND_MEM, + RAW_MEM, + FORMATTED_MEM; + + +extern LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME, + SIM_PHYSICS_STEP_TIME, + SIM_PHYSICS_SHAPE_UPDATE_TIME, + SIM_PHYSICS_OTHER_TIME, + SIM_AI_TIME, + SIM_AGENTS_TIME, + SIM_IMAGES_TIME, + SIM_SCRIPTS_TIME, + SIM_SPARE_TIME, + SIM_SLEEP_TIME, + SIM_PUMP_IO_TIME, + SIM_PING, + FRAMETIME_JITTER, + FRAMETIME_SLEW, + LOGIN_SECONDS, + REGION_CROSSING_TIME, + FRAME_STACKTIME, + UPDATE_STACKTIME, + NETWORK_STACKTIME, + IMAGE_STACKTIME, + REBUILD_STACKTIME, + RENDER_STACKTIME; } class LLViewerStats : public LLSingleton<LLViewerStats> diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index af28ea36eb..ccfedd8881 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1325,7 +1325,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size); + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); U8 codec; @@ -1399,7 +1399,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size); + LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); //llprintline("Start decode, image header..."); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 056132c165..9e495c46b1 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -703,11 +703,11 @@ void LLWorld::updateNetStats() S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); - LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits<F32> >(actual_in_bits); - LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits<F32> >(actual_out_bits); + LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits>(actual_in_bits); + LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits>(actual_out_bits); //LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); //LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits); + LLStatViewer::KBIT.add<LLUnits::Bits>(bits); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); -- cgit v1.2.3 From 8d2f7a526545a10cd3669bf837a0b6f02cf5fe71 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 15 Oct 2012 19:43:35 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system converted all remaining LLViewerStats to lltrace --- indra/llcommon/llstatenums.h | 2 +- indra/llcommon/lltrace.h | 1 + indra/llcommon/lltracerecording.h | 15 +- indra/llcommon/llunit.h | 4 + indra/llmessage/llassetstorage.cpp | 27 +++ indra/llui/llstatgraph.cpp | 2 +- indra/llui/llstatgraph.h | 3 +- indra/newview/llagent.cpp | 8 +- indra/newview/llappviewer.cpp | 3 +- indra/newview/llchatbar.cpp | 18 -- indra/newview/llcompilequeue.cpp | 2 +- indra/newview/llfloaterabout.cpp | 3 +- indra/newview/llfloaterregioninfo.cpp | 2 +- indra/newview/llfloatersnapshot.cpp | 3 +- indra/newview/llgesturemgr.cpp | 2 +- indra/newview/lllandmarklist.cpp | 2 +- indra/newview/llnearbychatbar.cpp | 3 +- indra/newview/llpanelface.cpp | 3 +- indra/newview/llpreviewgesture.cpp | 2 +- indra/newview/llpreviewnotecard.cpp | 2 +- indra/newview/llpreviewscript.cpp | 11 +- indra/newview/llselectmgr.cpp | 7 +- indra/newview/llstartup.cpp | 3 +- indra/newview/llstatusbar.cpp | 4 +- indra/newview/lltexlayer.cpp | 3 +- indra/newview/lltooldraganddrop.cpp | 9 +- indra/newview/lltoolplacer.cpp | 3 +- indra/newview/llviewermenu.cpp | 66 ------- indra/newview/llviewermenufile.cpp | 24 ++- indra/newview/llviewermessage.cpp | 264 ++++++++++++++------------ indra/newview/llviewerobject.cpp | 3 +- indra/newview/llviewerobjectlist.cpp | 12 +- indra/newview/llviewerstats.cpp | 344 +++++++++++++--------------------- indra/newview/llviewerstats.h | 221 ++++++---------------- indra/newview/llviewertexturelist.cpp | 21 +-- indra/newview/llviewertexturelist.h | 10 +- indra/newview/llviewerthrottle.cpp | 5 +- indra/newview/llviewerwindow.cpp | 6 +- indra/newview/llvoavatarself.cpp | 21 ++- indra/newview/llwearablelist.cpp | 2 +- indra/newview/llworld.cpp | 8 +- 41 files changed, 488 insertions(+), 666 deletions(-) diff --git a/indra/llcommon/llstatenums.h b/indra/llcommon/llstatenums.h index 81c4085d16..ab9b6709e8 100644 --- a/indra/llcommon/llstatenums.h +++ b/indra/llcommon/llstatenums.h @@ -26,7 +26,7 @@ #ifndef LL_LLSTATENUMS_H #define LL_LLSTATENUMS_H -enum +enum ESimStatID { LL_SIM_STAT_TIME_DILATION = 0, LL_SIM_STAT_FPS = 1, diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 221c226ad1..3e19c83bd7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -282,6 +282,7 @@ namespace LLTrace T getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } + U32 getSampleCount() const { return mNumSamples; } private: T mSum, diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index d9ac8c327a..bd4b944e5a 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -168,6 +168,12 @@ namespace LLTrace return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getLastValue(); } + template <typename T, typename IS_UNIT> + U32 getSampleCount(const Measurement<T, IS_UNIT>& stat) const + { + return stat.getAccumulator(mMeasurements).getSampleCount(); + } + F64 getDuration() const { return mElapsedSeconds; } // implementation for LLVCRControlsMixin @@ -208,7 +214,7 @@ namespace LLTrace return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; } - Recording& getCurRecordingPeriod() + Recording getCurRecordingPeriod() { return mRecordingPeriods[mCurPeriod]; } @@ -218,6 +224,13 @@ namespace LLTrace return mRecordingPeriods[mCurPeriod]; } + Recording snapshotCurRecordingPeriod() const + { + Recording recording_copy(getCurRecordingPeriod()); + recording_copy.stop(); + return recording_copy; + } + Recording& getTotalRecording(); private: diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 090e42607e..e8f6b2b2ba 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -261,6 +261,10 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.f / (1000000.f))); LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.f / (1000000000.f))); + LL_DECLARE_BASE_UNIT(Meters); + LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); + LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, 1 / 100); + LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, 1 / 1000); } #endif // LL_LLUNIT_H diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 9b86daebe5..328d15b4bc 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -50,10 +50,14 @@ #include "lltransfertargetvfile.h" // For debugging #include "llmetrics.h" +#include "lltrace.h" LLAssetStorage *gAssetStorage = NULL; LLMetrics *LLAssetStorage::metric_recipient = NULL; +static LLTrace::Count<> sFailedDownloadCount("faileddownloads", "Number of times LLAssetStorage::getAssetData() has failed"); + + const LLUUID CATEGORIZE_LOST_AND_FOUND_ID(std::string("00000000-0000-0000-0000-000000000010")); const U64 TOXIC_ASSET_LIFETIME = (120 * 1000000); // microseconds @@ -450,6 +454,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, LL if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, uuid, type, user_data, LL_ERR_ASSET_REQUEST_FAILED, LL_EXSTAT_NONE); } return; @@ -460,6 +465,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, LL // Special case early out for NULL uuid and for shutting down if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, uuid, type, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID); } return; @@ -572,6 +578,7 @@ void LLAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType at llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl; if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, uuid, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); } } @@ -649,6 +656,10 @@ void LLAssetStorage::downloadCompleteCallback( LLAssetRequest* tmp = *curiter; if (tmp->mDownCallback) { + if (result != LL_ERR_NOERR) + { + sFailedDownloadCount.add(1); + } tmp->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), tmp->mUserData, result, ext_status); } delete tmp; @@ -669,6 +680,7 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen // Special case early out for NULL uuid if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, asset_id, atype, user_data, LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE, LL_EXSTAT_NULL_UUID); } return; @@ -741,6 +753,7 @@ void LLAssetStorage::getEstateAsset(const LLHost &object_sim, const LLUUID &agen llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl; if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); } } @@ -783,6 +796,10 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback( } } + if (result != LL_ERR_NOERR) + { + sFailedDownloadCount.add(1); + } req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getAType(), req->mUserData, result, ext_status); } @@ -883,6 +900,7 @@ void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &age llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl; if (callback) { + sFailedDownloadCount.add(1); callback(mVFS, asset_id, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM); } } @@ -925,6 +943,10 @@ void LLAssetStorage::downloadInvItemCompleteCallback( } } + if (result != LL_ERR_NOERR) + { + sFailedDownloadCount.add(1); + } req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), req->mUserData, result, ext_status); } @@ -1237,6 +1259,7 @@ bool LLAssetStorage::deletePendingRequestImpl(LLAssetStorage::request_list_t* re } if (req->mDownCallback) { + sFailedDownloadCount.add(1); req->mDownCallback(mVFS, req->getUUID(), req->getType(), req->mUserData, error, LL_EXSTAT_REQUEST_DROPPED); } if (req->mInfoCallback) @@ -1363,6 +1386,10 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss } } + if (status != LL_ERR_NOERR) + { + sFailedDownloadCount.add(1); + } legacy->mDownCallback(filename.c_str(), uuid, legacy->mUserData, status, ext_status); delete legacy; } diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index be3baeea76..e961e7d3c0 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -49,7 +49,7 @@ LLStatGraph::LLStatGraph(const Params& p) mPrecision(p.precision), mValue(p.value), mStatp(p.stat.legacy_stat), - mNewStatp(p.stat.rate_stat) + mNewStatp(p.stat.count_stat) { setToolTip(p.name()); diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 54a959f49e..5bbd9e9d24 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -60,7 +60,8 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { Alternative<LLStat*> legacy_stat; - Alternative<LLTrace::Count<>* > rate_stat; + Alternative<LLTrace::Count<>* > count_stat; + Alternative<LLTrace::Measurement<>* > measurement_stat; }; struct Params : public LLInitParam::Block<Params, LLView::Params> diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 447836910d..a41efbe0b2 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -753,7 +753,8 @@ void LLAgent::setFlying(BOOL fly) } if( !was_flying ) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT); + LLStatViewer::FLY.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT); } setControlFlags(AGENT_CONTROL_FLY); } @@ -3809,7 +3810,8 @@ bool LLAgent::teleportCore(bool is_local) gAgentCamera.resetView(FALSE); // local logic - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT); + LLStatViewer::TELEPORT.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT); if (is_local) { gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL ); @@ -4120,7 +4122,7 @@ void LLAgent::setTeleportState(ETeleportState state) case TELEPORT_ARRIVING: // First two position updates after a teleport tend to be weird - LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2; + //LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2; // Let the interested parties know we've teleported. LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal()); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a43776912c..6e0b298b2a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4810,7 +4810,8 @@ void LLAppViewer::idleNetwork() gPrintMessagesThisFrame = FALSE; } } - LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); + LLStatViewer::NUM_NEW_OBJECTS.sample(gObjectList.mNumNewObjects); + //LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); // Retransmit unacknowledged packets. gXferManager->retransmitUnackedPackets(); diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp index d6095cce07..f6bad18070 100644 --- a/indra/newview/llchatbar.cpp +++ b/indra/newview/llchatbar.cpp @@ -618,24 +618,6 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL send_chat_from_viewer(utf8_out_text, type, channel); } -/* -void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel) -{ - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_ChatFromViewer); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_ChatData); - msg->addStringFast(_PREHASH_Message, utf8_out_text); - msg->addU8Fast(_PREHASH_Type, type); - msg->addS32("Channel", channel); - - gAgent.sendReliableMessage(); - - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); -} -*/ void LLChatBar::onCommitGesture(LLUICtrl* ctrl) { diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index 4f5f9e22b6..6739910c38 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -436,7 +436,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index 83fb887d81..58701ca3c9 100644 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -296,7 +296,8 @@ LLSD LLFloaterAbout::getInfo() if (gPacketsIn > 0) { - info["PACKETS_LOST"] = LLViewerStats::getInstance()->mPacketsLostStat.getCurrent(); + LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecordingPeriod(); + info["PACKETS_LOST"] = cur_frame.getSum(LLStatViewer::PACKETS_LOST); info["PACKETS_IN"] = F32(gPacketsIn); info["PACKETS_PCT"] = 100.f*info["PACKETS_LOST"].asReal() / info["PACKETS_IN"].asReal(); } diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index fe29bb38c7..8234841966 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -2491,7 +2491,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index d8d62e5bbb..4a58e0186c 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -992,7 +992,8 @@ void LLSnapshotLivePreview::saveTexture() llwarns << "Error encoding snapshot" << llendl; } - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); + LLStatViewer::SNAPSHOT.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); mDataSize = 0; } diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 66ca76bfb0..63ef8c3d21 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -1137,7 +1137,7 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp index dd402de394..1666425cbe 100644 --- a/indra/newview/lllandmarklist.cpp +++ b/indra/newview/lllandmarklist.cpp @@ -141,7 +141,7 @@ void LLLandmarkList::processGetAssetReply( } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); // SJB: No use case for a notification here. Use lldebugs instead if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index c00dc4bc89..0aced5c575 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -638,7 +638,8 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 gAgent.sendReliableMessage(); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); + LLStatViewer::CHAT_COUNT.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); } class LLChatCommandHandler : public LLCommandHandler diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 202be9671b..52ed24f06d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1049,7 +1049,8 @@ BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) void LLPanelFace::onCommitTexture( const LLSD& data ) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); + LLStatViewer::EDIT_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); sendTexture(); } diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index f47928b131..4082d272f2 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -883,7 +883,7 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 3a9360fd23..b93b97f1e0 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -339,7 +339,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 88727bf59b..059d5d4061 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -942,7 +942,8 @@ void LLScriptEdCore::onBtnInsertFunction(LLUICtrl *ui, void* userdata) void LLScriptEdCore::doSave( BOOL close_after_save ) { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); + LLStatViewer::LSL_SAVES.add(1); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); if( mSaveCallback ) { @@ -1146,8 +1147,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) void LLScriptEdCore::onBtnSaveToFile( void* userdata ) { - - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); + LLStatViewer::LSL_SAVES.add(1); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); LLScriptEdCore* self = (LLScriptEdCore*) userdata; @@ -1670,7 +1671,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) @@ -1902,7 +1903,7 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index c3c37141ed..fd03d7c0be 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1550,7 +1550,8 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) } // apply texture for the selected faces - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); + LLStatViewer::EDIT_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); object->setTEImage(te, image); dialog_refresh_all(); @@ -3424,9 +3425,7 @@ bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response, gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR); // Keep track of how many objects have been deleted. - F64 obj_delete_count = LLViewerStats::getInstance()->getStat(LLViewerStats::ST_OBJECT_DELETE_COUNT); - obj_delete_count += LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount(); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_OBJECT_DELETE_COUNT, obj_delete_count ); + LLStatViewer::DELETE_OBJECT.add(LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount()); } break; case 1: diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 1e7c325d30..cb3c90ea2a 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2071,7 +2071,8 @@ bool idle_startup() if (wearables_time > MAX_WEARABLES_TIME) { LLNotificationsUtil::add("ClothingLoading"); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); + LLStatViewer::LOADING_WEARABLES_LONG_DELAY.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; } diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 6f2a0de894..5720395d05 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild() sgp.rect(r); sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); sgp.mouse_opaque(false); - sgp.stat.rate_stat(&LLStatViewer::KBIT); + sgp.stat.count_stat(&LLStatViewer::KBIT); sgp.units("Kbps"); sgp.precision(0); mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); @@ -212,7 +212,7 @@ BOOL LLStatusBar::postBuild() pgp.rect(r); pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); pgp.mouse_opaque(false); - pgp.stat.legacy_stat(&LLViewerStats::getInstance()->mPacketsLostPercentStat); + pgp.stat.measurement_stat(&LLStatViewer::PACKETS_LOST_PERCENT); pgp.units("%"); pgp.min(0.f); pgp.max(5.f); diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 467115c928..e354a5c59d 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -460,7 +460,8 @@ BOOL LLTexLayerSetBuffer::requestUpdateImmediate() void LLTexLayerSetBuffer::doUpload() { llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl; - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); + LLStatViewer::TEX_BAKES.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); // Don't need caches since we're baked now. (note: we won't *really* be baked // until this image is sent to the server and the Avatar Appearance message is received.) diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index c69999981c..791da59a1a 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1062,7 +1062,8 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, return; } LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); + LLStatViewer::EDIT_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); S32 num_faces = hit_obj->getNumTEs(); for( S32 face = 0; face < num_faces; face++ ) { @@ -1130,7 +1131,8 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, } // update viewer side image in anticipation of update from simulator LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); + LLStatViewer::EDIT_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); hit_obj->setTEImage(hit_face, image); dialog_refresh_all(); @@ -1354,7 +1356,8 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target, effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT); + LLStatViewer::OBJECT_REZ.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT); } void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj, diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index 93ba3b2558..cf5a6e3762 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -433,7 +433,8 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT); + LLStatViewer::OBJECT_CREATE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT); return TRUE; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4ec498dc33..219e01fe81 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3973,72 +3973,6 @@ void handle_duplicate_in_place(void*) LLSelectMgr::getInstance()->selectDuplicate(offset, TRUE); } -/* dead code 30-apr-2008 -void handle_deed_object_to_group(void*) -{ - LLUUID group_id; - - LLSelectMgr::getInstance()->selectGetGroup(group_id); - LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT); -} - -BOOL enable_deed_object_to_group(void*) -{ - if(LLSelectMgr::getInstance()->getSelection()->isEmpty()) return FALSE; - LLPermissions perm; - LLUUID group_id; - - if (LLSelectMgr::getInstance()->selectGetGroup(group_id) && - gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && - LLSelectMgr::getInstance()->selectGetPermissions(perm) && - perm.deedToGroup(gAgent.getID(), group_id)) - { - return TRUE; - } - return FALSE; -} - -*/ - - -/* - * No longer able to support viewer side manipulations in this way - * -void god_force_inv_owner_permissive(LLViewerObject* object, - LLInventoryObject::object_list_t* inventory, - S32 serial_num, - void*) -{ - typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t; - item_array_t items; - - LLInventoryObject::object_list_t::const_iterator inv_it = inventory->begin(); - LLInventoryObject::object_list_t::const_iterator inv_end = inventory->end(); - for ( ; inv_it != inv_end; ++inv_it) - { - if(((*inv_it)->getType() != LLAssetType::AT_CATEGORY)) - { - LLInventoryObject* obj = *inv_it; - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem((LLViewerInventoryItem*)obj); - LLPermissions perm(new_item->getPermissions()); - perm.setMaskBase(PERM_ALL); - perm.setMaskOwner(PERM_ALL); - new_item->setPermissions(perm); - items.push_back(new_item); - } - } - item_array_t::iterator end = items.end(); - item_array_t::iterator it; - for(it = items.begin(); it != end; ++it) - { - // since we have the inventory item in the callback, it should not - // invalidate iteration through the selection manager. - object->updateInventory((*it), TASK_INVENTORY_ITEM_KEY, false); - } -} -*/ - void handle_object_owner_permissive(void*) { // only send this if they're a god. diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index be78603e2d..7ce8cdcfd8 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1096,17 +1096,20 @@ void upload_new_resource( if( LLAssetType::AT_SOUND == asset_type ) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT ); + LLStatViewer::UPLOAD_SOUND.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT ); } else if( LLAssetType::AT_TEXTURE == asset_type ) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); + LLStatViewer::UPLOAD_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); } else if( LLAssetType::AT_ANIMATION == asset_type) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT ); + LLStatViewer::ANIMATION_UPLOADS.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT ); } if(LLInventoryType::IT_NONE == inv_type) @@ -1231,18 +1234,21 @@ void increase_new_upload_stats(LLAssetType::EType asset_type) { if ( LLAssetType::AT_SOUND == asset_type ) { - LLViewerStats::getInstance()->incStat( - LLViewerStats::ST_UPLOAD_SOUND_COUNT ); + LLStatViewer::UPLOAD_SOUND.add(1); + //LLViewerStats::getInstance()->incStat( + // LLViewerStats::ST_UPLOAD_SOUND_COUNT ); } else if ( LLAssetType::AT_TEXTURE == asset_type ) { - LLViewerStats::getInstance()->incStat( - LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); + LLStatViewer::UPLOAD_TEXTURE.add(1); + //LLViewerStats::getInstance()->incStat( + // LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); } else if ( LLAssetType::AT_ANIMATION == asset_type ) { - LLViewerStats::getInstance()->incStat( - LLViewerStats::ST_UPLOAD_ANIM_COUNT ); + LLStatViewer::ANIMATION_UPLOADS.add(1); + //LLViewerStats::getInstance()->incStat( + // LLViewerStats::ST_UPLOAD_ANIM_COUNT ); } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ec7d91ec4f..b3e1c9bdbe 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4753,125 +4753,150 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) F32 stat_value; msg->getU32("Stat", "StatID", stat_id, i); msg->getF32("Stat", "StatValue", stat_value, i); - switch (stat_id) + LLStatViewer::SimMeasurementSampler* measurementp = LLStatViewer::SimMeasurementSampler::getInstance((ESimStatID)stat_id); + + if (measurementp ) { - case LL_SIM_STAT_TIME_DILATION: - LLStatViewer::SIM_TIME_DILATION.sample(stat_value); - //LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value); - break; - case LL_SIM_STAT_FPS: - LLStatViewer::SIM_FPS.sample(stat_value); - //LLViewerStats::getInstance()->mSimFPS.addValue(stat_value); - break; - case LL_SIM_STAT_PHYSFPS: - LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value); - //LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value); - break; - case LL_SIM_STAT_AGENTUPS: - LLStatViewer::SIM_AGENT_UPS.sample(stat_value); - //LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); - break; - case LL_SIM_STAT_FRAMEMS: - LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value); - break; - case LL_SIM_STAT_NETMS: - LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMOTHERMS: - LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMPHYSICSMS: - LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value); - break; - case LL_SIM_STAT_AGENTMS: - LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value); - break; - case LL_SIM_STAT_IMAGESMS: - LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SCRIPTMS: - LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value); - break; - case LL_SIM_STAT_NUMTASKS: - LLViewerStats::getInstance()->mSimObjects.addValue(stat_value); - break; - case LL_SIM_STAT_NUMTASKSACTIVE: - LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value); - break; - case LL_SIM_STAT_NUMAGENTMAIN: - LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value); - break; - case LL_SIM_STAT_NUMAGENTCHILD: - LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value); - break; - case LL_SIM_STAT_NUMSCRIPTSACTIVE: - LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value); - break; - case LL_SIM_STAT_SCRIPT_EPS: - LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value); - break; - case LL_SIM_STAT_INPPS: - LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value); - break; - case LL_SIM_STAT_OUTPPS: - LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value); - break; - case LL_SIM_STAT_PENDING_DOWNLOADS: - LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value); - break; - case LL_SIM_STAT_PENDING_UPLOADS: - LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value); - break; - case LL_SIM_STAT_PENDING_LOCAL_UPLOADS: - LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value); - break; - case LL_SIM_STAT_TOTAL_UNACKED_BYTES: - LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f); - break; - case LL_SIM_STAT_PHYSICS_PINNED_TASKS: - LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value); - break; - case LL_SIM_STAT_PHYSICS_LOD_TASKS: - LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value); - break; - case LL_SIM_STAT_SIMPHYSICSSTEPMS: - LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMPHYSICSSHAPEMS: - LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMPHYSICSOTHERMS: - LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMPHYSICSMEMORY: - LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value); - break; - case LL_SIM_STAT_SIMSPARETIME: - LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SIMSLEEPTIME: - LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value); - break; - case LL_SIM_STAT_IOPUMPTIME: - LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value); - break; - case LL_SIM_STAT_PCTSCRIPTSRUN: - LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value); - break; - case LL_SIM_STAT_SIMAISTEPTIMEMS: - LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value); - break; - case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS: - LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value); - break; - case LL_SIM_STAT_PCTSTEPPEDCHARACTERS: - LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value); - break; - default: - // Used to be a commented out warning. - LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL; - break; + measurementp->sample(stat_value); } + else + { + llwarns << "Unknown sim stat identifier: " << stat_id << llendl; + } + //switch (stat_id) + //{ + //case LL_SIM_STAT_TIME_DILATION: + // LLStatViewer::SIM_TIME_DILATION.sample(stat_value); + // //LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value); + // break; + //case LL_SIM_STAT_FPS: + // LLStatViewer::SIM_FPS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimFPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_PHYSFPS: + // LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_AGENTUPS: + // LLStatViewer::SIM_AGENT_UPS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_FRAMEMS: + // LLStatViewer::SIM_FRAME_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_NETMS: + // LLStatViewer::SIM_NET_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMOTHERMS: + // LLStatViewer::SIM_PHYSICS_OTHER_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMPHYSICSMS: + // LLStatViewer::SIM_PHYSICS_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_AGENTMS: + // LLStatViewer::SIM_AGENTS_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_IMAGESMS: + // LLStatViewer::SIM_IMAGES_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SCRIPTMS: + // LLStatViewer::SIM_SCRIPTS_TIME.sample(stat_value); + // //LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_NUMTASKS: + // LLStatViewer::SIM_OBJECTS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimObjects.addValue(stat_value); + // break; + //case LL_SIM_STAT_NUMTASKSACTIVE: + // LLStatViewer::SIM_ACTIVE_OBJECTS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value); + // break; + //case LL_SIM_STAT_NUMAGENTMAIN: + // LLStatViewer::SIM_MAIN_AGENTS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value); + // break; + //case LL_SIM_STAT_NUMAGENTCHILD: + // LLStatViewer::SIM_CHILD_AGENTS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value); + // break; + //case LL_SIM_STAT_NUMSCRIPTSACTIVE: + // LLStatViewer::SIM_ACTIVE_SCRIPTS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value); + // break; + //case LL_SIM_STAT_SCRIPT_EPS: + // LLStatViewer::SIM_SCRIPT_EPS.sample(stat_value); + // //LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_INPPS: + // LLStatViewer::SIM_IN_PACKETS_PER_SEC.sample(stat_value); + // //LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_OUTPPS: + // LLStatViewer::SIM_OUT_PACKETS_PER_SEC.sample(stat_value); + // //LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value); + // break; + //case LL_SIM_STAT_PENDING_DOWNLOADS: + // LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value); + // break; + //case LL_SIM_STAT_PENDING_UPLOADS: + // LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value); + // break; + //case LL_SIM_STAT_PENDING_LOCAL_UPLOADS: + // LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value); + // break; + //case LL_SIM_STAT_TOTAL_UNACKED_BYTES: + // LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f); + // break; + //case LL_SIM_STAT_PHYSICS_PINNED_TASKS: + // LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value); + // break; + //case LL_SIM_STAT_PHYSICS_LOD_TASKS: + // LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMPHYSICSSTEPMS: + // LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMPHYSICSSHAPEMS: + // LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMPHYSICSOTHERMS: + // LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMPHYSICSMEMORY: + // LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMSPARETIME: + // LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMSLEEPTIME: + // LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_IOPUMPTIME: + // LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_PCTSCRIPTSRUN: + // LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value); + // break; + //case LL_SIM_STAT_SIMAISTEPTIMEMS: + // LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value); + // break; + //case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS: + // LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value); + // break; + //case LL_SIM_STAT_PCTSTEPPEDCHARACTERS: + // LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value); + // break; + //default: + // // Used to be a commented out warning. + // LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL; + // break; + //} } /* @@ -5942,7 +5967,8 @@ void process_alert_core(const std::string& message, BOOL modal) // HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml if ( message == "You died and have been teleported to your home location") { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); + LLStatViewer::KILLED.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); } else if( message == "Home position set." ) { @@ -7369,7 +7395,7 @@ void onCovenantLoadComplete(LLVFS *vfs, } else { - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index aba1d131e1..989a1c4e5a 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2033,7 +2033,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) ) { - LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); + LLStatViewer::AGENT_POSITION_SNAP.sample<LLUnits::Meters>(diff.length()); + //LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); } } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 88bb087742..2f171f89d7 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1029,10 +1029,14 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) } */ - LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size()); - LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count); - LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled); - LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); + LLStatViewer::NUM_OBJECTS.sample(mObjects.size()); + LLStatViewer::NUM_ACTIVE_OBJECTS.sample(idle_count); + LLStatViewer::NUM_SIZE_CULLED.sample(mNumSizeCulled); + LLStatViewer::NUM_VIS_CULLED.sample(mNumVisCulled); + //LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size()); + //LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count); + //LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled); + //LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); } void LLViewerObjectList::fetchObjectCosts() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index a3d04d655a..f0ad04e0ba 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -76,7 +76,6 @@ LLTrace::Count<> FPS("fpsstat"), OBJECT_REZ("objectrez", "Object rez count"), LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"), LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"), - FAILED_DOWNLOADS("faileddownloads", "Number of times LLAssetStorage::getAssetData() has failed"), LSL_SAVES("lslsaves", "Number of times user has saved a script"), ANIMATION_UPLOADS("animationuploads", "Animations uploaded"), FLY("fly", "Fly count"), @@ -108,28 +107,28 @@ LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"), LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%"); -LLTrace::Measurement<> SIM_TIME_DILATION("simtimedilation"), - SIM_FPS("simfps"), - SIM_PHYSICS_FPS("simphysicsfps"), - SIM_AGENT_UPS("simagentups"), - SIM_SCRIPT_EPS("simscripteps"), - SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"), - SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"), - SIM_MAIN_AGENTS("simmainagents"), - SIM_CHILD_AGENTS("simchildagents"), - SIM_OBJECTS("simobjects"), - SIM_ACTIVE_OBJECTS("simactiveobjects"), - SIM_ACTIVE_SCRIPTS("simactivescripts"), - SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"), - SIM_IN_PACKETS_PER_SEC("siminpps"), - SIM_OUT_PACKETS_PER_SEC("simoutpps"), - SIM_PENDING_DOWNLOADS("simpendingdownloads"), - SIM_PENDING_UPLOADS("simpendinguploads"), - SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads"), - SIM_PENDING_VFS_OPERATIONS("vfspendingoperations"), - SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"), - SIM_PHYSICS_LOD_TASKS("physicslodtasks"), - NUM_IMAGES("numimagesstat"), +SimMeasurement<> SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DILATION), + SIM_FPS("simfps", "", LL_SIM_STAT_FPS), + SIM_PHYSICS_FPS("simphysicsfps", "", LL_SIM_STAT_PHYSFPS), + SIM_AGENT_UPS("simagentups", "", LL_SIM_STAT_AGENTUPS), + SIM_SCRIPT_EPS("simscripteps", "", LL_SIM_STAT_SCRIPT_EPS), + SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps", "", LL_SIM_STAT_SKIPPEDAISILSTEPS_PS), + SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS), + SIM_MAIN_AGENTS("simmainagents", "", LL_SIM_STAT_NUMAGENTMAIN), + SIM_CHILD_AGENTS("simchildagents", "", LL_SIM_STAT_NUMAGENTCHILD), + SIM_OBJECTS("simobjects", "", LL_SIM_STAT_NUMTASKS), + SIM_ACTIVE_OBJECTS("simactiveobjects", "", LL_SIM_STAT_NUMTASKSACTIVE), + SIM_ACTIVE_SCRIPTS("simactivescripts", "", LL_SIM_STAT_NUMSCRIPTSACTIVE), + SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN), + SIM_IN_PACKETS_PER_SEC("siminpps", "", LL_SIM_STAT_INPPS), + SIM_OUT_PACKETS_PER_SEC("simoutpps", "", LL_SIM_STAT_OUTPPS), + SIM_PENDING_DOWNLOADS("simpendingdownloads", "", LL_SIM_STAT_PENDING_DOWNLOADS), + SIM_PENDING_UPLOADS("simpendinguploads", "", LL_SIM_STAT_PENDING_UPLOADS), + SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads", "", LL_SIM_STAT_PENDING_LOCAL_UPLOADS), + SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS), + SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS); + +LLTrace::Measurement<> NUM_IMAGES("numimagesstat"), NUM_RAW_IMAGES("numrawimagesstat"), NUM_OBJECTS("numobjectsstat"), NUM_ACTIVE_OBJECTS("numactiveobjectsstat"), @@ -137,134 +136,61 @@ LLTrace::Measurement<> SIM_TIME_DILATION("simtimedilation"), NUM_SIZE_CULLED("numsizeculledstat"), NUM_VIS_CULLED("numvisculledstat"), ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"), - DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), - MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"), LIGHTING_DETAIL("lightingdetail", "Lighting Detail"), VISIBLE_AVATARS("visibleavatars", "Visible Avatars"), SHADER_OBJECTS("shaderobjects", "Object Shaders"), DRAW_DISTANCE("drawdistance", "Draw Distance"), CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"), + PENDING_VFS_OPERATIONS("vfspendingoperations"), + PACKETS_LOST_PERCENT("packetslostpercentstat"), WINDOW_WIDTH("windowwidth", "Window width"), WINDOW_HEIGHT("windowheight", "Window height"); +LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); + + LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), SIM_PHYSICS_MEM("physicsmemoryallocated"), GL_TEX_MEM("gltexmemstat"), GL_BOUND_MEM("glboundmemstat"), RAW_MEM("rawmemstat"), - FORMATTED_MEM("formattedmemstat"); - - -LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME("simsimphysicsmsec"), - SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"), - SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"), - SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"), - SIM_AI_TIME("simsimaistepmsec"), - SIM_AGENTS_TIME("simagentmsec"), - SIM_IMAGES_TIME("simimagesmsec"), - SIM_SCRIPTS_TIME("simscriptmsec"), - SIM_SPARE_TIME("simsparemsec"), - SIM_SLEEP_TIME("simsleepmsec"), - SIM_PUMP_IO_TIME("simpumpiomsec"), - SIM_PING("simpingstat"), - FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), - FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), - LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), - REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), - FRAME_STACKTIME("framestacktime", "FRAME_SECS"), - UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"), - NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"), - IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"), - REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"), - RENDER_STACKTIME("renderstacktime", "RENDER_SECS"); -} + FORMATTED_MEM("formattedmemstat"), + DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), + MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); + + +SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS), + SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS), + SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS), + SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS), + SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec", "", LL_SIM_STAT_SIMPHYSICSSTEPMS), + SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec", "", LL_SIM_STAT_SIMPHYSICSSHAPEMS), + SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec", "", LL_SIM_STAT_SIMPHYSICSOTHERMS), + SIM_AI_TIME("simsimaistepmsec", "", LL_SIM_STAT_SIMAISTEPTIMEMS), + SIM_AGENTS_TIME("simagentmsec", "", LL_SIM_STAT_AGENTMS), + SIM_IMAGES_TIME("simimagesmsec", "", LL_SIM_STAT_IMAGESMS), + SIM_SCRIPTS_TIME("simscriptmsec", "", LL_SIM_STAT_SCRIPTMS), + SIM_SPARE_TIME("simsparemsec", "", LL_SIM_STAT_SIMSPARETIME), + SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME), + SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME); + +LLTrace::Measurement<LLUnits::Milliseconds> FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), + FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), + LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), + REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), + FRAME_STACKTIME("framestacktime", "FRAME_SECS"), + UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"), + NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"), + IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"), + REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"), + RENDER_STACKTIME("renderstacktime", "RENDER_SECS"), + SIM_PING("simpingstat"); -class StatAttributes -{ -public: - StatAttributes(const char* name, - const BOOL enabled) - : mName(name), - mEnabled(enabled) - { - } - - std::string mName; - BOOL mEnabled; -}; +} -LLViewerStats::LLViewerStats() : - //mVFSPendingOperations("vfspendingoperations"), - //mFPSStat("fpsstat"), - //mPacketsInStat("packetsinstat"), - //mPacketsLostStat("packetsloststat"), - //mPacketsOutStat("packetsoutstat"), - //mPacketsLostPercentStat("packetslostpercentstat"), - //mTexturePacketsStat("texturepacketsstat"), - //mActualInKBitStat("actualinkbitstat"), - //mActualOutKBitStat("actualoutkbitstat"), - //mTrianglesDrawnStat("trianglesdrawnstat"), - //mSimTimeDilation("simtimedilation"), - mSimFPS("simfps"), - mSimPhysicsFPS("simphysicsfps"), - mSimAgentUPS("simagentups"), - mSimScriptEPS("simscripteps"), - mSimFrameMsec("simframemsec"), - mSimNetMsec("simnetmsec"), - mSimSimOtherMsec("simsimothermsec"), - mSimSimPhysicsMsec("simsimphysicsmsec"), - mSimSimPhysicsStepMsec("simsimphysicsstepmsec"), - mSimSimPhysicsShapeUpdateMsec("simsimphysicsshapeupdatemsec"), - mSimSimPhysicsOtherMsec("simsimphysicsothermsec"), - mSimSimAIStepMsec("simsimaistepmsec"), - mSimSimSkippedSilhouetteSteps("simsimskippedsilhouettesteps"), - mSimSimPctSteppedCharacters("simsimpctsteppedcharacters"), - mSimAgentMsec("simagentmsec"), - mSimImagesMsec("simimagesmsec"), - mSimScriptMsec("simscriptmsec"), - mSimSpareMsec("simsparemsec"), - mSimSleepMsec("simsleepmsec"), - mSimPumpIOMsec("simpumpiomsec"), - mSimMainAgents("simmainagents"), - mSimChildAgents("simchildagents"), - mSimObjects("simobjects"), - mSimActiveObjects("simactiveobjects"), - mSimActiveScripts("simactivescripts"), - mSimPctScriptsRun("simpctscriptsrun"), - mSimInPPS("siminpps"), - mSimOutPPS("simoutpps"), - mSimPendingDownloads("simpendingdownloads"), - mSimPendingUploads("simpendinguploads"), - mSimPendingLocalUploads("simpendinglocaluploads"), - mSimTotalUnackedBytes("simtotalunackedbytes"), - mPhysicsPinnedTasks("physicspinnedtasks"), - mPhysicsLODTasks("physicslodtasks"), - mPhysicsMemoryAllocated("physicsmemoryallocated"), - mSimPingStat("simpingstat"), - mNumImagesStat("numimagesstat", TRUE), - mNumRawImagesStat("numrawimagesstat", TRUE), - mGLTexMemStat("gltexmemstat", TRUE), - mGLBoundMemStat("glboundmemstat", TRUE), - mRawMemStat("rawmemstat", TRUE), - mFormattedMemStat("formattedmemstat", TRUE), - mNumObjectsStat("numobjectsstat"), - mNumActiveObjectsStat("numactiveobjectsstat"), - mNumNewObjectsStat("numnewobjectsstat"), - mNumSizeCulledStat("numsizeculledstat"), - mNumVisCulledStat("numvisculledstat"), - mLastTimeDiff(0.0) +LLViewerStats::LLViewerStats() +: mLastTimeDiff(0.0) { - for (S32 i = 0; i < ST_COUNT; i++) - { - mStats[i] = 0.0; - } - - if (LLTimer::knownBadTimer()) - { - mStats[ST_HAS_BAD_TIMER] = 1.0; - } - - mAgentPositionSnaps.reset(); mRecording.start(); LLTrace::get_frame_recording().start(); } @@ -275,93 +201,80 @@ LLViewerStats::~LLViewerStats() void LLViewerStats::resetStats() { - LLViewerStats& stats = LLViewerStats::instance(); - stats.mRecording.reset(); - //stats.mVFSPendingOperations.reset(); - //stats.mPacketsInStat.reset(); - //stats.mPacketsLostStat.reset(); - //stats.mPacketsOutStat.reset(); - //stats.mFPSStat.reset(); - //stats.mTexturePacketsStat.reset(); - //stats.mAgentPositionSnaps.reset(); -} - - -F64 LLViewerStats::getStat(EStatType type) const -{ - return mStats[type]; -} - -F64 LLViewerStats::setStat(EStatType type, F64 value) -{ - mStats[type] = value; - return mStats[type]; -} - -F64 LLViewerStats::incStat(EStatType type, F64 value) -{ - mStats[type] += value; - return mStats[type]; + LLViewerStats::instance().mRecording.reset(); } void LLViewerStats::updateFrameStats(const F64 time_diff) { - if (mPacketsLostPercentStat.getCurrent() > 5.0) + if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0) { - incStat(ST_LOSS_05_SECONDS, time_diff); + LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff); + //incStat(ST_LOSS_05_SECONDS, time_diff); } - if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f) + F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS); + if (0.f < sim_fps && sim_fps < 20.f) { - incStat(ST_SIM_FPS_20_SECONDS, time_diff); + LLStatViewer::SIM_20_FPS_TIME.add(time_diff); + //incStat(ST_SIM_FPS_20_SECONDS, time_diff); } - if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f) + F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS); + + if (0.f < sim_physics_fps && sim_physics_fps < 20.f) { - incStat(ST_PHYS_FPS_20_SECONDS, time_diff); + LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff); + //incStat(ST_PHYS_FPS_20_SECONDS, time_diff); } if (time_diff >= 0.5) { - incStat(ST_FPS_2_SECONDS, time_diff); + LLStatViewer::FPS_2_TIME.add(time_diff); + //incStat(ST_FPS_2_SECONDS, time_diff); } if (time_diff >= 0.125) { - incStat(ST_FPS_8_SECONDS, time_diff); + LLStatViewer::FPS_8_TIME.add(time_diff); + //incStat(ST_FPS_8_SECONDS, time_diff); } if (time_diff >= 0.1) { - incStat(ST_FPS_10_SECONDS, time_diff); + LLStatViewer::FPS_10_TIME.add(time_diff); + //incStat(ST_FPS_10_SECONDS, time_diff); } if (gFrameCount && mLastTimeDiff > 0.0) { // new "stutter" meter - setStat(ST_FPS_DROP_50_RATIO, - (getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + - (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount); + LLStatViewer::FRAMETIME_DOUBLED.add(time_diff >= 2.0 * mLastTimeDiff ? 1 : 0); + //setStat(ST_FPS_DROP_50_RATIO, + // (getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + + // (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount); // old stats that were never really used - setStat(ST_FRAMETIME_JITTER, - (getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + - fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount); + LLStatViewer::FRAMETIME_JITTER.sample(mLastTimeDiff - time_diff); + //setStat(ST_FRAMETIME_JITTER, + // (getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + + // fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount); F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount; - setStat(ST_FRAMETIME_SLEW, - (getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + - fabs(average_frametime - time_diff) / average_frametime) / gFrameCount); + LLStatViewer::FRAMETIME_SLEW.sample(average_frametime - time_diff); + //setStat(ST_FRAMETIME_SLEW, + // (getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + + // fabs(average_frametime - time_diff) / average_frametime) / gFrameCount); F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth; - setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); + LLStatViewer::DELTA_BANDWIDTH.sample<LLUnits::Bits>(delta_bandwidth); + //setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); - setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); + LLStatViewer::MAX_BANDWIDTH.sample<LLUnits::Bits>(max_bandwidth); + //setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); } mLastTimeDiff = time_diff; - } void LLViewerStats::addToMessage(LLSD &body) const @@ -370,11 +283,11 @@ void LLViewerStats::addToMessage(LLSD &body) const misc["Version"] = TRUE; //TODO RN: get last value, not mean - misc["Vertex Buffers Enabled"] = mRecording.getMean(LLStatViewer::ENABLE_VBO); + misc["Vertex Buffers Enabled"] = getRecording().getMean(LLStatViewer::ENABLE_VBO); - body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD(); - llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() - << "; Count = " << mAgentPositionSnaps.getCount() << llendl; + body["AgentPositionSnaps"] = getRecording().getSum(LLStatViewer::AGENT_POSITION_SNAP).value(); //mAgentPositionSnaps.asLLSD(); + llinfos << "STAT: AgentPositionSnaps: Mean = " << getRecording().getMean(LLStatViewer::AGENT_POSITION_SNAP).value() << "; StdDev = " << getRecording().getStandardDeviation(LLStatViewer::AGENT_POSITION_SNAP).value() + << "; Count = " << getRecording().getSampleCount(LLStatViewer::AGENT_POSITION_SNAP) << llendl; } // *NOTE:Mani The following methods used to exist in viewer.cpp @@ -386,8 +299,6 @@ F32 gAveLandCompression = 0.f, gAveWaterCompression = 0.f; F32 gBestLandCompression = 1.f, gBestWaterCompression = 1.f; F32 gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f; - - U32 gTotalWorldBytes = 0, gTotalObjectBytes = 0, gTotalTextureBytes = 0, gSimPingCount = 0; U32 gObjectBits = 0; F32 gAvgSimPing = 0.f; @@ -403,51 +314,61 @@ void update_statistics() gTotalWorldBytes += gVLManager.getTotalBytes(); gTotalObjectBytes += gObjectBits / 8; - LLViewerStats& stats = LLViewerStats::instance(); - // make sure we have a valid time delta for this frame if (gFrameIntervalSeconds > 0.f) { if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds); + LLStatViewer::MOUSELOOK_TIME.add(gFrameIntervalSeconds); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds); } else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds); + LLStatViewer::AVATAR_EDIT_TIME.add(gFrameIntervalSeconds); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds); } else if (LLFloaterReg::instanceVisible("build")) { - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds); + LLStatViewer::TOOLBOX_TIME.add(gFrameIntervalSeconds); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds); } } - stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); - stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); - stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); - stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); - - stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); + LLStatViewer::ENABLE_VBO.sample((F64)gSavedSettings.getBOOL("RenderVBOEnable")); + //stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); + LLStatViewer::LIGHTING_DETAIL.sample((F64)gPipeline.getLightingDetail()); + //stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); + LLStatViewer::DRAW_DISTANCE.sample((F64)gSavedSettings.getF32("RenderFarClip")); + //stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); + LLStatViewer::CHAT_BUBBLES.sample((F64)gSavedSettings.getBOOL("UseChatBubbles")); + //stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); + + LLStatViewer::FRAME_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Frame")); + //stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle"); F64 network_secs = gDebugView->mFastTimerView->getTime("Network"); - stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs); - stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs); - stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images")); - stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State")); - stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry")); + LLStatViewer::UPDATE_STACKTIME.sample(idle_secs - network_secs); + //stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs); + LLStatViewer::NETWORK_STACKTIME.sample(network_secs); + //stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs); + LLStatViewer::IMAGE_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Update Images")); + //stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images")); + LLStatViewer::REBUILD_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Sort Draw State")); + //stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State")); + LLStatViewer::RENDER_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Geometry")); + //stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry")); LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay()); - stats.mSimPingStat.addValue(cdp->getPingDelay()); + //stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { - LLUnits::Seconds i(10000); - LLStatViewer::SIM_PING.sample(i);//<LLUnits::Seconds<U32> >(10000); - stats.mSimPingStat.addValue(10000); + LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(10000); + //stats.mSimPingStat.addValue(10000); } //stats.mFPSStat.addValue(1); @@ -458,7 +379,7 @@ void update_statistics() LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); - LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); + LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -481,7 +402,8 @@ void update_statistics() visible_avatar_frames = 1.f; avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames; } - stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars); + LLStatViewer::VISIBLE_AVATARS.sample((F64)avg_visible_avatars); + //stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars); } LLWorld::getInstance()->updateNetStats(); LLWorld::getInstance()->requestCacheMisses(); diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 5412294cf2..40109bcea3 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -28,12 +28,39 @@ #define LL_LLVIEWERSTATS_H #include "llstat.h" +#include "llstatenums.h" #include "lltextureinfo.h" #include "lltracerecording.h" #include "lltrace.h" namespace LLStatViewer { + +struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, ESimStatID> +{ + SimMeasurementSampler(ESimStatID id) + : LLInstanceTracker(id) + {} + virtual ~SimMeasurementSampler() {} + virtual void sample(F64 value) = 0; +}; + +template<typename T = F64> +struct SimMeasurement : public LLTrace::Measurement<T>, public SimMeasurementSampler +{ + SimMeasurement(const char* name, const char* description, ESimStatID stat_id) + : LLTrace::Measurement<T>(name, description), + SimMeasurementSampler(stat_id) + {} + + using SimMeasurementSampler::getInstance; + + /*virtual*/ void sample(F64 value) + { + LLTrace::Measurement<T>::sample(value); + } +}; + extern LLTrace::Count<> FPS, PACKETS_IN, PACKETS_LOST, @@ -46,7 +73,6 @@ extern LLTrace::Count<> FPS, OBJECT_REZ, LOADING_WEARABLES_LONG_DELAY, LOGIN_TIMEOUTS, - FAILED_DOWNLOADS, LSL_SAVES, ANIMATION_UPLOADS, FLY, @@ -80,7 +106,7 @@ extern LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME, SIM_PHYSICS_20_FPS_TIME, LOSS_5_PERCENT_TIME; -extern LLTrace::Measurement<> SIM_TIME_DILATION, +extern SimMeasurement<> SIM_TIME_DILATION, SIM_FPS, SIM_PHYSICS_FPS, SIM_AGENT_UPS, @@ -98,10 +124,10 @@ extern LLTrace::Measurement<> SIM_TIME_DILATION, SIM_PENDING_DOWNLOADS, SIM_PENDING_UPLOADS, SIM_PENDING_LOCAL_UPLOADS, - SIM_PENDING_VFS_OPERATIONS, SIM_PHYSICS_PINNED_TASKS, - SIM_PHYSICS_LOD_TASKS, - NUM_IMAGES, + SIM_PHYSICS_LOD_TASKS; + +extern LLTrace::Measurement<> NUM_IMAGES, NUM_RAW_IMAGES, NUM_OBJECTS, NUM_ACTIVE_OBJECTS, @@ -109,25 +135,31 @@ extern LLTrace::Measurement<> SIM_TIME_DILATION, NUM_SIZE_CULLED, NUM_VIS_CULLED, ENABLE_VBO, - DELTA_BANDWIDTH, - MAX_BANDWIDTH, LIGHTING_DETAIL, VISIBLE_AVATARS, SHADER_OBJECTS, DRAW_DISTANCE, CHAT_BUBBLES, + PENDING_VFS_OPERATIONS, + PACKETS_LOST_PERCENT, WINDOW_WIDTH, WINDOW_HEIGHT; +extern LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP; + extern LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES, + DELTA_BANDWIDTH, + MAX_BANDWIDTH, SIM_PHYSICS_MEM, GL_TEX_MEM, GL_BOUND_MEM, RAW_MEM, FORMATTED_MEM; - -extern LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME, +extern SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME, + SIM_NET_TIME, + SIM_OTHER_TIME, + SIM_PHYSICS_TIME, SIM_PHYSICS_STEP_TIME, SIM_PHYSICS_SHAPE_UPDATE_TIME, SIM_PHYSICS_OTHER_TIME, @@ -137,171 +169,32 @@ extern LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME, SIM_SCRIPTS_TIME, SIM_SPARE_TIME, SIM_SLEEP_TIME, - SIM_PUMP_IO_TIME, - SIM_PING, - FRAMETIME_JITTER, - FRAMETIME_SLEW, - LOGIN_SECONDS, - REGION_CROSSING_TIME, - FRAME_STACKTIME, - UPDATE_STACKTIME, - NETWORK_STACKTIME, - IMAGE_STACKTIME, - REBUILD_STACKTIME, - RENDER_STACKTIME; + SIM_PUMP_IO_TIME; + + +extern LLTrace::Measurement<LLUnits::Milliseconds> FRAMETIME_JITTER, + FRAMETIME_SLEW, + LOGIN_SECONDS, + REGION_CROSSING_TIME, + FRAME_STACKTIME, + UPDATE_STACKTIME, + NETWORK_STACKTIME, + IMAGE_STACKTIME, + REBUILD_STACKTIME, + RENDER_STACKTIME, + SIM_PING; } class LLViewerStats : public LLSingleton<LLViewerStats> { public: - LLStat mVFSPendingOperations, - mFPSStat, - mPacketsInStat, - mPacketsLostStat, - mPacketsOutStat, - mPacketsLostPercentStat, - mTexturePacketsStat, - mActualInKBitStat, // From the packet ring (when faking a bad connection) - mActualOutKBitStat, // From the packet ring (when faking a bad connection) - mTrianglesDrawnStat; - - // Simulator stats - LLStat mSimTimeDilation; - - LLStat mSimFPS, - mSimPhysicsFPS, - mSimAgentUPS, - mSimScriptEPS; - - LLStat mSimFrameMsec, - mSimNetMsec, - mSimSimOtherMsec, - mSimSimPhysicsMsec; - - LLStat mSimSimPhysicsStepMsec, - mSimSimPhysicsShapeUpdateMsec, - mSimSimPhysicsOtherMsec, - mSimSimAIStepMsec, - mSimSimSkippedSilhouetteSteps, - mSimSimPctSteppedCharacters; - - LLStat mSimAgentMsec, - mSimImagesMsec, - mSimScriptMsec, - mSimSpareMsec, - mSimSleepMsec, - mSimPumpIOMsec; - - LLStat mSimMainAgents, - mSimChildAgents, - mSimObjects, - mSimActiveObjects, - mSimActiveScripts, - mSimPctScriptsRun; - - LLStat mSimInPPS, - mSimOutPPS, - mSimPendingDownloads, - mSimPendingUploads, - mSimPendingLocalUploads, - mSimTotalUnackedBytes; - - LLStat mPhysicsPinnedTasks, - mPhysicsLODTasks, - mPhysicsMemoryAllocated; - - LLStat mSimPingStat; - - LLStat mNumImagesStat, - mNumRawImagesStat, - mGLTexMemStat, - mGLBoundMemStat, - mRawMemStat, - mFormattedMemStat; - - LLStat mNumObjectsStat, - mNumActiveObjectsStat, - mNumNewObjectsStat, - mNumSizeCulledStat, - mNumVisCulledStat; - void resetStats(); public: - // If you change this, please also add a corresponding text label in llviewerstats.cpp - enum EStatType - { - ST_VERSION = 0, - ST_AVATAR_EDIT_SECONDS = 1, - ST_TOOLBOX_SECONDS = 2, - ST_CHAT_COUNT = 3, - ST_IM_COUNT = 4, - ST_FULLSCREEN_BOOL = 5, - ST_RELEASE_COUNT= 6, - ST_CREATE_COUNT = 7, - ST_REZ_COUNT = 8, - ST_FPS_10_SECONDS = 9, - ST_FPS_2_SECONDS = 10, - ST_MOUSELOOK_SECONDS = 11, - ST_FLY_COUNT = 12, - ST_TELEPORT_COUNT = 13, - ST_OBJECT_DELETE_COUNT = 14, - ST_SNAPSHOT_COUNT = 15, - ST_UPLOAD_SOUND_COUNT = 16, - ST_UPLOAD_TEXTURE_COUNT = 17, - ST_EDIT_TEXTURE_COUNT = 18, - ST_KILLED_COUNT = 19, - ST_FRAMETIME_JITTER = 20, - ST_FRAMETIME_SLEW = 21, - ST_INVENTORY_TOO_LONG = 22, - ST_WEARABLES_TOO_LONG = 23, - ST_LOGIN_SECONDS = 24, - ST_LOGIN_TIMEOUT_COUNT = 25, - ST_HAS_BAD_TIMER = 26, - ST_DOWNLOAD_FAILED = 27, - ST_LSL_SAVE_COUNT = 28, - ST_UPLOAD_ANIM_COUNT = 29, - ST_FPS_8_SECONDS = 30, - ST_SIM_FPS_20_SECONDS = 31, - ST_PHYS_FPS_20_SECONDS = 32, - ST_LOSS_05_SECONDS = 33, - ST_FPS_DROP_50_RATIO = 34, - ST_ENABLE_VBO = 35, - ST_DELTA_BANDWIDTH = 36, - ST_MAX_BANDWIDTH = 37, - ST_LIGHTING_DETAIL = 38, - ST_VISIBLE_AVATARS = 39, - ST_SHADER_OBJECTS = 40, - ST_SHADER_ENVIRONMENT = 41, - ST_DRAW_DIST = 42, - ST_CHAT_BUBBLES = 43, - ST_SHADER_AVATAR = 44, - ST_FRAME_SECS = 45, - ST_UPDATE_SECS = 46, - ST_NETWORK_SECS = 47, - ST_IMAGE_SECS = 48, - ST_REBUILD_SECS = 49, - ST_RENDER_SECS = 50, - ST_CROSSING_AVG = 51, - ST_CROSSING_MAX = 52, - ST_LIBXUL_WIDGET_USED = 53, // Unused - ST_WINDOW_WIDTH = 54, - ST_WINDOW_HEIGHT = 55, - ST_TEX_BAKES = 56, - ST_TEX_REBAKES = 57, - - ST_COUNT = 58 - }; - LLViewerStats(); ~LLViewerStats(); - // all return latest value of given stat - F64 getStat(EStatType type) const; - F64 setStat(EStatType type, F64 value); // set the stat to value - F64 incStat(EStatType type, F64 value = 1.f); // add value to the stat - void updateFrameStats(const F64 time_diff); void addToMessage(LLSD &body) const; @@ -388,8 +281,6 @@ public: } }; - StatsAccumulator mAgentPositionSnaps; - // Phase tracking (originally put in for avatar rezzing), tracking // progress of active/completed phases for activities like outfit changing. typedef std::map<std::string,LLFrameTimer> phase_map_t; @@ -412,9 +303,9 @@ public: }; LLTrace::Recording& getRecording() { return mRecording; } + const LLTrace::Recording& getRecording() const { return mRecording; } private: - F64 mStats[ST_COUNT]; LLTrace::Recording mRecording; F64 mLastTimeDiff; // used for time stat updates diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index ccfedd8881..56ccf3b1f0 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -66,12 +66,6 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL; S32 LLViewerTextureList::sNumImages = 0; -LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE); -LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE); -LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", TRUE); -LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", TRUE); -LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", TRUE); -LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", TRUE); LLViewerTextureList gTextureList; static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images"); @@ -625,12 +619,15 @@ void LLViewerTextureList::updateImages(F32 max_time) LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value()); - LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages); - LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount); - LLViewerStats::getInstance()->mGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes)); - LLViewerStats::getInstance()->mGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes)); - LLViewerStats::getInstance()->mRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory)); - LLViewerStats::getInstance()->mFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory)); + { + using namespace LLStatViewer; + NUM_IMAGES.sample(sNumImages); + NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount); + GL_TEX_MEM.sample<LLUnits::Bytes>(LLImageGL::sGlobalTextureMemoryInBytes); + GL_BOUND_MEM.sample<LLUnits::Bytes>(LLImageGL::sBoundTextureMemoryInBytes); + RAW_MEM.sample<LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory); + FORMATTED_MEM.sample<LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory); + } { //loading from fast cache diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index ab6f009e28..a00f48b5a2 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -1,5 +1,5 @@ /** - * @file llviewertexturelist.h + * @file llviewertexturelinumimagest.h * @brief Object for managing the list of images within a region * * $LicenseInfo:firstyear=2000&license=viewerlgpl$ @@ -200,14 +200,6 @@ private: S32 mMaxTotalTextureMemInMegaBytes; LLFrameTimer mForceDecodeTimer; -public: - static LLStat sNumImagesStat; - static LLStat sNumRawImagesStat; - static LLStat sGLTexMemStat; - static LLStat sGLBoundMemStat; - static LLStat sRawMemStat; - static LLStat sFormattedMemStat; - private: static S32 sNumImages; static void (*sUUIDCallback)(void**, const LLUUID &); diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp index 5147272122..34f2c8f6e6 100644 --- a/indra/newview/llviewerthrottle.cpp +++ b/indra/newview/llviewerthrottle.cpp @@ -304,7 +304,8 @@ void LLViewerThrottle::updateDynamicThrottle() } mUpdateTimer.reset(); - if (LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean() > TIGHTEN_THROTTLE_THRESHOLD) + F32 mean_packets_lost = LLViewerStats::instance().getRecording().getMean(LLStatViewer::PACKETS_LOST_PERCENT); + if (mean_packets_lost > TIGHTEN_THROTTLE_THRESHOLD) { if (mThrottleFrac <= MIN_FRACTIONAL || mCurrentBandwidth / 1024.0f <= MIN_BANDWIDTH) { @@ -317,7 +318,7 @@ void LLViewerThrottle::updateDynamicThrottle() mCurrent.sendToSim(); llinfos << "Tightening network throttle to " << mCurrentBandwidth << llendl; } - else if (LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean() <= EASE_THROTTLE_THRESHOLD) + else if (mean_packets_lost <= EASE_THROTTLE_THRESHOLD) { if (mThrottleFrac >= MAX_FRACTIONAL || mCurrentBandwidth / 1024.0f >= MAX_BANDWIDTH) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 4ad7c49d4b..8161caf5e4 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2184,8 +2184,10 @@ void LLViewerWindow::reshape(S32 width, S32 height) } } - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); + LLStatViewer::WINDOW_WIDTH.sample((F64)width); + //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); + LLStatViewer::WINDOW_HEIGHT.sample((F64)height); + //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); LLLayoutStack::updateClass(); } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index fd892db3d3..3e8b07b6dc 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -911,13 +911,14 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) { ++mRegionCrossingCount; F64 delta = (F64)mRegionCrossingTimer.getElapsedTimeF32(); - F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG); - F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount; - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg); - - F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX); - max = llmax(delta, max); - LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max); + //F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG); + //F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount; + LLStatViewer::REGION_CROSSING_TIME.sample(delta); + //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg); + // + //F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX); + //max = llmax(delta, max); + //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max); // Diagnostics llinfos << "Region crossing took " << (F32)(delta * 1000.0) << " ms " << llendl; @@ -2587,7 +2588,8 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) llinfos << "TAT: rebake - matched entry " << (S32)index << llendl; gAgentAvatarp->invalidateComposite(layer_set, TRUE); found = TRUE; - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); + LLStatViewer::TEX_REBAKES.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } } } @@ -2632,7 +2634,8 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug) } invalidateComposite(layer_set, TRUE); - LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); + LLStatViewer::TEX_REBAKES.add(1); + //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } else { diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 6f6411ce3c..20033d6fe4 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -136,7 +136,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { LLFile::remove(std::string(filename)); } - LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); + //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); LL_WARNS("Wearable") << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << LL_ENDL; switch( status ) diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 9e495c46b1..604741ff27 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -712,13 +712,15 @@ void LLWorld::updateNetStats() LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); LLStatViewer::PACKETS_LOST.add(packets_lost); + LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); //LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); //LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); //LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); - //if (packets_in) - //{ + if (packets_in) + { + LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); - //} + } //else //{ // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f); -- cgit v1.2.3 From e6ca5471a2a816a24888ae1b38332531b22b7254 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 17 Oct 2012 00:06:22 -0700 Subject: SH-3275 Update viewer metrics system to be more flexible put template parameter back in LLUnit units added free function operators for mathematical manipulation of unit values converted texture memory tracking to units --- indra/llcommon/lltrace.h | 36 +++- indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/llunit.h | 376 +++++++++++++++++++++++----------- indra/llrender/llimagegl.cpp | 16 +- indra/llrender/llimagegl.h | 7 +- indra/newview/lltexturefetch.cpp | 2 +- indra/newview/lltextureview.cpp | 20 +- indra/newview/llviewerobject.cpp | 2 +- indra/newview/llviewerstats.cpp | 28 +-- indra/newview/llviewerstats.h | 12 +- indra/newview/llviewertexture.cpp | 43 ++-- indra/newview/llviewertexture.h | 15 +- indra/newview/llviewertexturelist.cpp | 20 +- indra/newview/llviewerwindow.cpp | 2 +- indra/newview/llvoavatarself.cpp | 2 +- indra/newview/llworld.cpp | 6 +- 16 files changed, 379 insertions(+), 210 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3e19c83bd7..1c6726605a 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -46,6 +46,30 @@ namespace LLTrace { class Recording; + typedef LLUnit::Bytes<F64> Bytes; + typedef LLUnit::Kilobytes<F64> Kilobytes; + typedef LLUnit::Megabytes<F64> Megabytes; + typedef LLUnit::Gigabytes<F64> Gigabytes; + typedef LLUnit::Bits<F64> Bits; + typedef LLUnit::Kilobits<F64> Kilobits; + typedef LLUnit::Megabits<F64> Megabits; + typedef LLUnit::Gigabits<F64> Gigabits; + + typedef LLUnit::Seconds<F64> Seconds; + typedef LLUnit::Milliseconds<F64> Milliseconds; + typedef LLUnit::Minutes<F64> Minutes; + typedef LLUnit::Hours<F64> Hours; + typedef LLUnit::Days<F64> Days; + typedef LLUnit::Weeks<F64> Weeks; + typedef LLUnit::Milliseconds<F64> Milliseconds; + typedef LLUnit::Microseconds<F64> Microseconds; + typedef LLUnit::Nanoseconds<F64> Nanoseconds; + + typedef LLUnit::Meters<F64> Meters; + typedef LLUnit::Kilometers<F64> Kilometers; + typedef LLUnit::Centimeters<F64> Centimeters; + typedef LLUnit::Millimeters<F64> Millimeters; + void init(); void cleanup(); @@ -353,15 +377,15 @@ namespace LLTrace template <typename T> class LL_COMMON_API Measurement <T, typename T::is_unit_t> - : public Measurement<typename T::value_t> + : public Measurement<typename T::storage_t> { public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; - typedef Measurement<typename T::value_t> base_measurement_t; + typedef Measurement<typename T::storage_t> base_measurement_t; Measurement(const char* name, const char* description = NULL) - : Measurement<typename T::value_t>(name) + : Measurement<typename T::storage_t>(name, description) {} template<typename UNIT_T> @@ -393,15 +417,15 @@ namespace LLTrace template <typename T> class LL_COMMON_API Count <T, typename T::is_unit_t> - : public Count<typename T::value_t> + : public Count<typename T::storage_t> { public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; - typedef Count<typename T::value_t> base_count_t; + typedef Count<typename T::storage_t> base_count_t; Count(const char* name, const char* description = NULL) - : Count<typename T::value_t>(name) + : Count<typename T::storage_t>(name) {} template<typename UNIT_T> diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index bd4b944e5a..5e7b0752c6 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -214,7 +214,7 @@ namespace LLTrace return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; } - Recording getCurRecordingPeriod() + Recording& getCurRecordingPeriod() { return mRecordingPeriods[mCurPeriod]; } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index e8f6b2b2ba..d980989c91 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -34,60 +34,43 @@ template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT = BASE struct LLUnitType : public BASE_UNIT { typedef DERIVED_UNIT unit_t; - typedef typename BASE_UNIT::value_t value_t; + + typedef typename STORAGE_TYPE storage_t; typedef void is_unit_t; LLUnitType() {} - explicit LLUnitType(value_t value) + explicit LLUnitType(storage_t value) : BASE_UNIT(convertToBase(value)) {} + // implicit downcast operator unit_t& () { return static_cast<unit_t&>(*this); } - value_t value() const + storage_t value() const { return convertToDerived(mBaseValue); } template<typename CONVERTED_TYPE> - value_t value() const + storage_t value() const { return CONVERTED_TYPE(*this).value(); } - static value_t convertToBase(value_t derived_value) - { - return (value_t)((F32)derived_value * unit_t::conversionToBaseFactor()); - } - - static value_t convertToDerived(value_t base_value) - { - return (value_t)((F32)base_value / unit_t::conversionToBaseFactor()); - } - - unit_t operator + (const unit_t other) const - { - return unit_t(mBaseValue + other.mBaseValue); - } - - unit_t operator - (const unit_t other) const - { - return unit_t(mBaseValue - other.mBaseValue); - } - - unit_t operator * (value_t multiplicand) const +protected: + static storage_t convertToBase(storage_t derived_value) { - return unit_t(mBaseValue * multiplicand); + return (storage_t)((F32)derived_value * unit_t::conversionToBaseFactor()); } - unit_t operator / (value_t divisor) const + static storage_t convertToDerived(storage_t base_value) { - return unit_t(mBaseValue / divisor); + return (storage_t)((F32)base_value / unit_t::conversionToBaseFactor()); } }; @@ -96,43 +79,40 @@ template<typename STORAGE_TYPE, typename T> struct LLUnitType<STORAGE_TYPE, T, T> { typedef T unit_t; - typedef typename STORAGE_TYPE value_t; + typedef STORAGE_TYPE storage_t; typedef void is_unit_t; + typedef T base_unit_t; LLUnitType() : mBaseValue() {} - explicit LLUnitType(value_t value) + explicit LLUnitType(storage_t value) : mBaseValue(value) {} - unit_t& operator=(value_t value) + unit_t& operator=(storage_t value) { setBaseValue(value); return *this; } + //implicit downcast operator unit_t& () { return static_cast<unit_t&>(*this); } - value_t value() const { return mBaseValue; } + storage_t value() const { return mBaseValue; } - static value_t convertToBase(value_t derived_value) + static storage_t convertToBase(storage_t derived_value) { - return (value_t)derived_value; + return (storage_t)derived_value; } - static value_t convertToDerived(value_t base_value) + static storage_t convertToDerived(storage_t base_value) { - return (value_t)base_value; - } - - unit_t operator + (const unit_t other) const - { - return unit_t(mBaseValue + other.mBaseValue); + return (storage_t)base_value; } void operator += (const unit_t other) @@ -140,108 +120,266 @@ struct LLUnitType<STORAGE_TYPE, T, T> mBaseValue += other.mBaseValue; } - unit_t operator - (const unit_t other) const - { - return unit_t(mBaseValue - other.mBaseValue); - } - void operator -= (const unit_t other) { mBaseValue -= other.mBaseValue; } - unit_t operator * (value_t multiplicand) const - { - return unit_t(mBaseValue * multiplicand); - } - - void operator *= (value_t multiplicand) + void operator *= (storage_t multiplicand) { mBaseValue *= multiplicand; } - unit_t operator / (value_t divisor) const - { - return unit_t(mBaseValue / divisor); - } - - void operator /= (value_t divisor) + void operator /= (storage_t divisor) { mBaseValue /= divisor; } protected: - void setBaseValue(value_t value) + void setBaseValue(storage_t value) { mBaseValue = value; } - value_t mBaseValue; + storage_t mBaseValue; }; -#define LL_DECLARE_BASE_UNIT(unit_name) \ - struct unit_name : public LLUnitType<F64, unit_name> \ - { \ - typedef unit_name base_unit_t; \ - typedef LLUnitType<F64, unit_name> unit_t; \ - typedef F64 storage_t; \ - \ - unit_name(F64 value) \ - : LLUnitType(value) \ - {} \ - \ - unit_name() \ - {} \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - unit_name(const LLUnitType<SOURCE_STORAGE_TYPE, unit_name, SOURCE_TYPE>& source) \ - { \ - setBaseValue((F64)source.unit_name::unit_t::value()); \ - } \ - \ - using LLUnitType::operator +; \ - using LLUnitType::operator +=; \ - using LLUnitType::operator -; \ - using LLUnitType::operator -=; \ - using LLUnitType::operator *; \ - using LLUnitType::operator *=; \ - using LLUnitType::operator /; \ - using LLUnitType::operator /=; \ +// +// operator + +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first + second.value()); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return DERIVED_UNIT(first.value() + second); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first.value() + second.value()); +} + +// +// operator - +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator - (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first - second.value()); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return DERIVED_UNIT(first.value() - second); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first.value() - second.value()); +} + +// +// operator * +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator * (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first * second.value()); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return DERIVED_UNIT(first.value() * second); +} + +// +// operator / +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator / (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return DERIVED_UNIT(first * second.value()); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +DERIVED_UNIT operator / (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return DERIVED_UNIT(first.value() * second); +} + +// +// operator < +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator < (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first < second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() < second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() < second.value(); +} + +// +// operator <= +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator <= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first <= second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() <= second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() <= second.value(); +} + +// +// operator > +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator > (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first > second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() > second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() > second.value(); +} +// +// operator >= +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator >= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first >= second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() >= second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() >= second.value(); +} + +// +// operator == +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator == (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first == second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() == second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() == second.value(); +} + +// +// operator != +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator != (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +{ + return first != second.value(); +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +{ + return first.value() != second; +} + +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> +bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +{ + return first.value() != second.value(); +} + +#define LL_DECLARE_BASE_UNIT(unit_name) \ + template<typename STORAGE> \ + struct unit_name : public LLUnitType<STORAGE, unit_name<STORAGE>, unit_name<STORAGE> > \ + { \ + typedef LLUnitType<STORAGE, unit_name> unit_t; \ + \ + unit_name(storage_t value = 0) \ + : LLUnitType(value) \ + {} \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + unit_name(LLUnitType<SOURCE_STORAGE_TYPE, unit_name<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.unit_name<SOURCE_STORAGE_TYPE>::unit_t::value()); \ + } \ + \ }; -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - struct derived_unit : public LLUnitType<F64, base_unit, derived_unit> \ - { \ - typedef base_unit base_unit_t; \ - typedef LLUnitType<F64, base_unit, derived_unit> unit_t; \ - typedef F64 storage_t; \ - \ - derived_unit(value_t value) \ - : LLUnitType(value) \ - {} \ - \ - derived_unit() \ - {} \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - derived_unit(const LLUnitType<SOURCE_STORAGE_TYPE, base_unit, SOURCE_TYPE>& source) \ - { \ - setBaseValue((F64)source.base_unit::unit_t::value()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - using LLUnitType::operator +; \ - using LLUnitType::operator +=; \ - using LLUnitType::operator -; \ - using LLUnitType::operator -=; \ - using LLUnitType::operator *; \ - using LLUnitType::operator *=; \ - using LLUnitType::operator /; \ - using LLUnitType::operator /=; \ +#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ + template<typename STORAGE> \ + struct derived_unit : public LLUnitType<STORAGE, base_unit<STORAGE>, derived_unit<STORAGE> > \ + { \ + typedef LLUnitType<STORAGE, base_unit<STORAGE>, derived_unit<STORAGE> > unit_t; \ + \ + derived_unit(storage_t value = 0) \ + : LLUnitType(value) \ + {} \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + derived_unit(LLUnitType<SOURCE_STORAGE_TYPE, base_unit<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.base_unit<SOURCE_STORAGE_TYPE>::unit_t::value()); \ + } \ + \ + static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ + \ }; -namespace LLUnits +namespace LLUnit { LL_DECLARE_BASE_UNIT(Bytes); LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a4d7872ec2..fc1edbe664 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -50,9 +50,9 @@ U32 wpo2(U32 i); U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -S32 LLImageGL::sGlobalTextureMemoryInBytes = 0; -S32 LLImageGL::sBoundTextureMemoryInBytes = 0; -S32 LLImageGL::sCurBoundTextureMemory = 0; +LLUnit::Bytes<S32> LLImageGL::sGlobalTextureMemory = 0; +LLUnit::Bytes<S32> LLImageGL::sBoundTextureMemory = 0; +LLUnit::Bytes<S32> LLImageGL::sCurBoundTextureMemory = 0; S32 LLImageGL::sCount = 0; LLImageGL::dead_texturelist_t LLImageGL::sDeadTextureList[LLTexUnit::TT_NONE]; U32 LLImageGL::sCurTexName = 1; @@ -243,7 +243,7 @@ void LLImageGL::updateStats(F32 current_time) { LLFastTimer t(FTM_IMAGE_UPDATE_STATS); sLastFrameTime = current_time; - sBoundTextureMemoryInBytes = sCurBoundTextureMemory; + sBoundTextureMemory = sCurBoundTextureMemory; sCurBoundTextureMemory = 0; } @@ -251,7 +251,7 @@ void LLImageGL::updateStats(F32 current_time) S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) { LLImageGL::sCurBoundTextureMemory += mem ; - return LLImageGL::sCurBoundTextureMemory; + return LLImageGL::sCurBoundTextureMemory.value(); } //---------------------------------------------------------------------------- @@ -1395,7 +1395,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ if (old_name != 0) { - sGlobalTextureMemoryInBytes -= mTextureMemory; + sGlobalTextureMemory -= mTextureMemory; LLImageGL::deleteTextures(mBindTarget, mFormatInternal, mMipLevels, 1, &old_name); @@ -1403,7 +1403,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ } mTextureMemory = getMipBytes(discard_level); - sGlobalTextureMemoryInBytes += mTextureMemory; + sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; // mark this as bound at this point, so we don't throw it out immediately @@ -1562,7 +1562,7 @@ void LLImageGL::destroyGLTexture() { if(mTextureMemory) { - sGlobalTextureMemoryInBytes -= mTextureMemory; + sGlobalTextureMemory -= mTextureMemory; mTextureMemory = 0; } diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index cf3c484c79..dfa59f2a34 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -34,6 +34,7 @@ #include "llpointer.h" #include "llrefcount.h" #include "v2math.h" +#include "llunit.h" #include "llrender.h" class LLTextureAtlas ; @@ -245,9 +246,9 @@ public: static F32 sLastFrameTime; // Global memory statistics - static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem - static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame - static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame + static LLUnit::Bytes<S32> sGlobalTextureMemory; // Tracks main memory texmem + static LLUnit::Bytes<S32> sBoundTextureMemory; // Tracks bound texmem for last completed frame + static LLUnit::Bytes<S32> sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f2caa01644..8ddaac5cc8 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2316,7 +2316,7 @@ S32 LLTextureFetch::update(F32 max_time_ms) if(mCurlGetRequest) { - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits>(mCurlGetRequest->getTotalReceivedBits()); + LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bits>(mCurlGetRequest->getTotalReceivedBits()); //gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index c60b4155a0..a88233e120 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -503,13 +503,13 @@ private: void LLGLTexMemBar::draw() { - S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); - S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; - S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); - S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; + LLUnit::Megabytes<S32> bound_mem = LLViewerTexture::sBoundTextureMemory; + LLUnit::Megabytes<S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; + LLUnit::Megabytes<S32> total_mem = LLViewerTexture::sTotalTextureMemory; + LLUnit::Megabytes<S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; - F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; - F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; + F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ; + F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); @@ -526,10 +526,10 @@ void LLGLTexMemBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", - total_mem, - max_total_mem, - bound_mem, - max_bound_mem, + total_mem.value(), + max_total_mem.value(), + bound_mem.value(), + max_bound_mem.value(), LLRenderTarget::sBytesAllocated/(1024*1024), LLImageRaw::sGlobalRawMemory >> 20, discard_bias, cache_usage, cache_max_usage); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 989a1c4e5a..747dfd3250 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2033,7 +2033,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) ) { - LLStatViewer::AGENT_POSITION_SNAP.sample<LLUnits::Meters>(diff.length()); + LLStatViewer::AGENT_POSITION_SNAP.sample<LLTrace::Meters>(diff.length()); //LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); } } diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index f0ad04e0ba..ccc0c9ba59 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -89,7 +89,7 @@ LLTrace::Count<> FPS("fpsstat"), FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"), TEX_BAKES("texbakes"), TEX_REBAKES("texrebakes"); -LLTrace::Count<LLUnits::Kilobits> KBIT("kbitstat"), +LLTrace::Count<LLTrace::Kilobits> KBIT("kbitstat"), LAYERS_KBIT("layerskbitstat"), OBJECT_KBIT("objectkbitstat"), ASSET_KBIT("assetkbitstat"), @@ -97,7 +97,7 @@ LLTrace::Count<LLUnits::Kilobits> KBIT("kbitstat"), ACTUAL_IN_KBIT("actualinkbit"), ACTUAL_OUT_KBIT("actualoutkbit"); -LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), +LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"), FPS_10_TIME("fps10time", "Seconds below 10 FPS"), @@ -146,10 +146,10 @@ LLTrace::Measurement<> NUM_IMAGES("numimagesstat"), WINDOW_WIDTH("windowwidth", "Window width"), WINDOW_HEIGHT("windowheight", "Window height"); -LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); +LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); -LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), +LLTrace::Measurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), SIM_PHYSICS_MEM("physicsmemoryallocated"), GL_TEX_MEM("gltexmemstat"), GL_BOUND_MEM("glboundmemstat"), @@ -159,7 +159,7 @@ LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); -SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS), +SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS), SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS), SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS), SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS), @@ -174,7 +174,7 @@ SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_ SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME), SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME); -LLTrace::Measurement<LLUnits::Milliseconds> FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), +LLTrace::Measurement<LLTrace::Milliseconds> FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), @@ -266,10 +266,10 @@ void LLViewerStats::updateFrameStats(const F64 time_diff) F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth; - LLStatViewer::DELTA_BANDWIDTH.sample<LLUnits::Bits>(delta_bandwidth); + LLStatViewer::DELTA_BANDWIDTH.sample<LLTrace::Bits>(delta_bandwidth); //setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); - LLStatViewer::MAX_BANDWIDTH.sample<LLUnits::Bits>(max_bandwidth); + LLStatViewer::MAX_BANDWIDTH.sample<LLTrace::Bits>(max_bandwidth); //setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); } @@ -360,27 +360,27 @@ void update_statistics() LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { - LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay()); + LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay()); //stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { - LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(10000); + LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000); //stats.mSimPingStat.addValue(10000); } //stats.mFPSStat.addValue(1); LLStatViewer::FPS.add(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits>(layer_bits); + LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits); + LLStatViewer::OBJECT_KBIT.add<LLTrace::Bits>(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); - LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); + LLStatViewer::ASSET_KBIT.add<LLTrace::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -419,7 +419,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - gTotalTextureBytes = LLUnits::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); + gTotalTextureBytes = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); texture_stats_timer.reset(); } } diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 40109bcea3..b182a40403 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -88,7 +88,7 @@ extern LLTrace::Count<> FPS, TEX_REBAKES; -extern LLTrace::Count<LLUnits::Kilobits> KBIT, +extern LLTrace::Count<LLTrace::Kilobits> KBIT, LAYERS_KBIT, OBJECT_KBIT, ASSET_KBIT, @@ -96,7 +96,7 @@ extern LLTrace::Count<LLUnits::Kilobits> KBIT, ACTUAL_IN_KBIT, ACTUAL_OUT_KBIT; -extern LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME, +extern LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME, TOOLBOX_TIME, MOUSELOOK_TIME, FPS_10_TIME, @@ -145,9 +145,9 @@ extern LLTrace::Measurement<> NUM_IMAGES, WINDOW_WIDTH, WINDOW_HEIGHT; -extern LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP; +extern LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP; -extern LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES, +extern LLTrace::Measurement<LLTrace::Bytes> SIM_UNACKED_BYTES, DELTA_BANDWIDTH, MAX_BANDWIDTH, SIM_PHYSICS_MEM, @@ -156,7 +156,7 @@ extern LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES, RAW_MEM, FORMATTED_MEM; -extern SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME, +extern SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME, SIM_NET_TIME, SIM_OTHER_TIME, SIM_PHYSICS_TIME, @@ -172,7 +172,7 @@ extern SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME, SIM_PUMP_IO_TIME; -extern LLTrace::Measurement<LLUnits::Milliseconds> FRAMETIME_JITTER, +extern LLTrace::Measurement<LLTrace::Milliseconds> FRAMETIME_JITTER, FRAMETIME_SLEW, LOGIN_SECONDS, REGION_CROSSING_TIME, diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index b0f8f60d1e..f64134b8b7 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -64,6 +64,11 @@ #include "lltexturecache.h" /////////////////////////////////////////////////////////////////////////////// +// extern +const LLUnit::Megabytes<S32> gMinVideoRam = 32; +const LLUnit::Megabytes<S32> gMaxVideoRam = 512; + + // statics LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL; LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL; @@ -82,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S32 LLViewerTexture::sBoundTextureMemoryInBytes = 0; -S32 LLViewerTexture::sTotalTextureMemoryInBytes = 0; -S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0; -S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0; -S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ; +LLUnit::Bytes<S32> LLViewerTexture::sBoundTextureMemory = 0; +LLUnit::Bytes<S32> LLViewerTexture::sTotalTextureMemory = 0; +LLUnit::Megabytes<S32> LLViewerTexture::sMaxBoundTextureMem = 0; +LLUnit::Megabytes<S32> LLViewerTexture::sMaxTotalTextureMem = 0; +LLUnit::Bytes<S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ; S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; F32 LLViewerTexture::sCameraMovingBias = 0.0f ; S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size @@ -518,17 +523,17 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity LLViewerMediaTexture::updateClass() ; } - sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes - sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes - sMaxBoundTextureMemInMegaBytes = gTextureList.getMaxResidentTexMem();//in MB - sMaxTotalTextureMemInMegaBytes = gTextureList.getMaxTotalTextureMem() ;//in MB - sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small. + sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes + sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes + sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem();//in MB + sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem() ;//in MB + sMaxDesiredTextureMem = sMaxTotalTextureMem ; //in Bytes, by default and when total used texture memory is small. - if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes || - BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes) + if (sBoundTextureMemory >= sMaxBoundTextureMem || + sTotalTextureMemory >= sMaxTotalTextureMem) { //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes<S32>)gMaxVideoRam) ;//512 MB // If we are using more texture memory than we should, // scale up the desired discard level @@ -544,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sEvaluationTimer.reset(); } else if (sDesiredDiscardBias > 0.0f && - BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale && - BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale) + sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale && + sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale) { // If we are using less texture memory than we should, // scale down the desired discard level @@ -563,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1); sCameraMovingDiscardBias = (S8)(sCameraMovingBias); - LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && - (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ; + LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) && + (sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ; } //end of static functions @@ -3301,13 +3306,13 @@ void LLViewerLODTexture::processTextureStats() scaleDown() ; } // Limit the amount of GL memory bound each frame - else if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale && + else if ( sBoundTextureMemory > sMaxBoundTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; } // Only allow GL to have 2x the video card memory - else if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale && + else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 2ea9a07e9a..aa1e2010b4 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -34,12 +34,13 @@ #include "llgltypes.h" #include "llrender.h" #include "llmetricperformancetester.h" +#include "llunit.h" #include <map> #include <list> -#define MIN_VIDEO_RAM_IN_MEGA_BYTES 32 -#define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons. +extern const LLUnit::Megabytes<S32> gMinVideoRam; +extern const LLUnit::Megabytes<S32> gMaxVideoRam; class LLFace; class LLImageGL ; @@ -322,11 +323,11 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static S32 sBoundTextureMemoryInBytes; - static S32 sTotalTextureMemoryInBytes; - static S32 sMaxBoundTextureMemInMegaBytes; - static S32 sMaxTotalTextureMemInMegaBytes; - static S32 sMaxDesiredTextureMemInBytes ; + static LLUnit::Bytes<S32> sBoundTextureMemory; + static LLUnit::Bytes<S32> sTotalTextureMemory; + static LLUnit::Megabytes<S32> sMaxBoundTextureMem; + static LLUnit::Megabytes<S32> sMaxTotalTextureMem; + static LLUnit::Bytes<S32> sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 56ccf3b1f0..d355432e8a 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -606,8 +606,8 @@ void LLViewerTextureList::updateImages(F32 max_time) if(gTeleportDisplay) { if(!cleared) - { - clearFetchingRequests(); + { + clearFetchingRequests(); gPipeline.clearRebuildGroups(); cleared = TRUE; } @@ -623,10 +623,10 @@ void LLViewerTextureList::updateImages(F32 max_time) using namespace LLStatViewer; NUM_IMAGES.sample(sNumImages); NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount); - GL_TEX_MEM.sample<LLUnits::Bytes>(LLImageGL::sGlobalTextureMemoryInBytes); - GL_BOUND_MEM.sample<LLUnits::Bytes>(LLImageGL::sBoundTextureMemoryInBytes); - RAW_MEM.sample<LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory); - FORMATTED_MEM.sample<LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory); + GL_TEX_MEM.sample(LLImageGL::sGlobalTextureMemory); + GL_BOUND_MEM.sample(LLImageGL::sBoundTextureMemory); + RAW_MEM.sample<LLTrace::Bytes>(LLImageRaw::sGlobalRawMemory); + FORMATTED_MEM.sample<LLTrace::Bytes>(LLImageFormatted::sGlobalFormattedMemory); } { @@ -1184,7 +1184,7 @@ S32 LLViewerTextureList::getMinVideoRamSetting() { S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); //min texture mem sets to 64M if total physical mem is more than 1.5GB - return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM_IN_MEGA_BYTES ; + return (system_ram > 1500) ? 64 : gMinVideoRam.value() ; } //static @@ -1234,7 +1234,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) else max_texmem = llmin(max_texmem, (S32)(system_ram)); - max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam.value()); return max_texmem; } @@ -1322,7 +1322,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size); + LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); U8 codec; @@ -1396,7 +1396,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size); + LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); //llprintline("Start decode, image header..."); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8161caf5e4..2062f07650 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4740,7 +4740,7 @@ void LLViewerWindow::stopGL(BOOL save_state) gGLManager.mIsDisabled = TRUE; stop_glerror(); - llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl; + llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << llendl; } } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 3e8b07b6dc..9f0921ff59 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2790,7 +2790,7 @@ void LLVOAvatarSelf::deleteScratchTextures() sScratchTexNames.deleteAllData(); sScratchTexLastBindTime.deleteAllData(); - LLImageGL::sGlobalTextureMemoryInBytes -= sScratchTexBytes; + LLImageGL::sGlobalTextureMemory -= sScratchTexBytes; sScratchTexBytes = 0; } } diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 604741ff27..dced5a847b 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -703,11 +703,11 @@ void LLWorld::updateNetStats() S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); - LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits>(actual_in_bits); - LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits>(actual_out_bits); + LLStatViewer::ACTUAL_IN_KBIT.add<LLTrace::Bits>(actual_in_bits); + LLStatViewer::ACTUAL_OUT_KBIT.add<LLTrace::Bits>(actual_out_bits); //LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); //LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - LLStatViewer::KBIT.add<LLUnits::Bits>(bits); + LLStatViewer::KBIT.add<LLTrace::Bits>(bits); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); -- cgit v1.2.3 From a52d203a4f1d2988e8ffba16258f3f132f22f56d Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 17 Oct 2012 20:00:07 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system started conversion of llviewerassetstats removed old, dead LLViewerStats code made units tracing require units declaration clean up of units handling --- indra/llcommon/lltrace.h | 44 +++---- indra/llcommon/lltracerecording.h | 95 ++++++++++++--- indra/llcommon/llunit.h | 34 ++++-- indra/llui/llstatbar.cpp | 3 +- indra/llui/llstatbar.h | 2 +- indra/llui/llstatgraph.h | 10 +- indra/newview/llagent.cpp | 2 - indra/newview/llappviewer.cpp | 5 +- indra/newview/llappviewer.h | 3 +- indra/newview/llcompilequeue.cpp | 2 - indra/newview/llfloaterjoystick.cpp | 2 +- indra/newview/llfloaterregioninfo.cpp | 2 - indra/newview/llfloatersnapshot.cpp | 1 - indra/newview/llgesturemgr.cpp | 2 - indra/newview/lllandmarklist.cpp | 1 - indra/newview/llnearbychatbar.cpp | 1 - indra/newview/llpanelface.cpp | 1 - indra/newview/llpanelpermissions.cpp | 1 - indra/newview/llpreviewgesture.cpp | 2 - indra/newview/llpreviewnotecard.cpp | 2 - indra/newview/llpreviewscript.cpp | 6 - indra/newview/llselectmgr.cpp | 1 - indra/newview/llsidepaneltaskinfo.cpp | 1 - indra/newview/llspatialpartition.cpp | 4 +- indra/newview/llstartup.cpp | 1 - indra/newview/lltexlayer.cpp | 1 - indra/newview/lltextureview.cpp | 6 +- indra/newview/lltooldraganddrop.cpp | 3 - indra/newview/lltoolplacer.cpp | 1 - indra/newview/llviewerassetstats.cpp | 27 +++++ indra/newview/llviewerassetstats.h | 7 ++ indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewerjoystick.cpp | 6 +- indra/newview/llviewermenufile.cpp | 9 -- indra/newview/llviewermessage.cpp | 155 ++---------------------- indra/newview/llviewerobject.cpp | 1 - indra/newview/llviewerobjectlist.cpp | 4 - indra/newview/llviewerstats.cpp | 95 +++++---------- indra/newview/llviewerstats.h | 8 +- indra/newview/llviewertexturelist.cpp | 6 +- indra/newview/llviewerwindow.cpp | 12 +- indra/newview/llvoavatar.cpp | 4 +- indra/newview/llvoavatarself.cpp | 13 +- indra/newview/llwearablelist.cpp | 1 - indra/newview/pipeline.cpp | 16 +-- indra/newview/tests/llviewerassetstats_test.cpp | 13 +- 46 files changed, 255 insertions(+), 365 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1c6726605a..2a479b31d7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -192,10 +192,12 @@ namespace LLTrace template<typename ACCUMULATOR> class LL_COMMON_API TraceType + : public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string> { public: TraceType(const char* name, const char* description = NULL) - : mName(name), + : LLInstanceTracker(name), + mName(name), mDescription(description ? description : "") { mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); @@ -355,18 +357,17 @@ namespace LLTrace U32 mNumSamples; }; + typedef TraceType<MeasurementAccumulator<F64> > measurement_common_t; + template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Measurement - : public TraceType<MeasurementAccumulator<T> >, - public LLInstanceTracker<Measurement<T, IS_UNIT>, std::string> + : public TraceType<MeasurementAccumulator<T> > { public: typedef T storage_t; - typedef T base_unit_t; Measurement(const char* name, const char* description = NULL) - : TraceType(name), - LLInstanceTracker(name) + : TraceType(name, description) {} void sample(T value) @@ -376,37 +377,37 @@ namespace LLTrace }; template <typename T> - class LL_COMMON_API Measurement <T, typename T::is_unit_t> - : public Measurement<typename T::storage_t> + class LL_COMMON_API Measurement <T, typename T::is_unit_tag_t> + : public TraceType<MeasurementAccumulator<typename T::storage_t> > { public: typedef typename T::storage_t storage_t; - typedef typename T::base_unit_t base_unit_t; typedef Measurement<typename T::storage_t> base_measurement_t; Measurement(const char* name, const char* description = NULL) - : Measurement<typename T::storage_t>(name, description) + : TraceType(name, description) {} template<typename UNIT_T> void sample(UNIT_T value) { - base_measurement_t::sample(((T)value).value()); + T converted_value; + converted_value.assignFrom(value); + getPrimaryAccumulator().sample(converted_value.value()); } }; + typedef TraceType<CountAccumulator<F64> > count_common_t; + template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Count - : public TraceType<CountAccumulator<T> >, - public LLInstanceTracker<Count<T>, std::string> + : public TraceType<CountAccumulator<T> > { public: typedef T storage_t; - typedef T base_unit_t; Count(const char* name, const char* description = NULL) - : TraceType(name), - LLInstanceTracker(name) + : TraceType(name) {} void add(T value) @@ -416,22 +417,23 @@ namespace LLTrace }; template <typename T> - class LL_COMMON_API Count <T, typename T::is_unit_t> - : public Count<typename T::storage_t> + class LL_COMMON_API Count <T, typename T::is_unit_tag_t> + : public TraceType<CountAccumulator<typename T::storage_t> > { public: typedef typename T::storage_t storage_t; - typedef typename T::base_unit_t base_unit_t; typedef Count<typename T::storage_t> base_count_t; Count(const char* name, const char* description = NULL) - : Count<typename T::storage_t>(name) + : TraceType(name) {} template<typename UNIT_T> void add(UNIT_T value) { - base_count_t::add(((T)value).value()); + T converted_value; + converted_value.assignFrom(value); + getPrimaryAccumulator().add(converted_value.value()); } }; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 5e7b0752c6..25f4f5c721 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -112,64 +112,121 @@ namespace LLTrace void update(); // Count accessors + template <typename T> + T getSum(const TraceType<CountAccumulator<T> >& stat) const + { + return (T)stat.getAccumulator(mCounts).getSum(); + } + template <typename T, typename IS_UNIT> - typename Count<T, IS_UNIT>::base_unit_t getSum(const Count<T, IS_UNIT>& stat) const + T getSum(const Count<T, IS_UNIT>& stat) const + { + return (T)stat.getAccumulator(mCounts).getSum(); + } + + template <typename T> + T getPerSec(const TraceType<CountAccumulator<T> >& stat) const { - return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mCounts).getSum(); + return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; } template <typename T, typename IS_UNIT> - typename Count<T, IS_UNIT>::base_unit_t getPerSec(const Count<T, IS_UNIT>& stat) const + T getPerSec(const Count<T, IS_UNIT>& stat) const { - return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; + return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; } // Measurement accessors + template <typename T> + T getSum(const TraceType<MeasurementAccumulator<T> >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getSum(); + + } + template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getSum(const Measurement<T, IS_UNIT>& stat) const + T getSum(const Measurement<T, IS_UNIT>& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum(); + return (T)stat.getAccumulator(mMeasurements).getSum(); + + } + template <typename T> + T getPerSec(const TraceType<MeasurementAccumulator<T> >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getPerSec(const Measurement<T, IS_UNIT>& stat) const + T getPerSec(const Measurement<T, IS_UNIT>& stat) const { return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; } - template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getMin(const Measurement<T, IS_UNIT>& stat) const + template <typename T> + T getMin(const TraceType<MeasurementAccumulator<T> >& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMin(); + return (T)stat.getAccumulator(mMeasurements).getMin(); } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getMax(const Measurement<T, IS_UNIT>& stat) const + T getMin(const Measurement<T, IS_UNIT>& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMax(); + return (T)stat.getAccumulator(mMeasurements).getMin(); + } + + + template <typename T> + T getMax(const TraceType<MeasurementAccumulator<T> >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMax(); } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getMean(Measurement<T, IS_UNIT>& stat) const + T getMax(const Measurement<T, IS_UNIT>& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMax(); + } + + template <typename T> + T getMean(const TraceType<MeasurementAccumulator<T> >& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getMean(); + return (T)stat.getAccumulator(mMeasurements).getMean(); } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getStandardDeviation(const Measurement<T, IS_UNIT>& stat) const + T getMean(Measurement<T, IS_UNIT>& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMean(); + } + + template <typename T> + T getStandardDeviation(const TraceType<MeasurementAccumulator<T> >& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getStandardDeviation(); + return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); } template <typename T, typename IS_UNIT> - typename Measurement<T, IS_UNIT>::base_unit_t getLastValue(const Measurement<T, IS_UNIT>& stat) const + T getStandardDeviation(const Measurement<T, IS_UNIT>& stat) const { - return (typename Measurement<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getLastValue(); + return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); + } + + template <typename T> + T getLastValue(const TraceType<MeasurementAccumulator<T> >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getLastValue(); } template <typename T, typename IS_UNIT> - U32 getSampleCount(const Measurement<T, IS_UNIT>& stat) const + T getLastValue(const Measurement<T, IS_UNIT>& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getLastValue(); + } + + + template <typename T> + U32 getSampleCount(const TraceType<MeasurementAccumulator<T> >& stat) const { return stat.getAccumulator(mMeasurements).getSampleCount(); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index d980989c91..e778383959 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -36,7 +36,7 @@ struct LLUnitType : public BASE_UNIT typedef DERIVED_UNIT unit_t; typedef typename STORAGE_TYPE storage_t; - typedef void is_unit_t; + typedef void is_unit_tag_t; LLUnitType() {} @@ -57,7 +57,7 @@ struct LLUnitType : public BASE_UNIT } template<typename CONVERTED_TYPE> - storage_t value() const + storage_t as() const { return CONVERTED_TYPE(*this).value(); } @@ -80,8 +80,7 @@ struct LLUnitType<STORAGE_TYPE, T, T> { typedef T unit_t; typedef STORAGE_TYPE storage_t; - typedef void is_unit_t; - typedef T base_unit_t; + typedef void is_unit_tag_t; LLUnitType() : mBaseValue() @@ -105,6 +104,13 @@ struct LLUnitType<STORAGE_TYPE, T, T> storage_t value() const { return mBaseValue; } + template<typename CONVERTED_TYPE> + storage_t as() const + { + return CONVERTED_TYPE(*this).value(); + } + + static storage_t convertToBase(storage_t derived_value) { return (storage_t)derived_value; @@ -354,10 +360,16 @@ bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUni template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ unit_name(LLUnitType<SOURCE_STORAGE_TYPE, unit_name<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ { \ - setBaseValue((storage_t)source.unit_name<SOURCE_STORAGE_TYPE>::unit_t::value()); \ + assignFrom(source); \ } \ \ - }; + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + void assignFrom(LLUnitType<SOURCE_STORAGE_TYPE, unit_name<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.unit_name<SOURCE_STORAGE_TYPE>::unit_t::value()); \ + } \ + \ + }; \ #define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ template<typename STORAGE> \ @@ -372,12 +384,18 @@ bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUni template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ derived_unit(LLUnitType<SOURCE_STORAGE_TYPE, base_unit<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ { \ - setBaseValue((storage_t)source.base_unit<SOURCE_STORAGE_TYPE>::unit_t::value()); \ + assignFrom(source); \ + } \ + \ + template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ + void assignFrom(LLUnitType<SOURCE_STORAGE_TYPE, base_unit<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.base_unit<SOURCE_STORAGE_TYPE>::unit_t::value()); \ } \ \ static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ \ - }; + }; \ namespace LLUnit { diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index c60e5431ae..535c6f96e3 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -56,8 +56,7 @@ LLStatBar::LLStatBar(const Params& p) mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), mDisplayMean(p.show_mean) -{ -} +{} BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index e4b0c61c42..d510f0e3fe 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -99,7 +99,7 @@ private: LLTrace::PeriodicRecording* mFrameRecording; LLStat* mStatp; - LLTrace::Count<>* mNewStatp; + LLTrace::count_common_t* mNewStatp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 5bbd9e9d24..b20966d608 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -59,9 +59,9 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { - Alternative<LLStat*> legacy_stat; - Alternative<LLTrace::Count<>* > count_stat; - Alternative<LLTrace::Measurement<>* > measurement_stat; + Alternative<LLStat*> legacy_stat; + Alternative<LLTrace::count_common_t* > count_stat; + Alternative<LLTrace::measurement_common_t* > measurement_stat; }; struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -106,8 +106,8 @@ public: /*virtual*/ void setValue(const LLSD& value); private: - LLStat* mStatp; - LLTrace::Count<>* mNewStatp; + LLStat* mStatp; + LLTrace::count_common_t* mNewStatp; BOOL mPerSec; diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index a41efbe0b2..ac33f09718 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -754,7 +754,6 @@ void LLAgent::setFlying(BOOL fly) if( !was_flying ) { LLStatViewer::FLY.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT); } setControlFlags(AGENT_CONTROL_FLY); } @@ -3811,7 +3810,6 @@ bool LLAgent::teleportCore(bool is_local) // local logic LLStatViewer::TELEPORT.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT); if (is_local) { gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL ); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6e0b298b2a..4ab0e3336a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -277,7 +277,7 @@ LLPumpIO* gServicePump = NULL; U64 gFrameTime = 0; F32 gFrameTimeSeconds = 0.f; -F32 gFrameIntervalSeconds = 0.f; +LLUnit::Seconds<F32> gFrameIntervalSeconds = 0.f; F32 gFPSClamped = 10.f; // Pretend we start at target rate. F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets U64 gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds @@ -1395,7 +1395,7 @@ bool LLAppViewer::mainLoop() { S32 work_pending = 0; S32 io_pending = 0; - F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f); + F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f); { LLFastTimer ftm(FTM_TEXTURE_CACHE); @@ -4811,7 +4811,6 @@ void LLAppViewer::idleNetwork() } } LLStatViewer::NUM_NEW_OBJECTS.sample(gObjectList.mNumNewObjects); - //LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects); // Retransmit unacknowledged packets. gXferManager->retransmitUnackedPackets(); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index cdf4426469..d9d888c626 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -31,6 +31,7 @@ #include "llcontrol.h" #include "llsys.h" // for LLOSInfo #include "lltimer.h" +#include "llunit.h" class LLCommandLineParser; class LLFrameTimer; @@ -321,7 +322,7 @@ extern LLPumpIO* gServicePump; extern U64 gFrameTime; // The timestamp of the most-recently-processed frame extern F32 gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... -extern F32 gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds +extern LLUnit::Seconds<F32> gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame extern F32 gFrameDTClamped; extern U64 gStartTime; diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index 6739910c38..033c8f4865 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -436,8 +436,6 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { LLSD args; diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index d0c22d25f2..f7b2670b8e 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -61,7 +61,7 @@ void LLFloaterJoystick::draw() for (U32 i = 0; i < 6; i++) { F32 value = joystick->getJoystickAxis(i); - mAxisStats[i]->addValue(value * gFrameIntervalSeconds); + mAxisStats[i]->addValue(value * gFrameIntervalSeconds.value()); if (mAxisStatsBar[i]) { F32 minbar, maxbar; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 8234841966..6cce013105 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -2491,8 +2491,6 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 4a58e0186c..0d90037e7b 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -993,7 +993,6 @@ void LLSnapshotLivePreview::saveTexture() } LLStatViewer::SNAPSHOT.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); mDataSize = 0; } diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 63ef8c3d21..27a29d3ace 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -1137,8 +1137,6 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp index 1666425cbe..2a131eff58 100644 --- a/indra/newview/lllandmarklist.cpp +++ b/indra/newview/lllandmarklist.cpp @@ -141,7 +141,6 @@ void LLLandmarkList::processGetAssetReply( } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); // SJB: No use case for a notification here. Use lldebugs instead if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index 0aced5c575..23cbfae044 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -639,7 +639,6 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 gAgent.sendReliableMessage(); LLStatViewer::CHAT_COUNT.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT); } class LLChatCommandHandler : public LLCommandHandler diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 52ed24f06d..39ded21183 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1050,7 +1050,6 @@ BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) void LLPanelFace::onCommitTexture( const LLSD& data ) { LLStatViewer::EDIT_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); sendTexture(); } diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 51ab7649a4..8027783bd8 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -915,7 +915,6 @@ bool callback_deed_to_group(const LLSD& notification, const LLSD& response) if(group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED))) { LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE); -// LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT); } } return false; diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 4082d272f2..cbb4d5f964 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -883,8 +883,6 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index b93b97f1e0..97c9de4b72 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -339,8 +339,6 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 059d5d4061..7607df5a55 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -943,7 +943,6 @@ void LLScriptEdCore::onBtnInsertFunction(LLUICtrl *ui, void* userdata) void LLScriptEdCore::doSave( BOOL close_after_save ) { LLStatViewer::LSL_SAVES.add(1); - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); if( mSaveCallback ) { @@ -1148,7 +1147,6 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) void LLScriptEdCore::onBtnSaveToFile( void* userdata ) { LLStatViewer::LSL_SAVES.add(1); - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); LLScriptEdCore* self = (LLScriptEdCore*) userdata; @@ -1671,8 +1669,6 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { @@ -1903,8 +1899,6 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index fd03d7c0be..36ce7bb60e 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1551,7 +1551,6 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item) // apply texture for the selected faces LLStatViewer::EDIT_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); object->setTEImage(te, image); dialog_refresh_all(); diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index c351b1a128..8fb56eb6d8 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -945,7 +945,6 @@ static bool callback_deed_to_group(const LLSD& notification, const LLSD& respons if (group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED))) { LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE); -// LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT); } } return FALSE; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 5083478392..c4c9b0bd4c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1580,7 +1580,7 @@ void LLSpatialGroup::checkOcclusion() LLFastTimer t(FTM_OCCLUSION_WAIT); while (!available && max_loop-- > 0) { - F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f); + F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f); //do some usefu work while we wait LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread @@ -2574,7 +2574,7 @@ void renderOctree(LLSpatialGroup* group) LLVector4 col; if (group->mBuilt > 0.f) { - group->mBuilt -= 2.f * gFrameIntervalSeconds; + group->mBuilt -= 2.f * gFrameIntervalSeconds.value(); if (group->mBufferUsage == GL_STATIC_DRAW_ARB) { col.setVec(1.0f, 0, 0, group->mBuilt*0.5f); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index cb3c90ea2a..bf47bd44c3 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2072,7 +2072,6 @@ bool idle_startup() { LLNotificationsUtil::add("ClothingLoading"); LLStatViewer::LOADING_WEARABLES_LONG_DELAY.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; } diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index e354a5c59d..909745c5b6 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -461,7 +461,6 @@ void LLTexLayerSetBuffer::doUpload() { llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl; LLStatViewer::TEX_BAKES.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES); // Don't need caches since we're baked now. (note: we won't *really* be baked // until this image is sent to the server and the Avatar Appearance message is received.) diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index a88233e120..d734620f10 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -512,8 +512,8 @@ void LLGLTexMemBar::draw() F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); - F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); - F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024); + LLUnit::Megabytes<F32> total_texture_downloaded = gTotalTextureData; + LLUnit::Megabytes<F32> total_object_downloaded = gTotalObjectData; U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; @@ -537,7 +537,7 @@ void LLGLTexMemBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d", - total_texture_downloaded, total_object_downloaded, total_http_requests); + total_texture_downloaded.value(), total_object_downloaded.value(), total_http_requests); //, cache_entries, cache_max_entries LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, text_color, LLFontGL::LEFT, LLFontGL::TOP); diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 791da59a1a..652847aac9 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1063,7 +1063,6 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj, } LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); LLStatViewer::EDIT_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); S32 num_faces = hit_obj->getNumTEs(); for( S32 face = 0; face < num_faces; face++ ) { @@ -1132,7 +1131,6 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj, // update viewer side image in anticipation of update from simulator LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id); LLStatViewer::EDIT_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT ); hit_obj->setTEImage(hit_face, image); dialog_refresh_all(); @@ -1357,7 +1355,6 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target, effectp->setColor(LLColor4U(gAgent.getEffectColor())); LLStatViewer::OBJECT_REZ.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT); } void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj, diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp index cf5a6e3762..329249eee8 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -434,7 +434,6 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics ) effectp->setColor(LLColor4U(gAgent.getEffectColor())); LLStatViewer::OBJECT_CREATE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT); return TRUE; } diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index e556743cbf..44e4c54142 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -84,6 +84,30 @@ // ------------------------------------------------------ LLViewerAssetStats * gViewerAssetStatsMain(0); LLViewerAssetStats * gViewerAssetStatsThread1(0); +LLTrace::Count<> LLViewerAssetStats::sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", "Number of texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", "Number of texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestswearableudp", "Number of wearable asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestssoundudp", "Number of sound asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsgestureudp", "Number of gesture asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsother", "Number of other asset requests enqueued")}; +LLTrace::Count<> LLViewerAssetStats::sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", "Number of texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", "Number of texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestswearableudp", "Number of wearable asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestssoundudp", "Number of sound asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsgestureudp", "Number of gesture asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsother", "Number of other asset requests dequeued")}; +LLTrace::Measurement<LLTrace::Seconds> LLViewerAssetStats::sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", "Time spent responding to temporary texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", "Time spent responding to temporary texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", "Time spent responding to texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", "Time spent responding to texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", "Time spent responding to wearable asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", "Time spent responding to sound asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", "Time spent responding to gesture asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", "Time spent responding to other asset requests")}; // ------------------------------------------------------ @@ -234,6 +258,7 @@ LLViewerAssetStats::recordGetEnqueued(LLViewerAssetType::EType at, bool with_htt const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); ++(mCurRegionStats->mRequests[int(eac)].mEnqueued); + sEnqueued[int(eac)].add(1); } void @@ -242,6 +267,7 @@ LLViewerAssetStats::recordGetDequeued(LLViewerAssetType::EType at, bool with_htt const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); ++(mCurRegionStats->mRequests[int(eac)].mDequeued); + sDequeued[int(eac)].add(1); } void @@ -250,6 +276,7 @@ LLViewerAssetStats::recordGetServiced(LLViewerAssetType::EType at, bool with_htt const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); mCurRegionStats->mRequests[int(eac)].mResponse.record(duration); + sResponse[int(eac)].sample<LLTrace::Seconds>(duration); } void diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index 8319752230..a750db2cc2 100755 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -37,6 +37,7 @@ #include "llsimplestat.h" #include "llsd.h" #include "llvoavatar.h" +#include "lltrace.h" /** * @class LLViewerAssetStats @@ -240,6 +241,7 @@ public: protected: typedef std::map<region_handle_t, LLPointer<PerRegionStats> > PerRegionContainer; + typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer; // Region of the currently-active region. Always valid but may // be zero after construction or when explicitly set. Unchanged @@ -251,8 +253,13 @@ protected: // Always points to a collection contained in mRegionStats. LLPointer<PerRegionStats> mCurRegionStats; + static LLTrace::Count<> sEnqueued[EVACCount]; + static LLTrace::Count<> sDequeued[EVACCount]; + static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount]; + // Metrics data for all regions during one collection cycle PerRegionContainer mRegionStats; + PerRegionRecordingContainer mRegionRecordings; // Time of last reset duration_t mResetTimestamp; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index ffeea2f4df..169b45c14e 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -607,7 +607,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM); - const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time + const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds.value(); // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); gPipeline.updateGeom(max_geom_update_time); @@ -760,7 +760,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(FTM_IMAGE_UPDATE_LIST); - F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds; // 50 ms/second decode time + F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds.value(); // 50 ms/second decode time max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame) gTextureList.updateImages(max_image_decode_time); } diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index f6e840adcd..f4155df4d1 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -501,7 +501,7 @@ void LLViewerJoystick::moveObjects(bool reset) }; F32 cur_delta[6]; - F32 time = gFrameIntervalSeconds; + F32 time = gFrameIntervalSeconds.value(); // avoid making ridicously big movements if there's a big drop in fps if (time > .2f) @@ -665,7 +665,7 @@ void LLViewerJoystick::moveAvatar(bool reset) }; // time interval in seconds between this frame and the previous - F32 time = gFrameIntervalSeconds; + F32 time = gFrameIntervalSeconds.value(); // avoid making ridicously big movements if there's a big drop in fps if (time > .2f) @@ -878,7 +878,7 @@ void LLViewerJoystick::moveFlycam(bool reset) gSavedSettings.getF32("FlycamAxisDeadZone6") }; - F32 time = gFrameIntervalSeconds; + F32 time = gFrameIntervalSeconds.value(); // avoid making ridiculously big movements if there's a big drop in fps if (time > .2f) diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 7ce8cdcfd8..50ca8db267 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -1097,19 +1097,16 @@ void upload_new_resource( if( LLAssetType::AT_SOUND == asset_type ) { LLStatViewer::UPLOAD_SOUND.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT ); } else if( LLAssetType::AT_TEXTURE == asset_type ) { LLStatViewer::UPLOAD_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); } else if( LLAssetType::AT_ANIMATION == asset_type) { LLStatViewer::ANIMATION_UPLOADS.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT ); } if(LLInventoryType::IT_NONE == inv_type) @@ -1235,20 +1232,14 @@ void increase_new_upload_stats(LLAssetType::EType asset_type) if ( LLAssetType::AT_SOUND == asset_type ) { LLStatViewer::UPLOAD_SOUND.add(1); - //LLViewerStats::getInstance()->incStat( - // LLViewerStats::ST_UPLOAD_SOUND_COUNT ); } else if ( LLAssetType::AT_TEXTURE == asset_type ) { LLStatViewer::UPLOAD_TEXTURE.add(1); - //LLViewerStats::getInstance()->incStat( - // LLViewerStats::ST_UPLOAD_TEXTURE_COUNT ); } else if ( LLAssetType::AT_ANIMATION == asset_type ) { LLStatViewer::ANIMATION_UPLOADS.add(1); - //LLViewerStats::getInstance()->incStat( - // LLViewerStats::ST_UPLOAD_ANIM_COUNT ); } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index b3e1c9bdbe..82caa05983 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4416,18 +4416,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) // *TODO: Remove this dependency, or figure out a better way to handle // this hack. -extern U32 gObjectBits; +extern LLUnit::Bits<U32> gObjectData; void process_object_update(LLMessageSystem *mesgsys, void **user_data) { // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectBits += mesgsys->getReceiveCompressedSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectBits += mesgsys->getReceiveSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4439,11 +4439,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectBits += mesgsys->getReceiveCompressedSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectBits += mesgsys->getReceiveSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4455,11 +4455,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data) // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectBits += mesgsys->getReceiveCompressedSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectBits += mesgsys->getReceiveSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4471,11 +4471,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_ { if (mesgsys->getReceiveCompressedSize()) { - gObjectBits += mesgsys->getReceiveCompressedSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectBits += mesgsys->getReceiveSize() * 8; + gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); } gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED); @@ -4763,140 +4763,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) { llwarns << "Unknown sim stat identifier: " << stat_id << llendl; } - //switch (stat_id) - //{ - //case LL_SIM_STAT_TIME_DILATION: - // LLStatViewer::SIM_TIME_DILATION.sample(stat_value); - // //LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value); - // break; - //case LL_SIM_STAT_FPS: - // LLStatViewer::SIM_FPS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimFPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_PHYSFPS: - // LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_AGENTUPS: - // LLStatViewer::SIM_AGENT_UPS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_FRAMEMS: - // LLStatViewer::SIM_FRAME_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_NETMS: - // LLStatViewer::SIM_NET_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMOTHERMS: - // LLStatViewer::SIM_PHYSICS_OTHER_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMPHYSICSMS: - // LLStatViewer::SIM_PHYSICS_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_AGENTMS: - // LLStatViewer::SIM_AGENTS_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_IMAGESMS: - // LLStatViewer::SIM_IMAGES_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SCRIPTMS: - // LLStatViewer::SIM_SCRIPTS_TIME.sample(stat_value); - // //LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_NUMTASKS: - // LLStatViewer::SIM_OBJECTS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimObjects.addValue(stat_value); - // break; - //case LL_SIM_STAT_NUMTASKSACTIVE: - // LLStatViewer::SIM_ACTIVE_OBJECTS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value); - // break; - //case LL_SIM_STAT_NUMAGENTMAIN: - // LLStatViewer::SIM_MAIN_AGENTS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value); - // break; - //case LL_SIM_STAT_NUMAGENTCHILD: - // LLStatViewer::SIM_CHILD_AGENTS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value); - // break; - //case LL_SIM_STAT_NUMSCRIPTSACTIVE: - // LLStatViewer::SIM_ACTIVE_SCRIPTS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value); - // break; - //case LL_SIM_STAT_SCRIPT_EPS: - // LLStatViewer::SIM_SCRIPT_EPS.sample(stat_value); - // //LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_INPPS: - // LLStatViewer::SIM_IN_PACKETS_PER_SEC.sample(stat_value); - // //LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_OUTPPS: - // LLStatViewer::SIM_OUT_PACKETS_PER_SEC.sample(stat_value); - // //LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value); - // break; - //case LL_SIM_STAT_PENDING_DOWNLOADS: - // LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value); - // break; - //case LL_SIM_STAT_PENDING_UPLOADS: - // LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value); - // break; - //case LL_SIM_STAT_PENDING_LOCAL_UPLOADS: - // LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value); - // break; - //case LL_SIM_STAT_TOTAL_UNACKED_BYTES: - // LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f); - // break; - //case LL_SIM_STAT_PHYSICS_PINNED_TASKS: - // LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value); - // break; - //case LL_SIM_STAT_PHYSICS_LOD_TASKS: - // LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMPHYSICSSTEPMS: - // LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMPHYSICSSHAPEMS: - // LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMPHYSICSOTHERMS: - // LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMPHYSICSMEMORY: - // LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMSPARETIME: - // LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMSLEEPTIME: - // LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_IOPUMPTIME: - // LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_PCTSCRIPTSRUN: - // LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value); - // break; - //case LL_SIM_STAT_SIMAISTEPTIMEMS: - // LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value); - // break; - //case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS: - // LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value); - // break; - //case LL_SIM_STAT_PCTSTEPPEDCHARACTERS: - // LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value); - // break; - //default: - // // Used to be a commented out warning. - // LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL; - // break; - //} } /* @@ -5968,7 +5834,6 @@ void process_alert_core(const std::string& message, BOOL modal) if ( message == "You died and have been teleported to your home location") { LLStatViewer::KILLED.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT); } else if( message == "Home position set." ) { @@ -7395,8 +7260,6 @@ void onCovenantLoadComplete(LLVFS *vfs, } else { - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); - if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 747dfd3250..ca404858cf 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2034,7 +2034,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) ) { LLStatViewer::AGENT_POSITION_SNAP.sample<LLTrace::Meters>(diff.length()); - //LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); } } diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 2f171f89d7..14a2ac3384 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1033,10 +1033,6 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) LLStatViewer::NUM_ACTIVE_OBJECTS.sample(idle_count); LLStatViewer::NUM_SIZE_CULLED.sample(mNumSizeCulled); LLStatViewer::NUM_VIS_CULLED.sample(mNumVisCulled); - //LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size()); - //LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count); - //LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled); - //LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled); } void LLViewerObjectList::fetchObjectCosts() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index ccc0c9ba59..963d2ebb81 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -206,72 +206,53 @@ void LLViewerStats::resetStats() void LLViewerStats::updateFrameStats(const F64 time_diff) { + LLTrace::Seconds time_diff_seconds(time_diff); if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0) { - LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff); - //incStat(ST_LOSS_05_SECONDS, time_diff); + LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff_seconds); } F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS); if (0.f < sim_fps && sim_fps < 20.f) { - LLStatViewer::SIM_20_FPS_TIME.add(time_diff); - //incStat(ST_SIM_FPS_20_SECONDS, time_diff); + LLStatViewer::SIM_20_FPS_TIME.add(time_diff_seconds); } F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS); if (0.f < sim_physics_fps && sim_physics_fps < 20.f) { - LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff); - //incStat(ST_PHYS_FPS_20_SECONDS, time_diff); + LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff_seconds); } if (time_diff >= 0.5) { - LLStatViewer::FPS_2_TIME.add(time_diff); - //incStat(ST_FPS_2_SECONDS, time_diff); + LLStatViewer::FPS_2_TIME.add(time_diff_seconds); } if (time_diff >= 0.125) { - LLStatViewer::FPS_8_TIME.add(time_diff); - //incStat(ST_FPS_8_SECONDS, time_diff); + LLStatViewer::FPS_8_TIME.add(time_diff_seconds); } if (time_diff >= 0.1) { - LLStatViewer::FPS_10_TIME.add(time_diff); - //incStat(ST_FPS_10_SECONDS, time_diff); + LLStatViewer::FPS_10_TIME.add(time_diff_seconds); } if (gFrameCount && mLastTimeDiff > 0.0) { // new "stutter" meter LLStatViewer::FRAMETIME_DOUBLED.add(time_diff >= 2.0 * mLastTimeDiff ? 1 : 0); - //setStat(ST_FPS_DROP_50_RATIO, - // (getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + - // (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount); - // old stats that were never really used - LLStatViewer::FRAMETIME_JITTER.sample(mLastTimeDiff - time_diff); - //setStat(ST_FRAMETIME_JITTER, - // (getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + - // fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount); + LLStatViewer::FRAMETIME_JITTER.sample<LLTrace::Milliseconds>(mLastTimeDiff - time_diff); F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount; - LLStatViewer::FRAMETIME_SLEW.sample(average_frametime - time_diff); - //setStat(ST_FRAMETIME_SLEW, - // (getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + - // fabs(average_frametime - time_diff) / average_frametime) / gFrameCount); + LLStatViewer::FRAMETIME_SLEW.sample<LLTrace::Milliseconds>(average_frametime - time_diff); F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth; LLStatViewer::DELTA_BANDWIDTH.sample<LLTrace::Bits>(delta_bandwidth); - //setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); - LLStatViewer::MAX_BANDWIDTH.sample<LLTrace::Bits>(max_bandwidth); - //setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); - } mLastTimeDiff = time_diff; @@ -299,10 +280,13 @@ F32 gAveLandCompression = 0.f, gAveWaterCompression = 0.f; F32 gBestLandCompression = 1.f, gBestWaterCompression = 1.f; F32 gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f; -U32 gTotalWorldBytes = 0, gTotalObjectBytes = 0, gTotalTextureBytes = 0, gSimPingCount = 0; -U32 gObjectBits = 0; +LLUnit::Bytes<U32> gTotalWorldData = 0, + gTotalObjectData = 0, + gTotalTextureData = 0; +U32 gSimPingCount = 0; +LLUnit::Bits<U32> gObjectData = 0; F32 gAvgSimPing = 0.f; -U32 gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; +LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; extern U32 gVisCompared; extern U32 gVisTested; @@ -311,8 +295,8 @@ LLFrameTimer gTextureTimer; void update_statistics() { - gTotalWorldBytes += gVLManager.getTotalBytes(); - gTotalObjectBytes += gObjectBits / 8; + gTotalWorldData += gVLManager.getTotalBytes(); + gTotalObjectData += gObjectData; // make sure we have a valid time delta for this frame if (gFrameIntervalSeconds > 0.f) @@ -320,68 +304,48 @@ void update_statistics() if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) { LLStatViewer::MOUSELOOK_TIME.add(gFrameIntervalSeconds); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds); } else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR) { LLStatViewer::AVATAR_EDIT_TIME.add(gFrameIntervalSeconds); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds); } else if (LLFloaterReg::instanceVisible("build")) { LLStatViewer::TOOLBOX_TIME.add(gFrameIntervalSeconds); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds); } } LLStatViewer::ENABLE_VBO.sample((F64)gSavedSettings.getBOOL("RenderVBOEnable")); - //stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable")); LLStatViewer::LIGHTING_DETAIL.sample((F64)gPipeline.getLightingDetail()); - //stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail()); LLStatViewer::DRAW_DISTANCE.sample((F64)gSavedSettings.getF32("RenderFarClip")); - //stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip")); LLStatViewer::CHAT_BUBBLES.sample((F64)gSavedSettings.getBOOL("UseChatBubbles")); - //stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles")); - LLStatViewer::FRAME_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Frame")); - //stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame")); + LLStatViewer::FRAME_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Frame")); F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle"); F64 network_secs = gDebugView->mFastTimerView->getTime("Network"); - LLStatViewer::UPDATE_STACKTIME.sample(idle_secs - network_secs); - //stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs); - LLStatViewer::NETWORK_STACKTIME.sample(network_secs); - //stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs); - LLStatViewer::IMAGE_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Update Images")); - //stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images")); - LLStatViewer::REBUILD_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Sort Draw State")); - //stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State")); - LLStatViewer::RENDER_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Geometry")); - //stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry")); + LLStatViewer::UPDATE_STACKTIME.sample<LLTrace::Seconds>(idle_secs - network_secs); + LLStatViewer::NETWORK_STACKTIME.sample<LLTrace::Seconds>(network_secs); + LLStatViewer::IMAGE_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Update Images")); + LLStatViewer::REBUILD_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Sort Draw State")); + LLStatViewer::RENDER_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Geometry")); LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay()); - //stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000); - //stats.mSimPingStat.addValue(10000); } - //stats.mFPSStat.addValue(1); LLStatViewer::FPS.add(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits); - //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - LLStatViewer::OBJECT_KBIT.add<LLTrace::Bits>(gObjectBits); - //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); - //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); + LLStatViewer::OBJECT_KBIT.add(gObjectData); LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); LLStatViewer::ASSET_KBIT.add<LLTrace::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); - //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); if (LLAppViewer::getTextureFetch()->getNumRequests() == 0) @@ -403,14 +367,13 @@ void update_statistics() avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames; } LLStatViewer::VISIBLE_AVATARS.sample((F64)avg_visible_avatars); - //stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars); } LLWorld::getInstance()->updateNetStats(); LLWorld::getInstance()->requestCacheMisses(); // Reset all of these values. gVLManager.resetBitCounts(); - gObjectBits = 0; + gObjectData = 0; // gDecodedBits = 0; // Only update texture stats periodically so that they are less noisy @@ -419,7 +382,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - gTotalTextureBytes = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); + gTotalTextureData = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); texture_stats_timer.reset(); } } @@ -559,9 +522,9 @@ void send_stats() LLSD &download = body["downloads"]; - download["world_kbytes"] = gTotalWorldBytes / 1024.0; - download["object_kbytes"] = gTotalObjectBytes / 1024.0; - download["texture_kbytes"] = gTotalTextureBytes / 1024.0; + download["world_kbytes"] = LLTrace::Kilobytes(gTotalWorldData).value(); + download["object_kbytes"] = LLTrace::Kilobytes(gTotalObjectData).value(); + download["texture_kbytes"] = LLTrace::Kilobytes(gTotalTextureData).value(); download["mesh_kbytes"] = LLMeshRepository::sBytesReceived/1024.0; LLSD &in = body["stats"]["net"]["in"]; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index b182a40403..06f65b2cdd 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -57,7 +57,7 @@ struct SimMeasurement : public LLTrace::Measurement<T>, public SimMeasurementSam /*virtual*/ void sample(F64 value) { - LLTrace::Measurement<T>::sample(value); + LLTrace::Measurement<T>::sample(T(value)); } }; @@ -318,7 +318,7 @@ void update_statistics(); void send_stats(); extern LLFrameTimer gTextureTimer; -extern U32 gTotalTextureBytes; -extern U32 gTotalObjectBytes; -extern U32 gTotalTextureBytesPerBoostLevel[] ; +extern LLUnit::Bytes<U32> gTotalTextureData; +extern LLUnit::Bytes<U32> gTotalObjectData; +extern LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[] ; #endif // LL_LLVIEWERSTATS_H diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index d355432e8a..b9d5751412 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -709,7 +709,7 @@ void LLViewerTextureList::updateImagesDecodePriorities() // Update the decode priority for N images each frame { static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities"); // default: 32 - const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds) + 1, MAX_PRIO_UPDATES); + const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES); S32 update_counter = llmin(max_update_count, mUUIDMap.size()); uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID); while ((update_counter-- > 0) && !mUUIDMap.empty()) @@ -943,11 +943,11 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) static const F32 MIN_PRIORITY_THRESHOLD = gSavedSettings.getF32("TextureFetchUpdatePriorityThreshold"); // default: 0.0 static const bool SKIP_LOW_PRIO = gSavedSettings.getBOOL("TextureFetchUpdateSkipLowPriority"); // default: false - size_t max_priority_count = llmin((S32) (MAX_HIGH_PRIO_COUNT*MAX_HIGH_PRIO_COUNT*gFrameIntervalSeconds)+1, MAX_HIGH_PRIO_COUNT); + size_t max_priority_count = llmin((S32) (MAX_HIGH_PRIO_COUNT*MAX_HIGH_PRIO_COUNT*gFrameIntervalSeconds.value())+1, MAX_HIGH_PRIO_COUNT); max_priority_count = llmin(max_priority_count, mImageList.size()); size_t total_update_count = mUUIDMap.size(); - size_t max_update_count = llmin((S32) (MAX_UPDATE_COUNT*MAX_UPDATE_COUNT*gFrameIntervalSeconds)+1, MAX_UPDATE_COUNT); + size_t max_update_count = llmin((S32) (MAX_UPDATE_COUNT*MAX_UPDATE_COUNT*gFrameIntervalSeconds.value())+1, MAX_UPDATE_COUNT); max_update_count = llmin(max_update_count, total_update_count); // MAX_HIGH_PRIO_COUNT high priority entries diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2062f07650..06daf15c08 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -731,7 +731,7 @@ public: { if(gTotalTextureBytesPerBoostLevel[i] > 0) { - addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, (F32)gTotalTextureBytesPerBoostLevel[i] / (1024 * 1024))); + addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, LLUnit::Megabytes<F32>(gTotalTextureBytesPerBoostLevel[i]).value())); ypos += y_inc; } } @@ -1405,8 +1405,8 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S LLTrace::Recording& recording = LLViewerStats::instance().getRecording(); temp_str = llformat( "FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ recording.getPerSec(LLStatViewer::FPS), //mFPSStat.getMeanPerSec(), - recording.getMean(LLStatViewer::SIM_PHYSICS_FPS), //LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), - recording.getMean(LLStatViewer::SIM_TIME_DILATION)); //LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); + recording.getLastValue(LLStatViewer::SIM_PHYSICS_FPS), + recording.getLastValue(LLStatViewer::SIM_TIME_DILATION)); S32 len = temp_str.length(); TextOutA(hdc, 0, 0, temp_str.c_str(), len); @@ -2185,9 +2185,7 @@ void LLViewerWindow::reshape(S32 width, S32 height) } LLStatViewer::WINDOW_WIDTH.sample((F64)width); - //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width); LLStatViewer::WINDOW_HEIGHT.sample((F64)height); - //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height); LLLayoutStack::updateClass(); } @@ -3237,8 +3235,8 @@ void LLViewerWindow::updateMouseDelta() static F32 fdy = 0.f; F32 amount = 16.f; - fdx = fdx + ((F32) dx - fdx) * llmin(gFrameIntervalSeconds*amount,1.f); - fdy = fdy + ((F32) dy - fdy) * llmin(gFrameIntervalSeconds*amount,1.f); + fdx = fdx + ((F32) dx - fdx) * llmin(gFrameIntervalSeconds.value()*amount,1.f); + fdy = fdy + ((F32) dy - fdy) * llmin(gFrameIntervalSeconds.value()*amount,1.f); mCurrentMouseDelta.set(llround(fdx), llround(fdy)); mouse_vel.setVec(fdx,fdy); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d366455a62..97c1b07ebc 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7813,14 +7813,14 @@ void LLVOAvatar::cullAvatarsByPixelArea() if (gFrameTimeSeconds != sUnbakedUpdateTime) // only update once per frame { sUnbakedUpdateTime = gFrameTimeSeconds; - sUnbakedTime += gFrameIntervalSeconds; + sUnbakedTime += gFrameIntervalSeconds.value(); } if (grey_avatars > 0) { if (gFrameTimeSeconds != sGreyUpdateTime) // only update once per frame { sGreyUpdateTime = gFrameTimeSeconds; - sGreyTime += gFrameIntervalSeconds; + sGreyTime += gFrameIntervalSeconds.value(); } } } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 9f0921ff59..7c20e8eae7 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -910,18 +910,11 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp) if (mLastRegionHandle != 0) { ++mRegionCrossingCount; - F64 delta = (F64)mRegionCrossingTimer.getElapsedTimeF32(); - //F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG); - //F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount; + LLTrace::Seconds delta = mRegionCrossingTimer.getElapsedTimeF32(); LLStatViewer::REGION_CROSSING_TIME.sample(delta); - //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg); - // - //F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX); - //max = llmax(delta, max); - //LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max); // Diagnostics - llinfos << "Region crossing took " << (F32)(delta * 1000.0) << " ms " << llendl; + llinfos << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << llendl; } if (regionp) { @@ -2589,7 +2582,6 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**) gAgentAvatarp->invalidateComposite(layer_set, TRUE); found = TRUE; LLStatViewer::TEX_REBAKES.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } } } @@ -2635,7 +2627,6 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug) invalidateComposite(layer_set, TRUE); LLStatViewer::TEX_REBAKES.add(1); - //LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES); } else { diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 20033d6fe4..0eb00f7191 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -136,7 +136,6 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { LLFile::remove(std::string(filename)); } - //LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); LL_WARNS("Wearable") << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << LL_ENDL; switch( status ) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4582de805f..75af605ad7 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4892,7 +4892,7 @@ void LLPipeline::renderDebug() { DebugBlip& blip = *iter; - blip.mAge += gFrameIntervalSeconds; + blip.mAge += gFrameIntervalSeconds.value(); if (blip.mAge > 2.f) { mDebugBlips.erase(iter++); @@ -4902,7 +4902,7 @@ void LLPipeline::renderDebug() iter++; } - blip.mPosition.mV[2] += gFrameIntervalSeconds*2.f; + blip.mPosition.mV[2] += gFrameIntervalSeconds.value()*2.f; gGL.color4fv(blip.mColor.mV); gGL.vertex3fv(blip.mPosition.mV); @@ -5713,7 +5713,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) { if (farthest_light->fade >= 0.f) { - farthest_light->fade = -gFrameIntervalSeconds; + farthest_light->fade = -(gFrameIntervalSeconds.value()); } } else @@ -5809,12 +5809,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) if (fade >= 0.f) { fade = fade / LIGHT_FADE_TIME; - ((Light*) (&(*iter)))->fade += gFrameIntervalSeconds; + ((Light*) (&(*iter)))->fade += gFrameIntervalSeconds.value(); } else { fade = 1.f + fade / LIGHT_FADE_TIME; - ((Light*) (&(*iter)))->fade -= gFrameIntervalSeconds; + ((Light*) (&(*iter)))->fade -= gFrameIntervalSeconds.value(); } fade = llclamp(fade,0.f,1.f); light_color *= fade; @@ -7129,7 +7129,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield) } else if (transition_time < 1.f) { //currently in a transition, continue interpolating - transition_time += 1.f/CameraFocusTransitionTime*gFrameIntervalSeconds; + transition_time += 1.f/CameraFocusTransitionTime*gFrameIntervalSeconds.value(); transition_time = llmin(transition_time, 1.f); F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f; @@ -9121,7 +9121,7 @@ void LLPipeline::generateHighlight(LLCamera& camera) if (!mHighlightSet.empty()) { - F32 transition = gFrameIntervalSeconds/RenderHighlightFadeTime; + F32 transition = gFrameIntervalSeconds.value()/RenderHighlightFadeTime; LLGLDisable test(GL_ALPHA_TEST); LLGLDepthTest depth(GL_FALSE); @@ -9756,7 +9756,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f); + F32 fade_amt = gFrameIntervalSeconds.value() * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f); //update shadow targets for (U32 i = 0; i < 2; i++) diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index f8923b9868..4a190fbe23 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -220,7 +220,18 @@ get_region(const LLSD & sd, U64 region_handle1) namespace tut { struct tst_viewerassetstats_index - {}; + { + tst_viewerassetstats_index() + { + LLTrace::init(); + } + + ~tst_viewerassetstats_index() + { + LLTrace::cleanup(); + } + + }; typedef test_group<tst_viewerassetstats_index> tst_viewerassetstats_index_t; typedef tst_viewerassetstats_index_t::object tst_viewerassetstats_index_object_t; tut::tst_viewerassetstats_index_t tut_tst_viewerassetstats_index("tst_viewerassetstats_test"); -- cgit v1.2.3 From 1fadd6138eebf980776f80b9642f4c19279fcadd Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 18 Oct 2012 17:32:44 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed trace recording on background threads hitting null pointer --- indra/llcommon/lltrace.h | 19 ++++++++++++++----- indra/llcommon/lltracethreadrecorder.cpp | 9 ++++----- indra/llcommon/lltracethreadrecorder.h | 4 ++-- indra/newview/llviewerstats.cpp | 8 +++++--- indra/newview/llviewerstats.h | 7 ++++--- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 2a479b31d7..2cdae4b0d2 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -167,15 +167,24 @@ namespace LLTrace size_t next_slot = mNextStorageSlot++; if (next_slot >= mStorageSize) { - size_t new_size = mStorageSize + (mStorageSize >> 2); - delete [] mStorage; - mStorage = new ACCUMULATOR[new_size]; - mStorageSize = new_size; + resize(mStorageSize + (mStorageSize >> 2)); } - llassert(next_slot < mStorageSize); + llassert(mStorage && next_slot < mStorageSize); return next_slot; } + void resize(size_t new_size) + { + ACCUMULATOR* old_storage = mStorage; + mStorage = new ACCUMULATOR[new_size]; + for (S32 i = 0; i < mStorageSize; i++) + { + mStorage[i] = old_storage[i]; + } + mStorageSize = new_size; + delete[] old_storage; + } + static AccumulatorBuffer<ACCUMULATOR>& getDefaultBuffer() { static AccumulatorBuffer sBuffer(STATIC_ALLOC); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 02dc55771b..e81333f7f2 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -127,7 +127,6 @@ void ThreadRecorder::ActiveRecording::moveBaselineToTarget() /////////////////////////////////////////////////////////////////////// SlaveThreadRecorder::SlaveThreadRecorder() -: ThreadRecorder(getMasterThreadRecorder()) { getMasterThreadRecorder().addSlaveThread(this); } @@ -149,14 +148,14 @@ void SlaveThreadRecorder::pushToMaster() void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) { - LLMutexLock lock(&mRecorderMutex); - mRecorder.mergeRecording(source); + LLMutexLock lock(&mRecordingMutex); + mRecording.mergeRecording(source); } void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) { - LLMutexLock lock(&mRecorderMutex); - sink.mergeRecording(mRecorder); + LLMutexLock lock(&mRecordingMutex); + sink.mergeRecording(mRecording); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 678b1a89f0..c9231265af 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -114,8 +114,8 @@ namespace LLTrace void copyFrom(const Recording& source); void copyTo(Recording& sink); private: - LLMutex mRecorderMutex; - Recording mRecorder; + LLMutex mRecordingMutex; + Recording mRecording; }; SharedData mSharedData; }; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 963d2ebb81..03cc9b12e3 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -149,9 +149,7 @@ LLTrace::Measurement<> NUM_IMAGES("numimagesstat"), LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); -LLTrace::Measurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes"), - SIM_PHYSICS_MEM("physicsmemoryallocated"), - GL_TEX_MEM("gltexmemstat"), +LLTrace::Measurement<LLTrace::Bytes> GL_TEX_MEM("gltexmemstat"), GL_BOUND_MEM("glboundmemstat"), RAW_MEM("rawmemstat"), FORMATTED_MEM("formattedmemstat"), @@ -174,6 +172,10 @@ SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_ SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME), SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME); +SimMeasurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES), + SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY); + + LLTrace::Measurement<LLTrace::Milliseconds> FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 06f65b2cdd..78c4b89f71 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -147,10 +147,8 @@ extern LLTrace::Measurement<> NUM_IMAGES, extern LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP; -extern LLTrace::Measurement<LLTrace::Bytes> SIM_UNACKED_BYTES, - DELTA_BANDWIDTH, +extern LLTrace::Measurement<LLTrace::Bytes> DELTA_BANDWIDTH, MAX_BANDWIDTH, - SIM_PHYSICS_MEM, GL_TEX_MEM, GL_BOUND_MEM, RAW_MEM, @@ -171,6 +169,9 @@ extern SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME, SIM_SLEEP_TIME, SIM_PUMP_IO_TIME; +extern SimMeasurement<LLTrace::Bytes> SIM_UNACKED_BYTES, + SIM_PHYSICS_MEM; + extern LLTrace::Measurement<LLTrace::Milliseconds> FRAMETIME_JITTER, FRAMETIME_SLEW, -- cgit v1.2.3 From bd52d784f904cb0b46be5826f6c7df31b214fc09 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 18 Oct 2012 23:53:37 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system created param block skeleton for asset stats removed most of llviewerassetstats logic --- indra/newview/llappviewer.cpp | 22 +- indra/newview/lltexturefetch.cpp | 201 +----- indra/newview/llviewerassetstats.cpp | 867 +++++++++++------------- indra/newview/llviewerassetstats.h | 141 +--- indra/newview/llviewerassetstorage.cpp | 6 +- indra/newview/tests/llviewerassetstats_test.cpp | 118 ++-- 6 files changed, 494 insertions(+), 861 deletions(-) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 4ab0e3336a..559f427de6 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4278,10 +4278,6 @@ void LLAppViewer::idle() gObjectList.mNumUnknownUpdates = 0; } - // ViewerMetrics FPS piggy-backing on the debug timer. - // The 5-second interval is nice for this purpose. If the object debug - // bit moves or is disabled, please give this a suitable home. - LLViewerAssetStatsFF::record_fps_main(gFPSClamped); LLViewerAssetStatsFF::record_avatar_stats(); } } @@ -5220,17 +5216,7 @@ void LLAppViewer::metricsUpdateRegion(U64 region_handle) { if (0 != region_handle) { - LLViewerAssetStatsFF::set_region_main(region_handle); - if (LLAppViewer::sTextureFetch) - { - // Send a region update message into 'thread1' to get the new region. - LLAppViewer::sTextureFetch->commandSetRegion(region_handle); - } - else - { - // No 'thread1', a.k.a. TextureFetch, so update directly - LLViewerAssetStatsFF::set_region_thread1(region_handle); - } + LLViewerAssetStatsFF::set_region(region_handle); } } @@ -5241,7 +5227,7 @@ void LLAppViewer::metricsUpdateRegion(U64 region_handle) */ void LLAppViewer::metricsSend(bool enable_reporting) { - if (! gViewerAssetStatsMain) + if (! gViewerAssetStats) return; if (LLAppViewer::sTextureFetch) @@ -5254,7 +5240,7 @@ void LLAppViewer::metricsSend(bool enable_reporting) // Make a copy of the main stats to send into another thread. // Receiving thread takes ownership. - LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStatsMain)); + LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats)); // Send a report request into 'thread1' to get the rest of the data // and provide some additional parameters while here. @@ -5273,6 +5259,6 @@ void LLAppViewer::metricsSend(bool enable_reporting) // Reset even if we can't report. Rather than gather up a huge chunk of // data, we'll keep to our sampling interval and retain the data // resolution in time. - gViewerAssetStatsMain->reset(); + gViewerAssetStats->reset(); } diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 8ddaac5cc8..903fd6acee 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -368,15 +368,15 @@ public: if (worker->mMetricsStartTime) { - LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE, - true, - LLImageBase::TYPE_AVATAR_BAKE == worker->mType, - LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime); + LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE, + true, + LLImageBase::TYPE_AVATAR_BAKE == worker->mType, + LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime); worker->mMetricsStartTime = 0; } - LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE, - true, - LLImageBase::TYPE_AVATAR_BAKE == worker->mType); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, + true, + LLImageBase::TYPE_AVATAR_BAKE == worker->mType); } else { @@ -400,109 +400,6 @@ private: bool mFollowRedir; }; -////////////////////////////////////////////////////////////////////////////// - -// Cross-thread messaging for asset metrics. - -/** - * @brief Base class for cross-thread requests made of the fetcher - * - * I believe the intent of the LLQueuedThread class was to - * have these operations derived from LLQueuedThread::QueuedRequest - * but the texture fetcher has elected to manage the queue - * in its own manner. So these are free-standing objects which are - * managed in simple FIFO order on the mCommands queue of the - * LLTextureFetch object. - * - * What each represents is a simple command sent from an - * outside thread into the TextureFetch thread to be processed - * in order and in a timely fashion (though not an absolute - * higher priority than other operations of the thread). - * Each operation derives a new class from the base customizing - * members, constructors and the doWork() method to effect - * the command. - * - * The flow is one-directional. There are two global instances - * of the LLViewerAssetStats collector, one for the main program's - * thread pointed to by gViewerAssetStatsMain and one for the - * TextureFetch thread pointed to by gViewerAssetStatsThread1. - * Common operations has each thread recording metrics events - * into the respective collector unconcerned with locking and - * the state of any other thread. But when the agent moves into - * a different region or the metrics timer expires and a report - * needs to be sent back to the grid, messaging across threads - * is required to distribute data and perform global actions. - * In pseudo-UML, it looks like: - * - * Main Thread1 - * . . - * . . - * +-----+ . - * | AM | . - * +--+--+ . - * +-------+ | . - * | Main | +--+--+ . - * | | | SRE |---. . - * | Stats | +-----+ \ . - * | | | \ (uuid) +-----+ - * | Coll. | +--+--+ `-------->| SR | - * +-------+ | MSC | +--+--+ - * | ^ +-----+ | - * | | (uuid) / . +-----+ (uuid) - * | `--------' . | MSC |---------. - * | . +-----+ | - * | +-----+ . v - * | | TE | . +-------+ - * | +--+--+ . | Thd1 | - * | | . | | - * | +-----+ . | Stats | - * `--------->| RSC | . | | - * +--+--+ . | Coll. | - * | . +-------+ - * +--+--+ . | - * | SME |---. . | - * +-----+ \ . | - * . \ (clone) +-----+ | - * . `-------->| SM | | - * . +--+--+ | - * . | | - * . +-----+ | - * . | RSC |<--------' - * . +-----+ - * . | - * . +-----+ - * . | CP |--> HTTP POST - * . +-----+ - * . . - * . . - * - * - * Key: - * - * SRE - Set Region Enqueued. Enqueue a 'Set Region' command in - * the other thread providing the new UUID of the region. - * TFReqSetRegion carries the data. - * SR - Set Region. New region UUID is sent to the thread-local - * collector. - * SME - Send Metrics Enqueued. Enqueue a 'Send Metrics' command - * including an ownership transfer of a cloned LLViewerAssetStats. - * TFReqSendMetrics carries the data. - * SM - Send Metrics. Global metrics reporting operation. Takes - * the cloned stats from the command, merges it with the - * thread's local stats, converts to LLSD and sends it on - * to the grid. - * AM - Agent Moved. Agent has completed some sort of move to a - * new region. - * TE - Timer Expired. Metrics timer has expired (on the order - * of 10 minutes). - * CP - CURL Post - * MSC - Modify Stats Collector. State change in the thread-local - * collector. Typically a region change which affects the - * global pointers used to find the 'current stats'. - * RSC - Read Stats Collector. Extract collector data cloning it - * (i.e. deep copy) when necessary. - * - */ class LLTextureFetch::TFRequest // : public LLQueuedThread::QueuedRequest { public: @@ -521,36 +418,6 @@ public: namespace { -/** - * @brief Implements a 'Set Region' cross-thread command. - * - * When an agent moves to a new region, subsequent metrics need - * to be binned into a new or existing stats collection in 1:1 - * relationship with the region. We communicate this region - * change across the threads involved in the communication with - * this message. - * - * Corresponds to LLTextureFetch::commandSetRegion() - */ -class TFReqSetRegion : public LLTextureFetch::TFRequest -{ -public: - TFReqSetRegion(U64 region_handle) - : LLTextureFetch::TFRequest(), - mRegionHandle(region_handle) - {} - TFReqSetRegion & operator=(const TFReqSetRegion &); // Not defined - - virtual ~TFReqSetRegion() - {} - - virtual bool doWork(LLTextureFetch * fetcher); - -public: - const U64 mRegionHandle; -}; - - /** * @brief Implements a 'Send Metrics' cross-thread command. * @@ -1104,9 +971,9 @@ bool LLTextureFetchWorker::doWork(S32 param) { mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); } - LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, - false, - LLImageBase::TYPE_AVATAR_BAKE == mType); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, + false, + LLImageBase::TYPE_AVATAR_BAKE == mType); setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; @@ -1121,7 +988,7 @@ bool LLTextureFetchWorker::doWork(S32 param) //{ // mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); //} - //LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, false, + //LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, // LLImageBase::TYPE_AVATAR_BAKE == mType); //setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; @@ -1150,15 +1017,15 @@ bool LLTextureFetchWorker::doWork(S32 param) if (mMetricsStartTime) { - LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE, - false, - LLImageBase::TYPE_AVATAR_BAKE == mType, - LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime); + LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE, + false, + LLImageBase::TYPE_AVATAR_BAKE == mType, + LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime); mMetricsStartTime = 0; } - LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE, - false, - LLImageBase::TYPE_AVATAR_BAKE == mType); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, + false, + LLImageBase::TYPE_AVATAR_BAKE == mType); } else { @@ -1167,9 +1034,9 @@ bool LLTextureFetchWorker::doWork(S32 param) { mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); } - LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, - false, - LLImageBase::TYPE_AVATAR_BAKE == mType); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, + false, + LLImageBase::TYPE_AVATAR_BAKE == mType); setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); } return false; @@ -1226,9 +1093,9 @@ bool LLTextureFetchWorker::doWork(S32 param) { mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); } - LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, - true, - LLImageBase::TYPE_AVATAR_BAKE == mType); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, + true, + LLImageBase::TYPE_AVATAR_BAKE == mType); // Will call callbackHttpGet when curl request completes std::vector<std::string> headers; @@ -2848,13 +2715,6 @@ void LLTextureFetch::dump() // cross-thread command methods -void LLTextureFetch::commandSetRegion(U64 region_handle) -{ - TFReqSetRegion * req = new TFReqSetRegion(region_handle); - - cmdEnqueue(req); -} - void LLTextureFetch::commandSendMetrics(const std::string & caps_url, const LLUUID & session_id, const LLUUID & agent_id, @@ -2922,19 +2782,6 @@ void LLTextureFetch::cmdDoWork() namespace { -/** - * Implements the 'Set Region' command. - * - * Thread: Thread1 (TextureFetch) - */ -bool -TFReqSetRegion::doWork(LLTextureFetch *) -{ - LLViewerAssetStatsFF::set_region_thread1(mRegionHandle); - - return true; -} - TFReqSendMetrics::~TFReqSendMetrics() { diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index 44e4c54142..cc15d6433f 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -82,95 +82,7 @@ // ------------------------------------------------------ // Global data definitions // ------------------------------------------------------ -LLViewerAssetStats * gViewerAssetStatsMain(0); -LLViewerAssetStats * gViewerAssetStatsThread1(0); -LLTrace::Count<> LLViewerAssetStats::sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests enqueued"), - LLTrace::Count<>("enqueuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", "Number of texture asset http requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", "Number of texture asset udp requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestswearableudp", "Number of wearable asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestssoundudp", "Number of sound asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsgestureudp", "Number of gesture asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsother", "Number of other asset requests enqueued")}; -LLTrace::Count<> LLViewerAssetStats::sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests dequeued"), - LLTrace::Count<>("dequeuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", "Number of texture asset http requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", "Number of texture asset udp requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestswearableudp", "Number of wearable asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestssoundudp", "Number of sound asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsgestureudp", "Number of gesture asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsother", "Number of other asset requests dequeued")}; -LLTrace::Measurement<LLTrace::Seconds> LLViewerAssetStats::sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", "Time spent responding to temporary texture asset http requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", "Time spent responding to temporary texture asset udp requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", "Time spent responding to texture asset http requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", "Time spent responding to texture asset udp requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", "Time spent responding to wearable asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", "Time spent responding to sound asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", "Time spent responding to gesture asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", "Time spent responding to other asset requests")}; - - -// ------------------------------------------------------ -// Local declarations -// ------------------------------------------------------ -namespace -{ - -static LLViewerAssetStats::EViewerAssetCategories -asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp); - -} - -// ------------------------------------------------------ -// LLViewerAssetStats::PerRegionStats struct definition -// ------------------------------------------------------ -void -LLViewerAssetStats::PerRegionStats::reset() -{ - for (int i(0); i < LL_ARRAY_SIZE(mRequests); ++i) - { - mRequests[i].mEnqueued.reset(); - mRequests[i].mDequeued.reset(); - mRequests[i].mResponse.reset(); - } - mFPS.reset(); - - mTotalTime = 0; - mStartTimestamp = LLViewerAssetStatsFF::get_timestamp(); -} - - -void -LLViewerAssetStats::PerRegionStats::merge(const LLViewerAssetStats::PerRegionStats & src) -{ - // mRegionHandle, mTotalTime, mStartTimestamp are left alone. - - // mFPS - if (src.mFPS.getCount() && mFPS.getCount()) - { - mFPS.merge(src.mFPS); - } - - // Avatar stats - data all comes from main thread, so leave alone. - - // Requests - for (int i = 0; i < LL_ARRAY_SIZE(mRequests); ++i) - { - mRequests[i].mEnqueued.merge(src.mRequests[i].mEnqueued); - mRequests[i].mDequeued.merge(src.mRequests[i].mDequeued); - mRequests[i].mResponse.merge(src.mRequests[i].mResponse); - } - -} - - -void -LLViewerAssetStats::PerRegionStats::accumulateTime(duration_t now) -{ - mTotalTime += (now - mStartTimestamp); - mStartTimestamp = now; -} - +LLViewerAssetStats * gViewerAssetStats(0); // ------------------------------------------------------ // LLViewerAssetStats class definition @@ -183,47 +95,25 @@ LLViewerAssetStats::LLViewerAssetStats() LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src) - : mRegionHandle(src.mRegionHandle), - mResetTimestamp(src.mResetTimestamp), - mPhaseStats(src.mPhaseStats), - mAvatarRezStates(src.mAvatarRezStates) +: mRegionHandle(src.mRegionHandle), + mPhaseStats(src.mPhaseStats), + mAvatarRezStates(src.mAvatarRezStates), + mRegionRecordings(src.mRegionRecordings) { - const PerRegionContainer::const_iterator it_end(src.mRegionStats.end()); - for (PerRegionContainer::const_iterator it(src.mRegionStats.begin()); it_end != it; ++it) - { - mRegionStats[it->first] = new PerRegionStats(*it->second); - } - mCurRegionStats = mRegionStats[mRegionHandle]; + mCurRecording = &mRegionRecordings[mRegionHandle]; } -void -LLViewerAssetStats::reset() +void LLViewerAssetStats::reset() { // Empty the map of all region stats - mRegionStats.clear(); - - // If we have a current stats, reset it, otherwise, as at construction, - // create a new one as we must always have a current stats block. - if (mCurRegionStats) - { - mCurRegionStats->reset(); - } - else - { - mCurRegionStats = new PerRegionStats(mRegionHandle); - } + mRegionRecordings.clear(); - // And add reference to map - mRegionStats[mRegionHandle] = mCurRegionStats; - - // Start timestamp consistent with per-region collector - mResetTimestamp = mCurRegionStats->mStartTimestamp; + // initialize new recording for current region + mCurRecording = &mRegionRecordings[mRegionHandle]; } - -void -LLViewerAssetStats::setRegion(region_handle_t region_handle) +void LLViewerAssetStats::setRegion(region_handle_t region_handle) { if (region_handle == mRegionHandle) { @@ -231,207 +121,386 @@ LLViewerAssetStats::setRegion(region_handle_t region_handle) return; } - // Get duration for current set - const duration_t now = LLViewerAssetStatsFF::get_timestamp(); - mCurRegionStats->accumulateTime(now); + mCurRecording->stop(); + mCurRecording = &mRegionRecordings[region_handle]; + mCurRecording->start(); - // Prepare new set - PerRegionContainer::iterator new_stats = mRegionStats.find(region_handle); - if (mRegionStats.end() == new_stats) - { - // Haven't seen this region_id before, create a new block and make it current. - mCurRegionStats = new PerRegionStats(region_handle); - mRegionStats[region_handle] = mCurRegionStats; - } - else - { - mCurRegionStats = new_stats->second; - } - mCurRegionStats->mStartTimestamp = now; mRegionHandle = region_handle; } - -void -LLViewerAssetStats::recordGetEnqueued(LLViewerAssetType::EType at, bool with_http, bool is_temp) +void LLViewerAssetStats::recordAvatarStats() { - const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); - - ++(mCurRegionStats->mRequests[int(eac)].mEnqueued); - sEnqueued[int(eac)].add(1); + LLVOAvatar::getNearbyRezzedStats(mAvatarRezStates); + mPhaseStats.clear(); + mPhaseStats["cloud"] = LLViewerStats::PhaseMap::getPhaseStats("cloud"); + mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray"); } + +struct AssetRequestType : public LLInitParam::Block<AssetRequestType> +{ + Optional<S32> enqueued, + dequeued, + resp_count; + Optional<F64> resp_min, + resp_max, + resp_mean; -void -LLViewerAssetStats::recordGetDequeued(LLViewerAssetType::EType at, bool with_http, bool is_temp) + AssetRequestType() + : enqueued("enqueued"), + dequeued("dequeued"), + resp_count("resp_count"), + resp_min("resp_min"), + resp_max("resp_max"), + resp_mean("resp_mean") + {} +}; + +struct FPSStats : public LLInitParam::Block<FPSStats> { - const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); + Optional<S32> count; + Optional<F64> min, + max, + mean; + FPSStats() + : count("count"), + min("min"), + max("max"), + mean("mean") + {} +}; + +struct RegionStats : public LLInitParam::Block<RegionStats> +{ + Optional<AssetRequestType> get_texture_temp_http, + get_texture_temp_udp, + get_texture_non_temp_http, + get_texture_non_temp_udp, + get_wearable_udp, + get_sound_udp, + get_gesture_udp, + get_other; + Optional<FPSStats> fps; + Mandatory<S32> grid_x, + grid_y; + Mandatory<F64> duration; + + RegionStats() + : get_texture_temp_http("get_texture_temp_http"), + get_texture_temp_udp("get_texture_temp_udp"), + get_texture_non_temp_http("get_texture_non_temp_http"), + get_texture_non_temp_udp("get_texture_non_temp_udp"), + get_wearable_udp("get_wearable_udp"), + get_sound_udp("get_sound_udp"), + get_gesture_udp("get_gesture_udp"), + get_other("get_other"), + fps("fps"), + grid_x("grid_x"), + grid_y("grid_y"), + duration("duration") + {} +}; + +struct AvatarRezState : public LLInitParam::Block<AvatarRezState> +{ + Mandatory<S32> cloud, + gray, + textured; + AvatarRezState() + : cloud("cloud"), + gray("gray"), + textured("textured") + {} +}; + +struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats> +{ + Mandatory<LLSD> cloud, + cloud_or_gray; - ++(mCurRegionStats->mRequests[int(eac)].mDequeued); - sDequeued[int(eac)].add(1); -} + AvatarPhaseStats() + : cloud("cloud"), + cloud_or_gray("cloud-or-gray") + {} +}; -void -LLViewerAssetStats::recordGetServiced(LLViewerAssetType::EType at, bool with_http, bool is_temp, duration_t duration) +struct AvatarInfo : public LLInitParam::Block<AvatarInfo> { - const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); + Mandatory<AvatarRezState> nearby; + Mandatory<AvatarPhaseStats> phase_stats; - mCurRegionStats->mRequests[int(eac)].mResponse.record(duration); - sResponse[int(eac)].sample<LLTrace::Seconds>(duration); -} + AvatarInfo() + : nearby("nearby"), + phase_stats("phase_stats") + {} +}; -void -LLViewerAssetStats::recordFPS(F32 fps) +struct AssetStats : public LLInitParam::Block<AssetStats> { - mCurRegionStats->mFPS.record(fps); -} + Multiple<RegionStats> regions; + Mandatory<F64> duration; + + AssetStats() + : regions("regions"), + duration("duration") + {} + +}; + +//LLSD LLViewerAssetStats::asLLSD(bool compact_output) +//{ +// // Top-level tags +// static const LLSD::String tags[LLViewerAssetStatsFF::EVACCount] = +// { +// LLSD::String("get_texture_temp_http"), +// LLSD::String("get_texture_temp_udp"), +// LLSD::String("get_texture_non_temp_http"), +// LLSD::String("get_texture_non_temp_udp"), +// LLSD::String("get_wearable_udp"), +// LLSD::String("get_sound_udp"), +// LLSD::String("get_gesture_udp"), +// LLSD::String("get_other") +// }; +// +// // Stats Group Sub-tags. +// static const LLSD::String enq_tag("enqueued"); +// static const LLSD::String deq_tag("dequeued"); +// static const LLSD::String rcnt_tag("resp_count"); +// static const LLSD::String rmin_tag("resp_min"); +// static const LLSD::String rmax_tag("resp_max"); +// static const LLSD::String rmean_tag("resp_mean"); +// +// // MMM Group Sub-tags. +// static const LLSD::String cnt_tag("count"); +// static const LLSD::String min_tag("min"); +// static const LLSD::String max_tag("max"); +// static const LLSD::String mean_tag("mean"); +// +// // Avatar sub-tags +// static const LLSD::String avatar_tag("avatar"); +// static const LLSD::String avatar_nearby_tag("nearby"); +// static const LLSD::String avatar_phase_stats_tag("phase_stats"); +// +// const duration_t now = LLViewerAssetStatsFF::get_timestamp(); +// mCurRegionStats->accumulateTime(now); +// +// LLSD regions = LLSD::emptyArray(); +// for (PerRegionContainer::iterator it = mRegionStats.begin(); +// mRegionStats.end() != it; +// ++it) +// { +// if (0 == it->first) +// { +// // Never emit NULL UUID/handle in results. +// continue; +// } +// +// PerRegionStats & stats = *it->second; +// +// LLSD reg_stat = LLSD::emptyMap(); +// +// for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i) +// { +// PerRegionStats::prs_group & group(stats.mRequests[i]); +// +// if ((! compact_output) || +// group.mEnqueued.getCount() || +// group.mDequeued.getCount() || +// group.mResponse.getCount()) +// { +// LLSD & slot = reg_stat[tags[i]]; +// slot = LLSD::emptyMap(); +// slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount())); +// slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount())); +// slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount())); +// slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6)); +// slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6)); +// slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6)); +// } +// } +// +// if ((! compact_output) || stats.mFPS.getCount()) +// { +// LLSD & slot = reg_stat["fps"]; +// slot = LLSD::emptyMap(); +// slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount())); +// slot[min_tag] = LLSD(F64(stats.mFPS.getMin())); +// slot[max_tag] = LLSD(F64(stats.mFPS.getMax())); +// slot[mean_tag] = LLSD(F64(stats.mFPS.getMean())); +// } +// U32 grid_x(0), grid_y(0); +// grid_from_region_handle(it->first, &grid_x, &grid_y); +// reg_stat["grid_x"] = LLSD::Integer(grid_x); +// reg_stat["grid_y"] = LLSD::Integer(grid_y); +// reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6); +// regions.append(reg_stat); +// } +// +// LLSD ret = LLSD::emptyMap(); +// ret["regions"] = regions; +// ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6); +// LLSD avatar_info; +// avatar_info[avatar_nearby_tag] = LLSD::emptyArray(); +// for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) +// { +// std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); +// avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat]; +// } +// avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD(); +// avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD(); +// ret[avatar_tag] = avatar_info; +// +// return ret; +//} -void -LLViewerAssetStats::recordAvatarStats() -{ - std::vector<S32> rez_counts; - LLVOAvatar::getNearbyRezzedStats(rez_counts); - mAvatarRezStates = rez_counts; - mPhaseStats.clear(); - mPhaseStats["cloud"] = LLViewerStats::PhaseMap::getPhaseStats("cloud"); - mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray"); -} +// ------------------------------------------------------ +// Global free-function definitions (LLViewerAssetStatsFF namespace) +// ------------------------------------------------------ -LLSD -LLViewerAssetStats::asLLSD(bool compact_output) +namespace LLViewerAssetStatsFF { - // Top-level tags - static const LLSD::String tags[EVACCount] = + static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp) + { + // For statistical purposes, we divide GETs into several + // populations of asset fetches: + // - textures which are de-prioritized in the asset system + // - wearables (clothing, bodyparts) which directly affect + // user experiences when they log in + // - sounds + // - gestures + // - everything else. + // + llassert_always(50 == LLViewerAssetType::AT_COUNT); + + // Multiple asset definitions are floating around so this requires some + // maintenance and attention. + static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] = { - LLSD::String("get_texture_temp_http"), - LLSD::String("get_texture_temp_udp"), - LLSD::String("get_texture_non_temp_http"), - LLSD::String("get_texture_non_temp_udp"), - LLSD::String("get_wearable_udp"), - LLSD::String("get_sound_udp"), - LLSD::String("get_gesture_udp"), - LLSD::String("get_other") + EVACTextureTempHTTPGet, // (0) AT_TEXTURE + EVACSoundUDPGet, // AT_SOUND + EVACOtherGet, // AT_CALLINGCARD + EVACOtherGet, // AT_LANDMARK + EVACOtherGet, // AT_SCRIPT + EVACWearableUDPGet, // AT_CLOTHING + EVACOtherGet, // AT_OBJECT + EVACOtherGet, // AT_NOTECARD + EVACOtherGet, // AT_CATEGORY + EVACOtherGet, // AT_ROOT_CATEGORY + EVACOtherGet, // (10) AT_LSL_TEXT + EVACOtherGet, // AT_LSL_BYTECODE + EVACOtherGet, // AT_TEXTURE_TGA + EVACWearableUDPGet, // AT_BODYPART + EVACOtherGet, // AT_TRASH + EVACOtherGet, // AT_SNAPSHOT_CATEGORY + EVACOtherGet, // AT_LOST_AND_FOUND + EVACSoundUDPGet, // AT_SOUND_WAV + EVACOtherGet, // AT_IMAGE_TGA + EVACOtherGet, // AT_IMAGE_JPEG + EVACGestureUDPGet, // (20) AT_ANIMATION + EVACGestureUDPGet, // AT_GESTURE + EVACOtherGet, // AT_SIMSTATE + EVACOtherGet, // AT_FAVORITE + EVACOtherGet, // AT_LINK + EVACOtherGet, // AT_LINK_FOLDER + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // (30) + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // (40) + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // AT_MESH + // (50) }; - // Stats Group Sub-tags. - static const LLSD::String enq_tag("enqueued"); - static const LLSD::String deq_tag("dequeued"); - static const LLSD::String rcnt_tag("resp_count"); - static const LLSD::String rmin_tag("resp_min"); - static const LLSD::String rmax_tag("resp_max"); - static const LLSD::String rmean_tag("resp_mean"); - - // MMM Group Sub-tags. - static const LLSD::String cnt_tag("count"); - static const LLSD::String min_tag("min"); - static const LLSD::String max_tag("max"); - static const LLSD::String mean_tag("mean"); - - // Avatar sub-tags - static const LLSD::String avatar_tag("avatar"); - static const LLSD::String avatar_nearby_tag("nearby"); - static const LLSD::String avatar_phase_stats_tag("phase_stats"); - - const duration_t now = LLViewerAssetStatsFF::get_timestamp(); - mCurRegionStats->accumulateTime(now); - - LLSD regions = LLSD::emptyArray(); - for (PerRegionContainer::iterator it = mRegionStats.begin(); - mRegionStats.end() != it; - ++it) - { - if (0 == it->first) + if (at < 0 || at >= LLViewerAssetType::AT_COUNT) { - // Never emit NULL UUID/handle in results. - continue; + return EVACOtherGet; } - - PerRegionStats & stats = *it->second; - - LLSD reg_stat = LLSD::emptyMap(); - - for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i) + EViewerAssetCategories ret(asset_to_bin_map[at]); + if (EVACTextureTempHTTPGet == ret) { - PerRegionStats::prs_group & group(stats.mRequests[i]); - - if ((! compact_output) || - group.mEnqueued.getCount() || - group.mDequeued.getCount() || - group.mResponse.getCount()) + // Indexed with [is_temp][with_http] + static const EViewerAssetCategories texture_bin_map[2][2] = { - LLSD & slot = reg_stat[tags[i]]; - slot = LLSD::emptyMap(); - slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount())); - slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount())); - slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount())); - slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6)); - slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6)); - slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6)); - } - } - - if ((! compact_output) || stats.mFPS.getCount()) - { - LLSD & slot = reg_stat["fps"]; - slot = LLSD::emptyMap(); - slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount())); - slot[min_tag] = LLSD(F64(stats.mFPS.getMin())); - slot[max_tag] = LLSD(F64(stats.mFPS.getMax())); - slot[mean_tag] = LLSD(F64(stats.mFPS.getMean())); - } - U32 grid_x(0), grid_y(0); - grid_from_region_handle(it->first, &grid_x, &grid_y); - reg_stat["grid_x"] = LLSD::Integer(grid_x); - reg_stat["grid_y"] = LLSD::Integer(grid_y); - reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6); - regions.append(reg_stat); - } - - LLSD ret = LLSD::emptyMap(); - ret["regions"] = regions; - ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6); - LLSD avatar_info; - avatar_info[avatar_nearby_tag] = LLSD::emptyArray(); - for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) - { - std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); - avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat]; - } - avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD(); - avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD(); - ret[avatar_tag] = avatar_info; - - return ret; -} - -void -LLViewerAssetStats::merge(const LLViewerAssetStats & src) -{ - // mRegionHandle, mCurRegionStats and mResetTimestamp are left untouched. - // Just merge the stats bodies + { + EVACTextureNonTempUDPGet, + EVACTextureNonTempHTTPGet, + }, + { + EVACTextureTempUDPGet, + EVACTextureTempHTTPGet, + } + }; - const PerRegionContainer::const_iterator it_end(src.mRegionStats.end()); - for (PerRegionContainer::const_iterator it(src.mRegionStats.begin()); it_end != it; ++it) - { - PerRegionContainer::iterator dst(mRegionStats.find(it->first)); - if (mRegionStats.end() == dst) - { - // Destination is missing data, just make a private copy - mRegionStats[it->first] = new PerRegionStats(*it->second); - } - else - { - dst->second->merge(*it->second); + ret = texture_bin_map[is_temp][with_http]; } + return ret; } -} - - -// ------------------------------------------------------ -// Global free-function definitions (LLViewerAssetStatsFF namespace) -// ------------------------------------------------------ - -namespace LLViewerAssetStatsFF -{ +static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", + "Number of temporary texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequeststemptextureudp", + "Number of temporary texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", + "Number of texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", + "Number of texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestswearableudp", + "Number of wearable asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestssoundudp", + "Number of sound asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsgestureudp", + "Number of gesture asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsother", + "Number of other asset requests enqueued")}; + +static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", + "Number of temporary texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequeststemptextureudp", + "Number of temporary texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", + "Number of texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", + "Number of texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestswearableudp", + "Number of wearable asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestssoundudp", + "Number of sound asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsgestureudp", + "Number of gesture asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsother", + "Number of other asset requests dequeued")}; +static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", + "Time spent responding to temporary texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", + "Time spent responding to temporary texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", + "Time spent responding to texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", + "Time spent responding to texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", + "Time spent responding to wearable asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", + "Time spent responding to sound asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", + "Time spent responding to gesture asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", + "Time spent responding to other asset requests")}; // // Target thread is elaborated in the function name. This could @@ -452,227 +521,59 @@ namespace LLViewerAssetStatsFF // 'main' thread - initial program thread -void -set_region_main(LLViewerAssetStats::region_handle_t region_handle) +void set_region(LLViewerAssetStats::region_handle_t region_handle) { - if (! gViewerAssetStatsMain) + if (! gViewerAssetStats) return; - gViewerAssetStatsMain->setRegion(region_handle); + gViewerAssetStats->setRegion(region_handle); } -void -record_enqueue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp) +void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp) { - if (! gViewerAssetStatsMain) - return; - - gViewerAssetStatsMain->recordGetEnqueued(at, with_http, is_temp); -} - -void -record_dequeue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp) -{ - if (! gViewerAssetStatsMain) - return; - - gViewerAssetStatsMain->recordGetDequeued(at, with_http, is_temp); -} - -void -record_response_main(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration) -{ - if (! gViewerAssetStatsMain) - return; - - gViewerAssetStatsMain->recordGetServiced(at, with_http, is_temp, duration); -} - -void -record_fps_main(F32 fps) -{ - if (! gViewerAssetStatsMain) - return; - - gViewerAssetStatsMain->recordFPS(fps); -} - -void -record_avatar_stats() -{ - if (! gViewerAssetStatsMain) - return; + const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); - gViewerAssetStatsMain->recordAvatarStats(); + sEnqueued[int(eac)].add(1); } -// 'thread1' - should be for TextureFetch thread - -void -set_region_thread1(LLViewerAssetStats::region_handle_t region_handle) +void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp) { - if (! gViewerAssetStatsThread1) - return; - - gViewerAssetStatsThread1->setRegion(region_handle); -} - -void -record_enqueue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp) -{ - if (! gViewerAssetStatsThread1) - return; + const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); - gViewerAssetStatsThread1->recordGetEnqueued(at, with_http, is_temp); + sDequeued[int(eac)].add(1); } -void -record_dequeue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp) +void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration) { - if (! gViewerAssetStatsThread1) - return; + const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); - gViewerAssetStatsThread1->recordGetDequeued(at, with_http, is_temp); + sResponse[int(eac)].sample<LLTrace::Seconds>(duration); } -void -record_response_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration) +void record_avatar_stats() { - if (! gViewerAssetStatsThread1) + if (! gViewerAssetStats) return; - gViewerAssetStatsThread1->recordGetServiced(at, with_http, is_temp, duration); + gViewerAssetStats->recordAvatarStats(); } - -void -init() +void init() { - if (! gViewerAssetStatsMain) + if (! gViewerAssetStats) { - gViewerAssetStatsMain = new LLViewerAssetStats(); - } - if (! gViewerAssetStatsThread1) - { - gViewerAssetStatsThread1 = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); } } void cleanup() { - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = 0; - - delete gViewerAssetStatsThread1; - gViewerAssetStatsThread1 = 0; + delete gViewerAssetStats; + gViewerAssetStats = 0; } } // namespace LLViewerAssetStatsFF -// ------------------------------------------------------ -// Local function definitions -// ------------------------------------------------------ - -namespace -{ - -LLViewerAssetStats::EViewerAssetCategories -asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp) -{ - // For statistical purposes, we divide GETs into several - // populations of asset fetches: - // - textures which are de-prioritized in the asset system - // - wearables (clothing, bodyparts) which directly affect - // user experiences when they log in - // - sounds - // - gestures - // - everything else. - // - llassert_always(50 == LLViewerAssetType::AT_COUNT); - - // Multiple asset definitions are floating around so this requires some - // maintenance and attention. - static const LLViewerAssetStats::EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] = - { - LLViewerAssetStats::EVACTextureTempHTTPGet, // (0) AT_TEXTURE - LLViewerAssetStats::EVACSoundUDPGet, // AT_SOUND - LLViewerAssetStats::EVACOtherGet, // AT_CALLINGCARD - LLViewerAssetStats::EVACOtherGet, // AT_LANDMARK - LLViewerAssetStats::EVACOtherGet, // AT_SCRIPT - LLViewerAssetStats::EVACWearableUDPGet, // AT_CLOTHING - LLViewerAssetStats::EVACOtherGet, // AT_OBJECT - LLViewerAssetStats::EVACOtherGet, // AT_NOTECARD - LLViewerAssetStats::EVACOtherGet, // AT_CATEGORY - LLViewerAssetStats::EVACOtherGet, // AT_ROOT_CATEGORY - LLViewerAssetStats::EVACOtherGet, // (10) AT_LSL_TEXT - LLViewerAssetStats::EVACOtherGet, // AT_LSL_BYTECODE - LLViewerAssetStats::EVACOtherGet, // AT_TEXTURE_TGA - LLViewerAssetStats::EVACWearableUDPGet, // AT_BODYPART - LLViewerAssetStats::EVACOtherGet, // AT_TRASH - LLViewerAssetStats::EVACOtherGet, // AT_SNAPSHOT_CATEGORY - LLViewerAssetStats::EVACOtherGet, // AT_LOST_AND_FOUND - LLViewerAssetStats::EVACSoundUDPGet, // AT_SOUND_WAV - LLViewerAssetStats::EVACOtherGet, // AT_IMAGE_TGA - LLViewerAssetStats::EVACOtherGet, // AT_IMAGE_JPEG - LLViewerAssetStats::EVACGestureUDPGet, // (20) AT_ANIMATION - LLViewerAssetStats::EVACGestureUDPGet, // AT_GESTURE - LLViewerAssetStats::EVACOtherGet, // AT_SIMSTATE - LLViewerAssetStats::EVACOtherGet, // AT_FAVORITE - LLViewerAssetStats::EVACOtherGet, // AT_LINK - LLViewerAssetStats::EVACOtherGet, // AT_LINK_FOLDER - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // (30) - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // (40) - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // - LLViewerAssetStats::EVACOtherGet, // AT_MESH - // (50) - }; - - if (at < 0 || at >= LLViewerAssetType::AT_COUNT) - { - return LLViewerAssetStats::EVACOtherGet; - } - LLViewerAssetStats::EViewerAssetCategories ret(asset_to_bin_map[at]); - if (LLViewerAssetStats::EVACTextureTempHTTPGet == ret) - { - // Indexed with [is_temp][with_http] - static const LLViewerAssetStats::EViewerAssetCategories texture_bin_map[2][2] = - { - { - LLViewerAssetStats::EVACTextureNonTempUDPGet, - LLViewerAssetStats::EVACTextureNonTempHTTPGet, - }, - { - LLViewerAssetStats::EVACTextureTempUDPGet, - LLViewerAssetStats::EVACTextureTempHTTPGet, - } - }; - - ret = texture_bin_map[is_temp][with_http]; - } - return ret; -} - -} // anonymous namespace diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index a750db2cc2..469609ea1f 100755 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -77,20 +77,6 @@ class LLViewerAssetStats { public: - enum EViewerAssetCategories - { - EVACTextureTempHTTPGet, //< Texture GETs - temp/baked, HTTP - EVACTextureTempUDPGet, //< Texture GETs - temp/baked, UDP - EVACTextureNonTempHTTPGet, //< Texture GETs - perm, HTTP - EVACTextureNonTempUDPGet, //< Texture GETs - perm, UDP - EVACWearableUDPGet, //< Wearable GETs - EVACSoundUDPGet, //< Sound GETs - EVACGestureUDPGet, //< Gesture GETs - EVACOtherGet, //< Other GETs - - EVACCount // Must be last - }; - /** * Type for duration and other time values in the metrics. Selected * for compatibility with the pre-existing timestamp on the texture @@ -105,61 +91,6 @@ public: */ typedef U64 region_handle_t; - /** - * @brief Collected data for a single region visited by the avatar. - * - * Fairly simple, for each asset bin enumerated above a count - * of enqueue and dequeue operations and simple stats on response - * times for completed requests. - */ - class PerRegionStats : public LLRefCount - { - public: - PerRegionStats(const region_handle_t region_handle) - : LLRefCount(), - mRegionHandle(region_handle) - { - reset(); - } - - PerRegionStats(const PerRegionStats & src) - : LLRefCount(), - mRegionHandle(src.mRegionHandle), - mTotalTime(src.mTotalTime), - mStartTimestamp(src.mStartTimestamp), - mFPS(src.mFPS) - { - for (int i = 0; i < LL_ARRAY_SIZE(mRequests); ++i) - { - mRequests[i] = src.mRequests[i]; - } - } - - // Default assignment and destructor are correct. - - void reset(); - - void merge(const PerRegionStats & src); - - // Apply current running time to total and reset start point. - // Return current timestamp as a convenience. - void accumulateTime(duration_t now); - - public: - region_handle_t mRegionHandle; - duration_t mTotalTime; - duration_t mStartTimestamp; - LLSimpleStatMMM<> mFPS; - - struct prs_group - { - LLSimpleStatCounter mEnqueued; - LLSimpleStatCounter mDequeued; - LLSimpleStatMMM<duration_t> mResponse; - } - mRequests [EVACCount]; - }; - public: LLViewerAssetStats(); LLViewerAssetStats(const LLViewerAssetStats &); @@ -175,26 +106,9 @@ public: // collection calls. void setRegion(region_handle_t region_handle); - // Asset GET Requests - void recordGetEnqueued(LLViewerAssetType::EType at, bool with_http, bool is_temp); - void recordGetDequeued(LLViewerAssetType::EType at, bool with_http, bool is_temp); - void recordGetServiced(LLViewerAssetType::EType at, bool with_http, bool is_temp, duration_t duration); - - // Frames-Per-Second Samples - void recordFPS(F32 fps); - // Avatar-related statistics void recordAvatarStats(); - // Merge a source instance into a destination instance. This is - // conceptually an 'operator+=()' method: - // - counts are added - // - minimums are min'd - // - maximums are max'd - // - other scalars are ignored ('this' wins) - // - void merge(const LLViewerAssetStats & src); - // Retrieve current metrics for all visited regions (NULL region UUID/handle excluded) // Returned LLSD is structured as follows: // @@ -240,7 +154,6 @@ public: LLSD asLLSD(bool compact_output); protected: - typedef std::map<region_handle_t, LLPointer<PerRegionStats> > PerRegionContainer; typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer; // Region of the currently-active region. Always valid but may @@ -248,22 +161,12 @@ protected: // by a reset() call. region_handle_t mRegionHandle; - // Pointer to metrics collection for currently-active region. Always - // valid and unchanged after reset() though contents will be changed. - // Always points to a collection contained in mRegionStats. - LLPointer<PerRegionStats> mCurRegionStats; - - static LLTrace::Count<> sEnqueued[EVACCount]; - static LLTrace::Count<> sDequeued[EVACCount]; - static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount]; + // Pointer to metrics collection for currently-active region. + LLTrace::Recording* mCurRecording; // Metrics data for all regions during one collection cycle - PerRegionContainer mRegionStats; PerRegionRecordingContainer mRegionRecordings; - // Time of last reset - duration_t mResetTimestamp; - // Nearby avatar stats std::vector<S32> mAvatarRezStates; LLViewerStats::phase_stats_t mPhaseStats; @@ -284,12 +187,24 @@ protected: * - Main: main() program execution thread * - Thread1: TextureFetch worker thread */ -extern LLViewerAssetStats * gViewerAssetStatsMain; - -extern LLViewerAssetStats * gViewerAssetStatsThread1; +extern LLViewerAssetStats * gViewerAssetStats; namespace LLViewerAssetStatsFF { + enum EViewerAssetCategories + { + EVACTextureTempHTTPGet, //< Texture GETs - temp/baked, HTTP + EVACTextureTempUDPGet, //< Texture GETs - temp/baked, UDP + EVACTextureNonTempHTTPGet, //< Texture GETs - perm, HTTP + EVACTextureNonTempUDPGet, //< Texture GETs - perm, UDP + EVACWearableUDPGet, //< Wearable GETs + EVACSoundUDPGet, //< Sound GETs + EVACGestureUDPGet, //< Gesture GETs + EVACOtherGet, //< Other GETs + + EVACCount // Must be last + }; + /** * @brief Allocation and deallocation of globals. * @@ -314,31 +229,17 @@ inline LLViewerAssetStats::duration_t get_timestamp() /** * Region context, event and duration loggers for the Main thread. */ -void set_region_main(LLViewerAssetStats::region_handle_t region_handle); +void set_region(LLViewerAssetStats::region_handle_t region_handle); -void record_enqueue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp); +void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp); -void record_dequeue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp); +void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp); -void record_response_main(LLViewerAssetType::EType at, bool with_http, bool is_temp, +void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration); -void record_fps_main(F32 fps); - void record_avatar_stats(); -/** - * Region context, event and duration loggers for Thread 1. - */ -void set_region_thread1(LLViewerAssetStats::region_handle_t region_handle); - -void record_enqueue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp); - -void record_dequeue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp); - -void record_response_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp, - LLViewerAssetStats::duration_t duration); - } // namespace LLViewerAssetStatsFF #endif // LL_LLVIEWERASSETSTATUS_H diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index d042f62830..6f41abbd8a 100644 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -73,8 +73,8 @@ protected: { // Okay, it appears this request was used for useful things. Record // the expected dequeue and duration of request processing. - LLViewerAssetStatsFF::record_dequeue_main(mType, false, false); - LLViewerAssetStatsFF::record_response_main(mType, false, false, + LLViewerAssetStatsFF::record_dequeue(mType, false, false); + LLViewerAssetStatsFF::record_response(mType, false, false, (LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime)); mMetricsStartTime = 0; @@ -373,7 +373,7 @@ void LLViewerAssetStorage::_queueDataRequest( LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(mUpstreamHost, LLTCT_ASSET); ttcp->requestTransfer(spa, tpvf, 100.f + (is_priority ? 1.f : 0.f)); - LLViewerAssetStatsFF::record_enqueue_main(atype, false, false); + LLViewerAssetStatsFF::record_enqueue(atype, false, false); } } else diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index 4a190fbe23..e0126ce8d3 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -243,11 +243,11 @@ namespace tut // Check that helpers aren't bothered by missing global stats ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain)); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_response_main(LLViewerAssetType::AT_GESTURE, false, false, 12300000ULL); + LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_GESTURE, false, false, 12300000ULL); } // Create a non-global instance and check the structure @@ -326,13 +326,13 @@ namespace tut void tst_viewerassetstats_index_object_t::test<4>() { gViewerAssetStatsMain = new LLViewerAssetStats(); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); LLSD sd = gViewerAssetStatsMain->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); @@ -364,13 +364,13 @@ namespace tut { gViewerAssetStatsThread1 = new LLViewerAssetStats(); gViewerAssetStatsMain = new LLViewerAssetStats(); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); LLSD sd = gViewerAssetStatsThread1->asLLSD(false); ensure("Other collector is empty", is_no_stats_map(sd)); @@ -393,8 +393,6 @@ namespace tut delete gViewerAssetStatsMain; gViewerAssetStatsMain = NULL; - delete gViewerAssetStatsThread1; - gViewerAssetStatsThread1 = NULL; ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger())); @@ -406,20 +404,20 @@ namespace tut { gViewerAssetStatsMain = new LLViewerAssetStats(); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::set_region_main(region2_handle); + LLViewerAssetStatsFF::set_region(region2_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLSD sd = gViewerAssetStatsMain->asLLSD(false); @@ -465,35 +463,35 @@ namespace tut { gViewerAssetStatsMain = new LLViewerAssetStats(); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::set_region_main(region2_handle); + LLViewerAssetStatsFF::set_region(region2_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, true, true); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, true, true); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, true, true); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, true, true); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::set_region_main(region2_handle); + LLViewerAssetStatsFF::set_region(region2_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLSD sd = gViewerAssetStatsMain->asLLSD(false); @@ -538,30 +536,30 @@ namespace tut { gViewerAssetStatsThread1 = new LLViewerAssetStats(); gViewerAssetStatsMain = new LLViewerAssetStats(); - LLViewerAssetStatsFF::set_region_main(region1_handle); + LLViewerAssetStatsFF::set_region(region1_handle); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, true); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, true); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, true); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, true); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, true, false); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, true, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, true, false); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, true, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, true, true); - LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, true, true); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, true, true); + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, true, true); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, false, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, false, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, false, true); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, false, true); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, true, false); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, false); - LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, true, true); + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true); LLSD sd = gViewerAssetStatsThread1->asLLSD(false); ensure("Other collector is empty", is_no_stats_map(sd)); -- cgit v1.2.3 From 176ffa54b44f2ef73f23e3252dd439f52fab3265 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 19 Oct 2012 19:35:01 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system finished most of conversion of llviewerassetstats ported some param block fixes from viewer-chui converted viewer asset stats to param block format --- indra/llcommon/llinitparam.cpp | 5 - indra/llcommon/llinitparam.h | 43 +- indra/llcommon/llsdparam.cpp | 45 +- indra/llcommon/lltracerecording.h | 2 +- indra/newview/llsimplestat.h | 58 +-- indra/newview/lltexturefetch.cpp | 48 +- indra/newview/llviewerassetstats.cpp | 627 ++++++++++++++---------- indra/newview/llviewerassetstats.h | 90 +++- indra/newview/llviewerstats.cpp | 4 +- indra/newview/llviewerstats.h | 3 +- indra/newview/tests/llviewerassetstats_test.cpp | 510 ++----------------- 11 files changed, 623 insertions(+), 812 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index db72aa19b9..54e98e66f3 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -196,12 +196,7 @@ namespace LLInitParam if (serialize_func) { const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; - // each param descriptor remembers its serial number - // so we can inspect the same param under different names - // and see that it has the same number - name_stack.push_back(std::make_pair("", true)); serialize_func(*param, parser, name_stack, diff_param); - name_stack.pop_back(); } } diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 9a6d1eff5c..b7607e91b9 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -1156,10 +1156,18 @@ namespace LLInitParam static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { + Parser::name_stack_range_t new_name_stack_range(name_stack_range); self_t& typed_param = static_cast<self_t&>(param); value_t value; + + // pop first element if empty string + if (new_name_stack_range.first != new_name_stack_range.second && new_name_stack_range.first->first.empty()) + { + ++new_name_stack_range.first; + } + // no further names in stack, attempt to parse value now - if (name_stack_range.first == name_stack_range.second) + if (new_name_stack_range.first == new_name_stack_range.second) { // attempt to read value directly if (parser.readValue(value)) @@ -1192,14 +1200,14 @@ namespace LLInitParam static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided() || name_stack.empty()) return; + if (!typed_param.isProvided()) return; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; ++it) { std::string key = it->getValueName(); - name_stack.back().second = true; + name_stack.push_back(std::make_pair(std::string(), true)); if(key.empty()) // not parsed via name values, write out value directly @@ -1221,6 +1229,8 @@ namespace LLInitParam break; } } + + name_stack.pop_back(); } } @@ -1351,10 +1361,19 @@ namespace LLInitParam static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { + Parser::name_stack_range_t new_name_stack_range(name_stack_range); self_t& typed_param = static_cast<self_t&>(param); bool new_value = false; + bool new_array_value = false; + + // pop first element if empty string + if (new_name_stack_range.first != new_name_stack_range.second && new_name_stack_range.first->first.empty()) + { + new_array_value = new_name_stack_range.first->second; + ++new_name_stack_range.first; + } - if (new_name || typed_param.mValues.empty()) + if (new_name || new_array_value || typed_param.mValues.empty()) { new_value = true; typed_param.mValues.push_back(value_t()); @@ -1363,9 +1382,13 @@ namespace LLInitParam param_value_t& value = typed_param.mValues.back(); // attempt to parse block... - if(value.deserializeBlock(parser, name_stack_range, new_name)) + if(value.deserializeBlock(parser, new_name_stack_range, new_name)) { typed_param.setProvided(); + if (new_array_value) + { + name_stack_range.first->second = false; + } return true; } else if(name_value_lookup_t::valueNamesExist()) @@ -1379,6 +1402,10 @@ namespace LLInitParam { typed_param.mValues.back().setValueName(name); typed_param.setProvided(); + if (new_array_value) + { + name_stack_range.first->second = false; + } return true; } @@ -1396,13 +1423,13 @@ namespace LLInitParam static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided() || name_stack.empty()) return; + if (!typed_param.isProvided()) return; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; ++it) { - name_stack.back().second = true; + name_stack.push_back(std::make_pair(std::string(), true)); std::string key = it->getValueName(); if (!key.empty()) @@ -1415,6 +1442,8 @@ namespace LLInitParam { it->serializeBlock(parser, name_stack, NULL); } + + name_stack.pop_back(); } } diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 0e29873bb0..4b8a8dba5c 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -223,10 +223,14 @@ LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser: { bool new_traversal = it->second; - LLSD* child_sd = it->first.empty() ? sd_to_write : &(*sd_to_write)[it->first]; - - if (child_sd->isArray()) + LLSD* child_sd; + if (it->first.empty()) + { + child_sd = sd_to_write; + if (child_sd->isUndefined()) { + *child_sd = LLSD::emptyArray(); + } if (new_traversal) { // write to new element at end @@ -240,22 +244,7 @@ LLSD& LLParamSDParserUtilities::getSDWriteNode(LLSD& input, LLInitParam::Parser: } else { - if (new_traversal - && child_sd->isDefined() - && !child_sd->isArray()) - { - // copy child contents into first element of an array - LLSD new_array = LLSD::emptyArray(); - new_array.append(*child_sd); - // assign array to slot that previously held the single value - *child_sd = new_array; - // return next element in that array - sd_to_write = &((*child_sd)[1]); - } - else - { - sd_to_write = child_sd; - } + sd_to_write = &(*sd_to_write)[it->first]; } it->second = false; } @@ -283,8 +272,9 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI it != sd.endArray(); ++it) { - stack.back().second = true; + stack.push_back(make_pair(std::string(), true)); readSDValues(cb, *it, stack); + stack.pop_back(); } } else if (sd.isUndefined()) @@ -315,6 +305,12 @@ namespace LLInitParam // block param interface bool ParamValue<LLSD, TypeValues<LLSD>, false>::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack, bool new_name) { + if (name_stack.first == name_stack.second + && p.readValue<LLSD>(mValue)) + { + return true; + } + LLSD& sd = LLParamSDParserUtilities::getSDWriteNode(mValue, name_stack); LLSD::String string; @@ -335,8 +331,11 @@ namespace LLInitParam void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const { - // read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) - Parser::name_stack_t stack; - LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, stack); + // attempt to write LLSD out directly + if (!p.writeValue<LLSD>(mValue, name_stack)) + { + // otherwise read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) + LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, name_stack); + } } } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 25f4f5c721..d3f001ab6a 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -231,7 +231,7 @@ namespace LLTrace return stat.getAccumulator(mMeasurements).getSampleCount(); } - F64 getDuration() const { return mElapsedSeconds; } + LLUnit::Seconds<F64> getDuration() const { return mElapsedSeconds; } // implementation for LLVCRControlsMixin /*virtual*/ void handleStart(); diff --git a/indra/newview/llsimplestat.h b/indra/newview/llsimplestat.h index 9d7780c4f9..80ce99b774 100644 --- a/indra/newview/llsimplestat.h +++ b/indra/newview/llsimplestat.h @@ -99,43 +99,43 @@ public: * values back to zero. */ void reset() - { - mCount = 0; - mMin = Value(0); - mMax = Value(0); - mTotal = Value(0); - } + { + mCount = 0; + mMin = Value(0); + mMax = Value(0); + mTotal = Value(0); + } void record(Value v) + { + if (mCount) + { + mMin = llmin(mMin, v); + mMax = llmax(mMax, v); + } + else { - if (mCount) - { - mMin = llmin(mMin, v); - mMax = llmax(mMax, v); - } - else - { - mMin = v; - mMax = v; - } - mTotal += v; - ++mCount; + mMin = v; + mMax = v; } + mTotal += v; + ++mCount; + } void merge(const LLSimpleStatMMM<VALUE_T> & src) + { + if (! mCount) + { + *this = src; + } + else if (src.mCount) { - if (! mCount) - { - *this = src; - } - else if (src.mCount) - { - mMin = llmin(mMin, src.mMin); - mMax = llmax(mMax, src.mMax); - mCount += src.mCount; - mTotal += src.mTotal; - } + mMin = llmin(mMin, src.mMin); + mMax = llmax(mMax, src.mMax); + mCount += src.mCount; + mTotal += src.mTotal; } + } inline U32 getCount() const { return mCount; } inline Value getMin() const { return mMin; } diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 903fd6acee..ac83fe0ca8 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -53,6 +53,7 @@ #include "llviewerstatsrecorder.h" #include "llviewerassetstats.h" #include "llworld.h" +#include "llsdparam.h" #include "llsdutil.h" #include "llstartup.h" #include "llviewerstats.h" @@ -2867,8 +2868,8 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) }; // class lcl_responder - if (! gViewerAssetStatsThread1) - return true; + //if (! gViewerAssetStatsThread1) + // return true; static volatile bool reporting_started(false); static volatile S32 report_sequence(0); @@ -2878,31 +2879,42 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) // but leave it in 'this'. Destructor will rid us of it. LLViewerAssetStats & main_stats = *mMainStats; - // Merge existing stats into those from main, convert to LLSD - main_stats.merge(*gViewerAssetStatsThread1); - LLSD merged_llsd = main_stats.asLLSD(true); - - // Add some additional meta fields to the content - merged_llsd["session_id"] = mSessionID; - merged_llsd["agent_id"] = mAgentID; - merged_llsd["message"] = "ViewerAssetMetrics"; // Identifies the type of metrics - merged_llsd["sequence"] = report_sequence; // Sequence number - merged_llsd["initial"] = ! reporting_started; // Initial data from viewer - merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak; // Break in data prior to this report - + LLViewerAssetStats::AssetStats stats; + main_stats.getStats(stats); + //LLSD merged_llsd = main_stats.asLLSD(); + + stats.session_id = mSessionID; + stats.agent_id = mAgentID; + stats.message = "ViewerAssetMetrics"; + stats.sequence = static_cast<bool>(report_sequence); + stats.initial = static_cast<bool>(!reporting_started); + stats.break_ = static_cast<bool>(LLTextureFetch::svMetricsDataBreak); + //// Add some additional meta fields to the content + //merged_llsd["session_id"] = mSessionID; + //merged_llsd["agent_id"] = mAgentID; + //merged_llsd["message"] = "ViewerAssetMetrics"; // Identifies the type of metrics + //merged_llsd["sequence"] = report_sequence; // Sequence number + //merged_llsd["initial"] = ! reporting_started; // Initial data from viewer + //merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak; // Break in data prior to this report + + LLSD sd; + LLParamSDParser parser; + parser.writeSD(sd, stats); + // Update sequence number if (S32_MAX == ++report_sequence) report_sequence = 0; // Limit the size of the stats report if necessary. - merged_llsd["truncated"] = truncate_viewer_metrics(10, merged_llsd); + + sd["truncated"] = truncate_viewer_metrics(10, sd); if (! mCapsURL.empty()) { LLCurlRequest::headers_t headers; fetcher->getCurlRequest().post(mCapsURL, headers, - merged_llsd, + sd, new lcl_responder(fetcher, report_sequence, report_sequence, @@ -2917,10 +2929,10 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) // In QA mode, Metrics submode, log the result for ease of testing if (fetcher->isQAMode()) { - LL_INFOS("Textures") << ll_pretty_print_sd(merged_llsd) << LL_ENDL; + LL_INFOS("Textures") << ll_pretty_print_sd(sd) << LL_ENDL; } - gViewerAssetStatsThread1->reset(); + //gViewerAssetStatsThread1->reset(); return true; } diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index cc15d6433f..0b820f866e 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -31,6 +31,8 @@ #include "stdtypes.h" #include "llvoavatar.h" +#include "llsdparam.h" +#include "llsdutil.h" /* * Classes and utility functions for per-thread and per-region @@ -78,6 +80,152 @@ * */ +namespace LLViewerAssetStatsFF +{ + static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp) + { + // For statistical purposes, we divide GETs into several + // populations of asset fetches: + // - textures which are de-prioritized in the asset system + // - wearables (clothing, bodyparts) which directly affect + // user experiences when they log in + // - sounds + // - gestures + // - everything else. + // + llassert_always(50 == LLViewerAssetType::AT_COUNT); + + // Multiple asset definitions are floating around so this requires some + // maintenance and attention. + static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] = + { + EVACTextureTempHTTPGet, // (0) AT_TEXTURE + EVACSoundUDPGet, // AT_SOUND + EVACOtherGet, // AT_CALLINGCARD + EVACOtherGet, // AT_LANDMARK + EVACOtherGet, // AT_SCRIPT + EVACWearableUDPGet, // AT_CLOTHING + EVACOtherGet, // AT_OBJECT + EVACOtherGet, // AT_NOTECARD + EVACOtherGet, // AT_CATEGORY + EVACOtherGet, // AT_ROOT_CATEGORY + EVACOtherGet, // (10) AT_LSL_TEXT + EVACOtherGet, // AT_LSL_BYTECODE + EVACOtherGet, // AT_TEXTURE_TGA + EVACWearableUDPGet, // AT_BODYPART + EVACOtherGet, // AT_TRASH + EVACOtherGet, // AT_SNAPSHOT_CATEGORY + EVACOtherGet, // AT_LOST_AND_FOUND + EVACSoundUDPGet, // AT_SOUND_WAV + EVACOtherGet, // AT_IMAGE_TGA + EVACOtherGet, // AT_IMAGE_JPEG + EVACGestureUDPGet, // (20) AT_ANIMATION + EVACGestureUDPGet, // AT_GESTURE + EVACOtherGet, // AT_SIMSTATE + EVACOtherGet, // AT_FAVORITE + EVACOtherGet, // AT_LINK + EVACOtherGet, // AT_LINK_FOLDER + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // (30) + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // (40) + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // + EVACOtherGet, // AT_MESH + // (50) + }; + + if (at < 0 || at >= LLViewerAssetType::AT_COUNT) + { + return EVACOtherGet; + } + EViewerAssetCategories ret(asset_to_bin_map[at]); + if (EVACTextureTempHTTPGet == ret) + { + // Indexed with [is_temp][with_http] + static const EViewerAssetCategories texture_bin_map[2][2] = + { + { + EVACTextureNonTempUDPGet, + EVACTextureNonTempHTTPGet, + }, + { + EVACTextureTempUDPGet, + EVACTextureTempHTTPGet, + } + }; + + ret = texture_bin_map[is_temp][with_http]; + } + return ret; + } + static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", + "Number of temporary texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequeststemptextureudp", + "Number of temporary texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", + "Number of texture asset http requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", + "Number of texture asset udp requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestswearableudp", + "Number of wearable asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestssoundudp", + "Number of sound asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsgestureudp", + "Number of gesture asset requests enqueued"), + LLTrace::Count<>("enqueuedassetrequestsother", + "Number of other asset requests enqueued")}; + + static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", + "Number of temporary texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequeststemptextureudp", + "Number of temporary texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", + "Number of texture asset http requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", + "Number of texture asset udp requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestswearableudp", + "Number of wearable asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestssoundudp", + "Number of sound asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsgestureudp", + "Number of gesture asset requests dequeued"), + LLTrace::Count<>("dequeuedassetrequestsother", + "Number of other asset requests dequeued")}; + static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", + "Time spent responding to temporary texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", + "Time spent responding to temporary texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", + "Time spent responding to texture asset http requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", + "Time spent responding to texture asset udp requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", + "Time spent responding to wearable asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", + "Time spent responding to sound asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", + "Time spent responding to gesture asset requests"), + LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", + "Time spent responding to other asset requests")}; +} // ------------------------------------------------------ // Global data definitions @@ -88,7 +236,8 @@ LLViewerAssetStats * gViewerAssetStats(0); // LLViewerAssetStats class definition // ------------------------------------------------------ LLViewerAssetStats::LLViewerAssetStats() - : mRegionHandle(U64(0)) +: mRegionHandle(U64(0)), + mCurRecording(NULL) { reset(); } @@ -110,7 +259,10 @@ void LLViewerAssetStats::reset() mRegionRecordings.clear(); // initialize new recording for current region - mCurRecording = &mRegionRecordings[mRegionHandle]; + if (mRegionHandle) + { + mCurRecording = &mRegionRecordings[mRegionHandle]; + } } void LLViewerAssetStats::setRegion(region_handle_t region_handle) @@ -121,9 +273,15 @@ void LLViewerAssetStats::setRegion(region_handle_t region_handle) return; } - mCurRecording->stop(); - mCurRecording = &mRegionRecordings[region_handle]; - mCurRecording->start(); + if (mCurRecording) + { + mCurRecording->pause(); + } + if (region_handle) + { + mCurRecording = &mRegionRecordings[region_handle]; + mCurRecording->start(); + } mRegionHandle = region_handle; } @@ -136,116 +294,169 @@ void LLViewerAssetStats::recordAvatarStats() mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray"); } -struct AssetRequestType : public LLInitParam::Block<AssetRequestType> +void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) { - Optional<S32> enqueued, - dequeued, - resp_count; - Optional<F64> resp_min, - resp_max, - resp_mean; + using namespace LLViewerAssetStatsFF; + + if (mCurRecording) + { + mCurRecording->update(); + } - AssetRequestType() - : enqueued("enqueued"), - dequeued("dequeued"), - resp_count("resp_count"), - resp_min("resp_min"), - resp_max("resp_max"), - resp_mean("resp_mean") - {} -}; - -struct FPSStats : public LLInitParam::Block<FPSStats> -{ - Optional<S32> count; - Optional<F64> min, - max, - mean; - FPSStats() - : count("count"), - min("min"), - max("max"), - mean("mean") - {} -}; - -struct RegionStats : public LLInitParam::Block<RegionStats> -{ - Optional<AssetRequestType> get_texture_temp_http, - get_texture_temp_udp, - get_texture_non_temp_http, - get_texture_non_temp_udp, - get_wearable_udp, - get_sound_udp, - get_gesture_udp, - get_other; - Optional<FPSStats> fps; - Mandatory<S32> grid_x, - grid_y; - Mandatory<F64> duration; - - RegionStats() - : get_texture_temp_http("get_texture_temp_http"), - get_texture_temp_udp("get_texture_temp_udp"), - get_texture_non_temp_http("get_texture_non_temp_http"), - get_texture_non_temp_udp("get_texture_non_temp_udp"), - get_wearable_udp("get_wearable_udp"), - get_sound_udp("get_sound_udp"), - get_gesture_udp("get_gesture_udp"), - get_other("get_other"), - fps("fps"), - grid_x("grid_x"), - grid_y("grid_y"), - duration("duration") - {} -}; - -struct AvatarRezState : public LLInitParam::Block<AvatarRezState> -{ - Mandatory<S32> cloud, - gray, - textured; - AvatarRezState() - : cloud("cloud"), - gray("gray"), - textured("textured") - {} -}; - -struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats> -{ - Mandatory<LLSD> cloud, - cloud_or_gray; + if (mRegionRecordings.empty()) + { + stats.regions.add().empty.setProvided(); + } + else + { + for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end(); + it != end_it; + ++it) + { + RegionStats& r = stats.regions.add(); + LLTrace::Recording& rec = it->second; + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) + || rec.getSum(sDequeued[EVACTextureTempHTTPGet]) + || rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) + { + r.get_texture_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value()); + } + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureTempUDPGet]) + || rec.getSum(sDequeued[EVACTextureTempUDPGet]) + || rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) + { + r.get_texture_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value()); + } + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) + || rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]) + || rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) + { + r.get_texture_non_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) + || rec.getSum(sDequeued[EVACTextureNonTempUDPGet]) + || rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) + { + r.get_texture_non_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACWearableUDPGet]) + || rec.getSum(sDequeued[EVACWearableUDPGet]) + || rec.getSum(sResponse[EVACWearableUDPGet]).value()) + { + r.get_wearable_udp .enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACWearableUDPGet])) + .resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACSoundUDPGet]) + || rec.getSum(sDequeued[EVACSoundUDPGet]) + || rec.getSum(sResponse[EVACSoundUDPGet]).value()) + { + r.get_sound_udp .enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACSoundUDPGet])) + .resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACGestureUDPGet]) + || rec.getSum(sDequeued[EVACGestureUDPGet]) + || rec.getSum(sResponse[EVACGestureUDPGet]).value()) + { + r.get_gesture_udp .enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACGestureUDPGet])) + .resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACOtherGet]) + || rec.getSum(sDequeued[EVACOtherGet]) + || rec.getSum(sResponse[EVACOtherGet]).value()) + { + r.get_other .enqueued(rec.getSum(sEnqueued[EVACOtherGet])) + .dequeued(rec.getSum(sDequeued[EVACOtherGet])) + .resp_count(rec.getSum(sResponse[EVACOtherGet]).value()) + .resp_min(rec.getMin(sResponse[EVACOtherGet]).value()) + .resp_max(rec.getMax(sResponse[EVACOtherGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACOtherGet]).value()); + } + + S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE); + if (!compact_output || fps != 0) + { + r.fps.count(fps); + r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE)); + r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE)); + r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE)); + } + U32 grid_x(0), grid_y(0); + grid_from_region_handle(it->first, &grid_x, &grid_y); + r.grid_x(grid_x); + r.grid_y(grid_y); + r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value()); + } + } - AvatarPhaseStats() - : cloud("cloud"), - cloud_or_gray("cloud-or-gray") - {} -}; + stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0); + //stats.avatar.setProvided(true); -struct AvatarInfo : public LLInitParam::Block<AvatarInfo> -{ - Mandatory<AvatarRezState> nearby; - Mandatory<AvatarPhaseStats> phase_stats; + for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) + { + stats.avatar.nearby .cloud(mAvatarRezStates[0]) + .gray(mAvatarRezStates[1]) + .textured(mAvatarRezStates[2]); + } - AvatarInfo() - : nearby("nearby"), - phase_stats("phase_stats") - {} -}; + stats.avatar.phase_stats .cloud(mPhaseStats["cloud"].asLLSD()) + .cloud_or_gray(mPhaseStats["cloud-or-gray"].asLLSD()); +} -struct AssetStats : public LLInitParam::Block<AssetStats> +LLSD LLViewerAssetStats::asLLSD(bool compact_output) { - Multiple<RegionStats> regions; - Mandatory<F64> duration; - - AssetStats() - : regions("regions"), - duration("duration") - {} - -}; - + LLParamSDParser parser; + LLSD sd; + AssetStats stats; + getStats(stats, compact_output); + parser.writeSD(sd, stats); + llinfos << ll_pretty_print_sd(sd) << llendl; + return sd; +} //LLSD LLViewerAssetStats::asLLSD(bool compact_output) //{ // // Top-level tags @@ -358,150 +569,6 @@ struct AssetStats : public LLInitParam::Block<AssetStats> namespace LLViewerAssetStatsFF { - static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp) - { - // For statistical purposes, we divide GETs into several - // populations of asset fetches: - // - textures which are de-prioritized in the asset system - // - wearables (clothing, bodyparts) which directly affect - // user experiences when they log in - // - sounds - // - gestures - // - everything else. - // - llassert_always(50 == LLViewerAssetType::AT_COUNT); - - // Multiple asset definitions are floating around so this requires some - // maintenance and attention. - static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] = - { - EVACTextureTempHTTPGet, // (0) AT_TEXTURE - EVACSoundUDPGet, // AT_SOUND - EVACOtherGet, // AT_CALLINGCARD - EVACOtherGet, // AT_LANDMARK - EVACOtherGet, // AT_SCRIPT - EVACWearableUDPGet, // AT_CLOTHING - EVACOtherGet, // AT_OBJECT - EVACOtherGet, // AT_NOTECARD - EVACOtherGet, // AT_CATEGORY - EVACOtherGet, // AT_ROOT_CATEGORY - EVACOtherGet, // (10) AT_LSL_TEXT - EVACOtherGet, // AT_LSL_BYTECODE - EVACOtherGet, // AT_TEXTURE_TGA - EVACWearableUDPGet, // AT_BODYPART - EVACOtherGet, // AT_TRASH - EVACOtherGet, // AT_SNAPSHOT_CATEGORY - EVACOtherGet, // AT_LOST_AND_FOUND - EVACSoundUDPGet, // AT_SOUND_WAV - EVACOtherGet, // AT_IMAGE_TGA - EVACOtherGet, // AT_IMAGE_JPEG - EVACGestureUDPGet, // (20) AT_ANIMATION - EVACGestureUDPGet, // AT_GESTURE - EVACOtherGet, // AT_SIMSTATE - EVACOtherGet, // AT_FAVORITE - EVACOtherGet, // AT_LINK - EVACOtherGet, // AT_LINK_FOLDER - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // (30) - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // (40) - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // - EVACOtherGet, // AT_MESH - // (50) - }; - - if (at < 0 || at >= LLViewerAssetType::AT_COUNT) - { - return EVACOtherGet; - } - EViewerAssetCategories ret(asset_to_bin_map[at]); - if (EVACTextureTempHTTPGet == ret) - { - // Indexed with [is_temp][with_http] - static const EViewerAssetCategories texture_bin_map[2][2] = - { - { - EVACTextureNonTempUDPGet, - EVACTextureNonTempHTTPGet, - }, - { - EVACTextureTempUDPGet, - EVACTextureTempHTTPGet, - } - }; - - ret = texture_bin_map[is_temp][with_http]; - } - return ret; - } -static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", - "Number of temporary texture asset http requests enqueued"), - LLTrace::Count<>("enqueuedassetrequeststemptextureudp", - "Number of temporary texture asset udp requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", - "Number of texture asset http requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", - "Number of texture asset udp requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestswearableudp", - "Number of wearable asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestssoundudp", - "Number of sound asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsgestureudp", - "Number of gesture asset requests enqueued"), - LLTrace::Count<>("enqueuedassetrequestsother", - "Number of other asset requests enqueued")}; - -static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", - "Number of temporary texture asset http requests dequeued"), - LLTrace::Count<>("dequeuedassetrequeststemptextureudp", - "Number of temporary texture asset udp requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", - "Number of texture asset http requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", - "Number of texture asset udp requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestswearableudp", - "Number of wearable asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestssoundudp", - "Number of sound asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsgestureudp", - "Number of gesture asset requests dequeued"), - LLTrace::Count<>("dequeuedassetrequestsother", - "Number of other asset requests dequeued")}; -static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", - "Time spent responding to temporary texture asset http requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", - "Time spent responding to temporary texture asset udp requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", - "Time spent responding to texture asset http requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", - "Time spent responding to texture asset udp requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", - "Time spent responding to wearable asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", - "Time spent responding to sound asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", - "Time spent responding to gesture asset requests"), - LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", - "Time spent responding to other asset requests")}; - // // Target thread is elaborated in the function name. This could // have been something 'templatey' like specializations iterated @@ -577,3 +644,59 @@ cleanup() } // namespace LLViewerAssetStatsFF + +LLViewerAssetStats::AssetRequestType::AssetRequestType() +: enqueued("enqueued"), + dequeued("dequeued"), + resp_count("resp_count"), + resp_min("resp_min"), + resp_max("resp_max"), + resp_mean("resp_mean") +{} + +LLViewerAssetStats::FPSStats::FPSStats() +: count("count"), + min("min"), + max("max"), + mean("mean") +{} + +LLViewerAssetStats::RegionStats::RegionStats() +: get_texture_temp_http("get_texture_temp_http"), + get_texture_temp_udp("get_texture_temp_udp"), + get_texture_non_temp_http("get_texture_non_temp_http"), + get_texture_non_temp_udp("get_texture_non_temp_udp"), + get_wearable_udp("get_wearable_udp"), + get_sound_udp("get_sound_udp"), + get_gesture_udp("get_gesture_udp"), + get_other("get_other"), + fps("fps"), + grid_x("grid_x"), + grid_y("grid_y"), + duration("duration") +{} + +LLViewerAssetStats::AvatarRezState::AvatarRezState() +: cloud("cloud"), + gray("gray"), + textured("textured") +{} + +LLViewerAssetStats::AvatarInfo::AvatarInfo() +: nearby("nearby"), + phase_stats("phase_stats") +{ + +} + +LLViewerAssetStats::AssetStats::AssetStats() +: regions("regions"), + duration("duration"), + avatar("avatar"), + session_id("session_id"), + agent_id("agent_id"), + message("message"), + sequence("sequence"), + initial("initial"), + break_("break") +{} diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index 469609ea1f..2f50c52730 100755 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -91,6 +91,90 @@ public: */ typedef U64 region_handle_t; + struct AssetRequestType : public LLInitParam::Block<AssetRequestType> + { + Mandatory<S32> enqueued, + dequeued, + resp_count; + Mandatory<F64> resp_min, + resp_max, + resp_mean; + + AssetRequestType(); + }; + + struct FPSStats : public LLInitParam::Block<FPSStats> + { + Mandatory<S32> count; + Mandatory<F64> min, + max, + mean; + FPSStats(); + }; + + struct RegionStats : public LLInitParam::Block<RegionStats> + { + Optional<LLInitParam::Flag> empty; + Optional<AssetRequestType> get_texture_temp_http, + get_texture_temp_udp, + get_texture_non_temp_http, + get_texture_non_temp_udp, + get_wearable_udp, + get_sound_udp, + get_gesture_udp, + get_other; + Optional<FPSStats> fps; + Optional<S32> grid_x, + grid_y; + Optional<F64> duration; + + RegionStats(); + }; + + struct AvatarRezState : public LLInitParam::Block<AvatarRezState> + { + Mandatory<S32> cloud, + gray, + textured; + AvatarRezState(); + }; + + struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats> + { + Mandatory<LLSD> cloud, + cloud_or_gray; + + AvatarPhaseStats() + : cloud("cloud"), + cloud_or_gray("cloud-or-gray") + {} + }; + + struct AvatarInfo : public LLInitParam::Block<AvatarInfo> + { + Optional<AvatarRezState> nearby; + Optional<AvatarPhaseStats> phase_stats; + + AvatarInfo(); + }; + + struct AssetStats : public LLInitParam::Block<AssetStats> + { + Multiple<RegionStats> regions; + Mandatory<F64> duration; + Mandatory<AvatarInfo> avatar; + + Mandatory<LLUUID> session_id, + agent_id; + + Mandatory<std::string> message; + Mandatory<S32> sequence; + Mandatory<bool> initial, + break_; + + AssetStats(); + }; + public: LLViewerAssetStats(); LLViewerAssetStats(const LLViewerAssetStats &); @@ -146,11 +230,7 @@ public: // } // } // - // @param compact_output If true, omits from conversion any mmm_block - // or stats_block that would contain all zero data. - // Useful for transmission when the receiver knows - // what is expected and will assume zero for missing - // blocks. + void getStats(AssetStats& stats, bool compact_output); LLSD asLLSD(bool compact_output); protected: diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 03cc9b12e3..04b0c30b40 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -128,7 +128,8 @@ SimMeasurement<> SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DIL SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS), SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS); -LLTrace::Measurement<> NUM_IMAGES("numimagesstat"), +LLTrace::Measurement<> FPS_SAMPLE("fpssample"), + NUM_IMAGES("numimagesstat"), NUM_RAW_IMAGES("numrawimagesstat"), NUM_OBJECTS("numobjectsstat"), NUM_ACTIVE_OBJECTS("numactiveobjectsstat"), @@ -343,6 +344,7 @@ void update_statistics() } LLStatViewer::FPS.add(1); + LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS)); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits); LLStatViewer::OBJECT_KBIT.add(gObjectData); diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 78c4b89f71..34731481f5 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -127,7 +127,8 @@ extern SimMeasurement<> SIM_TIME_DILATION, SIM_PHYSICS_PINNED_TASKS, SIM_PHYSICS_LOD_TASKS; -extern LLTrace::Measurement<> NUM_IMAGES, +extern LLTrace::Measurement<> FPS_SAMPLE, + NUM_IMAGES, NUM_RAW_IMAGES, NUM_OBJECTS, NUM_ACTIVE_OBJECTS, diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index e0126ce8d3..f9d30408ac 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -37,6 +37,11 @@ #include "llregionhandle.h" #include "../llvoavatar.h" +namespace LLStatViewer +{ + LLTrace::Measurement<> FPS_SAMPLE("fpssample"); +} + void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts) { counts.resize(3); @@ -241,7 +246,7 @@ namespace tut void tst_viewerassetstats_index_object_t::test<1>() { // Check that helpers aren't bothered by missing global stats - ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain)); + ensure("Global gViewerAssetStats should be NULL", (NULL == gViewerAssetStats)); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); @@ -254,11 +259,11 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<2>() { - ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain)); + ensure("Global gViewerAssetStats should be NULL", (NULL == gViewerAssetStats)); LLViewerAssetStats * it = new LLViewerAssetStats(); - ensure("Global gViewerAssetStatsMain should still be NULL", (NULL == gViewerAssetStatsMain)); + ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats)); LLSD sd_full = it->asLLSD(false); @@ -325,7 +330,7 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<4>() { - gViewerAssetStatsMain = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); LLViewerAssetStatsFF::set_region(region1_handle); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); @@ -334,7 +339,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLSD sd = gViewerAssetStatsMain->asLLSD(false); + LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); sd = sd["regions"][0]; @@ -348,11 +353,11 @@ namespace tut // Reset and check zeros... // Reset leaves current region in place - gViewerAssetStatsMain->reset(); - sd = gViewerAssetStatsMain->asLLSD(false)["regions"][region1_handle_str]; + gViewerAssetStats->reset(); + sd = gViewerAssetStats->asLLSD(false)["regions"][region1_handle_str]; - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = NULL; + delete gViewerAssetStats; + gViewerAssetStats = NULL; ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger())); @@ -362,8 +367,7 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<5>() { - gViewerAssetStatsThread1 = new LLViewerAssetStats(); - gViewerAssetStatsMain = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); LLViewerAssetStatsFF::set_region(region1_handle); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); @@ -372,9 +376,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); - LLSD sd = gViewerAssetStatsThread1->asLLSD(false); - ensure("Other collector is empty", is_no_stats_map(sd)); - sd = gViewerAssetStatsMain->asLLSD(false); + LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); sd = sd["regions"][0]; @@ -388,11 +390,11 @@ namespace tut // Reset and check zeros... // Reset leaves current region in place - gViewerAssetStatsMain->reset(); - sd = gViewerAssetStatsMain->asLLSD(false)["regions"][0]; + gViewerAssetStats->reset(); + sd = gViewerAssetStats->asLLSD(false)["regions"][0]; - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = NULL; + delete gViewerAssetStats; + gViewerAssetStats = NULL; ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger())); @@ -402,7 +404,7 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<6>() { - gViewerAssetStatsMain = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); LLViewerAssetStatsFF::set_region(region1_handle); @@ -419,7 +421,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); - LLSD sd = gViewerAssetStatsMain->asLLSD(false); + LLSD sd = gViewerAssetStats->asLLSD(false); // std::cout << sd << std::endl; @@ -444,14 +446,14 @@ namespace tut // Reset and check zeros... // Reset leaves current region in place - gViewerAssetStatsMain->reset(); - sd = gViewerAssetStatsMain->asLLSD(false); + gViewerAssetStats->reset(); + sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle)); sd2 = sd["regions"][0]; - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = NULL; + delete gViewerAssetStats; + gViewerAssetStats = NULL; ensure("sd2[get_texture_non_temp_udp][enqueued] is reset", (0 == sd2["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd2[get_gesture_udp][enqueued] is reset", (0 == sd2["get_gesture_udp"]["enqueued"].asInteger())); @@ -461,7 +463,7 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<7>() { - gViewerAssetStatsMain = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); LLViewerAssetStatsFF::set_region(region1_handle); @@ -493,7 +495,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); - LLSD sd = gViewerAssetStatsMain->asLLSD(false); + LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar")); ensure("Correct double-slot LLSD array regions", is_double_slot_array(sd["regions"], region1_handle, region2_handle)); @@ -502,6 +504,8 @@ namespace tut ensure("Region1 is present in results", sd1.isMap()); ensure("Region2 is present in results", sd2.isMap()); + llinfos << ll_pretty_print_sd(sd1) << llendl; + // Check a few points on the tree for content ensure("sd1[get_texture_non_temp_udp][enqueued] is 1", (1 == sd1["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd1[get_texture_temp_udp][enqueued] is 0", (0 == sd1["get_texture_temp_udp"]["enqueued"].asInteger())); @@ -516,15 +520,15 @@ namespace tut // Reset and check zeros... // Reset leaves current region in place - gViewerAssetStatsMain->reset(); - sd = gViewerAssetStatsMain->asLLSD(false); + gViewerAssetStats->reset(); + sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar")); ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle)); sd2 = get_region(sd, region2_handle); ensure("Region2 is present in results", sd2.isMap()); - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = NULL; + delete gViewerAssetStats; + gViewerAssetStats = NULL; ensure_equals("sd2[get_texture_non_temp_udp][enqueued] is reset", sd2["get_texture_non_temp_udp"]["enqueued"].asInteger(), 0); ensure_equals("sd2[get_gesture_udp][enqueued] is reset", sd2["get_gesture_udp"]["enqueued"].asInteger(), 0); @@ -534,8 +538,7 @@ namespace tut template<> template<> void tst_viewerassetstats_index_object_t::test<8>() { - gViewerAssetStatsThread1 = new LLViewerAssetStats(); - gViewerAssetStatsMain = new LLViewerAssetStats(); + gViewerAssetStats = new LLViewerAssetStats(); LLViewerAssetStatsFF::set_region(region1_handle); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false); @@ -561,9 +564,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - LLSD sd = gViewerAssetStatsThread1->asLLSD(false); - ensure("Other collector is empty", is_no_stats_map(sd)); - sd = gViewerAssetStatsMain->asLLSD(false); + LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); sd = get_region(sd, region1_handle); @@ -581,445 +582,14 @@ namespace tut // Reset and check zeros... // Reset leaves current region in place - gViewerAssetStatsMain->reset(); - sd = get_region(gViewerAssetStatsMain->asLLSD(false), region1_handle); + gViewerAssetStats->reset(); + sd = get_region(gViewerAssetStats->asLLSD(false), region1_handle); ensure("Region1 is present in results", sd.isMap()); - delete gViewerAssetStatsMain; - gViewerAssetStatsMain = NULL; - delete gViewerAssetStatsThread1; - gViewerAssetStatsThread1 = NULL; + delete gViewerAssetStats; + gViewerAssetStats = NULL; ensure_equals("sd[get_texture_non_temp_udp][enqueued] is reset", sd["get_texture_non_temp_udp"]["enqueued"].asInteger(), 0); ensure_equals("sd[get_gesture_udp][dequeued] is reset", sd["get_gesture_udp"]["dequeued"].asInteger(), 0); } - - - // LLViewerAssetStats::merge() basic functions work - template<> template<> - void tst_viewerassetstats_index_object_t::test<9>() - { - LLViewerAssetStats s1; - LLViewerAssetStats s2; - - s1.setRegion(region1_handle); - s2.setRegion(region1_handle); - - s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 5000000); - s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 6000000); - s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 8000000); - s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 7000000); - s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 9000000); - - s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 2000000); - s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 3000000); - s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 4000000); - - s2.merge(s1); - - LLSD s2_llsd = get_region(s2.asLLSD(false), region1_handle); - ensure("Region1 is present in results", s2_llsd.isMap()); - - ensure_equals("count after merge", s2_llsd["get_texture_temp_http"]["resp_count"].asInteger(), 8); - ensure_approximately_equals("min after merge", s2_llsd["get_texture_temp_http"]["resp_min"].asReal(), 2.0, 22); - ensure_approximately_equals("max after merge", s2_llsd["get_texture_temp_http"]["resp_max"].asReal(), 9.0, 22); - ensure_approximately_equals("max after merge", s2_llsd["get_texture_temp_http"]["resp_mean"].asReal(), 5.5, 22); - } - - // LLViewerAssetStats::merge() basic functions work without corrupting source data - template<> template<> - void tst_viewerassetstats_index_object_t::test<10>() - { - LLViewerAssetStats s1; - LLViewerAssetStats s2; - - s1.setRegion(region1_handle); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900); - - - s2.setRegion(region2_handle); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000); - s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000); - - { - s2.merge(s1); - - LLSD src = s1.asLLSD(false); - LLSD dst = s2.asLLSD(false); - - ensure_equals("merge src has single region", src["regions"].size(), 1); - ensure_equals("merge dst has dual regions", dst["regions"].size(), 2); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - dst["regions"][1].erase("duration"); - - LLSD s1_llsd = get_region(src, region1_handle); - ensure("Region1 is present in src", s1_llsd.isMap()); - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure("result from src is in dst", llsd_equals(s1_llsd, s2_llsd)); - } - - s1.setRegion(region1_handle); - s2.setRegion(region1_handle); - s1.reset(); - s2.reset(); - - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900); - - - s2.setRegion(region1_handle); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000); - s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000); - - { - s2.merge(s1); - - LLSD src = s1.asLLSD(false); - LLSD dst = s2.asLLSD(false); - - ensure_equals("merge src has single region (p2)", src["regions"].size(), 1); - ensure_equals("merge dst has single region (p2)", dst["regions"].size(), 1); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - - LLSD s1_llsd = get_region(src, region1_handle); - ensure("Region1 is present in src", s1_llsd.isMap()); - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure_equals("src counts okay (enq)", s1_llsd["get_other"]["enqueued"].asInteger(), 4); - ensure_equals("src counts okay (deq)", s1_llsd["get_other"]["dequeued"].asInteger(), 4); - ensure_equals("src resp counts okay", s1_llsd["get_other"]["resp_count"].asInteger(), 2); - ensure_approximately_equals("src respmin okay", s1_llsd["get_other"]["resp_min"].asReal(), 0.2829, 20); - ensure_approximately_equals("src respmax okay", s1_llsd["get_other"]["resp_max"].asReal(), 23.2892, 20); - - ensure_equals("dst counts okay (enq)", s2_llsd["get_other"]["enqueued"].asInteger(), 12); - ensure_equals("src counts okay (deq)", s2_llsd["get_other"]["dequeued"].asInteger(), 11); - ensure_equals("dst resp counts okay", s2_llsd["get_other"]["resp_count"].asInteger(), 4); - ensure_approximately_equals("dst respmin okay", s2_llsd["get_other"]["resp_min"].asReal(), 0.010, 20); - ensure_approximately_equals("dst respmax okay", s2_llsd["get_other"]["resp_max"].asReal(), 23.2892, 20); - } - } - - - // Maximum merges are interesting when one side contributes nothing - template<> template<> - void tst_viewerassetstats_index_object_t::test<11>() - { - LLViewerAssetStats s1; - LLViewerAssetStats s2; - - s1.setRegion(region1_handle); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - // Want to test negative numbers here but have to work in U64 - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - - s2.setRegion(region1_handle); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - { - s2.merge(s1); - - LLSD src = s1.asLLSD(false); - LLSD dst = s2.asLLSD(false); - - ensure_equals("merge src has single region", src["regions"].size(), 1); - ensure_equals("merge dst has single region", dst["regions"].size(), 1); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure_equals("dst counts come from src only", s2_llsd["get_other"]["resp_count"].asInteger(), 3); - - ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum", - s2_llsd["get_other"]["resp_max"].asReal(), F64(0.0), 20); - } - - // Other way around - s1.setRegion(region1_handle); - s2.setRegion(region1_handle); - s1.reset(); - s2.reset(); - - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - // Want to test negative numbers here but have to work in U64 - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0); - - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - { - s1.merge(s2); - - LLSD src = s2.asLLSD(false); - LLSD dst = s1.asLLSD(false); - - ensure_equals("merge src has single region", src["regions"].size(), 1); - ensure_equals("merge dst has single region", dst["regions"].size(), 1); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure_equals("dst counts come from src only (flipped)", s2_llsd["get_other"]["resp_count"].asInteger(), 3); - - ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum (flipped)", - s2_llsd["get_other"]["resp_max"].asReal(), F64(0.0), 20); - } - } - - // Minimum merges are interesting when one side contributes nothing - template<> template<> - void tst_viewerassetstats_index_object_t::test<12>() - { - LLViewerAssetStats s1; - LLViewerAssetStats s2; - - s1.setRegion(region1_handle); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000); - - s2.setRegion(region1_handle); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - { - s2.merge(s1); - - LLSD src = s1.asLLSD(false); - LLSD dst = s2.asLLSD(false); - - ensure_equals("merge src has single region", src["regions"].size(), 1); - ensure_equals("merge dst has single region", dst["regions"].size(), 1); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure_equals("dst counts come from src only", s2_llsd["get_other"]["resp_count"].asInteger(), 3); - - ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum", - s2_llsd["get_other"]["resp_min"].asReal(), F64(2.7), 20); - } - - // Other way around - s1.setRegion(region1_handle); - s2.setRegion(region1_handle); - s1.reset(); - s2.reset(); - - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000); - s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000); - - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true); - - { - s1.merge(s2); - - LLSD src = s2.asLLSD(false); - LLSD dst = s1.asLLSD(false); - - ensure_equals("merge src has single region", src["regions"].size(), 1); - ensure_equals("merge dst has single region", dst["regions"].size(), 1); - - // Remove time stamps, they're a problem - src.erase("duration"); - src["regions"][0].erase("duration"); - dst.erase("duration"); - dst["regions"][0].erase("duration"); - - LLSD s2_llsd = get_region(dst, region1_handle); - ensure("Region1 is present in dst", s2_llsd.isMap()); - - ensure_equals("dst counts come from src only (flipped)", s2_llsd["get_other"]["resp_count"].asInteger(), 3); - - ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum (flipped)", - s2_llsd["get_other"]["resp_min"].asReal(), F64(2.7), 20); - } - } - } -- cgit v1.2.3 From b9303e9e80ef5c0992c45b0032a219ce9b57d6e8 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 19 Oct 2012 19:42:23 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system removed spam and dead code --- indra/newview/llviewerassetstats.cpp | 106 ----------------------------------- 1 file changed, 106 deletions(-) diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index 0b820f866e..e4f64f3076 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -454,114 +454,8 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output) AssetStats stats; getStats(stats, compact_output); parser.writeSD(sd, stats); - llinfos << ll_pretty_print_sd(sd) << llendl; return sd; } -//LLSD LLViewerAssetStats::asLLSD(bool compact_output) -//{ -// // Top-level tags -// static const LLSD::String tags[LLViewerAssetStatsFF::EVACCount] = -// { -// LLSD::String("get_texture_temp_http"), -// LLSD::String("get_texture_temp_udp"), -// LLSD::String("get_texture_non_temp_http"), -// LLSD::String("get_texture_non_temp_udp"), -// LLSD::String("get_wearable_udp"), -// LLSD::String("get_sound_udp"), -// LLSD::String("get_gesture_udp"), -// LLSD::String("get_other") -// }; -// -// // Stats Group Sub-tags. -// static const LLSD::String enq_tag("enqueued"); -// static const LLSD::String deq_tag("dequeued"); -// static const LLSD::String rcnt_tag("resp_count"); -// static const LLSD::String rmin_tag("resp_min"); -// static const LLSD::String rmax_tag("resp_max"); -// static const LLSD::String rmean_tag("resp_mean"); -// -// // MMM Group Sub-tags. -// static const LLSD::String cnt_tag("count"); -// static const LLSD::String min_tag("min"); -// static const LLSD::String max_tag("max"); -// static const LLSD::String mean_tag("mean"); -// -// // Avatar sub-tags -// static const LLSD::String avatar_tag("avatar"); -// static const LLSD::String avatar_nearby_tag("nearby"); -// static const LLSD::String avatar_phase_stats_tag("phase_stats"); -// -// const duration_t now = LLViewerAssetStatsFF::get_timestamp(); -// mCurRegionStats->accumulateTime(now); -// -// LLSD regions = LLSD::emptyArray(); -// for (PerRegionContainer::iterator it = mRegionStats.begin(); -// mRegionStats.end() != it; -// ++it) -// { -// if (0 == it->first) -// { -// // Never emit NULL UUID/handle in results. -// continue; -// } -// -// PerRegionStats & stats = *it->second; -// -// LLSD reg_stat = LLSD::emptyMap(); -// -// for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i) -// { -// PerRegionStats::prs_group & group(stats.mRequests[i]); -// -// if ((! compact_output) || -// group.mEnqueued.getCount() || -// group.mDequeued.getCount() || -// group.mResponse.getCount()) -// { -// LLSD & slot = reg_stat[tags[i]]; -// slot = LLSD::emptyMap(); -// slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount())); -// slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount())); -// slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount())); -// slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6)); -// slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6)); -// slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6)); -// } -// } -// -// if ((! compact_output) || stats.mFPS.getCount()) -// { -// LLSD & slot = reg_stat["fps"]; -// slot = LLSD::emptyMap(); -// slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount())); -// slot[min_tag] = LLSD(F64(stats.mFPS.getMin())); -// slot[max_tag] = LLSD(F64(stats.mFPS.getMax())); -// slot[mean_tag] = LLSD(F64(stats.mFPS.getMean())); -// } -// U32 grid_x(0), grid_y(0); -// grid_from_region_handle(it->first, &grid_x, &grid_y); -// reg_stat["grid_x"] = LLSD::Integer(grid_x); -// reg_stat["grid_y"] = LLSD::Integer(grid_y); -// reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6); -// regions.append(reg_stat); -// } -// -// LLSD ret = LLSD::emptyMap(); -// ret["regions"] = regions; -// ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6); -// LLSD avatar_info; -// avatar_info[avatar_nearby_tag] = LLSD::emptyArray(); -// for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) -// { -// std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat); -// avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat]; -// } -// avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD(); -// avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD(); -// ret[avatar_tag] = avatar_info; -// -// return ret; -//} // ------------------------------------------------------ // Global free-function definitions (LLViewerAssetStatsFF namespace) -- cgit v1.2.3 From bfe85fb24b30a24e08b48fdb2c734da0143fe845 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sat, 20 Oct 2012 10:46:57 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed build --- indra/newview/lltexturefetch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index ac83fe0ca8..2a72e77672 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2880,7 +2880,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) LLViewerAssetStats & main_stats = *mMainStats; LLViewerAssetStats::AssetStats stats; - main_stats.getStats(stats); + main_stats.getStats(stats, true); //LLSD merged_llsd = main_stats.asLLSD(); stats.session_id = mSessionID; -- cgit v1.2.3 From d8a83466deb4ce7eab047ab6e0c4a6aeee40982c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 22 Oct 2012 10:42:26 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system removed spam and dead code --- indra/newview/tests/llviewerassetstats_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index f9d30408ac..fc5cd781e6 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -504,8 +504,6 @@ namespace tut ensure("Region1 is present in results", sd1.isMap()); ensure("Region2 is present in results", sd2.isMap()); - llinfos << ll_pretty_print_sd(sd1) << llendl; - // Check a few points on the tree for content ensure("sd1[get_texture_non_temp_udp][enqueued] is 1", (1 == sd1["get_texture_non_temp_udp"]["enqueued"].asInteger())); ensure("sd1[get_texture_temp_udp][enqueued] is 0", (0 == sd1["get_texture_temp_udp"]["enqueued"].asInteger())); -- cgit v1.2.3 From d6634fcd2433e18eea1a9bf31da6d7e531817d77 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 22 Oct 2012 19:54:10 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system sanitized param block code to accept isValid and isProvided at any point added predicates to control serialization --- indra/llcommon/CMakeLists.txt | 2 + indra/llcommon/llinitparam.cpp | 35 +++++-- indra/llcommon/llinitparam.h | 221 ++++++++++++++++++++++++++--------------- indra/llcommon/llpredicate.cpp | 33 ++++++ indra/llcommon/llpredicate.h | 173 ++++++++++++++++++++++++++++++++ indra/llcommon/llsdparam.cpp | 2 +- 6 files changed, 376 insertions(+), 90 deletions(-) create mode 100644 indra/llcommon/llpredicate.cpp create mode 100644 indra/llcommon/llpredicate.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index c0e9266aa9..d876842cf1 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -77,6 +77,7 @@ set(llcommon_SOURCE_FILES llmutex.cpp lloptioninterface.cpp llptrto.cpp + llpredicate.cpp llprocess.cpp llprocessor.cpp llqueuedthread.cpp @@ -205,6 +206,7 @@ set(llcommon_HEADER_FILES llnametable.h lloptioninterface.h llpointer.h + llpredicate.h llpreprocessor.h llpriqueuemap.h llprocess.h diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index 54e98e66f3..a63e792925 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -164,24 +164,37 @@ namespace LLInitParam bool BaseBlock::validateBlock(bool emit_errors) const { - const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); - for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it) + // only validate block when it hasn't already passed validation with current data + if (!mValidated) { - const Param* param = getParamFromHandle(it->first); - if (!it->second(param)) + const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); + for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it) { - if (emit_errors) + const Param* param = getParamFromHandle(it->first); + if (!it->second(param)) { - llwarns << "Invalid param \"" << getParamName(block_data, param) << "\"" << llendl; + if (emit_errors) + { + llwarns << "Invalid param \"" << getParamName(block_data, param) << "\"" << llendl; + } + return false; } - return false; } + mValidated = true; } - return true; + return mValidated; } - void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const + void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const LLInitParam::BaseBlock* diff_block) const { + if (!isProvided()) + { + if ((~predicate_rule_t(PROVIDED) && predicate_rule).isTriviallyFalse()) + { + return; + } + } + // named param is one like LLView::Params::follows // unnamed param is like LLView::Params::rect - implicit const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); @@ -196,7 +209,7 @@ namespace LLInitParam if (serialize_func) { const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; - serialize_func(*param, parser, name_stack, diff_param); + serialize_func(*param, parser, name_stack, predicate_rule, diff_param); } } @@ -232,7 +245,7 @@ namespace LLInitParam name_stack.push_back(std::make_pair(it->first, !duplicate)); const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; - serialize_func(*param, parser, name_stack, diff_param); + serialize_func(*param, parser, name_stack, predicate_rule, diff_param); name_stack.pop_back(); } } diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index b7607e91b9..18c9669fba 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -32,10 +32,11 @@ #include <boost/function.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/unordered_map.hpp> -#include <boost/shared_ptr.hpp> +//#include <boost/shared_ptr.hpp> #include "llerror.h" #include "llstl.h" +#include "llpredicate.h" namespace LLInitParam { @@ -211,7 +212,6 @@ namespace LLInitParam LOG_CLASS(Parser); public: - typedef std::vector<std::pair<std::string, bool> > name_stack_t; typedef std::pair<name_stack_t::iterator, name_stack_t::iterator> name_stack_range_t; typedef std::vector<std::string> possible_values_t; @@ -293,6 +293,17 @@ namespace LLInitParam class Param; + enum ESerializePredicates + { + PROVIDED, + REQUIRED, + VALID, + NON_DEFAULT + }; + + typedef LLPredicate::Rule<ESerializePredicates> predicate_rule_t; + + // various callbacks and constraints associated with an individual param struct LL_COMMON_API ParamDescriptor { @@ -303,8 +314,8 @@ namespace LLInitParam typedef bool(*merge_func_t)(Param&, const Param&, bool); typedef bool(*deserialize_func_t)(Param&, Parser&, const Parser::name_stack_range_t&, bool); - typedef void(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const Param* diff_param); - typedef void(*inspect_func_t)(const Param&, Parser&, Parser::name_stack_t&, S32 min_count, S32 max_count); + typedef void(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const predicate_rule_t, const Param*); + typedef void(*inspect_func_t)(const Param&, Parser&, Parser::name_stack_t&, S32, S32); typedef bool(*validation_func_t)(const Param*); ParamDescriptor(param_handle_t p, @@ -331,7 +342,7 @@ namespace LLInitParam UserData* mUserData; }; - typedef boost::shared_ptr<ParamDescriptor> ParamDescriptorPtr; + typedef ParamDescriptor* ParamDescriptorPtr; // each derived Block class keeps a static data structure maintaining offsets to various params class LL_COMMON_API BlockDescriptor @@ -484,12 +495,28 @@ namespace LLInitParam LOG_CLASS(BaseBlock); friend class Param; + BaseBlock() + : mValidated(false), + mParamProvided(false) + {} + virtual ~BaseBlock() {} bool submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent=false); param_handle_t getHandleFromParam(const Param* param) const; bool validateBlock(bool emit_errors = true) const; + bool isProvided() const + { + return mParamProvided; + } + + bool isValid() const + { + return validateBlock(false); + } + + Param* getParamFromHandle(const param_handle_t param_handle) { if (param_handle == 0) return NULL; @@ -507,10 +534,19 @@ namespace LLInitParam void addSynonym(Param& param, const std::string& synonym); // Blocks can override this to do custom tracking of changes - virtual void paramChanged(const Param& changed_param, bool user_provided) {} + virtual void paramChanged(const Param& changed_param, bool user_provided) + { + if (user_provided) + { + // a child param has been explicitly changed + // so *some* aspect of this block is now provided + mValidated = false; + mParamProvided = true; + } + } bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; + void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule = predicate_rule_t(), const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const; virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return selfBlockDescriptor(); } @@ -549,6 +585,9 @@ namespace LLInitParam return sBlockDescriptor; } + mutable bool mValidated; // lazy validation flag + bool mParamProvided; + private: const std::string& getParamName(const BlockDescriptor& block_data, const Param* paramp) const; }; @@ -688,13 +727,11 @@ namespace LLInitParam typedef ParamValue<T, NAME_VALUE_LOOKUP, true> self_t; ParamValue() - : T(), - mValidated(false) + : T() {} ParamValue(value_assignment_t other) - : T(other), - mValidated(false) + : T(other) {} void setValue(value_assignment_t val) @@ -736,9 +773,6 @@ namespace LLInitParam return *this; } - - protected: - mutable bool mValidated; // lazy validation flag }; template<typename NAME_VALUE_LOOKUP> @@ -836,6 +870,8 @@ namespace LLInitParam bool isProvided() const { return Param::anyProvided(); } + bool isValid() const { return true; } + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { self_t& typed_param = static_cast<self_t&>(param); @@ -870,10 +906,26 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + const self_t* diff_typed_param = static_cast<const self_t*>(diff_param); + + LLPredicate::Value<ESerializePredicates> predicate; + if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) + { + predicate.set(NON_DEFAULT); + } + if (typed_param.isValid()) + { + predicate.set(VALID); + if (typed_param.anyProvided()) + { + predicate.set(PROVIDED); + } + } + + if (!predicate_rule.check(predicate)) return; if (!name_stack.empty()) { @@ -886,18 +938,18 @@ namespace LLInitParam if (!key.empty()) { - if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), key)) + if (!diff_typed_param || !ParamCompare<std::string>::equals(diff_typed_param->getValueName(), key)) { parser.writeValue(key, name_stack); } } // then try to serialize value directly - else if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), static_cast<const self_t*>(diff_param)->getValue())) + else if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) { if (!parser.writeValue(typed_param.getValue(), name_stack)) { std::string calculated_key = typed_param.calcValueName(typed_param.getValue()); - if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), calculated_key)) + if (!diff_typed_param || !ParamCompare<std::string>::equals(diff_typed_param->getValueName(), calculated_key)) { parser.writeValue(calculated_key, name_stack); } @@ -1014,10 +1066,26 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + const self_t* diff_typed_param = static_cast<const self_t*>(diff_param); + + LLPredicate::Value<ESerializePredicates> predicate; + if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) + { + predicate.set(NON_DEFAULT); + } + if (typed_param.isValid()) + { + predicate.set(VALID); + if (typed_param.anyProvided()) + { + predicate.set(PROVIDED); + } + } + + if (!predicate_rule.check(predicate)) return; if (!name_stack.empty()) { @@ -1034,7 +1102,7 @@ namespace LLInitParam } else { - typed_param.serializeBlock(parser, name_stack, static_cast<const self_t*>(diff_param)); + typed_param.serializeBlock(parser, name_stack, predicate_rule, static_cast<const self_t*>(diff_param)); } } @@ -1049,23 +1117,16 @@ namespace LLInitParam // *and* the block as a whole validates bool isProvided() const { - // only validate block when it hasn't already passed validation with current data - if (Param::anyProvided() && !param_value_t::mValidated) - { - // a sub-block is "provided" when it has been filled in enough to be valid - param_value_t::mValidated = param_value_t::validateBlock(false); - } - return Param::anyProvided() && param_value_t::mValidated; + return Param::anyProvided() && isValid(); } + using param_value_t::isValid; + // assign block contents to this param-that-is-a-block void set(value_assignment_t val, bool flag_as_provided = true) { setValue(val); param_value_t::clearValueName(); - // force revalidation of block - // next call to isProvided() will update provision status based on validity - param_value_t::mValidated = false; setProvided(flag_as_provided); } @@ -1080,9 +1141,6 @@ namespace LLInitParam param_value_t::paramChanged(changed_param, user_provided); if (user_provided) { - // a child param has been explicitly changed - // so *some* aspect of this block is now provided - param_value_t::mValidated = false; setProvided(); param_value_t::clearValueName(); } @@ -1134,7 +1192,9 @@ namespace LLInitParam typedef NAME_VALUE_LOOKUP name_value_lookup_t; TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) - : Param(block_descriptor.mCurrentBlockPtr) + : Param(block_descriptor.mCurrentBlockPtr), + mMinCount(min_count), + mMaxCount(max_count) { std::copy(value.begin(), value.end(), std::back_inserter(mValues)); @@ -1152,7 +1212,13 @@ namespace LLInitParam } } - bool isProvided() const { return Param::anyProvided(); } + bool isProvided() const { return Param::anyProvided() && isValid(); } + + bool isValid() const + { + size_t num_elements = numValidElements(); + return mMinCount < num_elements && num_elements < mMaxCount; + } static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { @@ -1197,7 +1263,7 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); if (!typed_param.isProvided()) return; @@ -1293,7 +1359,7 @@ namespace LLInitParam bool empty() const { return mValues.empty(); } size_t size() const { return mValues.size(); } - U32 numValidElements() const + size_t numValidElements() const { return mValues.size(); } @@ -1323,6 +1389,8 @@ namespace LLInitParam } container_t mValues; + size_t mMinCount, + mMaxCount; }; // container of block parameters @@ -1339,7 +1407,9 @@ namespace LLInitParam typedef NAME_VALUE_LOOKUP name_value_lookup_t; TypedParam(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) - : Param(block_descriptor.mCurrentBlockPtr) + : Param(block_descriptor.mCurrentBlockPtr), + mMinCount(min_count), + mMaxCount(max_count) { std::copy(value.begin(), value.end(), back_inserter(mValues)); @@ -1357,7 +1427,14 @@ namespace LLInitParam } } - bool isProvided() const { return Param::anyProvided(); } + bool isProvided() const { return Param::anyProvided() && isValid(); } + + bool isValid() const + { + size_t num_elements = numValidElements(); + return mMinCount < num_elements && num_elements < mMaxCount; + } + static bool deserializeParam(Param& param, Parser& parser, const Parser::name_stack_range_t& name_stack_range, bool new_name) { @@ -1420,9 +1497,13 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); + + LLPredicate::Value<ESerializePredicates> predicate_value; + if (typed_param.isProvided()) predicate_value.set(PROVIDED); + if (!typed_param.isProvided()) return; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); @@ -1437,10 +1518,10 @@ namespace LLInitParam parser.writeValue(key, name_stack); } // Not parsed via named values, write out value directly - // NOTE: currently we don't worry about removing default values in Multiple + // NOTE: currently we don't do diffing of Multiples else { - it->serializeBlock(parser, name_stack, NULL); + it->serializeBlock(parser, name_stack, predicate_rule, NULL); } name_stack.pop_back(); @@ -1500,14 +1581,14 @@ namespace LLInitParam bool empty() const { return mValues.empty(); } size_t size() const { return mValues.size(); } - U32 numValidElements() const + size_t numValidElements() const { - U32 count = 0; + size_t count = 0; for (const_iterator it = mValues.begin(), end_it = mValues.end(); it != end_it; ++it) { - if(it->validateBlock(false)) count++; + if(it->isValid()) count++; } return count; } @@ -1539,6 +1620,8 @@ namespace LLInitParam } container_t mValues; + size_t mMinCount, + mMaxCount; }; template <typename DERIVED_BLOCK, typename BASE_BLOCK = BaseBlock> @@ -1826,7 +1909,7 @@ namespace LLInitParam static bool validate(const Param* paramp) { - U32 num_valid = ((super_t*)paramp)->numValidElements(); + size_t num_valid = ((super_t*)paramp)->numValidElements(); return RANGE::minCount <= num_valid && num_valid <= RANGE::maxCount; } }; @@ -1943,13 +2026,11 @@ namespace LLInitParam typedef block_t value_t; ParamValue() - : block_t(), - mValidated(false) + : block_t() {} ParamValue(value_assignment_t other) - : block_t(other), - mValidated(false) + : block_t(other) { } @@ -1977,9 +2058,6 @@ namespace LLInitParam { return *this; } - - protected: - mutable bool mValidated; // lazy validation flag }; template<typename T, bool IS_BLOCK> @@ -1994,13 +2072,11 @@ namespace LLInitParam typedef T value_t; ParamValue() - : mValue(), - mValidated(false) + : mValue() {} ParamValue(value_assignment_t other) - : mValue(other), - mValidated(false) + : mValue(other) {} void setValue(value_assignment_t val) @@ -2033,11 +2109,11 @@ namespace LLInitParam return mValue.get().deserializeBlock(p, name_stack_range, new_name); } - void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const + void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block = NULL) const { if (mValue.empty()) return; - mValue.get().serializeBlock(p, name_stack, diff_block); + mValue.get().serializeBlock(p, name_stack, predicate_rule, diff_block); } bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const @@ -2047,9 +2123,6 @@ namespace LLInitParam return mValue.get().inspectBlock(p, name_stack, min_count, max_count); } - protected: - mutable bool mValidated; // lazy validation flag - private: BaseBlock::Lazy<T> mValue; }; @@ -2066,12 +2139,10 @@ namespace LLInitParam typedef const LLSD& value_assignment_t; ParamValue() - : mValidated(false) {} ParamValue(value_assignment_t other) - : mValue(other), - mValidated(false) + : mValue(other) {} void setValue(value_assignment_t val) { mValue = val; } @@ -2085,16 +2156,13 @@ namespace LLInitParam // block param interface LL_COMMON_API bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - LL_COMMON_API void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; + LL_COMMON_API void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const { //TODO: implement LLSD params as schema type Any return true; } - protected: - mutable bool mValidated; // lazy validation flag - private: static void serializeElement(Parser& p, const LLSD& sd, Parser::name_stack_t& name_stack); @@ -2123,8 +2191,7 @@ namespace LLInitParam CustomParamValue(const T& value = T()) : mValue(value), - mValueAge(VALUE_AUTHORITATIVE), - mValidated(false) + mValueAge(VALUE_AUTHORITATIVE) {} bool deserializeBlock(Parser& parser, Parser::name_stack_range_t name_stack_range, bool new_name) @@ -2148,7 +2215,7 @@ namespace LLInitParam return typed_param.BaseBlock::deserializeBlock(parser, name_stack_range, new_name); } - void serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const + void serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block = NULL) const { const derived_t& typed_param = static_cast<const derived_t&>(*this); const derived_t* diff_param = static_cast<const derived_t*>(diff_block); @@ -2184,11 +2251,11 @@ namespace LLInitParam // and serialize those params derived_t copy(typed_param); copy.updateBlockFromValue(true); - copy.block_t::serializeBlock(parser, name_stack, NULL); + copy.block_t::serializeBlock(parser, name_stack, predicate_rule, NULL); } else { - block_t::serializeBlock(parser, name_stack, NULL); + block_t::serializeBlock(parser, name_stack, predicate_rule, NULL); } } } @@ -2309,8 +2376,6 @@ namespace LLInitParam return block_t::mergeBlock(block_data, source, overwrite); } - mutable bool mValidated; // lazy validation flag - private: mutable T mValue; mutable EValueAge mValueAge; diff --git a/indra/llcommon/llpredicate.cpp b/indra/llcommon/llpredicate.cpp new file mode 100644 index 0000000000..8dcd9247b7 --- /dev/null +++ b/indra/llcommon/llpredicate.cpp @@ -0,0 +1,33 @@ +/** + * @file llpredicate.cpp + * @brief abstraction for filtering objects by predicates, with arbitrary boolean expressions + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llpredicate.h" + +namespace LLPredicate +{ + EmptyRule make_rule() { return EmptyRule(); } +} diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h new file mode 100644 index 0000000000..ad5ab363fa --- /dev/null +++ b/indra/llcommon/llpredicate.h @@ -0,0 +1,173 @@ +/** + * @file llpredicate.h + * @brief abstraction for filtering objects by predicates, with arbitrary boolean expressions + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPREDICATE_H +#define LL_LLPREDICATE_H + +#include "llerror.h" + +namespace LLPredicate +{ + template<typename ENUM> class Rule; + + template<typename ENUM> + struct Value + { + friend Rule<ENUM>; + public: + Value(ENUM e) + : mPredicateFlags(0x1), + mPredicateCombinationFlags(0x1) + { + set(e); + } + + Value() + : mPredicateFlags(0x1), + mPredicateCombinationFlags(0x1) + {} + + void set(ENUM predicate) + { + llassert(predicate <= 5); + int predicate_flag = 0x1 << (0x1 << (int)predicate); + if (!(mPredicateFlags & predicate_flag)) + { + mPredicateCombinationFlags *= predicate_flag; + mPredicateFlags |= predicate_flag; + } + } + + bool get(ENUM predicate) + { + int predicate_flag = 0x1 << (0x1 << (int)predicate); + return (mPredicateFlags & predicate_flag) != 0; + } + + void clear(ENUM predicate) + { + llassert(predicate <= 5); + int predicate_flag = 0x1 << (0x1 << (int)predicate); + if (mPredicateFlags & predicate_flag) + { + mPredicateCombinationFlags /= predicate_flag; + mPredicateFlags &= ~predicate_flag; + } + } + + private: + int mPredicateCombinationFlags; + int mPredicateFlags; + }; + + struct EmptyRule {}; + + template<typename ENUM> + class Rule + { + public: + Rule(EmptyRule e) + : mPredicateRequirements(0x1) + {} + + Rule(ENUM value) + : mPredicateRequirements(predicateFromValue(value)) + {} + + Rule() + : mPredicateRequirements(0x1) + {} + + Rule operator~() + { + Rule new_rule; + new_rule.mPredicateRequirements = ~mPredicateRequirements; + return new_rule; + } + + Rule operator &&(const Rule& other) + { + Rule new_rule; + new_rule.mPredicateRequirements = mPredicateRequirements & other.mPredicateRequirements; + return new_rule; + } + + Rule operator ||(const Rule& other) + { + Rule new_rule; + new_rule.mPredicateRequirements = mPredicateRequirements | other.mPredicateRequirements; + return new_rule; + } + + bool check(const Value<ENUM>& value) const + { + return ((value.mPredicateCombinationFlags | 0x1) & mPredicateRequirements) != 0; + } + + static int predicateFromValue(ENUM value) + { + int countdown = value; + bool bit_val = false; + + int predicate = 0x0; + + for (int bit_index = 0; bit_index < 32; bit_index++) + { + if (bit_val) + { + predicate |= 0x1 << bit_index; + } + + if (countdown-- == 0) + { + countdown = value; + bit_val = !bit_val; + } + } + return predicate; + } + + bool isTriviallyTrue() const + { + return mPredicateRequirements & 0x1; + } + + bool isTriviallyFalse() const + { + return mPredicateRequirements == 0; + } + + private: + int mPredicateRequirements; + }; + + template<typename ENUM> + Rule<ENUM> make_rule(ENUM e) { return Rule<ENUM>(e);} + + EmptyRule make_rule(); + +} +#endif // LL_LLPREDICATE_H diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 4b8a8dba5c..713f5ac605 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -329,7 +329,7 @@ namespace LLInitParam p.writeValue<LLSD::String>(sd.asString(), name_stack); } - void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const + void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const BaseBlock* diff_block) const { // attempt to write LLSD out directly if (!p.writeValue<LLSD>(mValue, name_stack)) -- cgit v1.2.3 From 50ad343366f5e18ced40e24e2a1cc2399411c7e5 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 22 Oct 2012 22:46:45 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system added return value to serialize function to track if any values were written --- indra/llcommon/llinitparam.cpp | 14 ++++--- indra/llcommon/llinitparam.h | 84 ++++++++++++++++++++++++++---------------- indra/llcommon/llsdparam.cpp | 3 +- 3 files changed, 64 insertions(+), 37 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index 54e98e66f3..d6326a7c11 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -180,8 +180,9 @@ namespace LLInitParam return true; } - void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const + bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const { + bool serialized = false; // named param is one like LLView::Params::follows // unnamed param is like LLView::Params::rect - implicit const BlockDescriptor& block_data = mostDerivedBlockDescriptor(); @@ -193,10 +194,10 @@ namespace LLInitParam param_handle_t param_handle = (*it)->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = (*it)->mSerializeFunc; - if (serialize_func) + if (serialize_func && param->anyProvided()) { const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; - serialize_func(*param, parser, name_stack, diff_param); + serialized |= serialize_func(*param, parser, name_stack, diff_param); } } @@ -232,10 +233,13 @@ namespace LLInitParam name_stack.push_back(std::make_pair(it->first, !duplicate)); const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; - serialize_func(*param, parser, name_stack, diff_param); + serialized |= serialize_func(*param, parser, name_stack, diff_param); name_stack.pop_back(); } } + + // was anything serialized in this block? + return serialized; } bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const @@ -354,7 +358,7 @@ namespace LLInitParam } //static - void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name) + void BaseBlock::addParam(BlockDescriptor& block_data, ParamDescriptorPtr in_param, const char* char_name) { // create a copy of the param descriptor in mAllParams // so other data structures can store a pointer to it diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index b7607e91b9..93e24d4040 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -32,10 +32,10 @@ #include <boost/function.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/unordered_map.hpp> -#include <boost/shared_ptr.hpp> #include "llerror.h" #include "llstl.h" +#include "llmemory.h" namespace LLInitParam { @@ -303,7 +303,7 @@ namespace LLInitParam typedef bool(*merge_func_t)(Param&, const Param&, bool); typedef bool(*deserialize_func_t)(Param&, Parser&, const Parser::name_stack_range_t&, bool); - typedef void(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const Param* diff_param); + typedef bool(*serialize_func_t)(const Param&, Parser&, Parser::name_stack_t&, const Param* diff_param); typedef void(*inspect_func_t)(const Param&, Parser&, Parser::name_stack_t&, S32 min_count, S32 max_count); typedef bool(*validation_func_t)(const Param*); @@ -331,7 +331,7 @@ namespace LLInitParam UserData* mUserData; }; - typedef boost::shared_ptr<ParamDescriptor> ParamDescriptorPtr; + typedef ParamDescriptor* ParamDescriptorPtr; // each derived Block class keeps a static data structure maintaining offsets to various params class LL_COMMON_API BlockDescriptor @@ -510,7 +510,7 @@ namespace LLInitParam virtual void paramChanged(const Param& changed_param, bool user_provided) {} bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; + bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const; virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return selfBlockDescriptor(); } @@ -870,10 +870,11 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { + bool serialized = false; const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + if (!typed_param.isProvided()) return false; if (!name_stack.empty()) { @@ -888,21 +889,23 @@ namespace LLInitParam { if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), key)) { - parser.writeValue(key, name_stack); + serialized = parser.writeValue(key, name_stack); } } // then try to serialize value directly else if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), static_cast<const self_t*>(diff_param)->getValue())) { - if (!parser.writeValue(typed_param.getValue(), name_stack)) + serialized = parser.writeValue(typed_param.getValue(), name_stack); + if (!serialized) { std::string calculated_key = typed_param.calcValueName(typed_param.getValue()); if (!diff_param || !ParamCompare<std::string>::equals(static_cast<const self_t*>(diff_param)->getValueName(), calculated_key)) { - parser.writeValue(calculated_key, name_stack); + serialized = parser.writeValue(calculated_key, name_stack); } } } + return serialized; } static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) @@ -1014,10 +1017,10 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + if (!typed_param.isProvided()) return false; if (!name_stack.empty()) { @@ -1027,15 +1030,17 @@ namespace LLInitParam std::string key = typed_param.getValueName(); if (!key.empty()) { - if (!parser.writeValue(key, name_stack)) + if (parser.writeValue(key, name_stack)) { - return; + return true; } } else { - typed_param.serializeBlock(parser, name_stack, static_cast<const self_t*>(diff_param)); + return typed_param.serializeBlock(parser, name_stack, static_cast<const self_t*>(diff_param)); } + + return false; } static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) @@ -1197,10 +1202,11 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { + bool serialized = false; const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + if (!typed_param.isProvided()) return false; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; @@ -1216,7 +1222,11 @@ namespace LLInitParam if (!value_written) { std::string calculated_key = it->calcValueName(it->getValue()); - if (!parser.writeValue(calculated_key, name_stack)) + if (parser.writeValue(calculated_key, name_stack)) + { + serialized = true; + } + else { break; } @@ -1224,7 +1234,11 @@ namespace LLInitParam } else { - if(!parser.writeValue(key, name_stack)) + if(parser.writeValue(key, name_stack)) + { + serialized = true; + } + else { break; } @@ -1232,6 +1246,7 @@ namespace LLInitParam name_stack.pop_back(); } + return serialized; } static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) @@ -1420,10 +1435,11 @@ namespace LLInitParam return false; } - static void serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) + static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const Param* diff_param) { + bool serialized = false; const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return; + if (!typed_param.isProvided()) return false; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; @@ -1434,17 +1450,18 @@ namespace LLInitParam std::string key = it->getValueName(); if (!key.empty()) { - parser.writeValue(key, name_stack); + serialized |= parser.writeValue(key, name_stack); } // Not parsed via named values, write out value directly // NOTE: currently we don't worry about removing default values in Multiple else { - it->serializeBlock(parser, name_stack, NULL); + serialized = it->serializeBlock(parser, name_stack, NULL); } name_stack.pop_back(); } + return serialized; } static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) @@ -2033,11 +2050,11 @@ namespace LLInitParam return mValue.get().deserializeBlock(p, name_stack_range, new_name); } - void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const + bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const { - if (mValue.empty()) return; + if (mValue.empty()) return false; - mValue.get().serializeBlock(p, name_stack, diff_block); + return mValue.get().serializeBlock(p, name_stack, diff_block); } bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const @@ -2085,7 +2102,7 @@ namespace LLInitParam // block param interface LL_COMMON_API bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - LL_COMMON_API void serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; + LL_COMMON_API bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const { //TODO: implement LLSD params as schema type Any @@ -2148,7 +2165,7 @@ namespace LLInitParam return typed_param.BaseBlock::deserializeBlock(parser, name_stack_range, new_name); } - void serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const + bool serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const BaseBlock* diff_block = NULL) const { const derived_t& typed_param = static_cast<const derived_t&>(*this); const derived_t* diff_param = static_cast<const derived_t*>(diff_block); @@ -2160,14 +2177,18 @@ namespace LLInitParam { if (!diff_param || !ParamCompare<std::string>::equals(diff_param->getValueName(), key)) { - parser.writeValue(key, name_stack); + return parser.writeValue(key, name_stack); } } // then try to serialize value directly else if (!diff_param || !ParamCompare<T>::equals(typed_param.getValue(), diff_param->getValue())) { - if (!parser.writeValue(typed_param.getValue(), name_stack)) + if (parser.writeValue(typed_param.getValue(), name_stack)) + { + return true; + } + else { //RN: *always* serialize provided components of BlockValue (don't pass diff_param on), // since these tend to be viewed as the constructor arguments for the value T. It seems @@ -2184,14 +2205,15 @@ namespace LLInitParam // and serialize those params derived_t copy(typed_param); copy.updateBlockFromValue(true); - copy.block_t::serializeBlock(parser, name_stack, NULL); + return copy.block_t::serializeBlock(parser, name_stack, NULL); } else { - block_t::serializeBlock(parser, name_stack, NULL); + return block_t::serializeBlock(parser, name_stack, NULL); } } } + return false; } bool inspectBlock(Parser& parser, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 4b8a8dba5c..e25a966609 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -329,7 +329,7 @@ namespace LLInitParam p.writeValue<LLSD::String>(sd.asString(), name_stack); } - void ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const + bool ParamValue<LLSD, TypeValues<LLSD>, false>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const BaseBlock* diff_block) const { // attempt to write LLSD out directly if (!p.writeValue<LLSD>(mValue, name_stack)) @@ -337,5 +337,6 @@ namespace LLInitParam // otherwise read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc) LLParamSDParserUtilities::readSDValues(boost::bind(&serializeElement, boost::ref(p), _1, _2), mValue, name_stack); } + return true; } } -- cgit v1.2.3 From 638a16eedd12fe03b85703fb821bc05f40aab355 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 23 Oct 2012 22:35:47 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system improved predicate system, added uncertain/unknown predicates --- indra/llcommon/llinitparam.cpp | 2 +- indra/llcommon/llinitparam.h | 69 +++++++++++++++++++++++++++++++--------- indra/llcommon/llpredicate.h | 71 ++++++++++++++++++++---------------------- indra/llui/llxuiparser.cpp | 2 +- 4 files changed, 89 insertions(+), 55 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index b4dcf3493c..69f97e87c4 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -185,7 +185,7 @@ namespace LLInitParam return mValidated; } - bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const + bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const LLInitParam::BaseBlock* diff_block) const { bool serialized = false; if (!isProvided()) diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index d3a0438d93..a3a5b3dc37 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -914,14 +914,15 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) { - predicate.set(NON_DEFAULT); + predicate.add(NON_DEFAULT); } + predicate.unknown(REQUIRED); if (typed_param.isValid()) { - predicate.set(VALID); + predicate.add(VALID); if (typed_param.anyProvided()) { - predicate.set(PROVIDED); + predicate.add(PROVIDED); } } @@ -1071,19 +1072,17 @@ namespace LLInitParam static bool serializeParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const Param* diff_param) { const self_t& typed_param = static_cast<const self_t&>(param); - const self_t* diff_typed_param = static_cast<const self_t*>(diff_param); LLPredicate::Value<ESerializePredicates> predicate; - if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) - { - predicate.set(NON_DEFAULT); - } + predicate.unknown(NON_DEFAULT); + predicate.unknown(REQUIRED); + if (typed_param.isValid()) { - predicate.set(VALID); + predicate.add(VALID); if (typed_param.anyProvided()) { - predicate.set(PROVIDED); + predicate.add(PROVIDED); } } @@ -1271,7 +1270,29 @@ namespace LLInitParam { bool serialized = false; const self_t& typed_param = static_cast<const self_t&>(param); - if (!typed_param.isProvided()) return false; + + LLPredicate::Value<ESerializePredicates> predicate; + predicate.unknown(NON_DEFAULT); + + if (typed_param.mMinCount > 0) + { + predicate.add(REQUIRED); + } + else + { + predicate.unknown(REQUIRED); + } + + if (typed_param.isValid()) + { + predicate.add(VALID); + if (typed_param.anyProvided()) + { + predicate.add(PROVIDED); + } + } + + if (!predicate_rule.check(predicate)) return false; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; @@ -1516,10 +1537,28 @@ namespace LLInitParam bool serialized = false; const self_t& typed_param = static_cast<const self_t&>(param); - LLPredicate::Value<ESerializePredicates> predicate_value; - if (typed_param.isProvided()) predicate_value.set(PROVIDED); - - if (!typed_param.isProvided()) return false; + LLPredicate::Value<ESerializePredicates> predicate; + predicate.unknown(NON_DEFAULT); + + if (typed_param.mMinCount > 0) + { + predicate.add(REQUIRED); + } + else + { + predicate.unknown(REQUIRED); + } + + if (typed_param.isValid()) + { + predicate.add(VALID); + if (typed_param.anyProvided()) + { + predicate.add(PROVIDED); + } + } + + if (!predicate_rule.check(predicate)) return false; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); it != end_it; diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index ad5ab363fa..35ef22138c 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -42,34 +42,28 @@ namespace LLPredicate : mPredicateFlags(0x1), mPredicateCombinationFlags(0x1) { - set(e); + add(e); } Value() - : mPredicateFlags(0x1), + : mPredicateFlags(0x1), mPredicateCombinationFlags(0x1) {} - void set(ENUM predicate) + void add(ENUM predicate) { - llassert(predicate <= 5); - int predicate_flag = 0x1 << (0x1 << (int)predicate); - if (!(mPredicateFlags & predicate_flag)) + llassert(predicate < 5); + if (!has(predicate)) { + int predicate_flag = 0x1 << (0x1 << (int)predicate); mPredicateCombinationFlags *= predicate_flag; mPredicateFlags |= predicate_flag; } } - bool get(ENUM predicate) - { - int predicate_flag = 0x1 << (0x1 << (int)predicate); - return (mPredicateFlags & predicate_flag) != 0; - } - - void clear(ENUM predicate) + void remove(ENUM predicate) { - llassert(predicate <= 5); + llassert(predicate < 5); int predicate_flag = 0x1 << (0x1 << (int)predicate); if (mPredicateFlags & predicate_flag) { @@ -78,6 +72,19 @@ namespace LLPredicate } } + void unknown(ENUM predicate) + { + add(predicate); + int predicate_shift = 0x1 << (int)predicate; + mPredicateCombinationFlags |= mPredicateCombinationFlags << predicate_shift; + } + + bool has(ENUM predicate) + { + int predicate_flag = 0x1 << (0x1 << (int)predicate); + return (mPredicateFlags & predicate_flag) != 0; + } + private: int mPredicateCombinationFlags; int mPredicateFlags; @@ -89,16 +96,12 @@ namespace LLPredicate class Rule { public: - Rule(EmptyRule e) - : mPredicateRequirements(0x1) - {} - Rule(ENUM value) - : mPredicateRequirements(predicateFromValue(value)) + : mPredicateRequirements(predicateFromValue(value)) {} Rule() - : mPredicateRequirements(0x1) + : mPredicateRequirements(0x1) {} Rule operator~() @@ -129,25 +132,16 @@ namespace LLPredicate static int predicateFromValue(ENUM value) { - int countdown = value; - bool bit_val = false; - - int predicate = 0x0; - - for (int bit_index = 0; bit_index < 32; bit_index++) + llassert(value < 5); + static const int predicates[5] = { - if (bit_val) - { - predicate |= 0x1 << bit_index; - } - - if (countdown-- == 0) - { - countdown = value; - bit_val = !bit_val; - } - } - return predicate; + 0xAAAAaaaa, // 10101010101010101010101010101010 + 0xCCCCcccc, // 11001100110011001100110011001100 + 0xF0F0F0F0, // 11110000111100001111000011110000 + 0xFF00FF00, // 11111111000000001111111100000000 + 0xFFFF0000 // 11111111111111110000000000000000 + }; + return predicates[value]; } bool isTriviallyTrue() const @@ -167,6 +161,7 @@ namespace LLPredicate template<typename ENUM> Rule<ENUM> make_rule(ENUM e) { return Rule<ENUM>(e);} + // return generic empty rule class to avoid requiring template argument to create an empty rule EmptyRule make_rule(); } diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index afc76024d1..179a1184af 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -865,7 +865,7 @@ void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &bloc { mWriteRootNode = node; name_stack_t name_stack = Parser::name_stack_t(); - block.serializeBlock(*this, name_stack, diff_block); + block.serializeBlock(*this, name_stack, LLPredicate::Rule<LLInitParam::ESerializePredicates>(), diff_block); mOutNodes.clear(); } -- cgit v1.2.3 From 28179ab0070a1c13193808bc1493761a8fed167f Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 23 Oct 2012 23:12:33 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system cleaned up predicate system, made unknown work with remove --- indra/llcommon/llpredicate.cpp | 14 +++++++++++ indra/llcommon/llpredicate.h | 55 +++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/indra/llcommon/llpredicate.cpp b/indra/llcommon/llpredicate.cpp index 8dcd9247b7..1ab1ab08f1 100644 --- a/indra/llcommon/llpredicate.cpp +++ b/indra/llcommon/llpredicate.cpp @@ -30,4 +30,18 @@ namespace LLPredicate { EmptyRule make_rule() { return EmptyRule(); } + + int predicateFlagsFromValue(int value) + { + llassert(value < 5); + static const int predicates[5] = + { + 0xAAAAaaaa, // 10101010101010101010101010101010 + 0xCCCCcccc, // 11001100110011001100110011001100 + 0xF0F0F0F0, // 11110000111100001111000011110000 + 0xFF00FF00, // 11111111000000001111111100000000 + 0xFFFF0000 // 11111111111111110000000000000000 + }; + return predicates[value]; + } } diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 35ef22138c..096238713c 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -33,21 +33,21 @@ namespace LLPredicate { template<typename ENUM> class Rule; + int predicateFlagsFromValue(int value); + template<typename ENUM> struct Value { friend Rule<ENUM>; public: Value(ENUM e) - : mPredicateFlags(0x1), - mPredicateCombinationFlags(0x1) + : mPredicateCombinationFlags(0x1) { add(e); } Value() - : mPredicateFlags(0x1), - mPredicateCombinationFlags(0x1) + : mPredicateCombinationFlags(0x1) {} void add(ENUM predicate) @@ -55,39 +55,42 @@ namespace LLPredicate llassert(predicate < 5); if (!has(predicate)) { - int predicate_flag = 0x1 << (0x1 << (int)predicate); - mPredicateCombinationFlags *= predicate_flag; - mPredicateFlags |= predicate_flag; + int predicate_shift = 0x1 << (int)predicate; + mPredicateCombinationFlags <<= predicate_shift; } } void remove(ENUM predicate) { llassert(predicate < 5); - int predicate_flag = 0x1 << (0x1 << (int)predicate); - if (mPredicateFlags & predicate_flag) - { - mPredicateCombinationFlags /= predicate_flag; - mPredicateFlags &= ~predicate_flag; - } + int predicate_shift = 0x1 << (int)predicate; + int flag_mask = predicateFlagsFromValue(predicate); + int flags_to_modify = mPredicateCombinationFlags & flag_mask; + // clear flags containing predicate to be removed + mPredicateCombinationFlags &= ~flag_mask; + // shift flags, in effect removing predicate + flags_to_modify >>= predicate_shift; + // put modified flags back + mPredicateCombinationFlags |= flags_to_modify; } void unknown(ENUM predicate) { add(predicate); - int predicate_shift = 0x1 << (int)predicate; - mPredicateCombinationFlags |= mPredicateCombinationFlags << predicate_shift; + int flags_with_predicate = mPredicateCombinationFlags; + remove(predicate); + // unknown is result of adding and removing predicate at the same time! + mPredicateCombinationFlags |= flags_with_predicate; } bool has(ENUM predicate) { - int predicate_flag = 0x1 << (0x1 << (int)predicate); - return (mPredicateFlags & predicate_flag) != 0; + int flag_mask = predicateFlagsFromValue(predicate); + return (mPredicateCombinationFlags & flag_mask) != 0; } private: int mPredicateCombinationFlags; - int mPredicateFlags; }; struct EmptyRule {}; @@ -97,7 +100,7 @@ namespace LLPredicate { public: Rule(ENUM value) - : mPredicateRequirements(predicateFromValue(value)) + : mPredicateRequirements(predicateFlagsFromValue(value)) {} Rule() @@ -130,20 +133,6 @@ namespace LLPredicate return ((value.mPredicateCombinationFlags | 0x1) & mPredicateRequirements) != 0; } - static int predicateFromValue(ENUM value) - { - llassert(value < 5); - static const int predicates[5] = - { - 0xAAAAaaaa, // 10101010101010101010101010101010 - 0xCCCCcccc, // 11001100110011001100110011001100 - 0xF0F0F0F0, // 11110000111100001111000011110000 - 0xFF00FF00, // 11111111000000001111111100000000 - 0xFFFF0000 // 11111111111111110000000000000000 - }; - return predicates[value]; - } - bool isTriviallyTrue() const { return mPredicateRequirements & 0x1; -- cgit v1.2.3 From 1de6ecb23851e0784016a2c4c9f691c976c6bda7 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 23 Oct 2012 23:35:15 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system converted "int" to "S32" --- indra/llcommon/llpredicate.cpp | 4 ++-- indra/llcommon/llpredicate.h | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/indra/llcommon/llpredicate.cpp b/indra/llcommon/llpredicate.cpp index 1ab1ab08f1..e3410ef3f6 100644 --- a/indra/llcommon/llpredicate.cpp +++ b/indra/llcommon/llpredicate.cpp @@ -31,10 +31,10 @@ namespace LLPredicate { EmptyRule make_rule() { return EmptyRule(); } - int predicateFlagsFromValue(int value) + S32 predicateFlagsFromValue(S32 value) { llassert(value < 5); - static const int predicates[5] = + static const S32 predicates[5] = { 0xAAAAaaaa, // 10101010101010101010101010101010 0xCCCCcccc, // 11001100110011001100110011001100 diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 096238713c..5fd1d30295 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -33,7 +33,7 @@ namespace LLPredicate { template<typename ENUM> class Rule; - int predicateFlagsFromValue(int value); + S32 predicateFlagsFromValue(S32 value); template<typename ENUM> struct Value @@ -41,31 +41,35 @@ namespace LLPredicate friend Rule<ENUM>; public: Value(ENUM e) - : mPredicateCombinationFlags(0x1) + : mPredicateCombinationFlags(0xFFFFffff) { add(e); } Value() - : mPredicateCombinationFlags(0x1) + : mPredicateCombinationFlags(0xFFFFffff) {} void add(ENUM predicate) { llassert(predicate < 5); - if (!has(predicate)) - { - int predicate_shift = 0x1 << (int)predicate; - mPredicateCombinationFlags <<= predicate_shift; - } + S32 predicate_shift = 0x1 << (S32)predicate; + S32 flag_mask = predicateFlagsFromValue(predicate); + S32 flags_to_modify = mPredicateCombinationFlags & ~flag_mask; + // clear flags containing predicate to be removed + mPredicateCombinationFlags &= ~flag_mask; + // shift flags, in effect removing predicate + flags_to_modify <<= predicate_shift; + // put modified flags back + mPredicateCombinationFlags |= flags_to_modify; } void remove(ENUM predicate) { llassert(predicate < 5); - int predicate_shift = 0x1 << (int)predicate; - int flag_mask = predicateFlagsFromValue(predicate); - int flags_to_modify = mPredicateCombinationFlags & flag_mask; + S32 predicate_shift = 0x1 << (S32)predicate; + S32 flag_mask = predicateFlagsFromValue(predicate); + S32 flags_to_modify = mPredicateCombinationFlags & flag_mask; // clear flags containing predicate to be removed mPredicateCombinationFlags &= ~flag_mask; // shift flags, in effect removing predicate @@ -77,7 +81,7 @@ namespace LLPredicate void unknown(ENUM predicate) { add(predicate); - int flags_with_predicate = mPredicateCombinationFlags; + S32 flags_with_predicate = mPredicateCombinationFlags; remove(predicate); // unknown is result of adding and removing predicate at the same time! mPredicateCombinationFlags |= flags_with_predicate; @@ -85,12 +89,12 @@ namespace LLPredicate bool has(ENUM predicate) { - int flag_mask = predicateFlagsFromValue(predicate); + S32 flag_mask = predicateFlagsFromValue(predicate); return (mPredicateCombinationFlags & flag_mask) != 0; } private: - int mPredicateCombinationFlags; + S32 mPredicateCombinationFlags; }; struct EmptyRule {}; @@ -144,7 +148,7 @@ namespace LLPredicate } private: - int mPredicateRequirements; + S32 mPredicateRequirements; }; template<typename ENUM> -- cgit v1.2.3 From 7f97aa2d5db0d1429136a40d04d2e4428cb184fe Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 25 Oct 2012 17:30:03 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed crash on exit --- indra/llcommon/llinitparam.h | 13 ------------- indra/llui/llxuiparser.cpp | 10 +++++++++- indra/llxml/llxmlnode.cpp | 3 ++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index a3a5b3dc37..9530e562f6 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -916,7 +916,6 @@ namespace LLInitParam { predicate.add(NON_DEFAULT); } - predicate.unknown(REQUIRED); if (typed_param.isValid()) { predicate.add(VALID); @@ -1074,8 +1073,6 @@ namespace LLInitParam const self_t& typed_param = static_cast<const self_t&>(param); LLPredicate::Value<ESerializePredicates> predicate; - predicate.unknown(NON_DEFAULT); - predicate.unknown(REQUIRED); if (typed_param.isValid()) { @@ -1272,16 +1269,11 @@ namespace LLInitParam const self_t& typed_param = static_cast<const self_t&>(param); LLPredicate::Value<ESerializePredicates> predicate; - predicate.unknown(NON_DEFAULT); if (typed_param.mMinCount > 0) { predicate.add(REQUIRED); } - else - { - predicate.unknown(REQUIRED); - } if (typed_param.isValid()) { @@ -1538,16 +1530,11 @@ namespace LLInitParam const self_t& typed_param = static_cast<const self_t&>(param); LLPredicate::Value<ESerializePredicates> predicate; - predicate.unknown(NON_DEFAULT); if (typed_param.mMinCount > 0) { predicate.add(REQUIRED); } - else - { - predicate.unknown(REQUIRED); - } if (typed_param.isValid()) { diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 179a1184af..95cda92632 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -880,16 +880,24 @@ LLXMLNodePtr LLXUIParser::getNode(name_stack_t& stack) it = next_it) { ++next_it; + bool force_new_node = false; + if (it->first.empty()) { it->second = false; continue; } + if (next_it != stack.end() && next_it->first.empty() && next_it->second) + { + force_new_node = true; + } + + out_nodes_t::iterator found_it = mOutNodes.find(it->first); // node with this name not yet written - if (found_it == mOutNodes.end() || it->second) + if (found_it == mOutNodes.end() || it->second || force_new_node) { // make an attribute if we are the last element on the name stack bool is_attribute = next_it == stack.end(); diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp index 2ffb0d8503..8746114f1b 100644 --- a/indra/llxml/llxmlnode.cpp +++ b/indra/llxml/llxmlnode.cpp @@ -273,7 +273,8 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child, LLXMLNodePtr after_child) new_child->mParent = this; if (new_child->mIsAttribute) { - mAttributes.insert(std::make_pair(new_child->mName, new_child)); + std::pair<LLXMLAttribList::iterator, bool> result = mAttributes.insert(std::make_pair(new_child->mName, new_child)); + llassert(result.second); } else { -- cgit v1.2.3 From 3ffd0be53af0c5338e6fdc77d240e976aeb10451 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 26 Oct 2012 20:03:33 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed llpredicate so that values and rules work uniformly with predicate logic and/or/negate works in parallel with set/clear --- indra/llcommon/llinitparam.cpp | 2 +- indra/llcommon/llinitparam.h | 64 ++++++------- indra/llcommon/llpredicate.cpp | 22 ++--- indra/llcommon/llpredicate.h | 199 ++++++++++++++++++++++++++--------------- 4 files changed, 166 insertions(+), 121 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index 69f97e87c4..c66659a696 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -190,7 +190,7 @@ namespace LLInitParam bool serialized = false; if (!isProvided()) { - if ((~predicate_rule_t(PROVIDED) && predicate_rule).isTriviallyFalse()) + if (predicate_rule_t(~ll_predicate(PROVIDED) && predicate_rule).isTriviallyFalse()) { return false; } diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 9530e562f6..b52ac809e0 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -545,7 +545,7 @@ namespace LLInitParam } bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule = predicate_rule_t(), const BaseBlock* diff_block = NULL) const; + bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule = predicate_rule_t(ll_predicate(PROVIDED) && ll_predicate(NON_DEFAULT)), const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const; virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return selfBlockDescriptor(); } @@ -912,17 +912,17 @@ namespace LLInitParam const self_t* diff_typed_param = static_cast<const self_t*>(diff_param); LLPredicate::Value<ESerializePredicates> predicate; - if (!diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) + predicate.set(NON_DEFAULT, !diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())); + + if (typed_param.isValid()) { - predicate.add(NON_DEFAULT); + predicate.set(VALID, true); + predicate.set(PROVIDED, typed_param.anyProvided()); } - if (typed_param.isValid()) + else { - predicate.add(VALID); - if (typed_param.anyProvided()) - { - predicate.add(PROVIDED); - } + predicate.set(VALID, false); + predicate.set(PROVIDED, false); } if (!predicate_rule.check(predicate)) return false; @@ -1076,11 +1076,13 @@ namespace LLInitParam if (typed_param.isValid()) { - predicate.add(VALID); - if (typed_param.anyProvided()) - { - predicate.add(PROVIDED); - } + predicate.set(VALID, true); + predicate.set(PROVIDED, typed_param.anyProvided()); + } + else + { + predicate.set(VALID, false); + predicate.set(PROVIDED, false); } if (!predicate_rule.check(predicate)) return false; @@ -1270,19 +1272,18 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; - if (typed_param.mMinCount > 0) - { - predicate.add(REQUIRED); - } + predicate.set(REQUIRED, typed_param.mMinCount > 0); if (typed_param.isValid()) { - predicate.add(VALID); - if (typed_param.anyProvided()) - { - predicate.add(PROVIDED); - } + predicate.set(VALID, true); + predicate.set(PROVIDED, typed_param.anyProvided()); } + else + { + predicate.set(VALID, false); + predicate.set(PROVIDED, false); + } if (!predicate_rule.check(predicate)) return false; @@ -1531,19 +1532,18 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; - if (typed_param.mMinCount > 0) - { - predicate.add(REQUIRED); - } + predicate.set(REQUIRED, typed_param.mMinCount > 0); if (typed_param.isValid()) { - predicate.add(VALID); - if (typed_param.anyProvided()) - { - predicate.add(PROVIDED); - } + predicate.set(VALID, true); + predicate.set(PROVIDED, typed_param.anyProvided()); } + else + { + predicate.set(VALID, false); + predicate.set(PROVIDED, false); + } if (!predicate_rule.check(predicate)) return false; diff --git a/indra/llcommon/llpredicate.cpp b/indra/llcommon/llpredicate.cpp index e3410ef3f6..1278948e24 100644 --- a/indra/llcommon/llpredicate.cpp +++ b/indra/llcommon/llpredicate.cpp @@ -29,19 +29,13 @@ namespace LLPredicate { - EmptyRule make_rule() { return EmptyRule(); } - - S32 predicateFlagsFromValue(S32 value) + const U32 cPredicateFlagsFromEnum[5] = { - llassert(value < 5); - static const S32 predicates[5] = - { - 0xAAAAaaaa, // 10101010101010101010101010101010 - 0xCCCCcccc, // 11001100110011001100110011001100 - 0xF0F0F0F0, // 11110000111100001111000011110000 - 0xFF00FF00, // 11111111000000001111111100000000 - 0xFFFF0000 // 11111111111111110000000000000000 - }; - return predicates[value]; - } + 0xAAAAaaaa, // 10101010101010101010101010101010 + 0xCCCCcccc, // 11001100110011001100110011001100 + 0xF0F0F0F0, // 11110000111100001111000011110000 + 0xFF00FF00, // 11111111000000001111111100000000 + 0xFFFF0000 // 11111111111111110000000000000000 + }; } + diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 5fd1d30295..3f1bf1c8e6 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -33,129 +33,180 @@ namespace LLPredicate { template<typename ENUM> class Rule; - S32 predicateFlagsFromValue(S32 value); + extern const U32 cPredicateFlagsFromEnum[5]; template<typename ENUM> - struct Value + class Literal { friend Rule<ENUM>; + public: - Value(ENUM e) - : mPredicateCombinationFlags(0xFFFFffff) + typedef U32 predicate_flag_t; + static const S32 cMaxEnum = 5; + + Literal(ENUM e) + : mPredicateFlags(cPredicateFlagsFromEnum[e]) { - add(e); + llassert(0 <= e && e < cMaxEnum); } - Value() - : mPredicateCombinationFlags(0xFFFFffff) + Literal() + : mPredicateFlags(0xFFFFffff) {} - void add(ENUM predicate) + Literal operator~() { - llassert(predicate < 5); - S32 predicate_shift = 0x1 << (S32)predicate; - S32 flag_mask = predicateFlagsFromValue(predicate); - S32 flags_to_modify = mPredicateCombinationFlags & ~flag_mask; - // clear flags containing predicate to be removed - mPredicateCombinationFlags &= ~flag_mask; - // shift flags, in effect removing predicate - flags_to_modify <<= predicate_shift; - // put modified flags back - mPredicateCombinationFlags |= flags_to_modify; + Literal new_rule; + new_rule.mPredicateFlags = ~mPredicateFlags; + return new_rule; } - void remove(ENUM predicate) + Literal operator &&(const Literal& other) { - llassert(predicate < 5); - S32 predicate_shift = 0x1 << (S32)predicate; - S32 flag_mask = predicateFlagsFromValue(predicate); - S32 flags_to_modify = mPredicateCombinationFlags & flag_mask; - // clear flags containing predicate to be removed - mPredicateCombinationFlags &= ~flag_mask; - // shift flags, in effect removing predicate - flags_to_modify >>= predicate_shift; - // put modified flags back - mPredicateCombinationFlags |= flags_to_modify; + Literal new_rule; + new_rule.mPredicateFlags = mPredicateFlags & other.mPredicateFlags; + return new_rule; } - void unknown(ENUM predicate) + Literal operator ||(const Literal& other) { - add(predicate); - S32 flags_with_predicate = mPredicateCombinationFlags; - remove(predicate); - // unknown is result of adding and removing predicate at the same time! - mPredicateCombinationFlags |= flags_with_predicate; + Literal new_rule; + new_rule.mPredicateFlags = mPredicateFlags | other.mPredicateFlags; + return new_rule; } - bool has(ENUM predicate) + void set(ENUM e, bool value) { - S32 flag_mask = predicateFlagsFromValue(predicate); - return (mPredicateCombinationFlags & flag_mask) != 0; + llassert(0 <= e && e < cMaxEnum); + modifyPredicate(0x1 << (S32)e, cPredicateFlagsFromEnum[e], value); + } + + void set(const Literal& other, bool value) + { + U32 predicate_flags = other.mPredicateFlags; + while(predicate_flags) + { + U32 next_flags = clearLSB(predicate_flags); + lsb_flag = predicate_flags ^ next_flags; + U32 mask = 0; + for (S32 i = 0; i < cMaxEnum; i++) + { + if (cPredicateFlagsFromEnum[i] & lsb_flag) + { + mask |= cPredicateFlagsFromEnum[i]; + } + } + + modifyPredicate(lsb_flag, mask, value); + + predicate_flags = next_flags; + } + } + + void forget(ENUM e) + { + set(e, true); + U32 flags_with_predicate = mPredicateFlags; + set(e, false); + // ambiguous value is result of adding and removing predicate at the same time! + mPredicateFlags |= flags_with_predicate; + } + + void forget(const Literal& literal) + { + set(literal, true); + U32 flags_with_predicate = mPredicateFlags; + set(literal, false); + // ambiguous value is result of adding and removing predicate at the same time! + mPredicateFlags |= flags_with_predicate; } private: - S32 mPredicateCombinationFlags; + + predicate_flag_t clearLSB(predicate_flag_t value) + { + return value & (value - 1); + } + + void modifyPredicate(predicate_flag_t predicate_flag, predicate_flag_t mask, bool value) + { + llassert(clearLSB(predicate_flag) == 0); + predicate_flag_t flags_to_modify; + + if (value) + { + flags_to_modify = (mPredicateFlags & ~mask); + // clear flags not containing predicate to be added + mPredicateFlags &= mask; + // shift flags, in effect adding predicate + flags_to_modify *= predicate_flag; + } + else + { + flags_to_modify = mPredicateFlags & mask; + // clear flags containing predicate to be removed + mPredicateFlags &= ~mask; + // shift flags, in effect removing predicate + flags_to_modify /= predicate_flag; + } + // put modified flags back + mPredicateFlags |= flags_to_modify; + } + + predicate_flag_t mPredicateFlags; }; - struct EmptyRule {}; + template<typename ENUM> + struct Value + : public Literal<ENUM> + { + public: + Value(ENUM e) + : Literal(e) + {} + + Value() + {} + }; template<typename ENUM> class Rule + : public Literal<ENUM> { public: Rule(ENUM value) - : mPredicateRequirements(predicateFlagsFromValue(value)) + : Literal(value) {} - Rule() - : mPredicateRequirements(0x1) + Rule(const Literal other) + : Literal(other) {} - Rule operator~() - { - Rule new_rule; - new_rule.mPredicateRequirements = ~mPredicateRequirements; - return new_rule; - } - - Rule operator &&(const Rule& other) - { - Rule new_rule; - new_rule.mPredicateRequirements = mPredicateRequirements & other.mPredicateRequirements; - return new_rule; - } - - Rule operator ||(const Rule& other) - { - Rule new_rule; - new_rule.mPredicateRequirements = mPredicateRequirements | other.mPredicateRequirements; - return new_rule; - } + Rule() + {} bool check(const Value<ENUM>& value) const { - return ((value.mPredicateCombinationFlags | 0x1) & mPredicateRequirements) != 0; + return (value.mPredicateFlags & mPredicateFlags) != 0; } bool isTriviallyTrue() const { - return mPredicateRequirements & 0x1; + return mPredicateFlags == 0xFFFFffff; } bool isTriviallyFalse() const { - return mPredicateRequirements == 0; + return mPredicateFlags == 0; } - - private: - S32 mPredicateRequirements; }; +} - template<typename ENUM> - Rule<ENUM> make_rule(ENUM e) { return Rule<ENUM>(e);} +template<typename ENUM> +LLPredicate::Literal<ENUM> ll_predicate(ENUM e) +{ + return LLPredicate::Literal<ENUM>(e); +} - // return generic empty rule class to avoid requiring template argument to create an empty rule - EmptyRule make_rule(); -} #endif // LL_LLPREDICATE_H -- cgit v1.2.3 From b71e991c1860bbea0387f9434cc2b4b31a26469a Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 29 Oct 2012 18:44:37 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed predicate update logic and reduced to 2 classes --- indra/llcommon/llinitparam.cpp | 2 +- indra/llcommon/llpredicate.h | 112 +++++++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 45 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index c66659a696..afeac0a905 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -190,7 +190,7 @@ namespace LLInitParam bool serialized = false; if (!isProvided()) { - if (predicate_rule_t(~ll_predicate(PROVIDED) && predicate_rule).isTriviallyFalse()) + if ((predicate_rule && !ll_predicate(PROVIDED)).isTriviallyFalse()) { return false; } diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 3f1bf1c8e6..a13172da68 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -36,43 +36,41 @@ namespace LLPredicate extern const U32 cPredicateFlagsFromEnum[5]; template<typename ENUM> - class Literal + class Value { - friend Rule<ENUM>; - public: typedef U32 predicate_flag_t; static const S32 cMaxEnum = 5; - Literal(ENUM e) + Value(ENUM e) : mPredicateFlags(cPredicateFlagsFromEnum[e]) { llassert(0 <= e && e < cMaxEnum); } - Literal() + Value() : mPredicateFlags(0xFFFFffff) {} - Literal operator~() + Value operator!() const { - Literal new_rule; - new_rule.mPredicateFlags = ~mPredicateFlags; - return new_rule; + Value new_value; + new_value.mPredicateFlags = ~mPredicateFlags; + return new_value; } - Literal operator &&(const Literal& other) + Value operator &&(const Value other) const { - Literal new_rule; - new_rule.mPredicateFlags = mPredicateFlags & other.mPredicateFlags; - return new_rule; + Value new_value; + new_value.mPredicateFlags = mPredicateFlags & other.mPredicateFlags; + return new_value; } - Literal operator ||(const Literal& other) + Value operator ||(const Value other) const { - Literal new_rule; - new_rule.mPredicateFlags = mPredicateFlags | other.mPredicateFlags; - return new_rule; + Value new_value; + new_value.mPredicateFlags = mPredicateFlags | other.mPredicateFlags; + return new_value; } void set(ENUM e, bool value) @@ -81,19 +79,21 @@ namespace LLPredicate modifyPredicate(0x1 << (S32)e, cPredicateFlagsFromEnum[e], value); } - void set(const Literal& other, bool value) + void set(const Value other, bool value) { U32 predicate_flags = other.mPredicateFlags; while(predicate_flags) { U32 next_flags = clearLSB(predicate_flags); lsb_flag = predicate_flags ^ next_flags; + U32 mask = 0; for (S32 i = 0; i < cMaxEnum; i++) { if (cPredicateFlagsFromEnum[i] & lsb_flag) { mask |= cPredicateFlagsFromEnum[i]; + modifyPredicate(0x1 << (0x1 << i ), cPredicateFlagsFromEnum[i], !value); } } @@ -112,15 +112,25 @@ namespace LLPredicate mPredicateFlags |= flags_with_predicate; } - void forget(const Literal& literal) + void forget(const Value value) { - set(literal, true); + set(value, true); U32 flags_with_predicate = mPredicateFlags; - set(literal, false); + set(value, false); // ambiguous value is result of adding and removing predicate at the same time! mPredicateFlags |= flags_with_predicate; } + bool allSet() const + { + return mPredicateFlags == ~0; + } + + bool noneSet() const + { + return mPredicateFlags == 0; + } + private: predicate_flag_t clearLSB(predicate_flag_t value) @@ -156,56 +166,70 @@ namespace LLPredicate predicate_flag_t mPredicateFlags; }; - template<typename ENUM> - struct Value - : public Literal<ENUM> - { - public: - Value(ENUM e) - : Literal(e) - {} - - Value() - {} - }; - template<typename ENUM> class Rule - : public Literal<ENUM> { public: Rule(ENUM value) - : Literal(value) + : mRule(value) + {} + + Rule(const Rule& other) + : mRule(other.mRule) {} - Rule(const Literal other) - : Literal(other) + Rule(const Value<ENUM> other) + : mRule(other) {} Rule() {} - bool check(const Value<ENUM>& value) const + bool check(const Value<ENUM> value) const { - return (value.mPredicateFlags & mPredicateFlags) != 0; + return !(mRule && value).noneSet(); } bool isTriviallyTrue() const { - return mPredicateFlags == 0xFFFFffff; + return mRule.allSet(); } bool isTriviallyFalse() const { - return mPredicateFlags == 0; + return mRule.noneSet(); + } + + Rule operator!() const + { + Rule new_rule; + new_rule.mRule = !mRule; + return new_rule; } + + Rule operator &&(const Rule other) const + { + Rule new_rule; + new_rule.mRule = mRule && other.mRule; + return new_rule; + } + + Rule operator ||(const Rule other) const + { + Rule new_rule; + new_rule.mRule = mRule || other.mRule; + return new_rule; + } + + private: + Value<ENUM> mRule; }; } template<typename ENUM> -LLPredicate::Literal<ENUM> ll_predicate(ENUM e) +LLPredicate::Value<ENUM> ll_predicate(ENUM e) { - return LLPredicate::Literal<ENUM>(e); + return LLPredicate::Value<ENUM>(e); } -- cgit v1.2.3 From 819adb5eb4d7f982121f3dbd82750e05d26864d9 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 1 Nov 2012 00:26:44 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system final removal of remaining LLStat code --- indra/llcommon/CMakeLists.txt | 2 - indra/llcommon/llinstancetracker.h | 10 +- indra/llcommon/llmetricperformancetester.cpp | 1 - indra/llcommon/llpredicate.h | 4 + indra/llcommon/llstat.cpp | 352 ---------------------- indra/llcommon/llstat.h | 103 ------- indra/llcommon/lltrace.h | 90 ++++-- indra/llcommon/lltracerecording.cpp | 119 +++++++- indra/llcommon/lltracerecording.h | 216 +++++++------ indra/llcommon/lltracethreadrecorder.cpp | 4 + indra/llui/llstatbar.cpp | 138 ++++++--- indra/llui/llstatbar.h | 11 +- indra/llui/llstatgraph.cpp | 20 +- indra/llui/llstatgraph.h | 13 +- indra/llvfs/llvfile.cpp | 2 +- indra/lscript/lscript_execute/lscript_execute.cpp | 1 - indra/newview/llagentcamera.cpp | 4 +- indra/newview/llappviewer.cpp | 3 + indra/newview/llfasttimerview.cpp | 1 - indra/newview/llfloaterjoystick.cpp | 17 +- indra/newview/llfloaterjoystick.h | 1 - indra/newview/llhudnametag.cpp | 5 +- indra/newview/llstatusbar.cpp | 4 +- indra/newview/llsurface.h | 1 - indra/newview/lltexturefetch.cpp | 10 +- indra/newview/lltexturefetch.h | 7 +- indra/newview/llviewercamera.cpp | 13 +- indra/newview/llviewercamera.h | 28 +- indra/newview/llviewerdisplay.cpp | 6 +- indra/newview/llviewermessage.cpp | 22 -- indra/newview/llviewerobjectlist.cpp | 4 +- indra/newview/llviewerobjectlist.h | 4 +- indra/newview/llviewerregion.cpp | 9 +- indra/newview/llviewerregion.h | 6 +- indra/newview/llviewerstats.cpp | 33 +- indra/newview/llviewerstats.h | 1 - indra/newview/llviewertexturelist.h | 1 - indra/newview/llviewerwindow.cpp | 11 +- indra/newview/llviewerwindow.h | 7 +- indra/newview/llvoavatar.cpp | 6 - indra/newview/llworld.cpp | 17 +- indra/newview/pipeline.cpp | 6 +- 42 files changed, 543 insertions(+), 770 deletions(-) delete mode 100644 indra/llcommon/llstat.cpp delete mode 100644 indra/llcommon/llstat.h diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index d876842cf1..0f5ded86ed 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -91,7 +91,6 @@ set(llcommon_SOURCE_FILES llsdutil.cpp llsecondlifeurls.cpp llsingleton.cpp - llstat.cpp llstacktrace.cpp llstreamqueue.cpp llstreamtools.cpp @@ -234,7 +233,6 @@ set(llcommon_HEADER_FILES llsortedvector.h llstack.h llstacktrace.h - llstat.h llstatenums.h llstl.h llstreamqueue.h diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 403df08990..3a1187a4c1 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -77,8 +77,8 @@ protected: /// This mix-in class adds support for tracking all instances of the specified class parameter T /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup /// If KEY is not provided, then instances are stored in a simple set -/// @NOTE: see explicit specialization below for default KEY==T* case -template<typename T, typename KEY = T*> +/// @NOTE: see explicit specialization below for default KEY==void case +template<typename T, typename KEY = void> class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker<T, KEY> MyT; @@ -224,12 +224,12 @@ private: KEY mInstanceKey; }; -/// explicit specialization for default case where KEY is T* +/// explicit specialization for default case where KEY is void /// use a simple std::set<T*> template<typename T> -class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase +class LLInstanceTracker<T, void> : public LLInstanceTrackerBase { - typedef LLInstanceTracker<T, T*> MyT; + typedef LLInstanceTracker<T, void> MyT; typedef typename std::set<T*> InstanceSet; struct StaticData: public StaticBase { diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index 41d3eb0bf3..a1b0a684c5 100644 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -29,7 +29,6 @@ #include "indra_constants.h" #include "llerror.h" #include "llsdserialize.h" -#include "llstat.h" #include "lltreeiterators.h" #include "llmetricperformancetester.h" diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 3f1bf1c8e6..75744667d9 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -165,6 +165,10 @@ namespace LLPredicate : Literal(e) {} + Value(const Literal other) + : Literal(other) + {} + Value() {} }; diff --git a/indra/llcommon/llstat.cpp b/indra/llcommon/llstat.cpp deleted file mode 100644 index b46d2e58b2..0000000000 --- a/indra/llcommon/llstat.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/** - * @file llstat.cpp - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llstat.h" -#include "lllivefile.h" -#include "llerrorcontrol.h" -#include "llframetimer.h" -#include "timing.h" -#include "llsd.h" -#include "llsdserialize.h" -#include "llstl.h" -#include "u64.h" - - -// statics -//------------------------------------------------------------------------ -LLTimer LLStat::sTimer; -LLFrameTimer LLStat::sFrameTimer; - -void LLStat::reset() -{ - mNumValues = 0; - mLastValue = 0.f; - delete[] mBins; - mBins = new ValueEntry[mNumBins]; - mCurBin = mNumBins-1; - mNextBin = 0; -} - -LLStat::LLStat(std::string name, BOOL use_frame_timer) -: LLInstanceTracker<LLStat, std::string>(name), - mUseFrameTimer(use_frame_timer), - mNumBins(50), - mName(name), - mBins(NULL) -{ - llassert(mNumBins > 0); - mLastTime = 0.f; - - reset(); -} - -LLStat::~LLStat() -{ - delete[] mBins; -} -// -//void LLStat::start() -//{ -// if (mUseFrameTimer) -// { -// mBins[mNextBin].mBeginTime = sFrameTimer.getElapsedSeconds(); -// } -// else -// { -// mBins[mNextBin].mBeginTime = sTimer.getElapsedTimeF64(); -// } -//} - -void LLStat::addValue(const F32 value) -{ - if (mNumValues < mNumBins) - { - mNumValues++; - } - - // Increment the bin counters. - mCurBin++; - if (mCurBin >= mNumBins) - { - mCurBin = 0; - } - mNextBin++; - if (mNextBin >= mNumBins) - { - mNextBin = 0; - } - - mBins[mCurBin].mValue = value; - if (mUseFrameTimer) - { - mBins[mCurBin].mTime = sFrameTimer.getElapsedSeconds(); - } - else - { - mBins[mCurBin].mTime = sTimer.getElapsedTimeF64(); - } - mBins[mCurBin].mDT = (F32)(mBins[mCurBin].mTime - mBins[mCurBin].mBeginTime); - - //this value is used to prime the min/max calls - mLastTime = mBins[mCurBin].mTime; - mLastValue = value; - - // Set the begin time for the next stat segment. - mBins[mNextBin].mBeginTime = mBins[mCurBin].mTime; - mBins[mNextBin].mTime = mBins[mCurBin].mTime; - mBins[mNextBin].mDT = 0.f; -} - - -F32 LLStat::getMax() const -{ - S32 i; - F32 current_max = mLastValue; - if (mNumBins == 0) - { - current_max = 0.f; - } - else - { - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - if (mBins[i].mValue > current_max) - { - current_max = mBins[i].mValue; - } - } - } - return current_max; -} - -F32 LLStat::getMean() const -{ - S32 i; - F32 current_mean = 0.f; - S32 samples = 0; - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - current_mean += mBins[i].mValue; - samples++; - } - - // There will be a wrap error at 2^32. :) - if (samples != 0) - { - current_mean /= samples; - } - else - { - current_mean = 0.f; - } - return current_mean; -} - -F32 LLStat::getMin() const -{ - S32 i; - F32 current_min = mLastValue; - - if (mNumBins == 0) - { - current_min = 0.f; - } - else - { - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - if (mBins[i].mValue < current_min) - { - current_min = mBins[i].mValue; - } - } - } - return current_min; -} - -F32 LLStat::getPrev(S32 age) const -{ - S32 bin; - bin = mCurBin - age; - - while (bin < 0) - { - bin += mNumBins; - } - - if (bin == mNextBin) - { - // Bogus for bin we're currently working on. - return 0.f; - } - return mBins[bin].mValue; -} - -F32 LLStat::getPrevPerSec(S32 age) const -{ - S32 bin; - bin = mCurBin - age; - - while (bin < 0) - { - bin += mNumBins; - } - - if (bin == mNextBin) - { - // Bogus for bin we're currently working on. - return 0.f; - } - return mBins[bin].mValue / mBins[bin].mDT; -} - -F32 LLStat::getCurrent() const -{ - return mBins[mCurBin].mValue; -} - -F32 LLStat::getCurrentPerSec() const -{ - return mBins[mCurBin].mValue / mBins[mCurBin].mDT; -} - -F32 LLStat::getMeanPerSec() const -{ - S32 i; - F32 value = 0.f; - F32 dt = 0.f; - - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - value += mBins[i].mValue; - dt += mBins[i].mDT; - } - - if (dt > 0.f) - { - return value/dt; - } - else - { - return 0.f; - } -} - -F32 LLStat::getMaxPerSec() const -{ - F32 value; - - if (mNextBin != 0) - { - value = mBins[0].mValue/mBins[0].mDT; - } - else if (mNumValues > 0) - { - value = mBins[1].mValue/mBins[1].mDT; - } - else - { - value = 0.f; - } - - for (S32 i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - value = llmax(value, mBins[i].mValue/mBins[i].mDT); - } - return value; -} - -F32 LLStat::getMinPerSec() const -{ - S32 i; - F32 value; - - if (mNextBin != 0) - { - value = mBins[0].mValue/mBins[0].mDT; - } - else if (mNumValues > 0) - { - value = mBins[1].mValue/mBins[0].mDT; - } - else - { - value = 0.f; - } - - for (i = 0; (i < mNumBins) && (i < mNumValues); i++) - { - // Skip the bin we're currently filling. - if (i == mNextBin) - { - continue; - } - value = llmin(value, mBins[i].mValue/mBins[i].mDT); - } - return value; -} - -U32 LLStat::getNumValues() const -{ - return mNumValues; -} - -S32 LLStat::getNumBins() const -{ - return mNumBins; -} - -S32 LLStat::getNextBin() const -{ - return mNextBin; -} - diff --git a/indra/llcommon/llstat.h b/indra/llcommon/llstat.h deleted file mode 100644 index 82a246275d..0000000000 --- a/indra/llcommon/llstat.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file llstat.h - * @brief Runtime statistics accumulation. - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLSTAT_H -#define LL_LLSTAT_H - -#include <map> - -#include "lltimer.h" -#include "llframetimer.h" -#include "llinstancetracker.h" - -class LLSD; - -// ---------------------------------------------------------------------------- -class LL_COMMON_API LLStat : public LLInstanceTracker<LLStat, std::string> -{ -public: - LLStat(std::string name = std::string(), BOOL use_frame_timer = FALSE); - ~LLStat(); - - //void start(); // Start the timer for the current "frame", otherwise uses the time tracked from - // the last addValue - void reset(); - void addValue(const F32 value = 1.f); // Adds the current value being tracked, and tracks the DT. - void addValue(const S32 value) { addValue((F32)value); } - void addValue(const U32 value) { addValue((F32)value); } - - S32 getNextBin() const; - - F32 getPrev(S32 age) const; // Age is how many "addValues" previously - zero is current - F32 getPrevPerSec(S32 age) const; // Age is how many "addValues" previously - zero is current - - F32 getCurrent() const; - F32 getCurrentPerSec() const; - - F32 getMin() const; - F32 getMinPerSec() const; - - F32 getMean() const; - F32 getMeanPerSec() const; - - F32 getMax() const; - F32 getMaxPerSec() const; - - U32 getNumValues() const; - S32 getNumBins() const; - -private: - bool mUseFrameTimer; - U32 mNumValues; - U32 mNumBins; - F32 mLastValue; - F64 mLastTime; - - struct ValueEntry - { - ValueEntry() - : mValue(0.f), - mBeginTime(0.0), - mTime(0.0), - mDT(0.f) - {} - F32 mValue; - F64 mBeginTime; - F64 mTime; - F32 mDT; - }; - ValueEntry* mBins; - - S32 mCurBin; - S32 mNextBin; - - std::string mName; - - static LLTimer sTimer; - static LLFrameTimer sFrameTimer; -}; - -#endif // LL_STAT_ diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 2cdae4b0d2..2823db5cbb 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -227,10 +227,33 @@ namespace LLTrace }; + template<typename T, typename IS_UNIT = void> + struct StorageType + { + typedef T type_t; + }; + + template<typename T> + struct StorageType<T, typename T::is_unit_tag_t> + { + typedef typename StorageType<typename T::storage_t>::type_t type_t; + }; + + template<> struct StorageType<F32> { typedef F64 type_t; }; + template<> struct StorageType<S32> { typedef S64 type_t; }; + template<> struct StorageType<U32> { typedef S64 type_t; }; + template<> struct StorageType<S16> { typedef S64 type_t; }; + template<> struct StorageType<U16> { typedef S64 type_t; }; + template<> struct StorageType<S8> { typedef S64 type_t; }; + template<> struct StorageType<U8> { typedef S64 type_t; }; + template<typename T> class LL_COMMON_API MeasurementAccumulator { public: + typedef T value_t; + typedef MeasurementAccumulator<T> self_t; + MeasurementAccumulator() : mSum(0), mMin(std::numeric_limits<T>::max()), @@ -243,23 +266,24 @@ namespace LLTrace LL_FORCE_INLINE void sample(T value) { + T storage_value(value); mNumSamples++; - mSum += value; - if (value < mMin) + mSum += storage_value; + if (storage_value < mMin) { - mMin = value; + mMin = storage_value; } - else if (value > mMax) + if (storage_value > mMax) { - mMax = value; + mMax = storage_value; } F64 old_mean = mMean; - mMean += ((F64)value - old_mean) / (F64)mNumSamples; - mVarianceSum += ((F64)value - old_mean) * ((F64)value - mMean); - mLastValue = value; + mMean += ((F64)storage_value - old_mean) / (F64)mNumSamples; + mVarianceSum += ((F64)storage_value - old_mean) * ((F64)storage_value - mMean); + mLastValue = storage_value; } - void addSamples(const MeasurementAccumulator<T>& other) + void addSamples(const self_t& other) { mSum += other.mSum; if (other.mMin < mMin) @@ -293,7 +317,7 @@ namespace LLTrace } else { - mVarianceSum = (F32)mNumSamples + mVarianceSum = (F64)mNumSamples * ((((n_1 - 1.f) * sd_1 * sd_1) + ((n_2 - 1.f) * sd_2 * sd_2) + (((n_1 * n_2) / (n_1 + n_2)) @@ -311,10 +335,10 @@ namespace LLTrace mMax = 0; } - T getSum() const { return mSum; } - T getMin() const { return mMin; } - T getMax() const { return mMax; } - T getLastValue() const { return mLastValue; } + T getSum() const { return (T)mSum; } + T getMin() const { return (T)mMin; } + T getMax() const { return (T)mMax; } + T getLastValue() const { return (T)mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } U32 getSampleCount() const { return mNumSamples; } @@ -325,7 +349,7 @@ namespace LLTrace mMax, mLastValue; - F64 mMean, + F64 mMean, mVarianceSum; U32 mNumSamples; @@ -335,6 +359,8 @@ namespace LLTrace class LL_COMMON_API CountAccumulator { public: + typedef T value_t; + CountAccumulator() : mSum(0), mNumSamples(0) @@ -358,7 +384,7 @@ namespace LLTrace mSum = 0; } - T getSum() const { return mSum; } + T getSum() const { return (T)mSum; } private: T mSum; @@ -366,14 +392,15 @@ namespace LLTrace U32 mNumSamples; }; - typedef TraceType<MeasurementAccumulator<F64> > measurement_common_t; + typedef TraceType<MeasurementAccumulator<F64> > measurement_common_float_t; + typedef TraceType<MeasurementAccumulator<S64> > measurement_common_int_t; template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Measurement - : public TraceType<MeasurementAccumulator<T> > + : public TraceType<MeasurementAccumulator<typename StorageType<T>::type_t> > { public: - typedef T storage_t; + typedef typename StorageType<T>::type_t storage_t; Measurement(const char* name, const char* description = NULL) : TraceType(name, description) @@ -381,17 +408,16 @@ namespace LLTrace void sample(T value) { - getPrimaryAccumulator().sample(value); + getPrimaryAccumulator().sample((storage_t)value); } }; template <typename T> class LL_COMMON_API Measurement <T, typename T::is_unit_tag_t> - : public TraceType<MeasurementAccumulator<typename T::storage_t> > + : public TraceType<MeasurementAccumulator<typename StorageType<typename T::storage_t>::type_t> > { public: - typedef typename T::storage_t storage_t; - typedef Measurement<typename T::storage_t> base_measurement_t; + typedef typename StorageType<typename T::storage_t>::type_t storage_t; Measurement(const char* name, const char* description = NULL) : TraceType(name, description) @@ -402,18 +428,19 @@ namespace LLTrace { T converted_value; converted_value.assignFrom(value); - getPrimaryAccumulator().sample(converted_value.value()); + getPrimaryAccumulator().sample((storage_t)converted_value.value()); } }; - typedef TraceType<CountAccumulator<F64> > count_common_t; + typedef TraceType<CountAccumulator<F64> > count_common_float_t; + typedef TraceType<CountAccumulator<S64> > count_common_int_t; template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Count - : public TraceType<CountAccumulator<T> > + : public TraceType<CountAccumulator<typename StorageType<T>::type_t> > { public: - typedef T storage_t; + typedef typename StorageType<T>::type_t storage_t; Count(const char* name, const char* description = NULL) : TraceType(name) @@ -421,17 +448,16 @@ namespace LLTrace void add(T value) { - getPrimaryAccumulator().add(value); + getPrimaryAccumulator().add((storage_t)value); } }; template <typename T> class LL_COMMON_API Count <T, typename T::is_unit_tag_t> - : public TraceType<CountAccumulator<typename T::storage_t> > + : public TraceType<CountAccumulator<typename StorageType<typename T::storage_t>::type_t> > { public: - typedef typename T::storage_t storage_t; - typedef Count<typename T::storage_t> base_count_t; + typedef typename StorageType<typename T::storage_t>::type_t storage_t; Count(const char* name, const char* description = NULL) : TraceType(name) @@ -442,7 +468,7 @@ namespace LLTrace { T converted_value; converted_value.assignFrom(value); - getPrimaryAccumulator().add(converted_value.value()); + getPrimaryAccumulator().add((storage_t)converted_value.value()); } }; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9a769ff344..f44a0a2764 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -39,8 +39,10 @@ namespace LLTrace Recording::Recording() : mElapsedSeconds(0), - mCounts(new AccumulatorBuffer<CountAccumulator<F64> >()), - mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), + mCountsFloat(new AccumulatorBuffer<CountAccumulator<F64> >()), + mMeasurementsFloat(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), + mCounts(new AccumulatorBuffer<CountAccumulator<S64> >()), + mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<S64> >()), mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) {} @@ -59,6 +61,8 @@ void Recording::update() void Recording::handleReset() { + mCountsFloat.write()->reset(); + mMeasurementsFloat.write()->reset(); mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); @@ -88,6 +92,8 @@ void Recording::handleSplitTo(Recording& other) void Recording::makePrimary() { + mCountsFloat.write()->makePrimary(); + mMeasurementsFloat.write()->makePrimary(); mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); @@ -100,14 +106,120 @@ bool Recording::isPrimary() const void Recording::mergeRecording( const Recording& other ) { + mCountsFloat.write()->addSamples(*other.mCountsFloat); + mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); mElapsedSeconds += other.mElapsedSeconds; } +F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mCountsFloat).getSum(); +} + +S64 Recording::getSum( const TraceType<CountAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mCounts).getSum(); +} + +F64 Recording::getSum( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return (F64)stat.getAccumulator(mMeasurementsFloat).getSum(); +} + +S64 Recording::getSum( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return (S64)stat.getAccumulator(mMeasurements).getSum(); +} + + + +F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mCountsFloat).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const +{ + return (F64)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getSum() / mElapsedSeconds; +} + +F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return (F64)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; +} + +F64 Recording::getMin( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMin(); +} + +S64 Recording::getMin( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F64 Recording::getMax( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMax(); +} + +S64 Recording::getMax( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F64 Recording::getMean( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getMean(); +} + +F64 Recording::getMean( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getStandardDeviation(); +} + +F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + +F64 Recording::getLastValue( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getLastValue(); +} + +S64 Recording::getLastValue( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getLastValue(); +} + +U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<F64> >& stat ) const +{ + return stat.getAccumulator(mMeasurementsFloat).getSampleCount(); +} + +U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& stat ) const +{ + return stat.getAccumulator(mMeasurements).getSampleCount(); +} + + + /////////////////////////////////////////////////////////////////////// -// Recording +// PeriodicRecording /////////////////////////////////////////////////////////////////////// PeriodicRecording::PeriodicRecording( S32 num_periods ) @@ -179,6 +291,7 @@ void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); } + /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index d3f001ab6a..4af973515d 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -112,124 +112,81 @@ namespace LLTrace void update(); // Count accessors + F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const; + S64 getSum(const TraceType<CountAccumulator<S64> >& stat) const; template <typename T> - T getSum(const TraceType<CountAccumulator<T> >& stat) const + T getSum(const Count<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mCounts).getSum(); - } - - template <typename T, typename IS_UNIT> - T getSum(const Count<T, IS_UNIT>& stat) const - { - return (T)stat.getAccumulator(mCounts).getSum(); + return (T)getSum(static_cast<const TraceType<CountAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat) const; + F64 getPerSec(const TraceType<CountAccumulator<S64> >& stat) const; template <typename T> - T getPerSec(const TraceType<CountAccumulator<T> >& stat) const + T getPerSec(const Count<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; - } - - template <typename T, typename IS_UNIT> - T getPerSec(const Count<T, IS_UNIT>& stat) const - { - return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; + return (T)getPerSec(static_cast<const TraceType<CountAccumulator<StorageType<T>::type_t> >&> (stat)); } // Measurement accessors + F64 getSum(const TraceType<MeasurementAccumulator<F64> >& stat) const; + S64 getSum(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getSum(const TraceType<MeasurementAccumulator<T> >& stat) const + T getSum(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getSum(); - - } - - template <typename T, typename IS_UNIT> - T getSum(const Measurement<T, IS_UNIT>& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getSum(); - + return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getPerSec(const TraceType<MeasurementAccumulator<F64> >& stat) const; + F64 getPerSec(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getPerSec(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; - } - - template <typename T, typename IS_UNIT> - T getPerSec(const Measurement<T, IS_UNIT>& stat) const + T getPerSec(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (typename Count<T, IS_UNIT>::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; + return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getMin(const TraceType<MeasurementAccumulator<F64> >& stat) const; + S64 getMin(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMin(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getMin(); - } - - template <typename T, typename IS_UNIT> - T getMin(const Measurement<T, IS_UNIT>& stat) const + T getMin(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getMin(); + return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } - + F64 getMax(const TraceType<MeasurementAccumulator<F64> >& stat) const; + S64 getMax(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMax(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getMax(); - } - - template <typename T, typename IS_UNIT> - T getMax(const Measurement<T, IS_UNIT>& stat) const + T getMax(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getMax(); + return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getMean(const TraceType<MeasurementAccumulator<F64> >& stat) const; + F64 getMean(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMean(const TraceType<MeasurementAccumulator<T> >& stat) const + T getMean(Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getMean(); - } - - template <typename T, typename IS_UNIT> - T getMean(Measurement<T, IS_UNIT>& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getMean(); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getStandardDeviation(const TraceType<MeasurementAccumulator<F64> >& stat) const; + F64 getStandardDeviation(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getStandardDeviation(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); - } - - template <typename T, typename IS_UNIT> - T getStandardDeviation(const Measurement<T, IS_UNIT>& stat) const + T getStandardDeviation(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } + F64 getLastValue(const TraceType<MeasurementAccumulator<F64> >& stat) const; + S64 getLastValue(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getLastValue(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return (T)stat.getAccumulator(mMeasurements).getLastValue(); - } - - template <typename T, typename IS_UNIT> - T getLastValue(const Measurement<T, IS_UNIT>& stat) const + T getLastValue(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)stat.getAccumulator(mMeasurements).getLastValue(); + return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); } - - template <typename T> - U32 getSampleCount(const TraceType<MeasurementAccumulator<T> >& stat) const - { - return stat.getAccumulator(mMeasurements).getSampleCount(); - } + U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const; + U32 getSampleCount(const TraceType<MeasurementAccumulator<S64> >& stat) const; LLUnit::Seconds<F64> getDuration() const { return mElapsedSeconds; } @@ -244,8 +201,10 @@ namespace LLTrace // returns data for current thread class ThreadRecorder* getThreadRecorder(); - LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > > mCounts; - LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurements; + LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<F64> > > mCountsFloat; + LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurementsFloat; + LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > > mCounts; + LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > > mMeasurements; LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; LLTimer mSamplingTimer; @@ -260,6 +219,7 @@ namespace LLTrace ~PeriodicRecording(); void nextPeriod(); + S32 getNumPeriods() { return mNumPeriods; } Recording& getLastRecordingPeriod() { @@ -268,7 +228,7 @@ namespace LLTrace const Recording& getLastRecordingPeriod() const { - return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; + return getPrevRecordingPeriod(1); } Recording& getCurRecordingPeriod() @@ -281,6 +241,16 @@ namespace LLTrace return mRecordingPeriods[mCurPeriod]; } + Recording& getPrevRecordingPeriod(S32 offset) + { + return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; + } + + const Recording& getPrevRecordingPeriod(S32 offset) const + { + return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; + } + Recording snapshotCurRecordingPeriod() const { Recording recording_copy(getCurRecordingPeriod()); @@ -290,6 +260,84 @@ namespace LLTrace Recording& getTotalRecording(); + template <typename T> + typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const + { + T min_val = std::numeric_limits<T>::max(); + for (S32 i = 0; i < mNumPeriods; i++) + { + min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat)); + } + return (T)min_val; + } + + template <typename T> + F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const + { + F64 min_val = std::numeric_limits<F64>::max(); + for (S32 i = 0; i < mNumPeriods; i++) + { + min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat)); + } + return min_val; + } + + template <typename T> + T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const + { + T max_val = std::numeric_limits<T>::min(); + for (S32 i = 0; i < mNumPeriods; i++) + { + max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat)); + } + return max_val; + } + + template <typename T> + F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const + { + F64 max_val = std::numeric_limits<F64>::min(); + for (S32 i = 0; i < mNumPeriods; i++) + { + max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat)); + } + return max_val; + } + + template <typename T> + F64 getPeriodMean(const TraceType<CountAccumulator<T> >& stat) const + { + F64 mean = 0.0; + F64 count = 0; + for (S32 i = 0; i < mNumPeriods; i++) + { + if (mRecordingPeriods[i].getDuration() > 0.f) + { + count++; + mean += mRecordingPeriods[i].getSum(stat); + } + } + mean /= (F64)mNumPeriods; + return mean; + } + + template <typename T> + F64 getPeriodMeanPerSec(const TraceType<CountAccumulator<T> >& stat) const + { + F64 mean = 0.0; + F64 count = 0; + for (S32 i = 0; i < mNumPeriods; i++) + { + if (mRecordingPeriods[i].getDuration() > 0.f) + { + count++; + mean += mRecordingPeriods[i].getPerSec(stat); + } + } + mean /= count; + return mean; + } + private: // implementation for LLVCRControlsMixin diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index e81333f7f2..15056b80e4 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -113,9 +113,13 @@ ThreadRecorder::ActiveRecording::ActiveRecording( Recording* target ) void ThreadRecorder::ActiveRecording::moveBaselineToTarget() { + mTargetRecording->mMeasurementsFloat.write()->addSamples(*mBaseline.mMeasurementsFloat); + mTargetRecording->mCountsFloat.write()->addSamples(*mBaseline.mCountsFloat); mTargetRecording->mMeasurements.write()->addSamples(*mBaseline.mMeasurements); mTargetRecording->mCounts.write()->addSamples(*mBaseline.mCounts); mTargetRecording->mStackTimers.write()->addSamples(*mBaseline.mStackTimers); + mBaseline.mMeasurementsFloat.write()->reset(); + mBaseline.mCountsFloat.write()->reset(); mBaseline.mMeasurements.write()->reset(); mBaseline.mCounts.write()->reset(); mBaseline.mStackTimers.write()->reset(); diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 535c6f96e3..6b40f8d475 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -34,7 +34,6 @@ #include "llgl.h" #include "llfontgl.h" -#include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" @@ -46,8 +45,10 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), - mStatp(LLStat::getInstance(p.stat)), - mNewStatp(LLTrace::Count<>::getInstance(p.stat)), + mCountFloatp(LLTrace::Count<>::getInstance(p.stat)), + mCountIntp(LLTrace::Count<S64>::getInstance(p.stat)), + mMeasurementFloatp(LLTrace::Measurement<>::getInstance(p.stat)), + mMeasurementIntp(LLTrace::Measurement<S64>::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -90,46 +91,62 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; - if (mStatp) + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + + if (mCountFloatp) { - // Get the values. + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + if (mPerSec) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + current = last_frame_recording.getPerSec(*mCountFloatp); + min = frame_recording.getPeriodMinPerSec(*mCountFloatp); + max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); + mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); } else { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + current = last_frame_recording.getSum(*mCountFloatp); + min = frame_recording.getPeriodMin(*mCountFloatp); + max = frame_recording.getPeriodMax(*mCountFloatp); + mean = frame_recording.getPeriodMean(*mCountFloatp); } } - else if (mNewStatp) + else if (mCountIntp) { - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); - LLTrace::Recording& windowed_frame_recording = frame_recording.getTotalRecording(); if (mPerSec) { - current = last_frame_recording.getPerSec(*mNewStatp); - //min = frame_window_recording.getMin(*mNewStatp) / frame_window_recording.getDuration(); - //max = frame_window_recording.getMax(*mNewStatp) / frame_window_recording.getDuration(); - mean = windowed_frame_recording.getPerSec(*mNewStatp);//frame_window_recording.getMean(*mNewStatp) / frame_window_recording.getDuration(); + current = last_frame_recording.getPerSec(*mCountIntp); + min = frame_recording.getPeriodMinPerSec(*mCountIntp); + max = frame_recording.getPeriodMaxPerSec(*mCountIntp); + mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); } else { - current = last_frame_recording.getSum(*mNewStatp); - //min = last_frame_recording.getMin(*mNewStatp); - //max = last_frame_recording.getMax(*mNewStatp); - mean = windowed_frame_recording.getSum(*mNewStatp); + current = last_frame_recording.getSum(*mCountIntp); + min = frame_recording.getPeriodMin(*mCountIntp); + max = frame_recording.getPeriodMax(*mCountIntp); + mean = frame_recording.getPeriodMean(*mCountIntp); } } - + else if (mMeasurementFloatp) + { + LLTrace::Recording& recording = frame_recording.getTotalRecording(); + current = recording.getLastValue(*mMeasurementFloatp); + min = recording.getMin(*mMeasurementFloatp); + max = recording.getMax(*mMeasurementFloatp); + mean = recording.getMean(*mMeasurementFloatp); + } + else if (mMeasurementIntp) + { + LLTrace::Recording& recording = frame_recording.getTotalRecording(); + current = recording.getLastValue(*mMeasurementIntp); + min = recording.getMin(*mMeasurementIntp); + max = recording.getMax(*mMeasurementIntp); + mean = recording.getMean(*mMeasurementIntp); + } if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { @@ -176,7 +193,7 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar && mStatp) + if (mDisplayBar && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { std::string tick_label; @@ -219,7 +236,7 @@ void LLStatBar::draw() right = width; gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); - if (mStatp->getNumValues() == 0) + if (frame_recording.getNumPeriods() == 0) { // No data, don't draw anything... return; @@ -236,26 +253,58 @@ void LLStatBar::draw() right = (S32) ((max - mMinBar) * value_scale); gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); - if (mDisplayHistory) + if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { - S32 num_values = mStatp->getNumValues() - 1; + S32 num_values = frame_recording.getNumPeriods() - 1; S32 i; - for (i = 0; i < num_values; i++) + for (i = 1; i <= num_values; i++) { - if (i == mStatp->getNextBin()) - { - continue; - } if (mPerSec) { - left = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale) + 1; + if (mCountFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + } + else if (mCountIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + } gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } else { - left = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale) + 1; + if (mCountFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + } + else if (mCountIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + } gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } } @@ -279,6 +328,15 @@ void LLStatBar::draw() LLView::draw(); } +void LLStatBar::setStat(const std::string& stat_name) +{ + mCountFloatp = LLTrace::Count<>::getInstance(stat_name); + mCountIntp = LLTrace::Count<S64>::getInstance(stat_name); + mMeasurementFloatp = LLTrace::Measurement<>::getInstance(stat_name); + mMeasurementIntp = LLTrace::Measurement<S64>::getInstance(stat_name); +} + + void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing) { mMinBar = bar_min; @@ -293,9 +351,9 @@ LLRect LLStatBar::getRequiredRect() if (mDisplayBar) { - if (mDisplayHistory && mStatp) + if (mDisplayHistory) { - rect.mTop = 35 + mStatp->getNumBins(); + rect.mTop = 35 + LLTrace::get_frame_recording().getNumPeriods(); } else { diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index d510f0e3fe..6aefb1e213 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -30,7 +30,6 @@ #include "llview.h" #include "llframetimer.h" #include "lltracerecording.h" -class LLStat; class LLStatBar : public LLView { @@ -79,7 +78,8 @@ public: virtual void draw(); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); - void setStat(LLStat* stat) { mStatp = stat; } + void setStat(const std::string& stat_name); + void setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing); void getRange(F32& bar_min, F32& bar_max) { bar_min = mMinBar; bar_max = mMaxBar; } @@ -96,10 +96,11 @@ private: BOOL mDisplayBar; // Display the bar graph. BOOL mDisplayHistory; BOOL mDisplayMean; // If true, display mean, if false, display current value - LLTrace::PeriodicRecording* mFrameRecording; - LLStat* mStatp; - LLTrace::count_common_t* mNewStatp; + LLTrace::count_common_float_t* mCountFloatp; + LLTrace::count_common_int_t* mCountIntp; + LLTrace::measurement_common_float_t* mMeasurementFloatp; + LLTrace::measurement_common_int_t* mMeasurementIntp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index e961e7d3c0..22c276a018 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -32,7 +32,6 @@ #include "llmath.h" #include "llui.h" -#include "llstat.h" #include "llgl.h" #include "llglheaders.h" #include "lltracerecording.h" @@ -48,8 +47,8 @@ LLStatGraph::LLStatGraph(const Params& p) mPerSec(true), mPrecision(p.precision), mValue(p.value), - mStatp(p.stat.legacy_stat), - mNewStatp(p.stat.count_stat) + mNewStatFloatp(p.stat.count_stat_float), + mNewStatIntp(p.stat.count_stat_int) { setToolTip(p.name()); @@ -73,30 +72,31 @@ void LLStatGraph::draw() { F32 range, frac; range = mMax - mMin; - if (mStatp) + if (mNewStatFloatp) { + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); + if (mPerSec) { - mValue = mStatp->getMeanPerSec(); + mValue = recording.getPerSec(*mNewStatFloatp); } else { - mValue = mStatp->getMean(); + mValue = recording.getSum(*mNewStatFloatp); } } - else if (mNewStatp) + else if (mNewStatIntp) { LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); if (mPerSec) { - mValue = recording.getPerSec(*mNewStatp); + mValue = recording.getPerSec(*mNewStatIntp); } else { - mValue = recording.getSum(*mNewStatp); + mValue = recording.getSum(*mNewStatIntp); } - } frac = (mValue - mMin) / range; diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index b20966d608..f33c784262 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -32,8 +32,6 @@ #include "v4color.h" #include "lltrace.h" -class LLStat; - class LLStatGraph : public LLView { public: @@ -59,9 +57,10 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { - Alternative<LLStat*> legacy_stat; - Alternative<LLTrace::count_common_t* > count_stat; - Alternative<LLTrace::measurement_common_t* > measurement_stat; + Alternative<LLTrace::count_common_float_t* > count_stat_float; + Alternative<LLTrace::count_common_int_t* > count_stat_int; + Alternative<LLTrace::measurement_common_float_t* > measurement_stat_float; + Alternative<LLTrace::measurement_common_int_t* > measurement_stat_int; }; struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -106,8 +105,8 @@ public: /*virtual*/ void setValue(const LLSD& value); private: - LLStat* mStatp; - LLTrace::count_common_t* mNewStatp; + LLTrace::count_common_float_t* mNewStatFloatp; + LLTrace::count_common_int_t* mNewStatIntp; BOOL mPerSec; diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp index ca749c5eaf..7f631ef0bb 100644 --- a/indra/llvfs/llvfile.cpp +++ b/indra/llvfs/llvfile.cpp @@ -30,8 +30,8 @@ #include "llerror.h" #include "llthread.h" -#include "llstat.h" #include "llvfs.h" +#include "lltimer.h" const S32 LLVFile::READ = 0x00000001; const S32 LLVFile::WRITE = 0x00000002; diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp index d79e9f8bde..23e1fe306e 100644 --- a/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/indra/lscript/lscript_execute/lscript_execute.cpp @@ -35,7 +35,6 @@ #include "lscript_library.h" #include "lscript_heapruntime.h" #include "lscript_alloc.h" -#include "llstat.h" // Static diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 751b73e1eb..8d80e3aa0a 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1081,8 +1081,8 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation(); LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation(); - if ((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) && - (root_at * last_at_axis > 0.95f)) + if (LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f + && (root_at * last_at_axis > 0.95f)) { LLVector3 vel = gAgentAvatarp->getVelocity(); if (vel.magVecSquared() > 4.f) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 559f427de6..2d090f0f74 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4305,6 +4305,9 @@ void LLAppViewer::idle() update_statistics(); } + LLTrace::get_frame_recording().nextPeriod(); + + //////////////////////////////////////// // // Handle the regular UI idle callbacks as well as diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 4dfb93f1bc..065b20ba2b 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -46,7 +46,6 @@ #include "llviewertexturelist.h" #include "llui.h" #include "llviewercontrol.h" -#include "llstat.h" #include "llfasttimer.h" #include "lltreeiterators.h" diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index f7b2670b8e..e2813a8272 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -33,7 +33,7 @@ #include "llerror.h" #include "llrect.h" #include "llstring.h" -#include "llstat.h" +#include "lltrace.h" // project includes #include "lluictrlfactory.h" @@ -42,6 +42,16 @@ #include "llviewerjoystick.h" #include "llcheckboxctrl.h" +static LLTrace::Measurement<> sJoystickAxes[6] = +{ + LLTrace::Measurement<>("Joystick axis 1"), + LLTrace::Measurement<>("Joystick axis 2"), + LLTrace::Measurement<>("Joystick axis 3"), + LLTrace::Measurement<>("Joystick axis 4"), + LLTrace::Measurement<>("Joystick axis 5"), + LLTrace::Measurement<>("Joystick axis 6") +}; + LLFloaterJoystick::LLFloaterJoystick(const LLSD& data) : LLFloater(data) { @@ -61,7 +71,7 @@ void LLFloaterJoystick::draw() for (U32 i = 0; i < 6; i++) { F32 value = joystick->getJoystickAxis(i); - mAxisStats[i]->addValue(value * gFrameIntervalSeconds.value()); + sJoystickAxes[i].sample(value * gFrameIntervalSeconds.value()); if (mAxisStatsBar[i]) { F32 minbar, maxbar; @@ -85,12 +95,11 @@ BOOL LLFloaterJoystick::postBuild() for (U32 i = 0; i < 6; i++) { std::string stat_name(llformat("Joystick axis %d", i)); - mAxisStats[i] = new LLStat(stat_name, 4); std::string axisname = llformat("axis%d", i); mAxisStatsBar[i] = getChild<LLStatBar>(axisname); if (mAxisStatsBar[i]) { - mAxisStatsBar[i]->setStat(mAxisStats[i]); + mAxisStatsBar[i]->setStat(stat_name); mAxisStatsBar[i]->setRange(-range, range, range * 0.25f, range * 0.5f); } } diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h index dfdb108ff8..9c3752540d 100644 --- a/indra/newview/llfloaterjoystick.h +++ b/indra/newview/llfloaterjoystick.h @@ -84,7 +84,6 @@ private: LLCheckBoxCtrl *mCheckFlycamEnabled; // stats view - LLStat* mAxisStats[6]; LLStatBar* mAxisStatsBar[6]; }; diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 482294c8a6..56fbdb429a 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -30,6 +30,7 @@ #include "llhudnametag.h" #include "llrender.h" +#include "lltracerecording.h" #include "llagent.h" #include "llviewercontrol.h" @@ -899,8 +900,8 @@ void LLHUDNameTag::updateAll() // } } - LLStat* camera_vel_stat = LLViewerCamera::getInstance()->getVelocityStat(); - F32 camera_vel = camera_vel_stat->getCurrent(); + LLTrace::Count<>* camera_vel_stat = LLViewerCamera::getVelocityStat(); + F32 camera_vel = LLTrace::get_frame_recording().getLastRecordingPeriod().getPerSec(*camera_vel_stat); if (camera_vel > MAX_STABLE_CAMERA_VELOCITY) { return; diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 5720395d05..b945ec2318 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild() sgp.rect(r); sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); sgp.mouse_opaque(false); - sgp.stat.count_stat(&LLStatViewer::KBIT); + sgp.stat.count_stat_float(&LLStatViewer::KBIT); sgp.units("Kbps"); sgp.precision(0); mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp); @@ -212,7 +212,7 @@ BOOL LLStatusBar::postBuild() pgp.rect(r); pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT); pgp.mouse_opaque(false); - pgp.stat.measurement_stat(&LLStatViewer::PACKETS_LOST_PERCENT); + pgp.stat.measurement_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT); pgp.units("%"); pgp.min(0.f); pgp.max(5.f); diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 9d24bf8771..33a64ae7d5 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -45,7 +45,6 @@ class LLTimer; class LLUUID; class LLAgent; -class LLStat; static const U8 NO_EDGE = 0x00; static const U8 EAST_EDGE = 0x01; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 2a72e77672..fa0e3acf5e 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -59,8 +59,8 @@ #include "llviewerstats.h" bool LLTextureFetchDebugger::sDebuggerEnabled = false ; -LLStat LLTextureFetch::sCacheHitRate("texture_cache_hits", 128); -LLStat LLTextureFetch::sCacheReadLatency("texture_cache_read_latency", 128); +LLTrace::Measurement<> LLTextureFetch::sCacheHitRate("texture_cache_hits"); +LLTrace::Measurement<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency"); ////////////////////////////////////////////////////////////////////////////// class LLTextureFetchWorker : public LLWorkerClass @@ -895,7 +895,7 @@ bool LLTextureFetchWorker::doWork(S32 param) LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize() << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight()) << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL; - LLTextureFetch::sCacheHitRate.addValue(100.f); + LLTextureFetch::sCacheHitRate.sample(100.f); } else { @@ -912,7 +912,7 @@ bool LLTextureFetchWorker::doWork(S32 param) } // fall through - LLTextureFetch::sCacheHitRate.addValue(0.f); + LLTextureFetch::sCacheHitRate.sample(0.f); } } @@ -2039,7 +2039,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, F32 cache_read_time = worker->mCacheReadTime; if (cache_read_time != 0.f) { - sCacheReadLatency.addValue(cache_read_time * 1000.f); + sCacheReadLatency.sample(cache_read_time * 1000.f); } res = true; LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 7ffa58660e..4ec67c8cdb 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -35,8 +35,7 @@ #include "lltextureinfo.h" #include "llapr.h" #include "llimageworker.h" -#include "llstat.h" -//#include "lltexturecache.h" +#include "lltrace.h" class LLViewerTexture; class LLTextureFetchWorker; @@ -166,8 +165,8 @@ private: LLMutex mQueueMutex; //to protect mRequestMap and mCommands only LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue. - static LLStat sCacheHitRate; - static LLStat sCacheReadLatency; + static LLTrace::Measurement<> sCacheHitRate; + static LLTrace::Measurement<> sCacheReadLatency; LLTextureCache* mTextureCache; LLImageDecodeThread* mImageDecodeThread; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index a437a8b3b5..831304f428 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -49,10 +49,14 @@ #include "llglheaders.h" #include "llquaternion.h" #include "llwindow.h" // getPixelAspectRatio() +#include "lltracerecording.h" // System includes #include <iomanip> // for setprecision +LLTrace::Count<> LLViewerCamera::sVelocityStat("camera_velocity"); +LLTrace::Count<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity"); + U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; //glu pick matrix implementation borrowed from Mesa3D @@ -163,11 +167,12 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, F32 drot; rotation.getAngleAxis(&drot, &x, &y, &z); - mVelocityStat.addValue(dpos); - mAngularVelocityStat.addValue(drot); + sVelocityStat.add(dpos); + sAngularVelocityStat.add(drot); - mAverageSpeed = mVelocityStat.getMeanPerSec() ; - mAverageAngularSpeed = mAngularVelocityStat.getMeanPerSec() ; + LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording(); + mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat); + mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat); mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect())); // update pixel meter ratio using default fov, not modified one diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index b857c7fe89..399eed7695 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -29,10 +29,10 @@ #include "llcamera.h" #include "llsingleton.h" -#include "llstat.h" #include "lltimer.h" #include "m4math.h" #include "llcoord.h" +#include "lltrace.h" class LLViewerObject; @@ -100,12 +100,12 @@ public: BOOL projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const BOOL clamp = TRUE) const; BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const; - const LLVector3* getVelocityDir() const {return &mVelocityDir;} - LLStat *getVelocityStat() { return &mVelocityStat; } - LLStat *getAngularVelocityStat() { return &mAngularVelocityStat; } - F32 getCosHalfFov() {return mCosHalfCameraFOV;} - F32 getAverageSpeed() {return mAverageSpeed ;} - F32 getAverageAngularSpeed() {return mAverageAngularSpeed;} + const LLVector3* getVelocityDir() const {return &mVelocityDir;} + static LLTrace::Count<>* getVelocityStat() {return &sVelocityStat; } + static LLTrace::Count<>* getAngularVelocityStat() {return &sAngularVelocityStat; } + F32 getCosHalfFov() {return mCosHalfCameraFOV;} + F32 getAverageSpeed() {return mAverageSpeed ;} + F32 getAverageAngularSpeed() {return mAverageAngularSpeed;} void getPixelVectors(const LLVector3 &pos_agent, LLVector3 &up, LLVector3 &right); LLVector3 roundToPixel(const LLVector3 &pos_agent); @@ -117,9 +117,9 @@ public: F32 getDefaultFOV() { return mCameraFOVDefault; } BOOL cameraUnderWater() const; - - const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; } BOOL areVertsVisible(LLViewerObject* volumep, BOOL all_verts); + + const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; } F32 getPixelMeterRatio() const { return mPixelMeterRatio; } S32 getScreenPixelArea() const { return mScreenPixelArea; } @@ -130,12 +130,12 @@ public: protected: void calcProjection(const F32 far_distance) const; - LLStat mVelocityStat; - LLStat mAngularVelocityStat; - LLVector3 mVelocityDir ; - F32 mAverageSpeed ; - F32 mAverageAngularSpeed ; + static LLTrace::Count<> sVelocityStat; + static LLTrace::Count<> sAngularVelocityStat; + LLVector3 mVelocityDir ; + F32 mAverageSpeed ; + F32 mAverageAngularSpeed ; mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix mutable LLMatrix4 mModelviewMatrix; F32 mCameraFOVDefault; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 169b45c14e..41a08398bb 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -748,8 +748,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(FTM_IMAGE_UPDATE_CLASS); - LLViewerTexture::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), - LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean()); + LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat(); + LLTrace::Count<>* angular_velocity_stat = LLViewerCamera::getAngularVelocityStat(); + LLViewerTexture::updateClass(LLTrace::get_frame_recording().getPeriodMeanPerSec(*velocity_stat), + LLTrace::get_frame_recording().getPeriodMeanPerSec(*angular_velocity_stat)); } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 82caa05983..acbe836c29 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4765,28 +4765,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data) } } - /* - msg->getF32Fast(_PREHASH_Statistics, _PREHASH_PhysicsTimeDilation, time_dilation); - LLViewerStats::getInstance()->mSimTDStat.addValue(time_dilation); - - // Process information - // { CpuUsage F32 } - // { SimMemTotal F32 } - // { SimMemRSS F32 } - // { ProcessUptime F32 } - F32 cpu_usage; - F32 sim_mem_total; - F32 sim_mem_rss; - F32 process_uptime; - msg->getF32Fast(_PREHASH_Statistics, _PREHASH_CpuUsage, cpu_usage); - msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemTotal, sim_mem_total); - msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemRSS, sim_mem_rss); - msg->getF32Fast(_PREHASH_Statistics, _PREHASH_ProcessUptime, process_uptime); - LLViewerStats::getInstance()->mSimCPUUsageStat.addValue(cpu_usage); - LLViewerStats::getInstance()->mSimMemTotalStat.addValue(sim_mem_total); - LLViewerStats::getInstance()->mSimMemRSSStat.addValue(sim_mem_rss); - */ - // // Various hacks that aren't statistics, but are being handled here. // diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 14a2ac3384..9c6045943f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -93,7 +93,7 @@ extern LLPipeline gPipeline; U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. std::map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; std::map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; -LLStat LLViewerObjectList::sCacheHitRate("object_cache_hits", 128); +LLTrace::Measurement<> LLViewerObjectList::sCacheHitRate("object_cache_hits"); LLViewerObjectList::LLViewerObjectList() { @@ -520,7 +520,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys, } justCreated = TRUE; mNumNewObjects++; - sCacheHitRate.addValue(cached ? 100.f : 0.f); + sCacheHitRate.sample(cached ? 100.f : 0.f); } diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 9936432a71..ca4110230f 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -31,8 +31,8 @@ #include <set> // common includes -#include "llstat.h" #include "llstring.h" +#include "lltrace.h" // project includes #include "llviewerobject.h" @@ -194,7 +194,7 @@ protected: std::vector<OrphanInfo> mOrphanChildren; // UUID's of orphaned objects S32 mNumOrphans; - static LLStat sCacheHitRate; + static LLTrace::Measurement<> sCacheHitRate; typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 31e3820a21..652e0ee70b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -291,7 +291,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mCacheLoaded(FALSE), mCacheDirty(FALSE), mReleaseNotesRequested(FALSE), - mCapabilitiesReceived(false) + mCapabilitiesReceived(false), + mBitsReceived(0.f), + mPacketsReceived(0.f) { mWidth = region_width_meters; mImpl->mOriginGlobal = from_region_handle(handle); @@ -909,9 +911,8 @@ void LLViewerRegion::updateNetStats() mPacketsLost = cdp->getPacketsLost(); mPingDelay = cdp->getPingDelay(); - mBitStat.addValue(mBitsIn - mLastBitsIn); - mPacketsStat.addValue(mPacketsIn - mLastPacketsIn); - mPacketsLostStat.addValue(mPacketsLost); + mBitsReceived += mBitsIn - mLastBitsIn; + mPacketsReceived += mPacketsIn - mLastPacketsIn; } diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index c9fffaf30e..756c0dc61f 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -34,7 +34,6 @@ #include "lldarray.h" #include "llwind.h" -#include "llstat.h" #include "v3dmath.h" #include "llstring.h" #include "llregionflags.h" @@ -351,9 +350,8 @@ public: LLWind mWind; LLViewerParcelOverlay *mParcelOverlay; - LLStat mBitStat; - LLStat mPacketsStat; - LLStat mPacketsLostStat; + F32 mBitsReceived; + F32 mPacketsReceived; LLMatrix4 mRenderMatrix; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 04b0c30b40..a42368cec4 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -94,8 +94,8 @@ LLTrace::Count<LLTrace::Kilobits> KBIT("kbitstat"), OBJECT_KBIT("objectkbitstat"), ASSET_KBIT("assetkbitstat"), TEXTURE_KBIT("texturekbitstat"), - ACTUAL_IN_KBIT("actualinkbit"), - ACTUAL_OUT_KBIT("actualoutkbit"); + ACTUAL_IN_KBIT("actualinkbitstat"), + ACTUAL_OUT_KBIT("actualoutkbitstat"); LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), @@ -276,20 +276,25 @@ void LLViewerStats::addToMessage(LLSD &body) const // *NOTE:Mani The following methods used to exist in viewer.cpp // Moving them here, but not merging them into LLViewerStats yet. -U32 gTotalLandIn = 0, gTotalLandOut = 0; -U32 gTotalWaterIn = 0, gTotalWaterOut = 0; - -F32 gAveLandCompression = 0.f, gAveWaterCompression = 0.f; -F32 gBestLandCompression = 1.f, gBestWaterCompression = 1.f; -F32 gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f; +U32 gTotalLandIn = 0, + gTotalLandOut = 0, + gTotalWaterIn = 0, + gTotalWaterOut = 0; + +F32 gAveLandCompression = 0.f, + gAveWaterCompression = 0.f, + gBestLandCompression = 1.f, + gBestWaterCompression = 1.f, + gWorstLandCompression = 0.f, + gWorstWaterCompression = 0.f; LLUnit::Bytes<U32> gTotalWorldData = 0, gTotalObjectData = 0, gTotalTextureData = 0; -U32 gSimPingCount = 0; +U32 gSimPingCount = 0; LLUnit::Bits<U32> gObjectData = 0; -F32 gAvgSimPing = 0.f; -LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; +F32 gAvgSimPing = 0.f; +LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; extern U32 gVisCompared; extern U32 gVisTested; @@ -334,13 +339,13 @@ void update_statistics() LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { - LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay()); + LLStatViewer::SIM_PING.sample<LLTrace::Milliseconds>(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { - LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000); + LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10); } LLStatViewer::FPS.add(1); @@ -390,8 +395,6 @@ void update_statistics() texture_stats_timer.reset(); } } - - LLTrace::get_frame_recording().nextPeriod(); } class ViewerStatsResponder : public LLHTTPClient::Responder diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 34731481f5..eda7b3329d 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -27,7 +27,6 @@ #ifndef LL_LLVIEWERSTATS_H #define LL_LLVIEWERSTATS_H -#include "llstat.h" #include "llstatenums.h" #include "lltextureinfo.h" #include "lltracerecording.h" diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index a00f48b5a2..e3df71cca2 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -30,7 +30,6 @@ #include "lluuid.h" //#include "message.h" #include "llgl.h" -#include "llstat.h" #include "llviewertexture.h" #include "llui.h" #include <list> diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 06daf15c08..b7415669bb 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -77,7 +77,6 @@ #include "llmediaentry.h" #include "llurldispatcher.h" #include "raytrace.h" -#include "llstat.h" // newview includes #include "llagent.h" @@ -249,6 +248,9 @@ std::string LLViewerWindow::sSnapshotDir; std::string LLViewerWindow::sMovieBaseName; +LLTrace::Measurement<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity"); + + class RecordToChatConsole : public LLError::Recorder, public LLSingleton<RecordToChatConsole> { public: @@ -1541,8 +1543,7 @@ LLViewerWindow::LLViewerWindow(const Params& p) mResDirty(false), mStatesDirty(false), mCurrResolutionIndex(0), - mProgressView(NULL), - mMouseVelocityStat(new LLStat("Mouse Velocity")) + mProgressView(NULL) { // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to // pass its value right now. Instead, pass it a nullary function that @@ -2072,8 +2073,6 @@ LLViewerWindow::~LLViewerWindow() delete mDebugText; mDebugText = NULL; - - delete mMouseVelocityStat; } @@ -3247,7 +3246,7 @@ void LLViewerWindow::updateMouseDelta() mouse_vel.setVec((F32) dx, (F32) dy); } - mMouseVelocityStat->addValue(mouse_vel.magVec()); + sMouseVelocityStat.sample(mouse_vel.magVec()); } void LLViewerWindow::updateKeyboardFocus() diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 5f475fe145..be2d6d885e 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -44,12 +44,12 @@ #include "llmousehandler.h" #include "llhandle.h" #include "llinitparam.h" +#include "lltrace.h" #include <boost/function.hpp> #include <boost/signals2.hpp> #include <boost/scoped_ptr.hpp> -class LLStat; class LLView; class LLViewerObject; class LLUUID; @@ -250,7 +250,7 @@ public: S32 getCurrentMouseDX() const { return mCurrentMouseDelta.mX; } S32 getCurrentMouseDY() const { return mCurrentMouseDelta.mY; } LLCoordGL getCurrentMouseDelta() const { return mCurrentMouseDelta; } - LLStat* getMouseVelocityStat() { return mMouseVelocityStat; } + static LLTrace::Measurement<>* getMouseVelocityStat() { return &sMouseVelocityStat; } BOOL getLeftMouseDown() const { return mLeftMouseDown; } BOOL getMiddleMouseDown() const { return mMiddleMouseDown; } BOOL getRightMouseDown() const { return mRightMouseDown; } @@ -427,7 +427,6 @@ private: LLCoordGL mCurrentMousePoint; // last mouse position in GL coords LLCoordGL mLastMousePoint; // Mouse point at last frame. LLCoordGL mCurrentMouseDelta; //amount mouse moved this frame - LLStat* mMouseVelocityStat; BOOL mLeftMouseDown; BOOL mMiddleMouseDown; BOOL mRightMouseDown; @@ -482,6 +481,8 @@ private: // Object temporarily hovered over while dragging LLPointer<LLViewerObject> mDragHoveredObject; + + static LLTrace::Measurement<> sMouseVelocityStat; }; // diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 97c1b07ebc..3c1f8ca6b0 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4318,8 +4318,6 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) //-------------------------------------------------------------------- // render all geometry attached to the skeleton //-------------------------------------------------------------------- - static LLStat render_stat; - LLViewerJointMesh::sRenderPass = pass; if (pass == AVATAR_RENDER_PASS_SINGLE) @@ -4372,10 +4370,6 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE; - //llinfos << "Avatar render: " << render_timer.getElapsedTimeF32() << llendl; - - //render_stat.addValue(render_timer.getElapsedTimeF32()*1000.f); - return num_indices; } diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index dced5a847b..e140f3b23b 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -692,8 +692,10 @@ void LLWorld::updateNetStats() { LLViewerRegion* regionp = *iter; regionp->updateNetStats(); - bits += regionp->mBitStat.getCurrent(); - packets += llfloor( regionp->mPacketsStat.getCurrent() ); + bits += regionp->mBitsReceived; + packets += llfloor( regionp->mPacketsReceived ); + regionp->mBitsReceived = 0.f; + regionp->mPacketsReceived = 0.f; } S32 packets_in = gMessageSystem->mPacketsIn - mLastPacketsIn; @@ -705,26 +707,15 @@ void LLWorld::updateNetStats() LLStatViewer::ACTUAL_IN_KBIT.add<LLTrace::Bits>(actual_in_bits); LLStatViewer::ACTUAL_OUT_KBIT.add<LLTrace::Bits>(actual_out_bits); - //LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); - //LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); LLStatViewer::KBIT.add<LLTrace::Bits>(bits); - //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); LLStatViewer::PACKETS_LOST.add(packets_lost); LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); - //LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in); - //LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out); - //LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets); if (packets_in) { LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); - // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in)); } - //else - //{ - // LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f); - //} mLastPacketsIn = gMessageSystem->mPacketsIn; mLastPacketsOut = gMessageSystem->mPacketsOut; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 75af605ad7..1e050d2588 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -488,7 +488,6 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_BUMP); getPool(LLDrawPool::POOL_GLOW); - //LLViewerStats::getInstance()->mTrianglesDrawnStat.reset(); resetFrameStats(); for (U32 i = 0; i < NUM_RENDER_TYPES; ++i) @@ -1769,7 +1768,6 @@ void LLPipeline::resetFrameStats() assertInitialized(); LLStatViewer::TRIANGLES_DRAWN.add(mTrianglesDrawn); - //LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f); if (mBatchCount > 0) { @@ -9756,7 +9754,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - F32 fade_amt = gFrameIntervalSeconds.value() * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f); + LLTrace::Measurement<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*velocity_stat), 1.0); //update shadow targets for (U32 i = 0; i < 2; i++) -- cgit v1.2.3 From 74fe126590fba03752d1d8d88dd3bb59c6900026 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 1 Nov 2012 17:52:11 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system output of floater_stats is now identical to pre-lltrace system (with some tweaks) --- indra/llcommon/lltrace.h | 95 ++++++++++++---------- indra/llcommon/lltracerecording.cpp | 34 ++++++-- indra/llcommon/lltracerecording.h | 6 +- indra/llcommon/lltracethreadrecorder.cpp | 6 +- indra/llui/llstatbar.cpp | 6 ++ indra/llui/llstatbar.h | 5 +- indra/newview/llviewercamera.cpp | 1 - indra/newview/llworld.cpp | 1 - indra/newview/pipeline.cpp | 4 +- .../newview/skins/default/xui/en/floater_stats.xml | 16 +++- 10 files changed, 108 insertions(+), 66 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 2823db5cbb..735c45754c 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -138,11 +138,11 @@ namespace LLTrace } } - void reset() + void reset(const AccumulatorBuffer<ACCUMULATOR>* other = NULL) { for (size_t i = 0; i < mNextStorageSlot; i++) { - mStorage[i].reset(); + mStorage[i].reset(other ? &other->mStorage[i] : NULL); } } @@ -285,54 +285,60 @@ namespace LLTrace void addSamples(const self_t& other) { - mSum += other.mSum; - if (other.mMin < mMin) - { - mMin = other.mMin; - } - if (other.mMax > mMax) - { - mMax = other.mMax; - } - mNumSamples += other.mNumSamples; - F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); - mMean = mMean * weight + other.mMean * (1.f - weight); - - F64 n_1 = (F64)mNumSamples, - n_2 = (F64)other.mNumSamples; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 sd_1 = getStandardDeviation(), - sd_2 = other.getStandardDeviation(); - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - if (n_1 == 0) + if (other.mNumSamples) { - mVarianceSum = other.mVarianceSum; + mSum += other.mSum; + if (other.mMin < mMin) + { + mMin = other.mMin; + } + if (other.mMax > mMax) + { + mMax = other.mMax; + } + F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); + mNumSamples += other.mNumSamples; + mMean = mMean * weight + other.mMean * (1.f - weight); + + F64 n_1 = (F64)mNumSamples, + n_2 = (F64)other.mNumSamples; + F64 m_1 = mMean, + m_2 = other.mMean; + F64 sd_1 = getStandardDeviation(), + sd_2 = other.getStandardDeviation(); + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + if (n_1 == 0) + { + mVarianceSum = other.mVarianceSum; + } + else if (n_2 == 0) + { + // don't touch variance + // mVarianceSum = mVarianceSum; + } + else + { + mVarianceSum = (F64)mNumSamples + * ((((n_1 - 1.f) * sd_1 * sd_1) + + ((n_2 - 1.f) * sd_2 * sd_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + } + mLastValue = other.mLastValue; } - else if (n_2 == 0) - { - // don't touch variance - // mVarianceSum = mVarianceSum; - } - else - { - mVarianceSum = (F64)mNumSamples - * ((((n_1 - 1.f) * sd_1 * sd_1) - + ((n_2 - 1.f) * sd_2 * sd_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); - } - mLastValue = other.mLastValue; } - void reset() + void reset(const self_t* other) { mNumSamples = 0; mSum = 0; mMin = 0; mMax = 0; + mMean = 0; + mVarianceSum = 0; + mLastValue = other ? other->mLastValue : 0; } T getSum() const { return (T)mSum; } @@ -359,6 +365,7 @@ namespace LLTrace class LL_COMMON_API CountAccumulator { public: + typedef CountAccumulator<T> self_t; typedef T value_t; CountAccumulator() @@ -378,7 +385,7 @@ namespace LLTrace mNumSamples += other.mNumSamples; } - void reset() + void reset(const self_t* other) { mNumSamples = 0; mSum = 0; @@ -475,6 +482,8 @@ namespace LLTrace class LL_COMMON_API TimerAccumulator { public: + typedef TimerAccumulator self_t; + U32 mTotalTimeCounter, mChildTimeCounter, mCalls; @@ -493,7 +502,7 @@ namespace LLTrace mCalls += other.mCalls; } - void reset() + void reset(const self_t* other) { mTotalTimeCounter = 0; mChildTimeCounter = 0; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f44a0a2764..a2733fd0e7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -87,6 +87,8 @@ void Recording::handleSplitTo(Recording& other) { stop(); other.restart(); + other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); + other.mMeasurements.write()->reset(mMeasurements); } @@ -104,7 +106,7 @@ bool Recording::isPrimary() const return mCounts->isPrimary(); } -void Recording::mergeRecording( const Recording& other ) +void Recording::appendRecording( const Recording& other ) { mCountsFloat.write()->addSamples(*other.mCountsFloat); mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); @@ -138,22 +140,34 @@ S64 Recording::getSum( const TraceType<MeasurementAccumulator<S64> >& stat ) con F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mCountsFloat).getSum() / mElapsedSeconds; + F64 sum = stat.getAccumulator(mCountsFloat).getSum(); + return (sum != 0.0) + ? (sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const { - return (F64)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; + S64 sum = stat.getAccumulator(mCounts).getSum(); + return (sum != 0) + ? ((F64)sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getSum() / mElapsedSeconds; + F64 sum = stat.getAccumulator(mMeasurementsFloat).getSum(); + return (sum != 0.0) + ? (sum / mElapsedSeconds) + : 0.0; } F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (F64)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; + S64 sum = stat.getAccumulator(mMeasurements).getSum(); + return (sum != 0) + ? ((F64)sum / mElapsedSeconds) + : 0.0; } F64 Recording::getMin( const TraceType<MeasurementAccumulator<F64> >& stat ) const @@ -240,17 +254,19 @@ PeriodicRecording::~PeriodicRecording() void PeriodicRecording::nextPeriod() { EPlayState play_state = getPlayState(); - getCurRecordingPeriod().stop(); + Recording& old_recording = getCurRecordingPeriod(); mCurPeriod = (mCurPeriod + 1) % mNumPeriods; + old_recording.splitTo(getCurRecordingPeriod()); + switch(play_state) { case STOPPED: + getCurRecordingPeriod().stop(); break; case PAUSED: getCurRecordingPeriod().pause(); break; case STARTED: - getCurRecordingPeriod().start(); break; } // new period, need to recalculate total @@ -264,7 +280,7 @@ Recording& PeriodicRecording::getTotalRecording() mTotalRecording.reset(); for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++) { - mTotalRecording.mergeRecording(mRecordingPeriods[i % mNumPeriods]); + mTotalRecording.appendRecording(mRecordingPeriods[i % mNumPeriods]); } } mTotalValid = true; @@ -298,7 +314,7 @@ void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) void ExtendableRecording::extend() { - mAcceptedRecording.mergeRecording(mPotentialRecording); + mAcceptedRecording.appendRecording(mPotentialRecording); mPotentialRecording.reset(); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 4af973515d..a11f04b14b 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -81,12 +81,12 @@ class LLVCRControlsMixin public: void splitTo(DERIVED& other) { - onSplitTo(other); + handleSplitTo(other); } void splitFrom(DERIVED& other) { - other.onSplitTo(*this); + other.handleSplitTo(*this); } private: // atomically stop this object while starting the other @@ -107,7 +107,7 @@ namespace LLTrace void makePrimary(); bool isPrimary() const; - void mergeRecording(const Recording& other); + void appendRecording(const Recording& other); void update(); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 15056b80e4..0feb3ab7af 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -73,7 +73,7 @@ std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Rec if (next_it != mActiveRecordings.end()) { // ...push our gathered data down to it - next_it->mBaseline.mergeRecording(it->mBaseline); + next_it->mBaseline.appendRecording(it->mBaseline); } // copy accumulated measurements into result buffer and clear accumulator (mBaseline) @@ -153,13 +153,13 @@ void SlaveThreadRecorder::pushToMaster() void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) { LLMutexLock lock(&mRecordingMutex); - mRecording.mergeRecording(source); + mRecording.appendRecording(source); } void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) { LLMutexLock lock(&mRecordingMutex); - sink.mergeRecording(mRecording); + sink.appendRecording(mRecording); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 6b40f8d475..1bc9a9fc67 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -53,6 +53,7 @@ LLStatBar::LLStatBar(const Params& p) mLabelSpacing(p.label_spacing), mPrecision(p.precision), mUpdatesPerSec(p.update_rate), + mUnitScale(p.unit_scale), mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), @@ -148,6 +149,11 @@ void LLStatBar::draw() mean = recording.getMean(*mMeasurementIntp); } + current *= mUnitScale; + min *= mUnitScale; + max *= mUnitScale; + mean *= mUnitScale; + if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { if (mDisplayMean) diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 6aefb1e213..083da8444e 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -44,7 +44,8 @@ public: bar_max, tick_spacing, label_spacing, - update_rate; + update_rate, + unit_scale; Optional<U32> precision; @@ -64,6 +65,7 @@ public: label_spacing("label_spacing", 10.0f), precision("precision", 0), update_rate("update_rate", 5.0f), + unit_scale("unit_scale", 1.f), show_per_sec("show_per_sec", true), show_bar("show_bar", TRUE), show_history("show_history", false), @@ -92,6 +94,7 @@ private: F32 mLabelSpacing; U32 mPrecision; F32 mUpdatesPerSec; + F32 mUnitScale; BOOL mPerSec; // Use the per sec stats. BOOL mDisplayBar; // Display the bar graph. BOOL mDisplayHistory; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 831304f428..f74897daa7 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -170,7 +170,6 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, sVelocityStat.add(dpos); sAngularVelocityStat.add(drot); - LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording(); mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat); mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat); mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect())); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index e140f3b23b..126dc59929 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -711,7 +711,6 @@ void LLWorld::updateNetStats() LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); LLStatViewer::PACKETS_LOST.add(packets_lost); - LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); if (packets_in) { LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1e050d2588..bf353cd1e0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9754,9 +9754,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - LLTrace::Measurement<>* velocity_stat = LLViewerCamera::getVelocityStat(); + LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat(); F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*velocity_stat), 1.0); + * llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0); //update shadow targets for (U32 i = 0; i < 2; i++) diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index f9eb16d224..273954ee3e 100644 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -104,6 +104,7 @@ label="KTris Drawn per Frame" unit_label="/fr" stat="trianglesdrawnstat" + unit_scale="0.001" bar_min="0" bar_max="10000" tick_spacing="1000" @@ -116,6 +117,7 @@ name="ktrissec" label="KTris Drawn per Sec" unit_label="/sec" + unit_scale="0.001" stat="trianglesdrawnstat" bar_min="0" bar_max="200000" @@ -222,6 +224,8 @@ name="gltexmemstat" label="GL Mem" stat="gltexmemstat" + unit_label="MB" + unit_scale="0.000001" bar_min="0.f" bar_max="400.f" tick_spacing="100.f" @@ -235,11 +239,13 @@ name="formattedmemstat" label="Formatted Mem" stat="formattedmemstat" + unit_label="MB" + unit_scale="0.000001" bar_min="0.f" bar_max="400.f" tick_spacing="100.f" label_spacing="200.f" - precision="1" + precision="3" show_per_sec="false" show_bar="false"> </stat_bar> @@ -247,12 +253,14 @@ <stat_bar name="rawmemstat" label="Raw Mem" + unit_label="MB" + unit_scale="0.000001" stat="rawmemstat" bar_min="0.f" bar_max="400.f" tick_spacing="100.f" label_spacing="200.f" - precision="1" + precision="3" show_per_sec="false" show_bar="false"> </stat_bar> @@ -261,11 +269,13 @@ name="glboundmemstat" label="Bound Mem" stat="glboundmemstat" + unit_label="MB" + unit_scale="0.000001" bar_min="0.f" bar_max="400.f" tick_spacing="100.f" label_spacing="200.f" - precision="1" + precision="3" show_per_sec="false" show_bar="false"> </stat_bar> -- cgit v1.2.3 From bb6bda9eef48f5b08b56af46321b79fe7f1d49d7 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 1 Nov 2012 19:55:06 -0700 Subject: SH-3499 Ensure asset stats output is correct added support for specifying predicates for xui and llsd serialization --- indra/llcommon/llinitparam.cpp | 11 ++++------- indra/llcommon/llinitparam.h | 2 +- indra/llcommon/llpredicate.h | 8 ++++---- indra/llcommon/llsdparam.cpp | 4 ++-- indra/llcommon/llsdparam.h | 2 +- indra/llcommon/lltracerecording.cpp | 12 ++++++------ indra/llcommon/lltracerecording.h | 22 +++++++++++----------- indra/llui/llfloater.cpp | 4 ++-- indra/llui/llpanel.cpp | 4 ++-- indra/llui/lluictrlfactory.h | 2 +- indra/llui/llxuiparser.cpp | 4 ++-- indra/llui/llxuiparser.h | 2 +- indra/newview/tests/llviewerassetstats_test.cpp | 1 + 13 files changed, 38 insertions(+), 40 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index afeac0a905..53254c3b56 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -188,12 +188,9 @@ namespace LLInitParam bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const predicate_rule_t predicate_rule, const LLInitParam::BaseBlock* diff_block) const { bool serialized = false; - if (!isProvided()) + if (!predicate_rule.check(ll_make_predicate(PROVIDED, isProvided()))) { - if ((predicate_rule && !ll_predicate(PROVIDED)).isTriviallyFalse()) - { - return false; - } + return false; } // named param is one like LLView::Params::follows // unnamed param is like LLView::Params::rect - implicit @@ -206,7 +203,7 @@ namespace LLInitParam param_handle_t param_handle = (*it)->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = (*it)->mSerializeFunc; - if (serialize_func && param->anyProvided()) + if (serialize_func && predicate_rule.check(ll_make_predicate(PROVIDED, param->anyProvided()))) { const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL; serialized |= serialize_func(*param, parser, name_stack, predicate_rule, diff_param); @@ -220,7 +217,7 @@ namespace LLInitParam param_handle_t param_handle = it->second->mParamHandle; const Param* param = getParamFromHandle(param_handle); ParamDescriptor::serialize_func_t serialize_func = it->second->mSerializeFunc; - if (serialize_func && param->anyProvided()) + if (serialize_func && predicate_rule.check(ll_make_predicate(PROVIDED, param->anyProvided()))) { // Ensure this param has not already been serialized // Prevents <rect> from being serialized as its own tag. diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index b52ac809e0..c82b1226ee 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -545,7 +545,7 @@ namespace LLInitParam } bool deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool new_name); - bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule = predicate_rule_t(ll_predicate(PROVIDED) && ll_predicate(NON_DEFAULT)), const BaseBlock* diff_block = NULL) const; + bool serializeBlock(Parser& p, Parser::name_stack_t& name_stack, const predicate_rule_t rule, const BaseBlock* diff_block = NULL) const; bool inspectBlock(Parser& p, Parser::name_stack_t name_stack = Parser::name_stack_t(), S32 min_count = 0, S32 max_count = S32_MAX) const; virtual const BlockDescriptor& mostDerivedBlockDescriptor() const { return selfBlockDescriptor(); } diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index a13172da68..3f7abe67f1 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -42,8 +42,8 @@ namespace LLPredicate typedef U32 predicate_flag_t; static const S32 cMaxEnum = 5; - Value(ENUM e) - : mPredicateFlags(cPredicateFlagsFromEnum[e]) + Value(ENUM e, bool predicate_value = true) + : mPredicateFlags(predicate_value ? cPredicateFlagsFromEnum[e] : ~cPredicateFlagsFromEnum[e]) { llassert(0 <= e && e < cMaxEnum); } @@ -227,9 +227,9 @@ namespace LLPredicate } template<typename ENUM> -LLPredicate::Value<ENUM> ll_predicate(ENUM e) +LLPredicate::Value<ENUM> ll_make_predicate(ENUM e, bool predicate_value = true) { - return LLPredicate::Value<ENUM>(e); + return LLPredicate::Value<ENUM>(e, predicate_value); } diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index 42ecc9897d..c10e1b1e20 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -102,13 +102,13 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool //readSDValues(sd, block); } -void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block) +void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules) { mNameStack.clear(); mWriteRootSD = &sd; name_stack_t name_stack; - block.serializeBlock(*this, name_stack); + block.serializeBlock(*this, name_stack, rules); } /*virtual*/ std::string LLParamSDParser::getCurrentElementName() diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 6ef5debd7b..032e506fd8 100644 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -50,7 +50,7 @@ typedef LLInitParam::Parser parser_t; public: LLParamSDParser(); void readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent = false); - void writeSD(LLSD& sd, const LLInitParam::BaseBlock& block); + void writeSD(LLSD& sd, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules = LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT); /*virtual*/ std::string getCurrentElementName(); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a2733fd0e7..a8e1a5eec9 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -347,7 +347,7 @@ PeriodicRecording& get_frame_recording() } -void LLVCRControlsMixinCommon::start() +void LLStopWatchControlsMixinCommon::start() { switch (mPlayState) { @@ -365,7 +365,7 @@ void LLVCRControlsMixinCommon::start() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::stop() +void LLStopWatchControlsMixinCommon::stop() { switch (mPlayState) { @@ -381,7 +381,7 @@ void LLVCRControlsMixinCommon::stop() mPlayState = STOPPED; } -void LLVCRControlsMixinCommon::pause() +void LLStopWatchControlsMixinCommon::pause() { switch (mPlayState) { @@ -396,7 +396,7 @@ void LLVCRControlsMixinCommon::pause() mPlayState = PAUSED; } -void LLVCRControlsMixinCommon::resume() +void LLStopWatchControlsMixinCommon::resume() { switch (mPlayState) { @@ -412,7 +412,7 @@ void LLVCRControlsMixinCommon::resume() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::restart() +void LLStopWatchControlsMixinCommon::restart() { switch (mPlayState) { @@ -431,7 +431,7 @@ void LLVCRControlsMixinCommon::restart() mPlayState = STARTED; } -void LLVCRControlsMixinCommon::reset() +void LLStopWatchControlsMixinCommon::reset() { handleReset(); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index a11f04b14b..3a786c1357 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -34,10 +34,10 @@ #include "lltimer.h" #include "lltrace.h" -class LL_COMMON_API LLVCRControlsMixinCommon +class LL_COMMON_API LLStopWatchControlsMixinCommon { public: - virtual ~LLVCRControlsMixinCommon() {} + virtual ~LLStopWatchControlsMixinCommon() {} enum EPlayState { @@ -59,7 +59,7 @@ public: EPlayState getPlayState() { return mPlayState; } protected: - LLVCRControlsMixinCommon() + LLStopWatchControlsMixinCommon() : mPlayState(STOPPED) {} @@ -75,8 +75,8 @@ private: }; template<typename DERIVED> -class LLVCRControlsMixin -: public LLVCRControlsMixinCommon +class LLStopWatchControlsMixin +: public LLStopWatchControlsMixinCommon { public: void splitTo(DERIVED& other) @@ -97,7 +97,7 @@ private: namespace LLTrace { - class LL_COMMON_API Recording : public LLVCRControlsMixin<Recording> + class LL_COMMON_API Recording : public LLStopWatchControlsMixin<Recording> { public: Recording(); @@ -190,7 +190,7 @@ namespace LLTrace LLUnit::Seconds<F64> getDuration() const { return mElapsedSeconds; } - // implementation for LLVCRControlsMixin + // implementation for LLStopWatchControlsMixin /*virtual*/ void handleStart(); /*virtual*/ void handleStop(); /*virtual*/ void handleReset(); @@ -212,7 +212,7 @@ namespace LLTrace }; class LL_COMMON_API PeriodicRecording - : public LLVCRControlsMixin<PeriodicRecording> + : public LLStopWatchControlsMixin<PeriodicRecording> { public: PeriodicRecording(S32 num_periods); @@ -340,7 +340,7 @@ namespace LLTrace private: - // implementation for LLVCRControlsMixin + // implementation for LLStopWatchControlsMixin /*virtual*/ void handleStart(); /*virtual*/ void handleStop(); /*virtual*/ void handleReset(); @@ -357,12 +357,12 @@ namespace LLTrace PeriodicRecording& get_frame_recording(); class ExtendableRecording - : public LLVCRControlsMixin<ExtendableRecording> + : public LLStopWatchControlsMixin<ExtendableRecording> { void extend(); private: - // implementation for LLVCRControlsMixin + // implementation for LLStopWatchControlsMixin /*virtual*/ void handleStart(); /*virtual*/ void handleStop(); /*virtual*/ void handleReset(); diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index d14fe441fb..c4a5d1f05e 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -3085,7 +3085,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); return TRUE; } @@ -3117,7 +3117,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str setupParamsForExport(output_params, parent); Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); } // Default floater position to top-left corner of screen diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 00318cec6b..f3d6687e40 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -520,7 +520,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); return TRUE; } @@ -551,7 +551,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); } params.from_xui = true; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 4e54354731..6513f97ca0 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -273,7 +273,7 @@ private: // Export only the differences between this any default params typename T::Params default_params(getDefaultParams<T>()); copyName(node, output_node); - parser.writeXUI(output_node, output_params, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); } // Apply layout transformations, usually munging rect diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 95cda92632..6fc32dbf9c 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -861,11 +861,11 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo return any_parsed; } -void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, const LLInitParam::BaseBlock* diff_block) +void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block) { mWriteRootNode = node; name_stack_t name_stack = Parser::name_stack_t(); - block.serializeBlock(*this, name_stack, LLPredicate::Rule<LLInitParam::ESerializePredicates>(), diff_block); + block.serializeBlock(*this, name_stack, rules, diff_block); mOutNodes.clear(); } diff --git a/indra/llui/llxuiparser.h b/indra/llui/llxuiparser.h index d7cd256967..9b6b2a321b 100644 --- a/indra/llui/llxuiparser.h +++ b/indra/llui/llxuiparser.h @@ -109,7 +109,7 @@ public: /*virtual*/ void parserError(const std::string& message); void readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename = LLStringUtil::null, bool silent=false); - void writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const LLInitParam::BaseBlock* diff_block = NULL); + void writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules = LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, const LLInitParam::BaseBlock* diff_block = NULL); private: bool readXUIImpl(LLXMLNodePtr node, LLInitParam::BaseBlock& block); diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index fc5cd781e6..26a76eda2c 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -266,6 +266,7 @@ namespace tut ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats)); LLSD sd_full = it->asLLSD(false); + llinfos << ll_pretty_print_sd(sd_full) << llendl; // Default (NULL) region ID doesn't produce LLSD results so should // get an empty map back from output -- cgit v1.2.3 From f8eaee753174d0cab4e4edcf795f422706d6f302 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 2 Nov 2012 20:03:44 -0700 Subject: SH-3499 Ensure asset stats output is correct improvements to predicate API default rules encapsulated in LLInitParam removed empty flag from viewer asset stats --- indra/llcommon/llinitparam.cpp | 10 ++ indra/llcommon/llinitparam.h | 25 +++- indra/llcommon/llpredicate.h | 80 ++++++----- indra/llcommon/llsdparam.cpp | 4 +- indra/llcommon/llsdparam.h | 19 ++- indra/llui/llfloater.cpp | 5 +- indra/llui/llpanel.cpp | 4 +- indra/llui/lluictrlfactory.h | 4 +- indra/llui/llxuiparser.cpp | 2 +- indra/llui/llxuiparser.h | 18 ++- indra/newview/llviewerassetstats.cpp | 254 +++++++++++++++++------------------ indra/newview/llviewerassetstats.h | 1 - 12 files changed, 251 insertions(+), 175 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index 53254c3b56..d20fc03227 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -32,6 +32,12 @@ namespace LLInitParam { + + predicate_rule_t default_parse_rules() + { + return ll_make_predicate(PROVIDED) && !ll_make_predicate(EMPTY) && !ll_make_predicate(HAS_DEFAULT_VALUE); + } + // // Param // @@ -247,6 +253,10 @@ namespace LLInitParam } } + if (!serialized && predicate_rule.check(ll_make_predicate(EMPTY))) + { + serialized |= parser.writeValue(Flag(), name_stack); + } // was anything serialized in this block? return serialized; } diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index c82b1226ee..6177cc7d12 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -297,11 +297,13 @@ namespace LLInitParam PROVIDED, REQUIRED, VALID, - NON_DEFAULT + HAS_DEFAULT_VALUE, + EMPTY }; typedef LLPredicate::Rule<ESerializePredicates> predicate_rule_t; + predicate_rule_t default_parse_rules(); // various callbacks and constraints associated with an individual param struct LL_COMMON_API ParamDescriptor @@ -912,7 +914,10 @@ namespace LLInitParam const self_t* diff_typed_param = static_cast<const self_t*>(diff_param); LLPredicate::Value<ESerializePredicates> predicate; - predicate.set(NON_DEFAULT, !diff_typed_param || ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())); + if (diff_typed_param && ParamCompare<T>::equals(typed_param.getValue(), diff_typed_param->getValue())) + { + predicate.set(HAS_DEFAULT_VALUE); + } if (typed_param.isValid()) { @@ -925,6 +930,8 @@ namespace LLInitParam predicate.set(PROVIDED, false); } + predicate.set(EMPTY, false); + if (!predicate_rule.check(predicate)) return false; if (!name_stack.empty()) @@ -1285,6 +1292,8 @@ namespace LLInitParam predicate.set(PROVIDED, false); } + predicate.set(EMPTY, typed_param.mValues.empty()); + if (!predicate_rule.check(predicate)) return false; for (const_iterator it = typed_param.mValues.begin(), end_it = typed_param.mValues.end(); @@ -1325,6 +1334,12 @@ namespace LLInitParam name_stack.pop_back(); } + + if (!serialized && predicate_rule.check(ll_make_predicate(EMPTY))) + { + serialized |= parser.writeValue(Flag(), name_stack); + } + return serialized; } @@ -1567,6 +1582,12 @@ namespace LLInitParam name_stack.pop_back(); } + + if (!serialized && predicate_rule.check(ll_make_predicate(EMPTY))) + { + serialized |= parser.writeValue(Flag(), name_stack); + } + return serialized; } diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 3f7abe67f1..6c9e5fc145 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -73,43 +73,37 @@ namespace LLPredicate return new_value; } - void set(ENUM e, bool value) + void set(ENUM e, bool value = true) { llassert(0 <= e && e < cMaxEnum); - modifyPredicate(0x1 << (S32)e, cPredicateFlagsFromEnum[e], value); + mPredicateFlags = modifyPredicate(0x1 << (S32)e, cPredicateFlagsFromEnum[e], value, mPredicateFlags); } void set(const Value other, bool value) { - U32 predicate_flags = other.mPredicateFlags; - while(predicate_flags) + predicate_flag_t predicate_flags_to_set = other.mPredicateFlags; + predicate_flag_t cumulative_flags = 0; + while(predicate_flags_to_set) { - U32 next_flags = clearLSB(predicate_flags); - lsb_flag = predicate_flags ^ next_flags; + predicate_flag_t next_flags = clearLSB(predicate_flags_to_set); + predicate_flag_t lsb_flag = predicate_flags_to_set ^ next_flags; - U32 mask = 0; + predicate_flag_t mask = 0; + predicate_flag_t cur_flags = mPredicateFlags; for (S32 i = 0; i < cMaxEnum; i++) { if (cPredicateFlagsFromEnum[i] & lsb_flag) { mask |= cPredicateFlagsFromEnum[i]; - modifyPredicate(0x1 << (0x1 << i ), cPredicateFlagsFromEnum[i], !value); + cur_flags = modifyPredicate(0x1 << (0x1 << i ), cPredicateFlagsFromEnum[i], !value, cur_flags); } } - modifyPredicate(lsb_flag, mask, value); + cumulative_flags |= modifyPredicate(lsb_flag, mask, value, cur_flags); - predicate_flags = next_flags; - } - } - - void forget(ENUM e) - { - set(e, true); - U32 flags_with_predicate = mPredicateFlags; - set(e, false); - // ambiguous value is result of adding and removing predicate at the same time! - mPredicateFlags |= flags_with_predicate; + predicate_flags_to_set = next_flags; + } + mPredicateFlags = cumulative_flags; } void forget(const Value value) @@ -131,6 +125,11 @@ namespace LLPredicate return mPredicateFlags == 0; } + bool someSet() const + { + return mPredicateFlags != 0; + } + private: predicate_flag_t clearLSB(predicate_flag_t value) @@ -138,16 +137,16 @@ namespace LLPredicate return value & (value - 1); } - void modifyPredicate(predicate_flag_t predicate_flag, predicate_flag_t mask, bool value) + predicate_flag_t modifyPredicate(predicate_flag_t predicate_flag, predicate_flag_t mask, predicate_flag_t value, bool set) { llassert(clearLSB(predicate_flag) == 0); predicate_flag_t flags_to_modify; - if (value) + if (set) { flags_to_modify = (mPredicateFlags & ~mask); // clear flags not containing predicate to be added - mPredicateFlags &= mask; + value &= mask; // shift flags, in effect adding predicate flags_to_modify *= predicate_flag; } @@ -155,12 +154,13 @@ namespace LLPredicate { flags_to_modify = mPredicateFlags & mask; // clear flags containing predicate to be removed - mPredicateFlags &= ~mask; + value &= ~mask; // shift flags, in effect removing predicate flags_to_modify /= predicate_flag; } // put modified flags back - mPredicateFlags |= flags_to_modify; + value |= flags_to_modify; + return value; } predicate_flag_t mPredicateFlags; @@ -174,10 +174,6 @@ namespace LLPredicate : mRule(value) {} - Rule(const Rule& other) - : mRule(other.mRule) - {} - Rule(const Value<ENUM> other) : mRule(other) {} @@ -185,17 +181,37 @@ namespace LLPredicate Rule() {} + void require(const Value<ENUM> value) + { + mRule.set(value, require); + } + + void allow(const Value<ENUM> value) + { + mRule.forget(value); + } + bool check(const Value<ENUM> value) const { - return !(mRule && value).noneSet(); + return (mRule && value).someSet(); + } + + bool requires(const Value<ENUM> value) const + { + return (mRule && value).someSet() && (!mRule && value).noneSet(); + } + + bool isAmbivalent(const Value<ENUM> value) const + { + return (mRule && value).someSet() && (!mRule && value).someSet(); } - bool isTriviallyTrue() const + bool acceptsAll() const { return mRule.allSet(); } - bool isTriviallyFalse() const + bool acceptsNone() const { return mRule.noneSet(); } diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index c10e1b1e20..345e30f4b4 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -102,13 +102,13 @@ void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool //readSDValues(sd, block); } -void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules) +void LLParamSDParser::writeSDImpl(LLSD& sd, const LLInitParam::BaseBlock& block, const LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block) { mNameStack.clear(); mWriteRootSD = &sd; name_stack_t name_stack; - block.serializeBlock(*this, name_stack, rules); + block.serializeBlock(*this, name_stack, rules, diff_block); } /*virtual*/ std::string LLParamSDParser::getCurrentElementName() diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 032e506fd8..1181c2d433 100644 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -50,11 +50,28 @@ typedef LLInitParam::Parser parser_t; public: LLParamSDParser(); void readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent = false); - void writeSD(LLSD& sd, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules = LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT); + template<typename BLOCK> + void writeSD(LLSD& sd, + const BLOCK& block, + const LLInitParam::predicate_rule_t rules = LLInitParam::default_parse_rules(), + const LLInitParam::BaseBlock* diff_block = NULL) + { + if (!diff_block + && !rules.isAmbivalent(LLInitParam::HAS_DEFAULT_VALUE)) + { + diff_block = &LLInitParam::defaultValue<BLOCK>(); + } + writeSDImpl(sd, block, rules, diff_block); + } /*virtual*/ std::string getCurrentElementName(); private: + void writeSDImpl(LLSD& sd, + const LLInitParam::BaseBlock& block, + const LLInitParam::predicate_rule_t, + const LLInitParam::BaseBlock* diff_block); + void submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLInitParam::Parser::name_stack_t& name_stack); template<typename T> diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index c4a5d1f05e..34556b8aeb 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -3085,7 +3085,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName()); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); return TRUE; } @@ -3115,9 +3115,8 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str { Params output_params(params); setupParamsForExport(output_params, parent); - Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>()); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); } // Default floater position to top-left corner of screen diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index f3d6687e40..a5ffcc8ec7 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -520,7 +520,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); return TRUE; } @@ -551,7 +551,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu Params output_params(params); setupParamsForExport(output_params, parent); output_node->setName(node->getName()->mString); - parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params); } params.from_xui = true; diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 6513f97ca0..b53b71f690 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -270,10 +270,8 @@ private: // We always want to output top-left coordinates typename T::Params output_params(params); T::setupParamsForExport(output_params, parent); - // Export only the differences between this any default params - typename T::Params default_params(getDefaultParams<T>()); copyName(node, output_node); - parser.writeXUI(output_node, output_params, LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, &default_params); + parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &getDefaultParams<T>()); } // Apply layout transformations, usually munging rect diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 6fc32dbf9c..0c91390bc1 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -861,7 +861,7 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo return any_parsed; } -void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block) +void LLXUIParser::writeXUIImpl(LLXMLNodePtr node, const LLInitParam::BaseBlock &block, const LLInitParam::predicate_rule_t rules, const LLInitParam::BaseBlock* diff_block) { mWriteRootNode = node; name_stack_t name_stack = Parser::name_stack_t(); diff --git a/indra/llui/llxuiparser.h b/indra/llui/llxuiparser.h index 9b6b2a321b..8d0276a8ad 100644 --- a/indra/llui/llxuiparser.h +++ b/indra/llui/llxuiparser.h @@ -109,9 +109,25 @@ public: /*virtual*/ void parserError(const std::string& message); void readXUI(LLXMLNodePtr node, LLInitParam::BaseBlock& block, const std::string& filename = LLStringUtil::null, bool silent=false); - void writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock& block, LLInitParam::predicate_rule_t rules = LLInitParam::predicate_rule_t(LLInitParam::PROVIDED) && LLInitParam::NON_DEFAULT, const LLInitParam::BaseBlock* diff_block = NULL); + template<typename BLOCK> + void writeXUI(LLXMLNodePtr node, + const BLOCK& block, + const LLInitParam::predicate_rule_t rules = LLInitParam::default_parse_rules(), + const LLInitParam::BaseBlock* diff_block = NULL) + { + if (!diff_block + && !rules.isAmbivalent(LLInitParam::HAS_DEFAULT_VALUE)) + { + diff_block = &LLInitParam::defaultValue<BLOCK>(); + } + writeXUIImpl(node, block, rules, diff_block); + } private: + void writeXUIImpl(LLXMLNodePtr node, + const LLInitParam::BaseBlock& block, + const LLInitParam::predicate_rule_t rules, + const LLInitParam::BaseBlock* diff_block); bool readXUIImpl(LLXMLNodePtr node, LLInitParam::BaseBlock& block); bool readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block); diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index e4f64f3076..df43c4b344 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -303,138 +303,133 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) mCurRecording->update(); } - if (mRegionRecordings.empty()) - { - stats.regions.add().empty.setProvided(); - } - else + stats.regions.setProvided(); + + for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end(); + it != end_it; + ++it) { - for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end(); - it != end_it; - ++it) + RegionStats& r = stats.regions.add(); + LLTrace::Recording& rec = it->second; + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) + || rec.getSum(sDequeued[EVACTextureTempHTTPGet]) + || rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) { - RegionStats& r = stats.regions.add(); - LLTrace::Recording& rec = it->second; - if (!compact_output - || rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) - || rec.getSum(sDequeued[EVACTextureTempHTTPGet]) - || rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) - { - r.get_texture_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet])) - .dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet])) - .resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value()); - } - if (!compact_output - || rec.getSum(sEnqueued[EVACTextureTempUDPGet]) - || rec.getSum(sDequeued[EVACTextureTempUDPGet]) - || rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) - { - r.get_texture_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet])) - .dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet])) - .resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value()); - } - if (!compact_output - || rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) - || rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]) - || rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) - { - r.get_texture_non_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet])) - .dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])) - .resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value()); - } - - if (!compact_output - || rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) - || rec.getSum(sDequeued[EVACTextureNonTempUDPGet]) - || rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) - { - r.get_texture_non_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet])) - .dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet])) - .resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value()); - } - - if (!compact_output - || rec.getSum(sEnqueued[EVACWearableUDPGet]) - || rec.getSum(sDequeued[EVACWearableUDPGet]) - || rec.getSum(sResponse[EVACWearableUDPGet]).value()) - { - r.get_wearable_udp .enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet])) - .dequeued(rec.getSum(sDequeued[EVACWearableUDPGet])) - .resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value()); - } - - if (!compact_output - || rec.getSum(sEnqueued[EVACSoundUDPGet]) - || rec.getSum(sDequeued[EVACSoundUDPGet]) - || rec.getSum(sResponse[EVACSoundUDPGet]).value()) - { - r.get_sound_udp .enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet])) - .dequeued(rec.getSum(sDequeued[EVACSoundUDPGet])) - .resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value()); - } - - if (!compact_output - || rec.getSum(sEnqueued[EVACGestureUDPGet]) - || rec.getSum(sDequeued[EVACGestureUDPGet]) - || rec.getSum(sResponse[EVACGestureUDPGet]).value()) - { - r.get_gesture_udp .enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet])) - .dequeued(rec.getSum(sDequeued[EVACGestureUDPGet])) - .resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value()) - .resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value()) - .resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value()); - } - - if (!compact_output - || rec.getSum(sEnqueued[EVACOtherGet]) - || rec.getSum(sDequeued[EVACOtherGet]) - || rec.getSum(sResponse[EVACOtherGet]).value()) - { - r.get_other .enqueued(rec.getSum(sEnqueued[EVACOtherGet])) - .dequeued(rec.getSum(sDequeued[EVACOtherGet])) - .resp_count(rec.getSum(sResponse[EVACOtherGet]).value()) - .resp_min(rec.getMin(sResponse[EVACOtherGet]).value()) - .resp_max(rec.getMax(sResponse[EVACOtherGet]).value()) - .resp_mean(rec.getMean(sResponse[EVACOtherGet]).value()); - } - - S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE); - if (!compact_output || fps != 0) - { - r.fps.count(fps); - r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE)); - r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE)); - r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE)); - } - U32 grid_x(0), grid_y(0); - grid_from_region_handle(it->first, &grid_x, &grid_y); - r.grid_x(grid_x); - r.grid_y(grid_y); - r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value()); + r.get_texture_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value()); + } + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureTempUDPGet]) + || rec.getSum(sDequeued[EVACTextureTempUDPGet]) + || rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) + { + r.get_texture_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value()); + } + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) + || rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]) + || rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) + { + r.get_texture_non_temp_http .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) + || rec.getSum(sDequeued[EVACTextureNonTempUDPGet]) + || rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) + { + r.get_texture_non_temp_udp .enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet])) + .resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACWearableUDPGet]) + || rec.getSum(sDequeued[EVACWearableUDPGet]) + || rec.getSum(sResponse[EVACWearableUDPGet]).value()) + { + r.get_wearable_udp .enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACWearableUDPGet])) + .resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACSoundUDPGet]) + || rec.getSum(sDequeued[EVACSoundUDPGet]) + || rec.getSum(sResponse[EVACSoundUDPGet]).value()) + { + r.get_sound_udp .enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACSoundUDPGet])) + .resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value()); + } + + if (!compact_output + || rec.getSum(sEnqueued[EVACGestureUDPGet]) + || rec.getSum(sDequeued[EVACGestureUDPGet]) + || rec.getSum(sResponse[EVACGestureUDPGet]).value()) + { + r.get_gesture_udp .enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet])) + .dequeued(rec.getSum(sDequeued[EVACGestureUDPGet])) + .resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value()) + .resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value()) + .resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value()); } + + if (!compact_output + || rec.getSum(sEnqueued[EVACOtherGet]) + || rec.getSum(sDequeued[EVACOtherGet]) + || rec.getSum(sResponse[EVACOtherGet]).value()) + { + r.get_other .enqueued(rec.getSum(sEnqueued[EVACOtherGet])) + .dequeued(rec.getSum(sDequeued[EVACOtherGet])) + .resp_count(rec.getSum(sResponse[EVACOtherGet]).value()) + .resp_min(rec.getMin(sResponse[EVACOtherGet]).value()) + .resp_max(rec.getMax(sResponse[EVACOtherGet]).value()) + .resp_mean(rec.getMean(sResponse[EVACOtherGet]).value()); + } + + S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE); + if (!compact_output || fps != 0) + { + r.fps.count(fps); + r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE)); + r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE)); + r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE)); + } + U32 grid_x(0), grid_y(0); + grid_from_region_handle(it->first, &grid_x, &grid_y); + r.grid_x(grid_x); + r.grid_y(grid_y); + r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value()); } stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0); - //stats.avatar.setProvided(true); + stats.avatar.setProvided(true); for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) { @@ -453,7 +448,12 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output) LLSD sd; AssetStats stats; getStats(stats, compact_output); - parser.writeSD(sd, stats); + LLInitParam::predicate_rule_t rule = LLInitParam::default_parse_rules(); + if (!compact_output) + { + rule.allow(LLInitParam::EMPTY); + } + parser.writeSD(sd, stats, rule); return sd; } diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index 2f50c52730..f1ce3aeaa2 100755 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -114,7 +114,6 @@ public: struct RegionStats : public LLInitParam::Block<RegionStats> { - Optional<LLInitParam::Flag> empty; Optional<AssetRequestType> get_texture_temp_http, get_texture_temp_udp, get_texture_non_temp_http, -- cgit v1.2.3 From 0007114cf5a60779319ab8cbd0a23a0d462b8010 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 5 Nov 2012 16:10:57 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct fixed copy behavior of recordings and accumulator buffers --- indra/llcommon/llinitparam.cpp | 2 +- indra/llcommon/llinitparam.h | 81 +++++++--------------- indra/llcommon/llpredicate.h | 90 +++++++------------------ indra/llcommon/lltrace.h | 15 +++-- indra/llcommon/lltracerecording.cpp | 3 +- indra/llcommon/lltracerecording.h | 29 ++++++-- indra/llcommon/lltracethreadrecorder.cpp | 5 ++ indra/newview/llappviewer.cpp | 2 + indra/newview/llviewerassetstats.cpp | 36 +++------- indra/newview/llviewerassetstats.h | 41 ++--------- indra/newview/tests/llviewerassetstats_test.cpp | 5 ++ 11 files changed, 111 insertions(+), 198 deletions(-) diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index d20fc03227..32d4eec607 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -35,7 +35,7 @@ namespace LLInitParam predicate_rule_t default_parse_rules() { - return ll_make_predicate(PROVIDED) && !ll_make_predicate(EMPTY) && !ll_make_predicate(HAS_DEFAULT_VALUE); + return ll_make_predicate(PROVIDED) && !ll_make_predicate(EMPTY); } // diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 6177cc7d12..3d4e4331c0 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -919,17 +919,8 @@ namespace LLInitParam predicate.set(HAS_DEFAULT_VALUE); } - if (typed_param.isValid()) - { - predicate.set(VALID, true); - predicate.set(PROVIDED, typed_param.anyProvided()); - } - else - { - predicate.set(VALID, false); - predicate.set(PROVIDED, false); - } - + predicate.set(VALID, typed_param.isValid()); + predicate.set(PROVIDED, typed_param.anyProvided()); predicate.set(EMPTY, false); if (!predicate_rule.check(predicate)) return false; @@ -1014,15 +1005,15 @@ namespace LLInitParam }; // parameter that is a block - template <typename T, typename NAME_VALUE_LOOKUP> - class TypedParam<T, NAME_VALUE_LOOKUP, false, true> + template <typename BLOCK_T, typename NAME_VALUE_LOOKUP> + class TypedParam<BLOCK_T, NAME_VALUE_LOOKUP, false, true> : public Param, - public ParamValue<T, NAME_VALUE_LOOKUP> + public ParamValue<BLOCK_T, NAME_VALUE_LOOKUP> { public: - typedef ParamValue<T, NAME_VALUE_LOOKUP> param_value_t; + typedef ParamValue<BLOCK_T, NAME_VALUE_LOOKUP> param_value_t; typedef typename param_value_t::value_assignment_t value_assignment_t; - typedef TypedParam<T, NAME_VALUE_LOOKUP, false, true> self_t; + typedef TypedParam<BLOCK_T, NAME_VALUE_LOOKUP, false, true> self_t; typedef NAME_VALUE_LOOKUP name_value_lookup_t; using param_value_t::operator(); @@ -1081,16 +1072,8 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; - if (typed_param.isValid()) - { - predicate.set(VALID, true); - predicate.set(PROVIDED, typed_param.anyProvided()); - } - else - { - predicate.set(VALID, false); - predicate.set(PROVIDED, false); - } + predicate.set(VALID, typed_param.isValid()); + predicate.set(PROVIDED, typed_param.anyProvided()); if (!predicate_rule.check(predicate)) return false; @@ -1187,13 +1170,13 @@ namespace LLInitParam }; // container of non-block parameters - template <typename VALUE_TYPE, typename NAME_VALUE_LOOKUP> - class TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, false> + template <typename MULTI_VALUE_T, typename NAME_VALUE_LOOKUP> + class TypedParam<MULTI_VALUE_T, NAME_VALUE_LOOKUP, true, false> : public Param { public: - typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, false> self_t; - typedef ParamValue<VALUE_TYPE, NAME_VALUE_LOOKUP> param_value_t; + typedef TypedParam<MULTI_VALUE_T, NAME_VALUE_LOOKUP, true, false> self_t; + typedef ParamValue<MULTI_VALUE_T, NAME_VALUE_LOOKUP> param_value_t; typedef typename std::vector<param_value_t> container_t; typedef const container_t& value_assignment_t; @@ -1280,18 +1263,8 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; predicate.set(REQUIRED, typed_param.mMinCount > 0); - - if (typed_param.isValid()) - { - predicate.set(VALID, true); - predicate.set(PROVIDED, typed_param.anyProvided()); - } - else - { - predicate.set(VALID, false); - predicate.set(PROVIDED, false); - } - + predicate.set(VALID, typed_param.isValid()); + predicate.set(PROVIDED, typed_param.anyProvided()); predicate.set(EMPTY, typed_param.mValues.empty()); if (!predicate_rule.check(predicate)) return false; @@ -1345,7 +1318,7 @@ namespace LLInitParam static void inspectParam(const Param& param, Parser& parser, Parser::name_stack_t& name_stack, S32 min_count, S32 max_count) { - parser.inspectValue<VALUE_TYPE>(name_stack, min_count, max_count, NULL); + parser.inspectValue<MULTI_VALUE_T>(name_stack, min_count, max_count, NULL); if (name_value_lookup_t::getPossibleValues()) { parser.inspectValue<std::string>(name_stack, min_count, max_count, name_value_lookup_t::getPossibleValues()); @@ -1437,13 +1410,13 @@ namespace LLInitParam }; // container of block parameters - template <typename VALUE_TYPE, typename NAME_VALUE_LOOKUP> - class TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, true> + template <typename MULTI_BLOCK_T, typename NAME_VALUE_LOOKUP> + class TypedParam<MULTI_BLOCK_T, NAME_VALUE_LOOKUP, true, true> : public Param { public: - typedef TypedParam<VALUE_TYPE, NAME_VALUE_LOOKUP, true, true> self_t; - typedef ParamValue<VALUE_TYPE, NAME_VALUE_LOOKUP> param_value_t; + typedef TypedParam<MULTI_BLOCK_T, NAME_VALUE_LOOKUP, true, true> self_t; + typedef ParamValue<MULTI_BLOCK_T, NAME_VALUE_LOOKUP> param_value_t; typedef typename std::vector<param_value_t> container_t; typedef const container_t& value_assignment_t; typedef typename param_value_t::value_t value_t; @@ -1548,17 +1521,9 @@ namespace LLInitParam LLPredicate::Value<ESerializePredicates> predicate; predicate.set(REQUIRED, typed_param.mMinCount > 0); - - if (typed_param.isValid()) - { - predicate.set(VALID, true); - predicate.set(PROVIDED, typed_param.anyProvided()); - } - else - { - predicate.set(VALID, false); - predicate.set(PROVIDED, false); - } + predicate.set(VALID, typed_param.isValid()); + predicate.set(PROVIDED, typed_param.anyProvided()); + predicate.set(EMPTY, typed_param.mValues.empty()); if (!predicate_rule.check(predicate)) return false; diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index 6c9e5fc145..a0e970a799 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -76,41 +76,31 @@ namespace LLPredicate void set(ENUM e, bool value = true) { llassert(0 <= e && e < cMaxEnum); - mPredicateFlags = modifyPredicate(0x1 << (S32)e, cPredicateFlagsFromEnum[e], value, mPredicateFlags); - } - - void set(const Value other, bool value) - { - predicate_flag_t predicate_flags_to_set = other.mPredicateFlags; - predicate_flag_t cumulative_flags = 0; - while(predicate_flags_to_set) - { - predicate_flag_t next_flags = clearLSB(predicate_flags_to_set); - predicate_flag_t lsb_flag = predicate_flags_to_set ^ next_flags; - - predicate_flag_t mask = 0; - predicate_flag_t cur_flags = mPredicateFlags; - for (S32 i = 0; i < cMaxEnum; i++) - { - if (cPredicateFlagsFromEnum[i] & lsb_flag) - { - mask |= cPredicateFlagsFromEnum[i]; - cur_flags = modifyPredicate(0x1 << (0x1 << i ), cPredicateFlagsFromEnum[i], !value, cur_flags); - } - } - - cumulative_flags |= modifyPredicate(lsb_flag, mask, value, cur_flags); - - predicate_flags_to_set = next_flags; + predicate_flag_t flags_to_modify; + predicate_flag_t mask = cPredicateFlagsFromEnum[e]; + if (value) + { // add predicate "e" to flags that don't contain it already + flags_to_modify = (mPredicateFlags & ~mask); + // clear flags not containing e + mPredicateFlags &= mask; + // add back flags shifted to contain e + mPredicateFlags |= flags_to_modify << (0x1 << e); + } + else + { // remove predicate "e" from flags that contain it + flags_to_modify = (mPredicateFlags & mask); + // clear flags containing e + mPredicateFlags &= ~mask; + // add back flags shifted to not contain e + mPredicateFlags |= flags_to_modify >> (0x1 << e); } - mPredicateFlags = cumulative_flags; } - void forget(const Value value) + void forget(ENUM e) { - set(value, true); + set(e, true); U32 flags_with_predicate = mPredicateFlags; - set(value, false); + set(e, false); // ambiguous value is result of adding and removing predicate at the same time! mPredicateFlags |= flags_with_predicate; } @@ -131,38 +121,6 @@ namespace LLPredicate } private: - - predicate_flag_t clearLSB(predicate_flag_t value) - { - return value & (value - 1); - } - - predicate_flag_t modifyPredicate(predicate_flag_t predicate_flag, predicate_flag_t mask, predicate_flag_t value, bool set) - { - llassert(clearLSB(predicate_flag) == 0); - predicate_flag_t flags_to_modify; - - if (set) - { - flags_to_modify = (mPredicateFlags & ~mask); - // clear flags not containing predicate to be added - value &= mask; - // shift flags, in effect adding predicate - flags_to_modify *= predicate_flag; - } - else - { - flags_to_modify = mPredicateFlags & mask; - // clear flags containing predicate to be removed - value &= ~mask; - // shift flags, in effect removing predicate - flags_to_modify /= predicate_flag; - } - // put modified flags back - value |= flags_to_modify; - return value; - } - predicate_flag_t mPredicateFlags; }; @@ -181,14 +139,14 @@ namespace LLPredicate Rule() {} - void require(const Value<ENUM> value) + void require(ENUM e) { - mRule.set(value, require); + mRule.set(e, require); } - void allow(const Value<ENUM> value) + void allow(ENUM e) { - mRule.forget(value); + mRule.forget(e); } bool check(const Value<ENUM> value) const diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 735c45754c..8ad391e6e5 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,9 +38,9 @@ #include <list> -#define TOKEN_PASTE_ACTUAL(x, y) x##y -#define TOKEN_PASTE(x, y) TOKEN_PASTE_ACTUAL(x, y) -#define RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); +#define LL_TOKEN_PASTE_ACTUAL(x, y) x##y +#define LL_TOKEN_PASTE(x, y) LL_TOKEN_PASTE_ACTUAL(x, y) +#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); namespace LLTrace { @@ -93,13 +93,16 @@ namespace LLTrace public: - // copying an accumulator buffer does not copy the actual contents, but simply initializes the buffer size - // to be identical to the other buffer AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) : mStorageSize(other.mStorageSize), mStorage(new ACCUMULATOR[other.mStorageSize]), mNextStorageSlot(other.mNextStorageSlot) - {} + { + for (S32 i = 0; i < mNextStorageSlot; i++) + { + mStorage[i] = other.mStorage[i]; + } + } ~AccumulatorBuffer() { diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index a8e1a5eec9..9cdd89c223 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -52,9 +52,8 @@ Recording::~Recording() void Recording::update() { if (isStarted()) -{ + { LLTrace::get_thread_recorder()->update(this); - mElapsedSeconds = 0.0; mSamplingTimer.reset(); } } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 3a786c1357..e994949150 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -53,16 +53,20 @@ public: void restart(); void reset(); - bool isStarted() { return mPlayState == STARTED; } - bool isPaused() { return mPlayState == PAUSED; } - bool isStopped() { return mPlayState == STOPPED; } - EPlayState getPlayState() { return mPlayState; } + bool isStarted() const { return mPlayState == STARTED; } + bool isPaused() const { return mPlayState == PAUSED; } + bool isStopped() const { return mPlayState == STOPPED; } + EPlayState getPlayState() const { return mPlayState; } protected: LLStopWatchControlsMixinCommon() : mPlayState(STOPPED) {} + // derived classes can call this from their constructor in order + // to enforce invariants + void forceState(EPlayState state) { mPlayState = state; } + private: // trigger data accumulation (without reset) virtual void handleStart() = 0; @@ -102,6 +106,23 @@ namespace LLTrace public: Recording(); + Recording(const Recording& other) + { + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; + mMeasurementsFloat = other.mMeasurementsFloat; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + + if (other.isStarted()) + { + handleStart(); + } + + forceState(other.getPlayState()); + } ~Recording(); void makePrimary(); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 0feb3ab7af..af66a69492 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -86,6 +86,11 @@ std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Rec } } + if (it == end_it) + { + llerrs << "Recording not active on this thread" << llendl; + } + return it; } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 2d090f0f74..838a982cb4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -5244,6 +5244,8 @@ void LLAppViewer::metricsSend(bool enable_reporting) // Make a copy of the main stats to send into another thread. // Receiving thread takes ownership. LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats)); + + main_stats->updateStats(); // Send a report request into 'thread1' to get the rest of the data // and provide some additional parameters while here. diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index df43c4b344..000d061bec 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -246,9 +246,11 @@ LLViewerAssetStats::LLViewerAssetStats() LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src) : mRegionHandle(src.mRegionHandle), mPhaseStats(src.mPhaseStats), - mAvatarRezStates(src.mAvatarRezStates), - mRegionRecordings(src.mRegionRecordings) + mAvatarRezStates(src.mAvatarRezStates) { + src.mCurRecording->update(); + mRegionRecordings = src.mRegionRecordings; + mCurRecording = &mRegionRecordings[mRegionHandle]; } @@ -294,14 +296,17 @@ void LLViewerAssetStats::recordAvatarStats() mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray"); } -void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) +void LLViewerAssetStats::updateStats() { - using namespace LLViewerAssetStatsFF; - - if (mCurRecording) + if (mCurRecording && mCurRecording->isStarted()) { mCurRecording->update(); } +} + +void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) +{ + using namespace LLViewerAssetStatsFF; stats.regions.setProvided(); @@ -463,25 +468,6 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output) namespace LLViewerAssetStatsFF { -// -// Target thread is elaborated in the function name. This could -// have been something 'templatey' like specializations iterated -// over a set of constants but with so few, this is clearer I think. -// -// As for the threads themselves... rather than do fine-grained -// locking as we gather statistics, this code creates a collector -// for each thread, allocated and run independently. Logging -// happens at relatively infrequent intervals and at that time -// the data is sent to a single thread to be aggregated into -// a single entity with locks, thread safety and other niceties. -// -// A particularly fussy implementation would distribute the -// per-thread pointers across separate cache lines. But that should -// be beyond current requirements. -// - -// 'main' thread - initial program thread - void set_region(LLViewerAssetStats::region_handle_t region_handle) { if (! gViewerAssetStats) diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index f1ce3aeaa2..835df89149 100755 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -192,43 +192,12 @@ public: // Avatar-related statistics void recordAvatarStats(); + // gather latest metrics data + // call from main thread + void updateStats(); + // Retrieve current metrics for all visited regions (NULL region UUID/handle excluded) - // Returned LLSD is structured as follows: - // - // &stats_group = { - // enqueued : int, - // dequeued : int, - // resp_count : int, - // resp_min : float, - // resp_max : float, - // resp_mean : float - // } - // - // &mmm_group = { - // count : int, - // min : float, - // max : float, - // mean : float - // } - // - // { - // duration: int - // regions: { - // $: { // Keys are strings of the region's handle in hex - // duration: : int, - // fps: : &mmm_group, - // get_texture_temp_http : &stats_group, - // get_texture_temp_udp : &stats_group, - // get_texture_non_temp_http : &stats_group, - // get_texture_non_temp_udp : &stats_group, - // get_wearable_udp : &stats_group, - // get_sound_udp : &stats_group, - // get_gesture_udp : &stats_group, - // get_other : &stats_group - // } - // } - // } - // + // Uses AssetStats structure seen above void getStats(AssetStats& stats, bool compact_output); LLSD asLLSD(bool compact_output); diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index 26a76eda2c..1f299abe41 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -340,6 +340,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); + gViewerAssetStats->updateStats(); LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); @@ -377,6 +378,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false); LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false); + gViewerAssetStats->updateStats(); LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); @@ -422,6 +424,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + gViewerAssetStats->updateStats(); LLSD sd = gViewerAssetStats->asLLSD(false); // std::cout << sd << std::endl; @@ -496,6 +499,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false); + gViewerAssetStats->updateStats(); LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar")); @@ -563,6 +567,7 @@ namespace tut LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true); + gViewerAssetStats->updateStats(); LLSD sd = gViewerAssetStats->asLLSD(false); ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar")); ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle)); -- cgit v1.2.3 From 860ff2f7e2a7fe932dfb7c148f0dbc0067018038 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 7 Nov 2012 00:38:21 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct fixed trace data gathering and routing from background thread simplified slave->master thread communication (eliminated redundant recording and proxy object) improved performance of fast timer data gathering (slow iterators) --- indra/llcommon/llapr.h | 3 +- indra/llcommon/llfasttimer.cpp | 8 +- indra/llcommon/llqueuedthread.cpp | 5 +- indra/llcommon/lltrace.h | 5 +- indra/llcommon/lltracerecording.cpp | 189 +++++++++++++++++------- indra/llcommon/lltracerecording.h | 112 +++++++------- indra/llcommon/lltracethreadrecorder.cpp | 19 +-- indra/llcommon/lltracethreadrecorder.h | 11 +- indra/newview/llviewerassetstats.cpp | 2 +- indra/newview/llviewerstats.cpp | 5 +- indra/newview/tests/llviewerassetstats_test.cpp | 1 - 11 files changed, 224 insertions(+), 136 deletions(-) diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 821274aeb3..510725ffc6 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -334,14 +334,13 @@ public: {} explicit LLThreadLocalPointer(T* value) - : LLThreadLocalPointerBase(&cleanup) { set(value); } LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) - : LLThreadLocalPointerBase(other, &cleanup) + : LLThreadLocalPointerBase(other) { set(other.get()); } diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 0abaf73063..4f67004773 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -319,7 +319,7 @@ void LLFastTimer::NamedTimer::buildHierarchy() // set up initial tree { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) + for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { NamedTimer& timer = *it; if (&timer == NamedTimerFactory::instance().getRootTimer()) continue; @@ -449,7 +449,7 @@ void LLFastTimer::NamedTimer::resetFrame() LLSD sd; { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) + for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { NamedTimer& timer = *it; FrameState& info = timer.getFrameState(); @@ -472,7 +472,7 @@ void LLFastTimer::NamedTimer::resetFrame() } // reset for next frame - for (instance_iter it = beginInstances(); it != endInstances(); ++it) + for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { NamedTimer& timer = *it; @@ -512,7 +512,7 @@ void LLFastTimer::NamedTimer::reset() // reset all history { - for (instance_iter it = beginInstances(); it != endInstances(); ++it) + for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { NamedTimer& timer = *it; if (&timer != NamedTimerFactory::instance().getRootTimer()) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 218f6dbcd0..956642e97a 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -112,8 +112,6 @@ void LLQueuedThread::shutdown() // virtual S32 LLQueuedThread::update(F32 max_time_ms) { - LLTrace::get_thread_recorder()->pushToMaster(); - if (!mStarted) { if (!mThreaded) @@ -511,6 +509,9 @@ void LLQueuedThread::run() threadedUpdate(); int res = processNextRequest(); + + LLTrace::get_thread_recorder()->pushToMaster(); + if (res == 0) { mIdleThread = TRUE; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 8ad391e6e5..e2530a8a24 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -220,8 +220,7 @@ namespace LLTrace return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; } - ACCUMULATOR& getAccumulator(AccumulatorBuffer<ACCUMULATOR>* buffer) { return (*buffer)[mAccumulatorIndex]; } - const ACCUMULATOR& getAccumulator(const AccumulatorBuffer<ACCUMULATOR>* buffer) const { return (*buffer)[mAccumulatorIndex]; } + size_t getIndex() const { return mAccumulatorIndex; } protected: std::string mName; @@ -396,6 +395,8 @@ namespace LLTrace T getSum() const { return (T)mSum; } + U32 getSampleCount() const { return mNumSamples; } + private: T mSum; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9cdd89c223..435c49106f 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -117,29 +117,29 @@ void Recording::appendRecording( const Recording& other ) F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mCountsFloat).getSum(); + return (*mCountsFloat)[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType<CountAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mCounts).getSum(); + return (*mCounts)[stat.getIndex()].getSum(); } F64 Recording::getSum( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return (F64)stat.getAccumulator(mMeasurementsFloat).getSum(); + return (F64)(*mMeasurementsFloat)[stat.getIndex()].getSum(); } S64 Recording::getSum( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return (S64)stat.getAccumulator(mMeasurements).getSum(); + return (S64)(*mMeasurements)[stat.getIndex()].getSum(); } F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const { - F64 sum = stat.getAccumulator(mCountsFloat).getSum(); + F64 sum = (*mCountsFloat)[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -147,15 +147,26 @@ F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const { - S64 sum = stat.getAccumulator(mCounts).getSum(); + S64 sum = (*mCounts)[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; } +U32 Recording::getSampleCount( const TraceType<CountAccumulator<F64> >& stat ) const +{ + return (*mCountsFloat)[stat.getIndex()].getSampleCount(); +} + +U32 Recording::getSampleCount( const TraceType<CountAccumulator<S64> >& stat ) const +{ + return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); +} + + F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - F64 sum = stat.getAccumulator(mMeasurementsFloat).getSum(); + F64 sum = (*mMeasurementsFloat)[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; @@ -163,7 +174,7 @@ F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<F64> >& stat ) F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - S64 sum = stat.getAccumulator(mMeasurements).getSum(); + S64 sum = (*mMeasurements)[stat.getIndex()].getSum(); return (sum != 0) ? ((F64)sum / mElapsedSeconds) : 0.0; @@ -171,62 +182,62 @@ F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<S64> >& stat ) F64 Recording::getMin( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMin(); + return (*mMeasurementsFloat)[stat.getIndex()].getMin(); } S64 Recording::getMin( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getMin(); + return (*mMeasurements)[stat.getIndex()].getMin(); } F64 Recording::getMax( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMax(); + return (*mMeasurementsFloat)[stat.getIndex()].getMax(); } S64 Recording::getMax( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getMax(); + return (*mMeasurements)[stat.getIndex()].getMax(); } F64 Recording::getMean( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getMean(); + return (*mMeasurementsFloat)[stat.getIndex()].getMean(); } F64 Recording::getMean( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getMean(); + return (*mMeasurements)[stat.getIndex()].getMean(); } F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getStandardDeviation(); + return (*mMeasurementsFloat)[stat.getIndex()].getStandardDeviation(); } F64 Recording::getStandardDeviation( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getStandardDeviation(); + return (*mMeasurements)[stat.getIndex()].getStandardDeviation(); } F64 Recording::getLastValue( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getLastValue(); + return (*mMeasurementsFloat)[stat.getIndex()].getLastValue(); } S64 Recording::getLastValue( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getLastValue(); + return (*mMeasurements)[stat.getIndex()].getLastValue(); } U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<F64> >& stat ) const { - return stat.getAccumulator(mMeasurementsFloat).getSampleCount(); + return (*mMeasurementsFloat)[stat.getIndex()].getSampleCount(); } U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& stat ) const { - return stat.getAccumulator(mMeasurements).getSampleCount(); + return (*mMeasurements)[stat.getIndex()].getSampleCount(); } @@ -235,13 +246,14 @@ U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& st // PeriodicRecording /////////////////////////////////////////////////////////////////////// -PeriodicRecording::PeriodicRecording( S32 num_periods ) +PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state) : mNumPeriods(num_periods), mCurPeriod(0), mTotalValid(false), mRecordingPeriods( new Recording[num_periods]) { llassert(mNumPeriods > 0); + initTo(state); } PeriodicRecording::~PeriodicRecording() @@ -252,7 +264,7 @@ PeriodicRecording::~PeriodicRecording() void PeriodicRecording::nextPeriod() { - EPlayState play_state = getPlayState(); + EStopWatchState play_state = getPlayState(); Recording& old_recording = getCurRecordingPeriod(); mCurPeriod = (mCurPeriod + 1) % mNumPeriods; old_recording.splitTo(getCurRecordingPeriod()); @@ -286,24 +298,44 @@ Recording& PeriodicRecording::getTotalRecording() return mTotalRecording; } -void PeriodicRecording::handleStart() +void PeriodicRecording::start() +{ + getCurRecordingPeriod().start(); +} + +void PeriodicRecording::stop() +{ + getCurRecordingPeriod().stop(); +} + +void PeriodicRecording::pause() { - getCurRecordingPeriod().handleStart(); + getCurRecordingPeriod().pause(); } -void PeriodicRecording::handleStop() +void PeriodicRecording::resume() { - getCurRecordingPeriod().handleStop(); + getCurRecordingPeriod().resume(); } -void PeriodicRecording::handleReset() +void PeriodicRecording::restart() { - getCurRecordingPeriod().handleReset(); + getCurRecordingPeriod().restart(); } -void PeriodicRecording::handleSplitTo( PeriodicRecording& other ) +void PeriodicRecording::reset() { - getCurRecordingPeriod().handleSplitTo(other.getCurRecordingPeriod()); + getCurRecordingPeriod().reset(); +} + +void PeriodicRecording::splitTo(PeriodicRecording& other) +{ + getCurRecordingPeriod().splitTo(other.getCurRecordingPeriod()); +} + +void PeriodicRecording::splitFrom(PeriodicRecording& other) +{ + getCurRecordingPeriod().splitFrom(other.getCurRecordingPeriod()); } @@ -317,38 +349,59 @@ void ExtendableRecording::extend() mPotentialRecording.reset(); } -void ExtendableRecording::handleStart() +void ExtendableRecording::start() { - mPotentialRecording.handleStart(); + mPotentialRecording.start(); } -void ExtendableRecording::handleStop() +void ExtendableRecording::stop() { - mPotentialRecording.handleStop(); + mPotentialRecording.stop(); } -void ExtendableRecording::handleReset() +void ExtendableRecording::pause() { - mAcceptedRecording.handleReset(); - mPotentialRecording.handleReset(); + mPotentialRecording.pause(); } -void ExtendableRecording::handleSplitTo( ExtendableRecording& other ) +void ExtendableRecording::resume() { - mPotentialRecording.handleSplitTo(other.mPotentialRecording); + mPotentialRecording.resume(); +} + +void ExtendableRecording::restart() +{ + mAcceptedRecording.reset(); + mPotentialRecording.restart(); +} + +void ExtendableRecording::reset() +{ + mAcceptedRecording.reset(); + mPotentialRecording.reset(); +} + +void ExtendableRecording::splitTo(ExtendableRecording& other) +{ + mPotentialRecording.splitTo(other.mPotentialRecording); +} + +void ExtendableRecording::splitFrom(ExtendableRecording& other) +{ + mPotentialRecording.splitFrom(other.mPotentialRecording); } PeriodicRecording& get_frame_recording() { - static PeriodicRecording sRecording(64); - return sRecording; + static LLThreadLocalPointer<PeriodicRecording> sRecording(new PeriodicRecording(64, PeriodicRecording::STARTED)); + return *sRecording; } } void LLStopWatchControlsMixinCommon::start() { - switch (mPlayState) + switch (mState) { case STOPPED: handleReset(); @@ -360,13 +413,16 @@ void LLStopWatchControlsMixinCommon::start() case STARTED: handleReset(); break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::stop() { - switch (mPlayState) + switch (mState) { case STOPPED: break; @@ -376,13 +432,16 @@ void LLStopWatchControlsMixinCommon::stop() case STARTED: handleStop(); break; + default: + llassert(false); + break; } - mPlayState = STOPPED; + mState = STOPPED; } void LLStopWatchControlsMixinCommon::pause() { - switch (mPlayState) + switch (mState) { case STOPPED: break; @@ -391,13 +450,16 @@ void LLStopWatchControlsMixinCommon::pause() case STARTED: handleStop(); break; + default: + llassert(false); + break; } - mPlayState = PAUSED; + mState = PAUSED; } void LLStopWatchControlsMixinCommon::resume() { - switch (mPlayState) + switch (mState) { case STOPPED: handleStart(); @@ -407,13 +469,16 @@ void LLStopWatchControlsMixinCommon::resume() break; case STARTED: break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::restart() { - switch (mPlayState) + switch (mState) { case STOPPED: handleReset(); @@ -426,11 +491,33 @@ void LLStopWatchControlsMixinCommon::restart() case STARTED: handleReset(); break; + default: + llassert(false); + break; } - mPlayState = STARTED; + mState = STARTED; } void LLStopWatchControlsMixinCommon::reset() { handleReset(); } + +void LLStopWatchControlsMixinCommon::initTo( EStopWatchState state ) +{ + switch(state) + { + case STOPPED: + break; + case PAUSED: + break; + case STARTED: + handleStart(); + break; + default: + llassert(false); + break; + } + + mState = state; +} diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index e994949150..31901b599c 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -39,43 +39,42 @@ class LL_COMMON_API LLStopWatchControlsMixinCommon public: virtual ~LLStopWatchControlsMixinCommon() {} - enum EPlayState + enum EStopWatchState { STOPPED, PAUSED, STARTED }; - void start(); - void stop(); - void pause(); - void resume(); - void restart(); - void reset(); + virtual void start(); + virtual void stop(); + virtual void pause(); + virtual void resume(); + virtual void restart(); + virtual void reset(); - bool isStarted() const { return mPlayState == STARTED; } - bool isPaused() const { return mPlayState == PAUSED; } - bool isStopped() const { return mPlayState == STOPPED; } - EPlayState getPlayState() const { return mPlayState; } + bool isStarted() const { return mState == STARTED; } + bool isPaused() const { return mState == PAUSED; } + bool isStopped() const { return mState == STOPPED; } + EStopWatchState getPlayState() const { return mState; } protected: LLStopWatchControlsMixinCommon() - : mPlayState(STOPPED) + : mState(STOPPED) {} - // derived classes can call this from their constructor in order - // to enforce invariants - void forceState(EPlayState state) { mPlayState = state; } - + // derived classes can call this from their copy constructor in order + // to duplicate play state of source + void initTo(EStopWatchState state); private: - // trigger data accumulation (without reset) - virtual void handleStart() = 0; - // stop data accumulation, should put object in queryable state - virtual void handleStop() = 0; - // clear accumulated values, can be called while started - virtual void handleReset() = 0; - - EPlayState mPlayState; + // trigger active behavior (without reset) + virtual void handleStart(){}; + // stop active behavior + virtual void handleStop(){}; + // clear accumulated state, can be called while started + virtual void handleReset(){}; + + EStopWatchState mState; }; template<typename DERIVED> @@ -83,19 +82,20 @@ class LLStopWatchControlsMixin : public LLStopWatchControlsMixinCommon { public: - void splitTo(DERIVED& other) + typedef LLStopWatchControlsMixin<DERIVED> self_t; + virtual void splitTo(DERIVED& other) { handleSplitTo(other); } - void splitFrom(DERIVED& other) + virtual void splitFrom(DERIVED& other) { - other.handleSplitTo(*this); + static_cast<self_t&>(other).handleSplitTo(*static_cast<DERIVED*>(this)); } private: // atomically stop this object while starting the other // no data can be missed in between stop and start - virtual void handleSplitTo(DERIVED& other) = 0; + virtual void handleSplitTo(DERIVED& other) {}; }; @@ -108,20 +108,20 @@ namespace LLTrace Recording(const Recording& other) { - mSamplingTimer = other.mSamplingTimer; - mElapsedSeconds = other.mElapsedSeconds; - mCountsFloat = other.mCountsFloat; + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; mMeasurementsFloat = other.mMeasurementsFloat; - mCounts = other.mCounts; - mMeasurements = other.mMeasurements; - mStackTimers = other.mStackTimers; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + LLStopWatchControlsMixin::initTo(other.getPlayState()); if (other.isStarted()) { handleStart(); } - forceState(other.getPlayState()); } ~Recording(); @@ -149,6 +149,10 @@ namespace LLTrace return (T)getPerSec(static_cast<const TraceType<CountAccumulator<StorageType<T>::type_t> >&> (stat)); } + U32 getSampleCount(const TraceType<CountAccumulator<F64> >& stat) const; + U32 getSampleCount(const TraceType<CountAccumulator<S64> >& stat) const; + + // Measurement accessors F64 getSum(const TraceType<MeasurementAccumulator<F64> >& stat) const; S64 getSum(const TraceType<MeasurementAccumulator<S64> >& stat) const; @@ -211,14 +215,15 @@ namespace LLTrace LLUnit::Seconds<F64> getDuration() const { return mElapsedSeconds; } + private: + friend class ThreadRecorder; + // implementation for LLStopWatchControlsMixin /*virtual*/ void handleStart(); /*virtual*/ void handleStop(); /*virtual*/ void handleReset(); /*virtual*/ void handleSplitTo(Recording& other); - private: - friend class ThreadRecorder; // returns data for current thread class ThreadRecorder* getThreadRecorder(); @@ -236,7 +241,7 @@ namespace LLTrace : public LLStopWatchControlsMixin<PeriodicRecording> { public: - PeriodicRecording(S32 num_periods); + PeriodicRecording(S32 num_periods, EStopWatchState state = STOPPED); ~PeriodicRecording(); void nextPeriod(); @@ -359,15 +364,17 @@ namespace LLTrace return mean; } - private: - // implementation for LLStopWatchControlsMixin - /*virtual*/ void handleStart(); - /*virtual*/ void handleStop(); - /*virtual*/ void handleReset(); - - /*virtual*/ void handleSplitTo(PeriodicRecording& other); + /*virtual*/ void start(); + /*virtual*/ void stop(); + /*virtual*/ void pause(); + /*virtual*/ void resume(); + /*virtual*/ void restart(); + /*virtual*/ void reset(); + /*virtual*/ void splitTo(PeriodicRecording& other); + /*virtual*/ void splitFrom(PeriodicRecording& other); + private: Recording* mRecordingPeriods; Recording mTotalRecording; bool mTotalValid; @@ -382,13 +389,16 @@ namespace LLTrace { void extend(); - private: // implementation for LLStopWatchControlsMixin - /*virtual*/ void handleStart(); - /*virtual*/ void handleStop(); - /*virtual*/ void handleReset(); - /*virtual*/ void handleSplitTo(ExtendableRecording& other); - + /*virtual*/ void start(); + /*virtual*/ void stop(); + /*virtual*/ void pause(); + /*virtual*/ void resume(); + /*virtual*/ void restart(); + /*virtual*/ void reset(); + /*virtual*/ void splitTo(ExtendableRecording& other); + /*virtual*/ void splitFrom(ExtendableRecording& other); + private: Recording mAcceptedRecording; Recording mPotentialRecording; }; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index af66a69492..5a6ff14f97 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -171,15 +171,20 @@ void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) // MasterThreadRecorder /////////////////////////////////////////////////////////////////////// +LLFastTimer::DeclareTimer FTM_PULL_TRACE_DATA_FROM_SLAVES("Pull slave trace data"); void MasterThreadRecorder::pullFromSlaveThreads() { + LLFastTimer _(FTM_PULL_TRACE_DATA_FROM_SLAVES); + if (mActiveRecordings.empty()) return; + LLMutexLock lock(&mSlaveListMutex); + Recording& target_recording = mActiveRecordings.front().mBaseline; for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); it != end_it; ++it) { - (*it)->mRecorder->mSharedData.copyTo((*it)->mSlaveRecording); + (*it)->mSharedData.copyTo(target_recording); } } @@ -187,7 +192,7 @@ void MasterThreadRecorder::addSlaveThread( class SlaveThreadRecorder* child ) { LLMutexLock lock(&mSlaveListMutex); - mSlaveThreadRecorders.push_back(new SlaveThreadRecorderProxy(child)); + mSlaveThreadRecorders.push_back(child); } void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) @@ -198,7 +203,7 @@ void MasterThreadRecorder::removeSlaveThread( class SlaveThreadRecorder* child ) it != end_it; ++it) { - if ((*it)->mRecorder == child) + if ((*it) == child) { mSlaveThreadRecorders.erase(it); break; @@ -212,12 +217,4 @@ void MasterThreadRecorder::pushToMaster() MasterThreadRecorder::MasterThreadRecorder() {} -/////////////////////////////////////////////////////////////////////// -// MasterThreadRecorder::SlaveThreadTraceProxy -/////////////////////////////////////////////////////////////////////// - -MasterThreadRecorder::SlaveThreadRecorderProxy::SlaveThreadRecorderProxy( class SlaveThreadRecorder* recorder) -: mRecorder(recorder) -{} - } diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index c9231265af..44fe67384b 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -81,17 +81,8 @@ namespace LLTrace LLMutex* getSlaveListMutex() { return &mSlaveListMutex; } private: - struct SlaveThreadRecorderProxy - { - SlaveThreadRecorderProxy(class SlaveThreadRecorder* recorder); - class SlaveThreadRecorder* mRecorder; - Recording mSlaveRecording; - private: - //no need to copy these and then have to duplicate the storage - SlaveThreadRecorderProxy(const SlaveThreadRecorderProxy& other) {} - }; - typedef std::list<SlaveThreadRecorderProxy*> slave_thread_recorder_list_t; + typedef std::list<class SlaveThreadRecorder*> slave_thread_recorder_list_t; slave_thread_recorder_list_t mSlaveThreadRecorders; LLMutex mSlaveListMutex; diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index 000d061bec..bad2f5b4cd 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -494,7 +494,7 @@ void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, { const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp)); - sResponse[int(eac)].sample<LLTrace::Seconds>(duration); + sResponse[int(eac)].sample<LLTrace::Microseconds>(duration); } void record_avatar_stats() diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index a42368cec4..317fe5eaf8 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -349,7 +349,10 @@ void update_statistics() } LLStatViewer::FPS.add(1); - LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS)); + if (LLTrace::get_frame_recording().getTotalRecording().getSampleCount(LLStatViewer::FPS)) + { + LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS)); + } F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits); LLStatViewer::OBJECT_KBIT.add(gObjectData); diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index 1f299abe41..ecdd78a1da 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -266,7 +266,6 @@ namespace tut ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats)); LLSD sd_full = it->asLLSD(false); - llinfos << ll_pretty_print_sd(sd_full) << llendl; // Default (NULL) region ID doesn't produce LLSD results so should // get an empty map back from output -- cgit v1.2.3 From 9d70448a1275b80a829e16b6d08d29919748c823 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 7 Nov 2012 00:43:56 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct removed explicit constructor of LLUnit from integral types, as C++ already guarantees that I can't convert from LLUnit<Bytes> to LLUnits<Seconds> (requires 2 user defined conversions). Now this allows seamless replacement of existing integral types with Unit labeled types. --- indra/llcommon/llunit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index e778383959..98e4de32fa 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -41,7 +41,7 @@ struct LLUnitType : public BASE_UNIT LLUnitType() {} - explicit LLUnitType(storage_t value) + LLUnitType(storage_t value) : BASE_UNIT(convertToBase(value)) {} @@ -86,7 +86,7 @@ struct LLUnitType<STORAGE_TYPE, T, T> : mBaseValue() {} - explicit LLUnitType(storage_t value) + LLUnitType(storage_t value) : mBaseValue(value) {} -- cgit v1.2.3 From ed17c181dd37f56b808838748d289ee7bb5567ec Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 7 Nov 2012 15:32:12 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct further fixes to implicit conversion of unit types --- indra/llcommon/lldate.cpp | 11 +-- indra/llcommon/lldate.h | 3 +- indra/llcommon/lltimer.cpp | 15 ++-- indra/llcommon/lltimer.h | 21 +++--- indra/llcommon/lltracerecording.cpp | 19 +++++ indra/llcommon/lltracerecording.h | 18 +---- indra/llcommon/llunit.h | 141 +++++++++--------------------------- indra/llmath/v4color.h | 6 +- indra/llui/llnotifications.cpp | 2 +- indra/newview/llviewertexture.cpp | 4 +- 10 files changed, 86 insertions(+), 154 deletions(-) diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index 030ef6a3c7..d8b3dfe6c6 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -48,18 +48,15 @@ static const F64 LL_APR_USEC_PER_SEC = 1000000.0; LLDate::LLDate() : mSecondsSinceEpoch(DATE_EPOCH) -{ -} +{} LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) -{ -} +{} -LLDate::LLDate(F64 seconds_since_epoch) : +LLDate::LLDate(LLUnit::Seconds<F64> seconds_since_epoch) : mSecondsSinceEpoch(seconds_since_epoch) -{ -} +{} LLDate::LLDate(const std::string& iso8601_date) { diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 7ff8b550ad..0500b1dcd8 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -33,6 +33,7 @@ #include <string> #include "stdtypes.h" +#include "llunit.h" /** * @class LLDate @@ -58,7 +59,7 @@ public: * * @pararm seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(F64 seconds_since_epoch); + LLDate(LLUnit::Seconds<F64> seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 9ebc6de7f4..05f6b789e4 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -287,14 +287,15 @@ LLTimer::~LLTimer() } // static -U64 LLTimer::getTotalTime() +LLUnit::Microseconds<U64> LLTimer::getTotalTime() { + LLUnit::Seconds<F64> sec = LLUnit::Milliseconds<U32>(2000) + LLUnit::Hours<F32>(1.f / 360.f); // simply call into the implementation function. return totalTime(); } // static -F64 LLTimer::getTotalSeconds() +LLUnit::Seconds<F64> LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -343,23 +344,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -F64 LLTimer::getElapsedTimeF64() const +LLUnit::Seconds<F64> LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeF32() const +LLUnit::Seconds<F32> LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -F64 LLTimer::getElapsedTimeAndResetF64() +LLUnit::Seconds<F64> LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeAndResetF32() +LLUnit::Seconds<F32> LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -372,7 +373,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -F32 LLTimer::getRemainingTimeF32() const +LLUnit::Seconds<F32> LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 513de0605d..e0a880a346 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -37,6 +37,7 @@ #include <string> #include <list> // units conversions +#include "llunit.h" #ifndef USEC_PER_SEC const U32 USEC_PER_SEC = 1000000; #endif @@ -55,7 +56,7 @@ public: protected: U64 mLastClockCount; U64 mExpirationTicks; - BOOL mStarted; + bool mStarted; public: LLTimer(); @@ -66,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static F64 getElapsedSeconds() + static LLUnit::Seconds<F64> getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static U64 getTotalTime(); + static LLUnit::Microseconds<U64> getTotalTime(); // Return a high precision seconds since epoch - static F64 getTotalSeconds(); + static LLUnit::Seconds<F64> getTotalSeconds(); // MANIPULATORS @@ -86,18 +87,18 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - F32 getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - F64 getElapsedTimeAndResetF64(); + LLUnit::Seconds<F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnit::Seconds<F64> getElapsedTimeAndResetF64(); - F32 getRemainingTimeF32() const; + LLUnit::Seconds<F32> getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - F32 getElapsedTimeF32() const; // Returns elapsed time in seconds - F64 getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnit::Seconds<F32> getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnit::Seconds<F64> getElapsedTimeF64() const; // Returns elapsed time in seconds - BOOL getStarted() const { return mStarted; } + bool getStarted() const { return mStarted; } static U64 getCurrentClockCount(); // Returns the raw clockticks diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 435c49106f..4252ed57dc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,25 @@ Recording::Recording() mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) {} +Recording::Recording( const Recording& other ) +{ + llassert(other.mCountsFloat.get() != NULL); + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; + mMeasurementsFloat = other.mMeasurementsFloat; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + + LLStopWatchControlsMixin::initTo(other.getPlayState()); + if (other.isStarted()) + { + handleStart(); + } +} + + Recording::~Recording() {} diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 31901b599c..fc96631ce0 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -106,23 +106,7 @@ namespace LLTrace public: Recording(); - Recording(const Recording& other) - { - mSamplingTimer = other.mSamplingTimer; - mElapsedSeconds = other.mElapsedSeconds; - mCountsFloat = other.mCountsFloat; - mMeasurementsFloat = other.mMeasurementsFloat; - mCounts = other.mCounts; - mMeasurements = other.mMeasurements; - mStackTimers = other.mStackTimers; - - LLStopWatchControlsMixin::initTo(other.getPlayState()); - if (other.isStarted()) - { - handleStart(); - } - - } + Recording(const Recording& other); ~Recording(); void makePrimary(); diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 98e4de32fa..4519905707 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -51,6 +51,11 @@ struct LLUnitType : public BASE_UNIT return static_cast<unit_t&>(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return convertToDerived(mBaseValue); @@ -102,6 +107,11 @@ struct LLUnitType<STORAGE_TYPE, T, T> return static_cast<unit_t&>(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return mBaseValue; } template<typename CONVERTED_TYPE> @@ -110,7 +120,6 @@ struct LLUnitType<STORAGE_TYPE, T, T> return CONVERTED_TYPE(*this).value(); } - static storage_t convertToBase(storage_t derived_value) { return (storage_t)derived_value; @@ -150,99 +159,77 @@ protected: storage_t mBaseValue; }; -// -// operator + -// template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +struct LLUnitTypeWrapper +: public LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> { - return DERIVED_UNIT(first + second.value()); -} + typedef LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> unit_t; + LLUnitTypeWrapper(const unit_t& other) + : unit_t(other) + {} +}; -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return DERIVED_UNIT(first.value() + second); -} -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +// +// operator + +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> +DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE2, BASE_UNIT2, DERIVED_UNIT2> second) { - return DERIVED_UNIT(first.value() + second.value()); + return DERIVED_UNIT(first + LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); } + // // operator - // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> DERIVED_UNIT operator - (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { - return DERIVED_UNIT(first - second.value()); -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return DERIVED_UNIT(first.value() - second); -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return DERIVED_UNIT(first.value() - second.value()); + return DERIVED_UNIT(first - LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); } // // operator * // template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { return DERIVED_UNIT(first * second.value()); } template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) { return DERIVED_UNIT(first.value() * second); } + // // operator / // template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { - return DERIVED_UNIT(first * second.value()); + return DERIVED_UNIT(first / second.value()); } template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +DERIVED_UNIT operator / (LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) { - return DERIVED_UNIT(first.value() * second); + return DERIVED_UNIT(first.value() / second); } // // operator < // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> + bool operator < (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { return first < second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() < second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() < second.value(); -} - // // operator <= // @@ -252,17 +239,6 @@ bool operator <= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first <= second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() <= second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() <= second.value(); -} // // operator > @@ -273,17 +249,6 @@ bool operator > (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::sto return first > second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() > second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() > second.value(); -} // // operator >= // @@ -293,18 +258,6 @@ bool operator >= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first >= second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() >= second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() >= second.value(); -} - // // operator == // @@ -314,18 +267,6 @@ bool operator == (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first == second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() == second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() == second.value(); -} - // // operator != // @@ -335,18 +276,6 @@ bool operator != (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first != second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() != second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() != second.value(); -} - #define LL_DECLARE_BASE_UNIT(unit_name) \ template<typename STORAGE> \ struct unit_name : public LLUnitType<STORAGE, unit_name<STORAGE>, unit_name<STORAGE> > \ diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index b047f86e6e..78223e1e65 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -49,9 +49,9 @@ class LLColor4 LLColor4(); // Initializes LLColor4 to (0, 0, 0, 1) LLColor4(F32 r, F32 g, F32 b); // Initializes LLColor4 to (r, g, b, 1) LLColor4(F32 r, F32 g, F32 b, F32 a); // Initializes LLColor4 to (r. g, b, a) - LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) - LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) - LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) + explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) + explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) + explicit LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) explicit LLColor4(const LLSD& sd); explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 629eef2c3b..118c74b9b2 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -464,7 +464,7 @@ LLNotification::LLNotification(const LLNotification::Params& p) : mTimestamp(p.time_stamp), mSubstitutions(p.substitutions), mPayload(p.payload), - mExpiresAt(0), + mExpiresAt(0.0), mTemporaryResponder(false), mRespondedTo(false), mPriority(p.priority), diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index f64134b8b7..ceb8d3155c 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -533,7 +533,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sTotalTextureMemory >= sMaxTotalTextureMem) { //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes<S32>)gMaxVideoRam) ;//512 MB + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes<S32>(gMaxVideoRam)); // If we are using more texture memory than we should, // scale up the desired discard level @@ -3312,7 +3312,7 @@ void LLViewerLODTexture::processTextureStats() scaleDown() ; } // Only allow GL to have 2x the video card memory - else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale && + else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; -- cgit v1.2.3 From 0bb0bd514b235948c1a21c81ab0e8ab6223b1990 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 8 Nov 2012 23:42:18 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct Finished making LLUnit implicitly convertible to/from scalar integer values cleaned up test code --- indra/llcommon/lldate.cpp | 4 +- indra/llcommon/lldate.h | 4 +- indra/llcommon/lldefs.h | 3 + indra/llcommon/llerrorlegacy.h | 7 + indra/llcommon/lltimer.cpp | 15 +- indra/llcommon/lltimer.h | 16 +- indra/llcommon/lltrace.h | 54 +++-- indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/llunit.h | 404 ++++++++++++++++------------------- indra/llmath/v4color.h | 6 +- indra/llrender/llimagegl.cpp | 6 +- indra/llrender/llimagegl.h | 6 +- indra/newview/llappviewer.cpp | 2 +- indra/newview/llappviewer.h | 2 +- indra/newview/lldrawpoolwater.cpp | 2 +- indra/newview/lltextureview.cpp | 18 +- indra/newview/llviewerassetstats.cpp | 4 +- indra/newview/llviewermessage.cpp | 20 +- indra/newview/llviewerstats.cpp | 6 +- indra/newview/llviewerstats.h | 6 +- indra/newview/llviewertexture.cpp | 18 +- indra/newview/llviewertexture.h | 14 +- indra/newview/llviewerwindow.cpp | 2 +- 23 files changed, 295 insertions(+), 326 deletions(-) diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index d8b3dfe6c6..5569b4102d 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -54,8 +54,8 @@ LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) {} -LLDate::LLDate(LLUnit::Seconds<F64> seconds_since_epoch) : - mSecondsSinceEpoch(seconds_since_epoch) +LLDate::LLDate(LLUnit<LLUnits::Seconds, F64> seconds_since_epoch) : + mSecondsSinceEpoch(seconds_since_epoch.value()) {} LLDate::LLDate(const std::string& iso8601_date) diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 0500b1dcd8..b62a846147 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -57,9 +57,9 @@ public: /** * @brief Construct a date from a seconds since epoch value. * - * @pararm seconds_since_epoch The number of seconds since UTC epoch. + * @param seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(LLUnit::Seconds<F64> seconds_since_epoch); + LLDate(LLUnit<LLUnits::Seconds, F64> seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index 5a4b8325f4..d57b9dccff 100644 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -244,5 +244,8 @@ inline void llswap(LLDATATYPE& lhs, LLDATATYPE& rhs) rhs = tmp; } +#define LL_GLUE_IMPL(x, y) x##y +#define LL_GLUE_TOKENS(x, y) LL_GLUE_IMPL(x, y) + #endif // LL_LLDEFS_H diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h index 37cee579cd..58cc2899af 100644 --- a/indra/llcommon/llerrorlegacy.h +++ b/indra/llcommon/llerrorlegacy.h @@ -29,6 +29,7 @@ #define LL_LLERRORLEGACY_H #include "llpreprocessor.h" +#include <boost/static_assert.hpp> /* LEGACY -- DO NOT USE THIS STUFF ANYMORE @@ -111,6 +112,12 @@ const int LL_ERR_PRICE_MISMATCH = -23018; #define llverify(func) do {if (func) {}} while(0) #endif +#ifdef LL_WINDOWS +#define llstatic_assert(func, msg) static_assert(func, msg) +#else +#define llstatic_assert(func, msg) BOOST_STATIC_ASSERT(func) +#endif + // handy compile-time assert - enforce those template parameters! #define cassert(expn) typedef char __C_ASSERT__[(expn)?1:-1] /* Flawfinder: ignore */ //XXX: used in two places in llcommon/llskipmap.h diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 05f6b789e4..23cebf4336 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -287,15 +287,14 @@ LLTimer::~LLTimer() } // static -LLUnit::Microseconds<U64> LLTimer::getTotalTime() +LLUnit<LLUnits::Microseconds, U64> LLTimer::getTotalTime() { - LLUnit::Seconds<F64> sec = LLUnit::Milliseconds<U32>(2000) + LLUnit::Hours<F32>(1.f / 360.f); // simply call into the implementation function. return totalTime(); } // static -LLUnit::Seconds<F64> LLTimer::getTotalSeconds() +LLUnit<LLUnits::Seconds, F64> LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -344,23 +343,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -LLUnit::Seconds<F64> LLTimer::getElapsedTimeF64() const +LLUnit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -LLUnit::Seconds<F32> LLTimer::getElapsedTimeF32() const +LLUnit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -LLUnit::Seconds<F64> LLTimer::getElapsedTimeAndResetF64() +LLUnit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -LLUnit::Seconds<F32> LLTimer::getElapsedTimeAndResetF32() +LLUnit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -373,7 +372,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -LLUnit::Seconds<F32> LLTimer::getRemainingTimeF32() const +LLUnit<LLUnits::Seconds, F32> LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index e0a880a346..5cb2b18111 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -67,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static LLUnit::Seconds<F64> getElapsedSeconds() + static LLUnit<LLUnits::Seconds, F64> getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static LLUnit::Microseconds<U64> getTotalTime(); + static LLUnit<LLUnits::Microseconds, U64> getTotalTime(); // Return a high precision seconds since epoch - static LLUnit::Seconds<F64> getTotalSeconds(); + static LLUnit<LLUnits::Seconds, F64> getTotalSeconds(); // MANIPULATORS @@ -87,16 +87,16 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - LLUnit::Seconds<F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - LLUnit::Seconds<F64> getElapsedTimeAndResetF64(); + LLUnit<LLUnits::Seconds, F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnit<LLUnits::Seconds, F64> getElapsedTimeAndResetF64(); - LLUnit::Seconds<F32> getRemainingTimeF32() const; + LLUnit<LLUnits::Seconds, F32> getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - LLUnit::Seconds<F32> getElapsedTimeF32() const; // Returns elapsed time in seconds - LLUnit::Seconds<F64> getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnit<LLUnits::Seconds, F32> getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnit<LLUnits::Seconds, F64> getElapsedTimeF64() const; // Returns elapsed time in seconds bool getStarted() const { return mStarted; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index e2530a8a24..d289ea9a88 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,37 +38,35 @@ #include <list> -#define LL_TOKEN_PASTE_ACTUAL(x, y) x##y -#define LL_TOKEN_PASTE(x, y) LL_TOKEN_PASTE_ACTUAL(x, y) -#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); +#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer); namespace LLTrace { class Recording; - typedef LLUnit::Bytes<F64> Bytes; - typedef LLUnit::Kilobytes<F64> Kilobytes; - typedef LLUnit::Megabytes<F64> Megabytes; - typedef LLUnit::Gigabytes<F64> Gigabytes; - typedef LLUnit::Bits<F64> Bits; - typedef LLUnit::Kilobits<F64> Kilobits; - typedef LLUnit::Megabits<F64> Megabits; - typedef LLUnit::Gigabits<F64> Gigabits; - - typedef LLUnit::Seconds<F64> Seconds; - typedef LLUnit::Milliseconds<F64> Milliseconds; - typedef LLUnit::Minutes<F64> Minutes; - typedef LLUnit::Hours<F64> Hours; - typedef LLUnit::Days<F64> Days; - typedef LLUnit::Weeks<F64> Weeks; - typedef LLUnit::Milliseconds<F64> Milliseconds; - typedef LLUnit::Microseconds<F64> Microseconds; - typedef LLUnit::Nanoseconds<F64> Nanoseconds; - - typedef LLUnit::Meters<F64> Meters; - typedef LLUnit::Kilometers<F64> Kilometers; - typedef LLUnit::Centimeters<F64> Centimeters; - typedef LLUnit::Millimeters<F64> Millimeters; + typedef LLUnit<LLUnits::Bytes, F64> Bytes; + typedef LLUnit<LLUnits::Kilobytes, F64> Kilobytes; + typedef LLUnit<LLUnits::Megabytes, F64> Megabytes; + typedef LLUnit<LLUnits::Gigabytes, F64> Gigabytes; + typedef LLUnit<LLUnits::Bits, F64> Bits; + typedef LLUnit<LLUnits::Kilobits, F64> Kilobits; + typedef LLUnit<LLUnits::Megabits, F64> Megabits; + typedef LLUnit<LLUnits::Gigabits, F64> Gigabits; + + typedef LLUnit<LLUnits::Seconds, F64> Seconds; + typedef LLUnit<LLUnits::Milliseconds, F64> Milliseconds; + typedef LLUnit<LLUnits::Minutes, F64> Minutes; + typedef LLUnit<LLUnits::Hours, F64> Hours; + typedef LLUnit<LLUnits::Days, F64> Days; + typedef LLUnit<LLUnits::Weeks, F64> Weeks; + typedef LLUnit<LLUnits::Milliseconds, F64> Milliseconds; + typedef LLUnit<LLUnits::Microseconds, F64> Microseconds; + typedef LLUnit<LLUnits::Nanoseconds, F64> Nanoseconds; + + typedef LLUnit<LLUnits::Meters, F64> Meters; + typedef LLUnit<LLUnits::Kilometers, F64> Kilometers; + typedef LLUnit<LLUnits::Centimeters, F64> Centimeters; + typedef LLUnit<LLUnits::Millimeters, F64> Millimeters; void init(); void cleanup(); @@ -438,7 +436,7 @@ namespace LLTrace void sample(UNIT_T value) { T converted_value; - converted_value.assignFrom(value); + converted_value = value; getPrimaryAccumulator().sample((storage_t)converted_value.value()); } }; @@ -478,7 +476,7 @@ namespace LLTrace void add(UNIT_T value) { T converted_value; - converted_value.assignFrom(value); + converted_value = value; getPrimaryAccumulator().add((storage_t)converted_value.value()); } }; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index fc96631ce0..ca9950b78d 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -197,7 +197,7 @@ namespace LLTrace U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const; U32 getSampleCount(const TraceType<MeasurementAccumulator<S64> >& stat) const; - LLUnit::Seconds<F64> getDuration() const { return mElapsedSeconds; } + LLUnit<LLUnits::Seconds, F64> getDuration() const { return mElapsedSeconds; } private: friend class ThreadRecorder; diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 4519905707..0dcafbe26e 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -30,326 +30,288 @@ #include "stdtypes.h" #include "llpreprocessor.h" -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT = BASE_UNIT> -struct LLUnitType : public BASE_UNIT +namespace LLUnits { - typedef DERIVED_UNIT unit_t; - - typedef typename STORAGE_TYPE storage_t; - typedef void is_unit_tag_t; - - LLUnitType() - {} - - LLUnitType(storage_t value) - : BASE_UNIT(convertToBase(value)) - {} - - // implicit downcast - operator unit_t& () - { - return static_cast<unit_t&>(*this); - } - - operator storage_t () const - { - return value(); - } - - storage_t value() const - { - return convertToDerived(mBaseValue); - } - - template<typename CONVERTED_TYPE> - storage_t as() const - { - return CONVERTED_TYPE(*this).value(); - } - -protected: - static storage_t convertToBase(storage_t derived_value) - { - return (storage_t)((F32)derived_value * unit_t::conversionToBaseFactor()); - } - - static storage_t convertToDerived(storage_t base_value) +template<typename DERIVED_UNITS_TAG, typename BASE_UNITS_TAG> +struct ConversionFactor +{ + static F64 get() { - return (storage_t)((F32)base_value / unit_t::conversionToBaseFactor()); + llstatic_assert(sizeof(DERIVED_UNITS_TAG) == 0, "Cannot convert between types."); } +}; +template<typename BASE_UNITS_TAG> +struct ConversionFactor<BASE_UNITS_TAG, BASE_UNITS_TAG> +{ + static F64 get() { return 1.0; } }; +} -template<typename STORAGE_TYPE, typename T> -struct LLUnitType<STORAGE_TYPE, T, T> +template<typename UNIT_TYPE, typename STORAGE_TYPE> +struct LLUnit { - typedef T unit_t; - typedef STORAGE_TYPE storage_t; + typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t; + typedef typename STORAGE_TYPE storage_t; typedef void is_unit_tag_t; - LLUnitType() - : mBaseValue() + LLUnit(storage_t value = storage_t()) + : mValue(value) {} - LLUnitType(storage_t value) - : mBaseValue(value) + template<typename OTHER_UNIT, typename OTHER_STORAGE> + LLUnit(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) + : mValue(convert(other)) {} - unit_t& operator=(storage_t value) + LLUnit(self_t& other) + : mValue(other.mValue) + {} + + self_t& operator = (storage_t value) { - setBaseValue(value); + mValue = value; return *this; } - //implicit downcast - operator unit_t& () + template<typename OTHER_UNIT, typename OTHER_STORAGE> + self_t& operator = (LLUnit<OTHER_UNIT, OTHER_STORAGE> other) { - return static_cast<unit_t&>(*this); + mValue = convert(other); + return *this; } - operator storage_t () const + operator storage_t() const { return value(); } - storage_t value() const { return mBaseValue; } - - template<typename CONVERTED_TYPE> - storage_t as() const + storage_t value() const { - return CONVERTED_TYPE(*this).value(); + return mValue; } - static storage_t convertToBase(storage_t derived_value) + void operator += (storage_t value) { - return (storage_t)derived_value; + mValue += value; } - static storage_t convertToDerived(storage_t base_value) + template<typename OTHER_UNIT, typename OTHER_STORAGE> + void operator += (LLUnit<OTHER_UNIT, OTHER_STORAGE> other) { - return (storage_t)base_value; + mValue += convert(other); } - void operator += (const unit_t other) + void operator -= (storage_t value) { - mBaseValue += other.mBaseValue; + mValue -= value; } - void operator -= (const unit_t other) + template<typename OTHER_UNIT, typename OTHER_STORAGE> + void operator -= (LLUnit<OTHER_UNIT, OTHER_STORAGE> other) { - mBaseValue -= other.mBaseValue; + mValue -= convert(other); } void operator *= (storage_t multiplicand) { - mBaseValue *= multiplicand; + mValue *= multiplicand; + } + + template<typename OTHER_UNIT, typename OTHER_STORAGE> + void operator *= (LLUnit<OTHER_UNIT, OTHER_STORAGE> multiplicand) + { + llstatic_assert(sizeof(OTHER_UNIT) == false, "Multiplication of unit types not supported."); } void operator /= (storage_t divisor) { - mBaseValue /= divisor; + mValue /= divisor; } -protected: - void setBaseValue(storage_t value) + template<typename OTHER_UNIT, typename OTHER_STORAGE> + void operator /= (LLUnit<OTHER_UNIT, OTHER_STORAGE> divisor) { - mBaseValue = value; + llstatic_assert(sizeof(OTHER_UNIT) == false, "Division of unit types not supported."); } - storage_t mBaseValue; -}; + template<typename SOURCE_UNITS, typename SOURCE_VALUE> + static storage_t convert(LLUnit<SOURCE_UNITS, SOURCE_VALUE> v) + { + return (storage_t)(v.value() + * LLUnits::ConversionFactor<SOURCE_UNITS, typename UNIT_TYPE::base_unit_t>::get() + * LLUnits::ConversionFactor<typename UNIT_TYPE::base_unit_t, UNIT_TYPE>::get()); + } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -struct LLUnitTypeWrapper -: public LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> -{ - typedef LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> unit_t; - LLUnitTypeWrapper(const unit_t& other) - : unit_t(other) - {} -}; +protected: + storage_t mValue; +}; // // operator + // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> -DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE2, BASE_UNIT2, DERIVED_UNIT2> second) +template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> +LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator + (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) { - return DERIVED_UNIT(first + LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); + LLUnit<STORAGE_TYPE1, UNIT_TYPE1> result(first); + result += second; + return result; } +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator + (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) +{ + LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + result += second; + return result; +} -// -// operator - -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> -DERIVED_UNIT operator - (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator + (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) { - return DERIVED_UNIT(first - LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); + LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + result += second; + return result; } // -// operator * +// operator - // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> +LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator - (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) { - return DERIVED_UNIT(first * second.value()); + LLUnit<STORAGE_TYPE1, UNIT_TYPE1> result(first); + result -= second; + return result; } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) + +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator - (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) { - return DERIVED_UNIT(first.value() * second); + LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + result -= second; + return result; } +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator - (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) +{ + LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + result -= second; + return result; +} // -// operator / +// operator * // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator * (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) { - return DERIVED_UNIT(first / second.value()); + return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first * second.value()); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator * (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) { - return DERIVED_UNIT(first.value() / second); + return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first.value() * second); } -// -// operator < -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> - -bool operator < (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> +void operator * (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) { - return first < second.value(); + llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); } // -// operator <= +// operator / // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator <= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +SCALAR_TYPE operator / (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) { - return first <= second.value(); + return SCALAR_TYPE(first / second.value()); } - -// -// operator > -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator > (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> +LLUnit<STORAGE_TYPE, UNIT_TYPE> operator / (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) { - return first > second.value(); + return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first.value() / second); } -// -// operator >= -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator >= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> +void operator / (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) { - return first >= second.value(); + llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); } -// -// operator == -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator == (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) -{ - return first == second.value(); +#define COMPARISON_OPERATORS(op) \ +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> \ +bool operator op (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) \ +{ \ + return first op second.value(); \ +} \ + \ +template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> \ +bool operator op (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) \ +{ \ + return first.value() op second; \ +} \ + \ +template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> \ +bool operator op (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) \ +{ \ + return first.value() op first.convert(second); \ } -// -// operator != -// -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator != (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +COMPARISON_OPERATORS(<) +COMPARISON_OPERATORS(<=) +COMPARISON_OPERATORS(>) +COMPARISON_OPERATORS(>=) +COMPARISON_OPERATORS(==) +COMPARISON_OPERATORS(!=) + +namespace LLUnits { - return first != second.value(); +#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor)\ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ +}; \ +template<> \ +struct ConversionFactor<unit_name, base_unit_name> \ +{ \ + static F64 get() { return (conversion_factor); } \ +}; \ + \ +template<> \ +struct ConversionFactor<base_unit_name, unit_name> \ +{ \ + static F64 get() { return 1.0 / (conversion_factor); } \ } -#define LL_DECLARE_BASE_UNIT(unit_name) \ - template<typename STORAGE> \ - struct unit_name : public LLUnitType<STORAGE, unit_name<STORAGE>, unit_name<STORAGE> > \ - { \ - typedef LLUnitType<STORAGE, unit_name> unit_t; \ - \ - unit_name(storage_t value = 0) \ - : LLUnitType(value) \ - {} \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - unit_name(LLUnitType<SOURCE_STORAGE_TYPE, unit_name<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ - { \ - assignFrom(source); \ - } \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - void assignFrom(LLUnitType<SOURCE_STORAGE_TYPE, unit_name<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ - { \ - setBaseValue((storage_t)source.unit_name<SOURCE_STORAGE_TYPE>::unit_t::value()); \ - } \ - \ - }; \ - -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - template<typename STORAGE> \ - struct derived_unit : public LLUnitType<STORAGE, base_unit<STORAGE>, derived_unit<STORAGE> > \ - { \ - typedef LLUnitType<STORAGE, base_unit<STORAGE>, derived_unit<STORAGE> > unit_t; \ - \ - derived_unit(storage_t value = 0) \ - : LLUnitType(value) \ - {} \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - derived_unit(LLUnitType<SOURCE_STORAGE_TYPE, base_unit<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ - { \ - assignFrom(source); \ - } \ - \ - template <typename SOURCE_STORAGE_TYPE, typename SOURCE_TYPE> \ - void assignFrom(LLUnitType<SOURCE_STORAGE_TYPE, base_unit<SOURCE_STORAGE_TYPE>, SOURCE_TYPE> source) \ - { \ - setBaseValue((storage_t)source.base_unit<SOURCE_STORAGE_TYPE>::unit_t::value()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - }; \ - -namespace LLUnit -{ - LL_DECLARE_BASE_UNIT(Bytes); - LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.f / 8.f)); - LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); - LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); - LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); - - LL_DECLARE_BASE_UNIT(Seconds); - LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); - LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); - LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); - LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); - LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.f / 1000.f)); - LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.f / (1000000.f))); - LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.f / (1000000000.f))); - - LL_DECLARE_BASE_UNIT(Meters); - LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); - LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, 1 / 100); - LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, 1 / 1000); +struct Bytes { typedef Bytes base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.0 / 8.0)); +LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); +LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); +LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); + +struct Seconds { typedef Seconds base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); +LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); +LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); +LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); +LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.0 / 1000.0)); +LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.0 / (1000000.0))); +LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.0 / (1000000000.0))); + +struct Meters { typedef Meters base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); +LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, (1.0 / 100)); +LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, (1.0 / 1000)); } #endif // LL_LLUNIT_H diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 78223e1e65..0d632f59be 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -49,10 +49,10 @@ class LLColor4 LLColor4(); // Initializes LLColor4 to (0, 0, 0, 1) LLColor4(F32 r, F32 g, F32 b); // Initializes LLColor4 to (r, g, b, 1) LLColor4(F32 r, F32 g, F32 b, F32 a); // Initializes LLColor4 to (r. g, b, a) - explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) - explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) - explicit LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) + LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) explicit LLColor4(const LLSD& sd); + explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) + explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index fc1edbe664..5361d8e7be 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -50,9 +50,9 @@ U32 wpo2(U32 i); U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -LLUnit::Bytes<S32> LLImageGL::sGlobalTextureMemory = 0; -LLUnit::Bytes<S32> LLImageGL::sBoundTextureMemory = 0; -LLUnit::Bytes<S32> LLImageGL::sCurBoundTextureMemory = 0; +LLUnit<LLUnits::Bytes, S32> LLImageGL::sGlobalTextureMemory = 0; +LLUnit<LLUnits::Bytes, S32> LLImageGL::sBoundTextureMemory = 0; +LLUnit<LLUnits::Bytes, S32> LLImageGL::sCurBoundTextureMemory = 0; S32 LLImageGL::sCount = 0; LLImageGL::dead_texturelist_t LLImageGL::sDeadTextureList[LLTexUnit::TT_NONE]; U32 LLImageGL::sCurTexName = 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index dfa59f2a34..11555e20c4 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -246,9 +246,9 @@ public: static F32 sLastFrameTime; // Global memory statistics - static LLUnit::Bytes<S32> sGlobalTextureMemory; // Tracks main memory texmem - static LLUnit::Bytes<S32> sBoundTextureMemory; // Tracks bound texmem for last completed frame - static LLUnit::Bytes<S32> sCurBoundTextureMemory; // Tracks bound texmem for current frame + static LLUnit<LLUnits::Bytes, S32> sGlobalTextureMemory; // Tracks main memory texmem + static LLUnit<LLUnits::Bytes, S32> sBoundTextureMemory; // Tracks bound texmem for last completed frame + static LLUnit<LLUnits::Bytes, S32> sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 838a982cb4..ac659c409b 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -277,7 +277,7 @@ LLPumpIO* gServicePump = NULL; U64 gFrameTime = 0; F32 gFrameTimeSeconds = 0.f; -LLUnit::Seconds<F32> gFrameIntervalSeconds = 0.f; +LLUnit<LLUnits::Seconds, F32> gFrameIntervalSeconds = 0.f; F32 gFPSClamped = 10.f; // Pretend we start at target rate. F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets U64 gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index d9d888c626..f2bea7cdb2 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -322,7 +322,7 @@ extern LLPumpIO* gServicePump; extern U64 gFrameTime; // The timestamp of the most-recently-processed frame extern F32 gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... -extern LLUnit::Seconds<F32> gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds +extern LLUnit<LLUnits::Seconds, F32> gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame extern F32 gFrameDTClamped; extern U64 gStartTime; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4f6eaa5a5b..61f5ecc46f 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -463,7 +463,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face) gGL.getTexUnit(0)->bind(mHBTex[dr]); - LLOverrideFaceColor override(this, face->getFaceColor().mV); + LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); face->renderIndexed(); } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index d734620f10..288c1233e5 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -503,17 +503,17 @@ private: void LLGLTexMemBar::draw() { - LLUnit::Megabytes<S32> bound_mem = LLViewerTexture::sBoundTextureMemory; - LLUnit::Megabytes<S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; - LLUnit::Megabytes<S32> total_mem = LLViewerTexture::sTotalTextureMemory; - LLUnit::Megabytes<S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem; + LLUnit<LLUnits::Megabytes, S32> bound_mem = LLViewerTexture::sBoundTextureMemory; + LLUnit<LLUnits::Megabytes, S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; + LLUnit<LLUnits::Megabytes, S32> total_mem = LLViewerTexture::sTotalTextureMemory; + LLUnit<LLUnits::Megabytes, S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ; F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); - LLUnit::Megabytes<F32> total_texture_downloaded = gTotalTextureData; - LLUnit::Megabytes<F32> total_object_downloaded = gTotalObjectData; + LLUnit<LLUnits::Megabytes, F32> total_texture_downloaded = gTotalTextureData; + LLUnit<LLUnits::Megabytes, F32> total_object_downloaded = gTotalObjectData; U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; @@ -661,7 +661,7 @@ void LLGLTexSizeBar::draw() if(LLImageGL::sCurTexSizeBar == mIndex) { - F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); std::string text; text = llformat("%d", mTopLoaded) ; @@ -673,8 +673,8 @@ void LLGLTexSizeBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); } - F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; - F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; + LLColor4 loaded_color(1.0f, 0.0f, 0.0f, 0.75f); + LLColor4 bound_color(1.0f, 1.0f, 0.0f, 0.75f); gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; } diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index bad2f5b4cd..73a2e24424 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -430,10 +430,10 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) grid_from_region_handle(it->first, &grid_x, &grid_y); r.grid_x(grid_x); r.grid_y(grid_y); - r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value()); + r.duration(LLUnit<LLUnits::Microseconds, F64>(rec.getDuration()).value()); } - stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0); + stats.duration(mCurRecording ? LLUnit<LLUnits::Microseconds, F64>(mCurRecording->getDuration()).value() : 0.0); stats.avatar.setProvided(true); for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index acbe836c29..197d91593c 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2587,7 +2587,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD args; args["SUBJECT"] = subj; args["MESSAGE"] = mes; - LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(timestamp)); + LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(LLDate(timestamp))); } // Also send down the old path for now. @@ -4416,18 +4416,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) // *TODO: Remove this dependency, or figure out a better way to handle // this hack. -extern LLUnit::Bits<U32> gObjectData; +extern LLUnit<LLUnits::Bits, U32> gObjectData; void process_object_update(LLMessageSystem *mesgsys, void **user_data) { // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4439,11 +4439,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4455,11 +4455,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data) // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize(); } // Update the object... @@ -4471,11 +4471,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_ { if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize(); + gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize(); } gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 317fe5eaf8..36b1179e04 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -288,13 +288,13 @@ F32 gAveLandCompression = 0.f, gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f; -LLUnit::Bytes<U32> gTotalWorldData = 0, +LLUnit<LLUnits::Bytes, U32> gTotalWorldData = 0, gTotalObjectData = 0, gTotalTextureData = 0; U32 gSimPingCount = 0; -LLUnit::Bits<U32> gObjectData = 0; +LLUnit<LLUnits::Bits, U32> gObjectData = 0; F32 gAvgSimPing = 0.f; -LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; +LLUnit<LLUnits::Bytes, U32> gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; extern U32 gVisCompared; extern U32 gVisTested; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index eda7b3329d..14ee41dba0 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -319,7 +319,7 @@ void update_statistics(); void send_stats(); extern LLFrameTimer gTextureTimer; -extern LLUnit::Bytes<U32> gTotalTextureData; -extern LLUnit::Bytes<U32> gTotalObjectData; -extern LLUnit::Bytes<U32> gTotalTextureBytesPerBoostLevel[] ; +extern LLUnit<LLUnits::Bytes, U32> gTotalTextureData; +extern LLUnit<LLUnits::Bytes, U32> gTotalObjectData; +extern LLUnit<LLUnits::Bytes, U32> gTotalTextureBytesPerBoostLevel[] ; #endif // LL_LLVIEWERSTATS_H diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index ceb8d3155c..f4e8e3eae1 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -65,8 +65,8 @@ /////////////////////////////////////////////////////////////////////////////// // extern -const LLUnit::Megabytes<S32> gMinVideoRam = 32; -const LLUnit::Megabytes<S32> gMaxVideoRam = 512; +const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam = 32; +const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam = 512; // statics @@ -87,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -LLUnit::Bytes<S32> LLViewerTexture::sBoundTextureMemory = 0; -LLUnit::Bytes<S32> LLViewerTexture::sTotalTextureMemory = 0; -LLUnit::Megabytes<S32> LLViewerTexture::sMaxBoundTextureMem = 0; -LLUnit::Megabytes<S32> LLViewerTexture::sMaxTotalTextureMem = 0; -LLUnit::Bytes<S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ; +LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sBoundTextureMemory = 0; +LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sTotalTextureMemory = 0; +LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxBoundTextureMem = 0; +LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxTotalTextureMem = 0; +LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ; S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; F32 LLViewerTexture::sCameraMovingBias = 0.0f ; S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size @@ -532,8 +532,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity if (sBoundTextureMemory >= sMaxBoundTextureMem || sTotalTextureMemory >= sMaxTotalTextureMem) { - //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes<S32>(gMaxVideoRam)); + //when texture memory overflows, lower down the threshold to release the textures more aggressively. + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam)); // If we are using more texture memory than we should, // scale up the desired discard level diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index aa1e2010b4..e9efb751f8 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -39,8 +39,8 @@ #include <map> #include <list> -extern const LLUnit::Megabytes<S32> gMinVideoRam; -extern const LLUnit::Megabytes<S32> gMaxVideoRam; +extern const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam; +extern const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam; class LLFace; class LLImageGL ; @@ -323,11 +323,11 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static LLUnit::Bytes<S32> sBoundTextureMemory; - static LLUnit::Bytes<S32> sTotalTextureMemory; - static LLUnit::Megabytes<S32> sMaxBoundTextureMem; - static LLUnit::Megabytes<S32> sMaxTotalTextureMem; - static LLUnit::Bytes<S32> sMaxDesiredTextureMem ; + static LLUnit<LLUnits::Bytes, S32> sBoundTextureMemory; + static LLUnit<LLUnits::Bytes, S32> sTotalTextureMemory; + static LLUnit<LLUnits::Megabytes, S32> sMaxBoundTextureMem; + static LLUnit<LLUnits::Megabytes, S32> sMaxTotalTextureMem; + static LLUnit<LLUnits::Bytes, S32> sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b7415669bb..8e72ca1d74 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -733,7 +733,7 @@ public: { if(gTotalTextureBytesPerBoostLevel[i] > 0) { - addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, LLUnit::Megabytes<F32>(gTotalTextureBytesPerBoostLevel[i]).value())); + addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, LLUnit<LLUnits::Megabytes, F32>(gTotalTextureBytesPerBoostLevel[i]).value())); ypos += y_inc; } } -- cgit v1.2.3 From a3e3e8b4ccd96e98da73acf1c584bbfa5a8b2b56 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 12 Nov 2012 19:08:14 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system simplified llfasttimer code down to 2 classes llunit unit conversion now done in floating point or 64 bit integer precision, depending on source type --- indra/llcommon/llfasttimer.cpp | 270 ++++++++++++-------------------------- indra/llcommon/llfasttimer.h | 121 ++++++----------- indra/llcommon/llprocessor.cpp | 2 +- indra/llcommon/llprocessor.h | 4 +- indra/llcommon/lltrace.cpp | 1 + indra/llcommon/lltrace.h | 39 ++---- indra/llcommon/lltracerecording.h | 18 +-- indra/llcommon/llunit.h | 127 +++++++++++++----- indra/newview/llfasttimerview.cpp | 98 ++++++++------ indra/newview/llfasttimerview.h | 8 +- indra/newview/pipeline.cpp | 2 +- 11 files changed, 307 insertions(+), 383 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 4f67004773..c4839fed77 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -32,6 +32,7 @@ #include "llsingleton.h" #include "lltreeiterators.h" #include "llsdserialize.h" +#include "llunit.h" #include <boost/bind.hpp> @@ -73,13 +74,13 @@ U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution // FIXME: move these declarations to the relevant modules // helper functions -typedef LLTreeDFSPostIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_bottom_up_iterator_t; +typedef LLTreeDFSPostIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_bottom_up_iterator_t; -static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(LLFastTimer::NamedTimer& id) +static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(LLFastTimer::DeclareTimer& id) { return timer_tree_bottom_up_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); } static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() @@ -87,14 +88,14 @@ static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() return timer_tree_bottom_up_iterator_t(); } -typedef LLTreeDFSIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_dfs_iterator_t; +typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_dfs_iterator_t; -static timer_tree_dfs_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) +static timer_tree_dfs_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) { return timer_tree_dfs_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); } static timer_tree_dfs_iterator_t end_timer_tree() @@ -102,75 +103,12 @@ static timer_tree_dfs_iterator_t end_timer_tree() return timer_tree_dfs_iterator_t(); } -// factory class that creates NamedTimers via static DeclareTimer objects -class NamedTimerFactory : public LLSingleton<NamedTimerFactory> +LLFastTimer::DeclareTimer& LLFastTimer::DeclareTimer::getRootTimer() { -public: - NamedTimerFactory() - : mTimerRoot(NULL) - {} - - /*virtual */ void initSingleton() - { - mTimerRoot = new LLFastTimer::NamedTimer("root"); - mRootFrameState.setNamedTimer(mTimerRoot); - mTimerRoot->setFrameState(&mRootFrameState); - mTimerRoot->mParent = mTimerRoot; - mTimerRoot->setCollapsed(false); - mRootFrameState.mParent = &mRootFrameState; - } - - ~NamedTimerFactory() - { - std::for_each(mTimers.begin(), mTimers.end(), DeletePairedPointer()); - - delete mTimerRoot; - } - - LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state) - { - LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name); - timer->setFrameState(state); - timer->setParent(mTimerRoot); - mTimers.insert(std::make_pair(name, timer)); - - return *timer; - } - - LLFastTimer::NamedTimer* getTimerByName(const std::string& name) - { - timer_map_t::iterator found_it = mTimers.find(name); - if (found_it != mTimers.end()) - { - return found_it->second; - } - return NULL; - } - - LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; } - - typedef std::multimap<std::string, LLFastTimer::NamedTimer*> timer_map_t; - timer_map_t::iterator beginTimers() { return mTimers.begin(); } - timer_map_t::iterator endTimers() { return mTimers.end(); } - S32 timerCount() { return mTimers.size(); } - -private: - timer_map_t mTimers; - - LLFastTimer::NamedTimer* mTimerRoot; - LLFastTimer::FrameState mRootFrameState; -}; - -LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open ) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) -{ - mTimer.setCollapsed(!open); + static DeclareTimer root_timer("root", true, NULL); + return root_timer; } -LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name) -: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState)) -{ -} //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) @@ -183,7 +121,7 @@ U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz - static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0); + static LLUnit<LLUnits::Hertz, U64> sCPUClockFrequency = LLProcessorInfo().getCPUFrequency(); // we drop the low-order byte in our timers, so report a lower frequency #else @@ -206,49 +144,44 @@ LLFastTimer::FrameState::FrameState() : mActiveCount(0), mCalls(0), mSelfTimeCounter(0), - mParent(NULL), mLastCaller(NULL), mMoveUpTree(false) {} -LLFastTimer::NamedTimer::NamedTimer(const std::string& name) +LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open, DeclareTimer* parent) : mName(name), mCollapsed(true), mParent(NULL), mTreeTimeCounter(0), mCountAverage(0), mCallAverage(0), - mNeedsSorting(false), - mFrameState(NULL) + mNeedsSorting(false) { + setCollapsed(!open); + + if (parent) + { + setParent(parent); + } + else + { + mParent = this; + } + mCountHistory = new U32[HISTORY_NUM]; memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM); mCallHistory = new U32[HISTORY_NUM]; memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); } -LLFastTimer::NamedTimer::~NamedTimer() +LLFastTimer::DeclareTimer::~DeclareTimer() { delete[] mCountHistory; delete[] mCallHistory; } -std::string LLFastTimer::NamedTimer::getToolTip(S32 history_idx) -{ - F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); - if (history_idx < 0) - { - // by default, show average number of call - return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getCountAverage() * ms_multiplier), (S32)getCallAverage()); - } - else - { - return llformat("%s (%d ms, %d calls)", getName().c_str(), (S32)(getHistoricalCount(history_idx) * ms_multiplier), (S32)getHistoricalCalls(history_idx)); - } -} - -void LLFastTimer::NamedTimer::setParent(NamedTimer* parent) +void LLFastTimer::DeclareTimer::setParent(DeclareTimer* parent) { llassert_always(parent != this); llassert_always(parent != NULL); @@ -264,8 +197,8 @@ void LLFastTimer::NamedTimer::setParent(NamedTimer* parent) // subtract average timing from previous parent mParent->mCountAverage -= mCountAverage; - std::vector<NamedTimer*>& children = mParent->getChildren(); - std::vector<NamedTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); + std::vector<DeclareTimer*>& children = mParent->getChildren(); + std::vector<DeclareTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); if (found_it != children.end()) { children.erase(found_it); @@ -275,16 +208,15 @@ void LLFastTimer::NamedTimer::setParent(NamedTimer* parent) mParent = parent; if (parent) { - getFrameState().mParent = &parent->getFrameState(); parent->getChildren().push_back(this); parent->mNeedsSorting = true; } } -S32 LLFastTimer::NamedTimer::getDepth() +S32 LLFastTimer::DeclareTimer::getDepth() { S32 depth = 0; - NamedTimer* timerp = mParent; + DeclareTimer* timerp = mParent; while(timerp) { depth++; @@ -295,7 +227,7 @@ S32 LLFastTimer::NamedTimer::getDepth() } // static -void LLFastTimer::NamedTimer::processTimes() +void LLFastTimer::DeclareTimer::processTimes() { if (sCurFrameIndex < 0) return; @@ -306,14 +238,14 @@ void LLFastTimer::NamedTimer::processTimes() // sort child timers by name struct SortTimerByName { - bool operator()(const LLFastTimer::NamedTimer* i1, const LLFastTimer::NamedTimer* i2) + bool operator()(const LLFastTimer::DeclareTimer* i1, const LLFastTimer::DeclareTimer* i2) { return i1->getName() < i2->getName(); } }; //static -void LLFastTimer::NamedTimer::buildHierarchy() +void LLFastTimer::DeclareTimer::buildHierarchy() { if (sCurFrameIndex < 0 ) return; @@ -321,16 +253,16 @@ void LLFastTimer::NamedTimer::buildHierarchy() { for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - NamedTimer& timer = *it; - if (&timer == NamedTimerFactory::instance().getRootTimer()) continue; + DeclareTimer& timer = *it; + if (&timer == &DeclareTimer::getRootTimer()) continue; // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer()) + if (timer.mLastCaller && timer.mParent == &DeclareTimer::getRootTimer()) { - timer.setParent(timer.getFrameState().mLastCaller->mTimer); + timer.setParent(timer.mLastCaller); // no need to push up tree on first use, flag can be set spuriously - timer.getFrameState().mMoveUpTree = false; + timer.mMoveUpTree = false; } } } @@ -338,22 +270,22 @@ void LLFastTimer::NamedTimer::buildHierarchy() // bump timers up tree if they've been flagged as being in the wrong place // do this in a bottom up order to promote descendants first before promoting ancestors // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getRootTimer()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(DeclareTimer::getRootTimer()); it != end_timer_tree_bottom_up(); ++it) { - NamedTimer* timerp = *it; + DeclareTimer* timerp = *it; // skip root timer - if (timerp == NamedTimerFactory::instance().getRootTimer()) continue; + if (timerp == &DeclareTimer::getRootTimer()) continue; - if (timerp->getFrameState().mMoveUpTree) + if (timerp->mMoveUpTree) { // since ancestors have already been visited, reparenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - timerp->getFrameState().mMoveUpTree = false; + timerp->mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up it.skipAncestors(); @@ -361,11 +293,11 @@ void LLFastTimer::NamedTimer::buildHierarchy() } // sort timers by time last called, so call graph makes sense - for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(DeclareTimer::getRootTimer()); it != end_timer_tree(); ++it) { - NamedTimer* timerp = (*it); + DeclareTimer* timerp = (*it); if (timerp->mNeedsSorting) { std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); @@ -375,7 +307,7 @@ void LLFastTimer::NamedTimer::buildHierarchy() } //static -void LLFastTimer::NamedTimer::accumulateTimings() +void LLFastTimer::DeclareTimer::accumulateTimings() { U32 cur_time = getCPUClockCount32(); @@ -388,8 +320,8 @@ void LLFastTimer::NamedTimer::accumulateTimings() U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; - cur_data->mFrameState->mSelfTimeCounter += self_time_delta; - cur_data->mFrameState->mTotalTimeCounter += cumulative_time_delta; + cur_data->mTimerData->mSelfTimeCounter += self_time_delta; + cur_data->mTimerData->mTotalTimeCounter += cumulative_time_delta; cur_timer->mStartTime = cur_time; @@ -400,12 +332,12 @@ void LLFastTimer::NamedTimer::accumulateTimings() } // traverse tree in DFS post order, or bottom up - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(*NamedTimerFactory::instance().getRootTimer()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(DeclareTimer::getRootTimer()); it != end_timer_tree_bottom_up(); ++it) { - NamedTimer* timerp = (*it); - timerp->mTreeTimeCounter = timerp->getFrameState().mSelfTimeCounter; + DeclareTimer* timerp = (*it); + timerp->mTreeTimeCounter = timerp->mSelfTimeCounter; for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) { timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; @@ -418,15 +350,15 @@ void LLFastTimer::NamedTimer::accumulateTimings() int hidx = cur_frame % HISTORY_NUM; timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; - timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); - timerp->mCallHistory[hidx] = timerp->getFrameState().mCalls; - timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->getFrameState().mCalls) / (cur_frame+1); + timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); + timerp->mCallHistory[hidx] = timerp->mCalls; + timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->mCalls) / (cur_frame+1); } } } // static -void LLFastTimer::NamedTimer::resetFrame() +void LLFastTimer::DeclareTimer::resetFrame() { if (sLog) { //output current frame counts to performance log @@ -435,11 +367,11 @@ void LLFastTimer::NamedTimer::resetFrame() if (call_count % 100 == 0) { LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL; - LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << llendl; + LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << LL_ENDL; LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; - LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64())/((F64)LLProcessorInfo().getCPUFrequency()*1000000.0) << LL_ENDL; + LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL; } call_count++; @@ -451,14 +383,13 @@ void LLFastTimer::NamedTimer::resetFrame() { for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - NamedTimer& timer = *it; - FrameState& info = timer.getFrameState(); - sd[timer.getName()]["Time"] = (LLSD::Real) (info.mSelfTimeCounter*iclock_freq); - sd[timer.getName()]["Calls"] = (LLSD::Integer) info.mCalls; + DeclareTimer& timer = *it; + sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq); + sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls; // computing total time here because getting the root timer's getCountHistory // doesn't work correctly on the first frame - total_time = total_time + info.mSelfTimeCounter * iclock_freq; + total_time = total_time + timer.mSelfTimeCounter * iclock_freq; } } @@ -474,23 +405,16 @@ void LLFastTimer::NamedTimer::resetFrame() // reset for next frame for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - NamedTimer& timer = *it; - - FrameState& info = timer.getFrameState(); - info.mSelfTimeCounter = 0; - info.mCalls = 0; - info.mLastCaller = NULL; - info.mMoveUpTree = false; - // update parent pointer in timer state struct - if (timer.mParent) - { - info.mParent = &timer.mParent->getFrameState(); - } + DeclareTimer& timer = *it; + timer.mSelfTimeCounter = 0; + timer.mCalls = 0; + timer.mLastCaller = NULL; + timer.mMoveUpTree = false; } } //static -void LLFastTimer::NamedTimer::reset() +void LLFastTimer::DeclareTimer::reset() { resetFrame(); // reset frame data @@ -514,10 +438,10 @@ void LLFastTimer::NamedTimer::reset() { for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - NamedTimer& timer = *it; - if (&timer != NamedTimerFactory::instance().getRootTimer()) + DeclareTimer& timer = *it; + if (&timer != &DeclareTimer::getRootTimer()) { - timer.setParent(NamedTimerFactory::instance().getRootTimer()); + timer.setParent(&DeclareTimer::getRootTimer()); } timer.mCountAverage = 0; @@ -531,34 +455,29 @@ void LLFastTimer::NamedTimer::reset() sCurFrameIndex = 0; } -U32 LLFastTimer::NamedTimer::getHistoricalCount(S32 history_index) const +U32 LLFastTimer::DeclareTimer::getHistoricalCount(S32 history_index) const { - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::DeclareTimer::HISTORY_NUM; return mCountHistory[history_idx]; } -U32 LLFastTimer::NamedTimer::getHistoricalCalls(S32 history_index ) const +U32 LLFastTimer::DeclareTimer::getHistoricalCalls(S32 history_index ) const { - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::NamedTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::DeclareTimer::HISTORY_NUM; return mCallHistory[history_idx]; } -LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const -{ - return *mFrameState; -} - -std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::beginChildren() +std::vector<LLFastTimer::DeclareTimer*>::const_iterator LLFastTimer::DeclareTimer::beginChildren() { return mChildren.begin(); } -std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::endChildren() +std::vector<LLFastTimer::DeclareTimer*>::const_iterator LLFastTimer::DeclareTimer::endChildren() { return mChildren.end(); } -std::vector<LLFastTimer::NamedTimer*>& LLFastTimer::NamedTimer::getChildren() +std::vector<LLFastTimer::DeclareTimer*>& LLFastTimer::DeclareTimer::getChildren() { return mChildren; } @@ -575,12 +494,12 @@ void LLFastTimer::nextFrame() if (!sPauseHistory) { - NamedTimer::processTimes(); + DeclareTimer::processTimes(); sLastFrameIndex = sCurFrameIndex++; } // get ready for next frame - NamedTimer::resetFrame(); + DeclareTimer::resetFrame(); sLastFrameTime = frame_time; } @@ -588,17 +507,17 @@ void LLFastTimer::nextFrame() void LLFastTimer::dumpCurTimes() { // accumulate timings, etc. - NamedTimer::processTimes(); + DeclareTimer::processTimes(); F64 clock_freq = (F64)countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(*NamedTimerFactory::instance().getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(DeclareTimer::getRootTimer()); it != end_timer_tree(); ++it) { - NamedTimer* timerp = (*it); + DeclareTimer* timerp = (*it); F64 total_time_ms = ((F64)timerp->getHistoricalCount(0) * iclock_freq); // Don't bother with really brief times, keep output concise if (total_time_ms < 0.1) continue; @@ -621,7 +540,7 @@ void LLFastTimer::dumpCurTimes() //static void LLFastTimer::reset() { - NamedTimer::reset(); + DeclareTimer::reset(); } @@ -637,22 +556,3 @@ void LLFastTimer::writeLog(std::ostream& os) } } -//static -const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& name) -{ - return NamedTimerFactory::instance().getTimerByName(name); -} - -//LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) -//: mFrameState(state) -//{ -// U32 start_time = getCPUClockCount32(); -// mStartTime = start_time; -// mFrameState->mActiveCount++; -// LLFastTimer::sCurTimerData.mCurTimer = this; -// LLFastTimer::sCurTimerData.mFrameState = mFrameState; -// LLFastTimer::sCurTimerData.mChildTime = 0; -// mLastTimerData = LLFastTimer::sCurTimerData; -//} - - diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4660fad5e3..31872e4e65 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -30,7 +30,6 @@ #include "llinstancetracker.h" #define FAST_TIMER_ON 1 -#define DEBUG_FAST_TIMER_THREADS 1 class LLMutex; @@ -45,64 +44,53 @@ LL_COMMON_API void assert_main_thread(); class LL_COMMON_API LLFastTimer { public: - class NamedTimer; - + class DeclareTimer; struct LL_COMMON_API FrameState { FrameState(); - void setNamedTimer(class NamedTimer* timerp) { mTimer = timerp; } U32 mSelfTimeCounter; U32 mTotalTimeCounter; U32 mCalls; - FrameState* mParent; // info for caller timer - FrameState* mLastCaller; // used to bootstrap tree construction - class NamedTimer* mTimer; + DeclareTimer* mLastCaller; // used to bootstrap tree construction U16 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame }; // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances - class LL_COMMON_API NamedTimer - : public LLInstanceTracker<NamedTimer> + class LL_COMMON_API DeclareTimer + : public LLInstanceTracker<DeclareTimer> { - friend class DeclareTimer; public: - ~NamedTimer(); + DeclareTimer(const std::string& name, bool open = false, DeclareTimer* parent = &getRootTimer()); + ~DeclareTimer(); enum { HISTORY_NUM = 300 }; const std::string& getName() const { return mName; } - NamedTimer* getParent() const { return mParent; } - void setParent(NamedTimer* parent); + DeclareTimer* getParent() const { return mParent; } + void setParent(DeclareTimer* parent); S32 getDepth(); - std::string getToolTip(S32 history_index = -1); - typedef std::vector<NamedTimer*>::const_iterator child_const_iter; + typedef std::vector<DeclareTimer*>::const_iterator child_const_iter; child_const_iter beginChildren(); child_const_iter endChildren(); - std::vector<NamedTimer*>& getChildren(); + std::vector<DeclareTimer*>& getChildren(); - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } + U32 getCallAverage() const { return mCallAverage; } U32 getHistoricalCount(S32 history_index = 0) const; U32 getHistoricalCalls(S32 history_index = 0) const; - void setFrameState(FrameState* state) { mFrameState = state; state->setNamedTimer(this); } - FrameState& getFrameState() const; + static DeclareTimer& getRootTimer(); private: friend class LLFastTimer; - friend class NamedTimerFactory; - // - // methods - // - NamedTimer(const std::string& name); // recursive call to gather total time from children static void accumulateTimings(); @@ -117,82 +105,62 @@ public: // // members // - FrameState* mFrameState; + U32 mSelfTimeCounter; + U32 mTotalTimeCounter; + U32 mCalls; + DeclareTimer* mLastCaller; // used to bootstrap tree construction + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - std::string mName; + std::string mName; - // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; + // sum of recored self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; - U32 mCountAverage; - U32 mCallAverage; + U32 mCountAverage; + U32 mCallAverage; - U32* mCountHistory; - U32* mCallHistory; + U32* mCountHistory; + U32* mCallHistory; // tree structure - NamedTimer* mParent; // NamedTimer of caller(parent) - std::vector<NamedTimer*> mChildren; + DeclareTimer* mParent; // DeclareTimer of caller(parent) + std::vector<DeclareTimer*> mChildren; bool mCollapsed; // don't show children bool mNeedsSorting; // sort children whenever child added }; - // used to statically declare a new named timer - class LL_COMMON_API DeclareTimer - : public LLInstanceTracker<DeclareTimer> - { - friend class LLFastTimer; - public: - DeclareTimer(const std::string& name, bool open); - DeclareTimer(const std::string& name); - - NamedTimer& getNamedTimer() { return mTimer; } - - private: - FrameState mFrameState; - NamedTimer& mTimer; - }; - public: - //LLFastTimer(LLFastTimer::FrameState* state); - LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = &timer.mFrameState; mStartTime = getCPUClockCount32(); - frame_state->mActiveCount++; - frame_state->mCalls++; + timer.mActiveCount++; + timer.mCalls++; // keep current parent as long as it is active when we are - frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); + timer.mMoveUpTree |= (timer.mParent->mActiveCount == 0); LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; mLastTimerData = *cur_timer_data; cur_timer_data->mCurTimer = this; - cur_timer_data->mFrameState = frame_state; + cur_timer_data->mTimerData = &timer; cur_timer_data->mChildTime = 0; -#endif -#if DEBUG_FAST_TIMER_THREADS -#if !LL_RELEASE - assert_main_thread(); -#endif #endif } LL_FORCE_INLINE ~LLFastTimer() { #if FAST_TIMER_ON - LLFastTimer::FrameState* frame_state = LLFastTimer::sCurTimerData.mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; - - frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; - frame_state->mTotalTimeCounter += total_time; - frame_state->mActiveCount--; + DeclareTimer* timer_data = LLFastTimer::sCurTimerData.mTimerData; + timer_data->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + timer_data->mTotalTimeCounter += total_time; + timer_data->mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - frame_state->mLastCaller = mLastTimerData.mFrameState; + timer_data->mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; @@ -225,12 +193,11 @@ public: static S32 getCurFrameIndex() { return sCurFrameIndex; } static void writeLog(std::ostream& os); - static const NamedTimer* getTimerByName(const std::string& name); struct CurTimerData { LLFastTimer* mCurTimer; - FrameState* mFrameState; + DeclareTimer* mTimerData; U32 mChildTime; }; static CurTimerData sCurTimerData; @@ -374,15 +341,13 @@ private: #endif - static U64 sClockResolution; - - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; - static U64 sLastFrameTime; + static U64 sClockResolution; + static S32 sCurFrameIndex; + static S32 sLastFrameIndex; + static U64 sLastFrameTime; U32 mStartTime; LLFastTimer::CurTimerData mLastTimerData; - }; typedef class LLFastTimer LLFastTimer; diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index fd8f603d21..87a5930c14 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -877,7 +877,7 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL) LLProcessorInfo::~LLProcessorInfo() {} -F64 LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } +LLUnit<LLUnits::Megahertz, F64> LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } bool LLProcessorInfo::hasSSE() const { return mImpl->hasSSE(); } bool LLProcessorInfo::hasSSE2() const { return mImpl->hasSSE2(); } bool LLProcessorInfo::hasAltivec() const { return mImpl->hasAltivec(); } diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index 6364d3c8bb..2a21a5c115 100644 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -27,6 +27,8 @@ #ifndef LLPROCESSOR_H #define LLPROCESSOR_H +#include "llunit.h" + class LLProcessorInfoImpl; class LL_COMMON_API LLProcessorInfo @@ -35,7 +37,7 @@ public: LLProcessorInfo(); ~LLProcessorInfo(); - F64 getCPUFrequency() const; + LLUnit<LLUnits::Megahertz, F64> getCPUFrequency() const; bool hasSSE() const; bool hasSSE2() const; bool hasAltivec() const; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index d5911ece25..3f605f2c74 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -42,6 +42,7 @@ void init() void cleanup() { delete gMasterThreadRecorder; + LLUnitStrict<LLUnits::Seconds, F32> seconds; gMasterThreadRecorder = NULL; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index d289ea9a88..549e407822 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -57,8 +57,6 @@ namespace LLTrace typedef LLUnit<LLUnits::Milliseconds, F64> Milliseconds; typedef LLUnit<LLUnits::Minutes, F64> Minutes; typedef LLUnit<LLUnits::Hours, F64> Hours; - typedef LLUnit<LLUnits::Days, F64> Days; - typedef LLUnit<LLUnits::Weeks, F64> Weeks; typedef LLUnit<LLUnits::Milliseconds, F64> Milliseconds; typedef LLUnit<LLUnits::Microseconds, F64> Microseconds; typedef LLUnit<LLUnits::Nanoseconds, F64> Nanoseconds; @@ -226,27 +224,6 @@ namespace LLTrace size_t mAccumulatorIndex; }; - - template<typename T, typename IS_UNIT = void> - struct StorageType - { - typedef T type_t; - }; - - template<typename T> - struct StorageType<T, typename T::is_unit_tag_t> - { - typedef typename StorageType<typename T::storage_t>::type_t type_t; - }; - - template<> struct StorageType<F32> { typedef F64 type_t; }; - template<> struct StorageType<S32> { typedef S64 type_t; }; - template<> struct StorageType<U32> { typedef S64 type_t; }; - template<> struct StorageType<S16> { typedef S64 type_t; }; - template<> struct StorageType<U16> { typedef S64 type_t; }; - template<> struct StorageType<S8> { typedef S64 type_t; }; - template<> struct StorageType<U8> { typedef S64 type_t; }; - template<typename T> class LL_COMMON_API MeasurementAccumulator { @@ -406,10 +383,10 @@ namespace LLTrace template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Measurement - : public TraceType<MeasurementAccumulator<typename StorageType<T>::type_t> > + : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > { public: - typedef typename StorageType<T>::type_t storage_t; + typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t; Measurement(const char* name, const char* description = NULL) : TraceType(name, description) @@ -423,10 +400,10 @@ namespace LLTrace template <typename T> class LL_COMMON_API Measurement <T, typename T::is_unit_tag_t> - : public TraceType<MeasurementAccumulator<typename StorageType<typename T::storage_t>::type_t> > + : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t> > { public: - typedef typename StorageType<typename T::storage_t>::type_t storage_t; + typedef typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t storage_t; Measurement(const char* name, const char* description = NULL) : TraceType(name, description) @@ -446,10 +423,10 @@ namespace LLTrace template <typename T = F64, typename IS_UNIT = void> class LL_COMMON_API Count - : public TraceType<CountAccumulator<typename StorageType<T>::type_t> > + : public TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > { public: - typedef typename StorageType<T>::type_t storage_t; + typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t; Count(const char* name, const char* description = NULL) : TraceType(name) @@ -463,10 +440,10 @@ namespace LLTrace template <typename T> class LL_COMMON_API Count <T, typename T::is_unit_tag_t> - : public TraceType<CountAccumulator<typename StorageType<typename T::storage_t>::type_t> > + : public TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t> > { public: - typedef typename StorageType<typename T::storage_t>::type_t storage_t; + typedef typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t storage_t; Count(const char* name, const char* description = NULL) : TraceType(name) diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index ca9950b78d..16b80fd1d8 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -122,7 +122,7 @@ namespace LLTrace template <typename T> T getSum(const Count<T, typename T::is_unit_tag_t>& stat) const { - return (T)getSum(static_cast<const TraceType<CountAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat) const; @@ -130,7 +130,7 @@ namespace LLTrace template <typename T> T getPerSec(const Count<T, typename T::is_unit_tag_t>& stat) const { - return (T)getPerSec(static_cast<const TraceType<CountAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<CountAccumulator<F64> >& stat) const; @@ -143,7 +143,7 @@ namespace LLTrace template <typename T> T getSum(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -151,7 +151,7 @@ namespace LLTrace template <typename T> T getPerSec(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMin(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -159,7 +159,7 @@ namespace LLTrace template <typename T> T getMin(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMax(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -167,7 +167,7 @@ namespace LLTrace template <typename T> T getMax(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMean(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -175,7 +175,7 @@ namespace LLTrace template <typename T> T getMean(Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getStandardDeviation(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -183,7 +183,7 @@ namespace LLTrace template <typename T> T getStandardDeviation(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getLastValue(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -191,7 +191,7 @@ namespace LLTrace template <typename T> T getLastValue(const Measurement<T, typename T::is_unit_tag_t>& stat) const { - return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<StorageType<T>::type_t> >&> (stat)); + return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const; diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 0dcafbe26e..54ba1d67db 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -32,19 +32,44 @@ namespace LLUnits { -template<typename DERIVED_UNITS_TAG, typename BASE_UNITS_TAG> + +template<typename T, typename IS_UNIT = void> +struct HighestPrecisionType +{ + typedef T type_t; +}; + +template<typename T> +struct HighestPrecisionType<T, typename T::is_unit_tag_t> +{ + typedef typename HighestPrecisionType<typename T::storage_t>::type_t type_t; +}; + +template<> struct HighestPrecisionType<F32> { typedef F64 type_t; }; +template<> struct HighestPrecisionType<S32> { typedef S64 type_t; }; +template<> struct HighestPrecisionType<U32> { typedef S64 type_t; }; +template<> struct HighestPrecisionType<S16> { typedef S64 type_t; }; +template<> struct HighestPrecisionType<U16> { typedef S64 type_t; }; +template<> struct HighestPrecisionType<S8> { typedef S64 type_t; }; +template<> struct HighestPrecisionType<U8> { typedef S64 type_t; }; + +template<typename DERIVED_UNITS_TAG, typename BASE_UNITS_TAG, typename VALUE_TYPE> struct ConversionFactor { - static F64 get() + static typename HighestPrecisionType<VALUE_TYPE>::type_t get() { + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template llstatic_assert(sizeof(DERIVED_UNITS_TAG) == 0, "Cannot convert between types."); } }; -template<typename BASE_UNITS_TAG> -struct ConversionFactor<BASE_UNITS_TAG, BASE_UNITS_TAG> +template<typename BASE_UNITS_TAG, typename VALUE_TYPE> +struct ConversionFactor<BASE_UNITS_TAG, BASE_UNITS_TAG, VALUE_TYPE> { - static F64 get() { return 1.0; } + static typename HighestPrecisionType<VALUE_TYPE>::type_t get() + { + return 1; + } }; } @@ -91,6 +116,11 @@ struct LLUnit return mValue; } + template<typename NEW_UNIT_TYPE> LLUnit<NEW_UNIT_TYPE, STORAGE_TYPE> as() + { + return LLUnit<NEW_UNIT_TYPE, STORAGE_TYPE>(*this); + } + void operator += (storage_t value) { mValue += value; @@ -121,7 +151,8 @@ struct LLUnit template<typename OTHER_UNIT, typename OTHER_STORAGE> void operator *= (LLUnit<OTHER_UNIT, OTHER_STORAGE> multiplicand) { - llstatic_assert(sizeof(OTHER_UNIT) == false, "Multiplication of unit types not supported."); + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + llstatic_assert(sizeof(OTHER_UNIT) == 0, "Multiplication of unit types not supported."); } void operator /= (storage_t divisor) @@ -132,15 +163,16 @@ struct LLUnit template<typename OTHER_UNIT, typename OTHER_STORAGE> void operator /= (LLUnit<OTHER_UNIT, OTHER_STORAGE> divisor) { - llstatic_assert(sizeof(OTHER_UNIT) == false, "Division of unit types not supported."); + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + llstatic_assert(sizeof(OTHER_UNIT) == 0, "Division of unit types not supported."); } - template<typename SOURCE_UNITS, typename SOURCE_VALUE> - static storage_t convert(LLUnit<SOURCE_UNITS, SOURCE_VALUE> v) + template<typename SOURCE_UNITS, typename SOURCE_STORAGE> + static storage_t convert(LLUnit<SOURCE_UNITS, SOURCE_STORAGE> v) { return (storage_t)(v.value() - * LLUnits::ConversionFactor<SOURCE_UNITS, typename UNIT_TYPE::base_unit_t>::get() - * LLUnits::ConversionFactor<typename UNIT_TYPE::base_unit_t, UNIT_TYPE>::get()); + * LLUnits::ConversionFactor<SOURCE_UNITS, typename UNIT_TYPE::base_unit_t, SOURCE_STORAGE>::get() + * LLUnits::ConversionFactor<typename UNIT_TYPE::base_unit_t, UNIT_TYPE, STORAGE_TYPE>::get()); } protected: @@ -148,6 +180,32 @@ protected: storage_t mValue; }; +template<typename UNIT_TYPE, typename STORAGE_TYPE> +struct LLUnitStrict : public LLUnit<UNIT_TYPE, STORAGE_TYPE> +{ + typedef LLUnitStrict<UNIT_TYPE, STORAGE_TYPE> self_t; + + explicit LLUnitStrict(storage_t value = storage_t()) + : LLUnit(value) + {} + + template<typename OTHER_UNIT, typename OTHER_STORAGE> + LLUnitStrict(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) + : LLUnit(convert(other)) + {} + + LLUnitStrict(self_t& other) + : LLUnit(other) + {} + + +private: + operator storage_t() const + { + return value(); + } +}; + // // operator + // @@ -221,7 +279,8 @@ LLUnit<STORAGE_TYPE, UNIT_TYPE> operator * (LLUnit<STORAGE_TYPE, UNIT_TYPE> firs template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> void operator * (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) { - llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); } // @@ -242,7 +301,8 @@ LLUnit<STORAGE_TYPE, UNIT_TYPE> operator / (LLUnit<STORAGE_TYPE, UNIT_TYPE> firs template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> void operator / (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) { - llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); } #define COMPARISON_OPERATORS(op) \ @@ -273,21 +333,21 @@ COMPARISON_OPERATORS(!=) namespace LLUnits { -#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor)\ -struct unit_name \ -{ \ - typedef base_unit_name base_unit_t; \ -}; \ -template<> \ -struct ConversionFactor<unit_name, base_unit_name> \ -{ \ - static F64 get() { return (conversion_factor); } \ -}; \ - \ -template<> \ -struct ConversionFactor<base_unit_name, unit_name> \ -{ \ - static F64 get() { return 1.0 / (conversion_factor); } \ +#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor) \ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ +}; \ +template<typename STORAGE_TYPE> \ +struct ConversionFactor<unit_name, base_unit_name, STORAGE_TYPE> \ +{ \ + static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() { return typename HighestPrecisionType<STORAGE_TYPE>::type_t(conversion_factor); } \ +}; \ + \ +template<typename STORAGE_TYPE> \ +struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \ +{ \ + static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() { return typename HighestPrecisionType<STORAGE_TYPE>::type_t(1.0 / (conversion_factor)); } \ } struct Bytes { typedef Bytes base_unit_t; }; @@ -302,16 +362,19 @@ LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); struct Seconds { typedef Seconds base_unit_t; }; LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); -LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); -LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.0 / 1000.0)); LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.0 / (1000000.0))); LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.0 / (1000000000.0))); struct Meters { typedef Meters base_unit_t; }; LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); -LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, (1.0 / 100)); -LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, (1.0 / 1000)); +LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, (1.0 / 100.0)); +LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, (1.0 / 1000.0)); + +struct Hertz { typedef Hertz base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Hertz, Kilohertz, 1000); +LL_DECLARE_DERIVED_UNIT(Hertz, Megahertz, 1000 * 1000); +LL_DECLARE_DERIVED_UNIT(Hertz, Gigahertz, 1000 * 1000 * 1000); } #endif // LL_LLUNIT_H diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 065b20ba2b..0934028a8c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240; static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector<LLFastTimer::NamedTimer*> ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_iterator_t; +typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLFastTimer::NamedTimer::instanceCount(); + FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount(); mPrintStats = -1; } @@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) { S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()); bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY); - mPrintStats = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLFastTimer::NamedTimer* LLFastTimerView::getLegendID(S32 y) +LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* idp = getLegendID(y); + LLFastTimer::DeclareTimer* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex()); return TRUE; } @@ -288,7 +288,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* timer_id = getLegendID(y); + LLFastTimer::DeclareTimer* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -299,6 +299,23 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } +static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1) +{ + F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + + std::string tooltip; + if (history_index < 0) + { + // by default, show average number of call + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage()); + } + else + { + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + } + return tooltip; +} + BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) @@ -309,8 +326,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); + std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + LLToolTipMgr::instance().show(LLToolTip::Params() - .message(mHoverTimer->getToolTip(LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex)) + .message(tooltip) .sticky_rect(screen_rect) .delay_time(0.f)); @@ -322,10 +341,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* idp = getLegendID(y); + LLFastTimer::DeclareTimer* idp = getLegendID(y); if (idp) { - LLToolTipMgr::instance().show(idp->getToolTip()); + LLToolTipMgr::instance().show(get_tooltip(*idp)); return TRUE; } @@ -340,13 +359,13 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) LLFastTimer::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true); -static std::map<LLFastTimer::NamedTimer*, LLColor4> sTimerColors; +static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors; void LLFastTimerView::draw() { @@ -426,7 +445,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -446,12 +465,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map<LLFastTimer::NamedTimer*, S32> display_line; + std::map<LLFastTimer::DeclareTimer*, S32> display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -471,7 +490,7 @@ void LLFastTimerView::draw() S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; U64 ticks = idp->getHistoricalCount(hidx); ms = (F32)((F64)ticks * iclock_freq); calls = (S32)idp->getHistoricalCalls(hidx); @@ -509,7 +528,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::NamedTimer* next_parent = idp->getParent(); + LLFastTimer::DeclareTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -687,7 +706,7 @@ void LLFastTimerView::draw() S32 tidx; if (j >= 0) { - tidx = LLFastTimer::NamedTimer::HISTORY_NUM - j - 1 - mScrollIndex; + tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex; } else { @@ -701,14 +720,14 @@ void LLFastTimerView::draw() std::vector<S32> deltax; xpos.push_back(xleft); - LLFastTimer::NamedTimer* prev_id = NULL; + LLFastTimer::DeclareTimer* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); F32 frac = tidx == -1 ? (F32)idp->getCountAverage() / (F32)totalticks : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; @@ -735,7 +754,7 @@ void LLFastTimerView::draw() { U64 sublevelticks = 0; - for (LLFastTimer::NamedTimer::child_const_iter it = prev_id->beginChildren(); + for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -777,7 +796,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::NamedTimer* next_parent = idp->getParent(); + LLFastTimer::DeclareTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -842,10 +861,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex; + S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -872,7 +891,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -896,8 +915,8 @@ void LLFastTimerView::draw() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLFastTimer::NamedTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); - j < LLFastTimer::NamedTimer::HISTORY_NUM; + for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); + j < LLFastTimer::DeclareTimer::HISTORY_NUM; j++) { U64 ticks = idp->getHistoricalCount(j); @@ -918,7 +937,7 @@ void LLFastTimerView::draw() //normalize to highlighted timer cur_max = llmax(cur_max, ticks); } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1)*j; + F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j; F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); @@ -973,7 +992,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); if (!first) { @@ -995,7 +1014,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); if (!first) { @@ -1033,11 +1052,8 @@ void LLFastTimerView::draw() F64 LLFastTimerView::getTime(const std::string& name) { - const LLFastTimer::NamedTimer* timerp = LLFastTimer::getTimerByName(name); - if (timerp) - { - return (F64)timerp->getCountAverage() / (F64)LLFastTimer::countsPerSecond(); - } + //TODO: replace calls to this with use of timer object directly + //llstatic_assert(false, "TODO: implement"); return 0.0; } @@ -1552,9 +1568,9 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLFastTimer::NamedTimer& LLFastTimerView::getFrameTimer() +LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer() { - return FTM_FRAME.getNamedTimer(); + return FTM_FRAME; } diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 5766cfa0b0..01a3501e4b 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -46,7 +46,7 @@ private: static LLSD analyzePerformanceLogDefault(std::istream& is) ; static void exportCharts(const std::string& base, const std::string& target); void onPause(); - LLFastTimer::NamedTimer& getFrameTimer(); + LLFastTimer::DeclareTimer& getFrameTimer(); public: @@ -59,7 +59,7 @@ public: virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual void draw(); - LLFastTimer::NamedTimer* getLegendID(S32 y); + LLFastTimer::DeclareTimer* getLegendID(S32 y); F64 getTime(const std::string& name); protected: @@ -85,8 +85,8 @@ private: U64 mMaxCountTotal; LLRect mBarRect; S32 mScrollIndex; - LLFastTimer::NamedTimer* mHoverID; - LLFastTimer::NamedTimer* mHoverTimer; + LLFastTimer::DeclareTimer* mHoverID; + LLFastTimer::DeclareTimer* mHoverTimer; LLRect mToolTipRect; S32 mHoverBarIndex; LLFrameTimer mHighlightTimer; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bf353cd1e0..5ac5ae892a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2715,7 +2715,7 @@ void LLPipeline::updateGeom(F32 max_dtime) S32 count = 0; - max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, max_dtime); + max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnit<LLUnits::Seconds, F32>(max_dtime)); LLSpatialGroup* last_group = NULL; LLSpatialBridge* last_bridge = NULL; -- cgit v1.2.3 From c76ed72c609b80b08df6cebd68274c9da6d3de2c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 12 Nov 2012 19:12:20 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed remnants of LLFastTimer::FrameState --- indra/llcommon/llfasttimer.cpp | 16 ++++++---------- indra/llcommon/llfasttimer.h | 16 ---------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index c4839fed77..66452fd02a 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -140,15 +140,6 @@ U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer } #endif -LLFastTimer::FrameState::FrameState() -: mActiveCount(0), - mCalls(0), - mSelfTimeCounter(0), - mLastCaller(NULL), - mMoveUpTree(false) -{} - - LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open, DeclareTimer* parent) : mName(name), mCollapsed(true), @@ -156,7 +147,12 @@ LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open, Decl mTreeTimeCounter(0), mCountAverage(0), mCallAverage(0), - mNeedsSorting(false) + mNeedsSorting(false), + mActiveCount(0), + mCalls(0), + mSelfTimeCounter(0), + mLastCaller(NULL), + mMoveUpTree(false) { setCollapsed(!open); diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 31872e4e65..40c2af34e8 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,25 +38,9 @@ class LLMutex; #define LL_FASTTIMER_USE_RDTSC 1 - -LL_COMMON_API void assert_main_thread(); - class LL_COMMON_API LLFastTimer { public: - class DeclareTimer; - struct LL_COMMON_API FrameState - { - FrameState(); - - U32 mSelfTimeCounter; - U32 mTotalTimeCounter; - U32 mCalls; - DeclareTimer* mLastCaller; // used to bootstrap tree construction - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - }; - // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances class LL_COMMON_API DeclareTimer : public LLInstanceTracker<DeclareTimer> -- cgit v1.2.3 From 67ec47e6da389661934ed2ddfa55ca58455fa7e5 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 13 Nov 2012 17:10:10 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system moving fast timers into lltrace namespace and accumulation system --- indra/llcommon/llfasttimer.cpp | 186 ++++++++++++++------------ indra/llcommon/llfasttimer.h | 268 ++++++++++++++++++++------------------ indra/llcommon/lltrace.cpp | 7 +- indra/llcommon/lltrace.h | 194 +++------------------------ indra/llcommon/lltracerecording.h | 18 +-- indra/llcommon/llunit.h | 84 ++++++------ indra/llui/llstatbar.h | 8 +- indra/llui/llstatgraph.h | 8 +- 8 files changed, 330 insertions(+), 443 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 66452fd02a..cced0bdfa9 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -33,8 +33,10 @@ #include "lltreeiterators.h" #include "llsdserialize.h" #include "llunit.h" +#include "llsd.h" #include <boost/bind.hpp> +#include <queue> #if LL_WINDOWS @@ -50,37 +52,40 @@ #error "architecture not supported" #endif +namespace LLTrace +{ + ////////////////////////////////////////////////////////////////////////////// // statics -S32 LLFastTimer::sCurFrameIndex = -1; -S32 LLFastTimer::sLastFrameIndex = -1; -U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64(); -bool LLFastTimer::sPauseHistory = 0; -bool LLFastTimer::sResetHistory = 0; -LLFastTimer::CurTimerData LLFastTimer::sCurTimerData; -BOOL LLFastTimer::sLog = FALSE; -std::string LLFastTimer::sLogName = ""; -BOOL LLFastTimer::sMetricLog = FALSE; -LLMutex* LLFastTimer::sLogLock = NULL; -std::queue<LLSD> LLFastTimer::sLogQueue; +S32 Time::sCurFrameIndex = -1; +S32 Time::sLastFrameIndex = -1; +U64 Time::sLastFrameTime = Time::getCPUClockCount64(); +bool Time::sPauseHistory = 0; +bool Time::sResetHistory = 0; +LLThreadLocalPointer<Time::CurTimerData> Time::sCurTimerData; +bool Time::sLog = FALSE; +std::string Time::sLogName = ""; +bool Time::sMetricLog = FALSE; +static LLMutex* sLogLock = NULL; +static std::queue<LLSD> sLogQueue; #if LL_LINUX || LL_SOLARIS -U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution +U64 Time::sClockResolution = 1000000000; // Nanosecond resolution #else -U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution +U64 Time::sClockResolution = 1000000; // Microsecond resolution #endif // FIXME: move these declarations to the relevant modules // helper functions -typedef LLTreeDFSPostIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_bottom_up_iterator_t; +typedef LLTreeDFSPostIter<BlockTimer, BlockTimer::child_const_iter> timer_tree_bottom_up_iterator_t; -static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(LLFastTimer::DeclareTimer& id) +static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(BlockTimer& id) { return timer_tree_bottom_up_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&BlockTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&BlockTimer::endChildren), _1)); } static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() @@ -88,14 +93,14 @@ static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() return timer_tree_bottom_up_iterator_t(); } -typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_dfs_iterator_t; +typedef LLTreeDFSIter<BlockTimer, BlockTimer::child_const_iter> timer_tree_dfs_iterator_t; -static timer_tree_dfs_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) +static timer_tree_dfs_iterator_t begin_timer_tree(BlockTimer& id) { return timer_tree_dfs_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&BlockTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&BlockTimer::endChildren), _1)); } static timer_tree_dfs_iterator_t end_timer_tree() @@ -103,21 +108,21 @@ static timer_tree_dfs_iterator_t end_timer_tree() return timer_tree_dfs_iterator_t(); } -LLFastTimer::DeclareTimer& LLFastTimer::DeclareTimer::getRootTimer() +BlockTimer& BlockTimer::getRootTimer() { - static DeclareTimer root_timer("root", true, NULL); + static BlockTimer root_timer("root", true, NULL); return root_timer; } //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 Time::countsPerSecond() // counts per second for the *32-bit* timer { return sClockResolution >> 8; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 Time::countsPerSecond() // counts per second for the *32-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz @@ -140,19 +145,14 @@ U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer } #endif -LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open, DeclareTimer* parent) -: mName(name), +BlockTimer::BlockTimer(const char* name, bool open, BlockTimer* parent) +: TraceType(name), mCollapsed(true), mParent(NULL), mTreeTimeCounter(0), mCountAverage(0), mCallAverage(0), - mNeedsSorting(false), - mActiveCount(0), - mCalls(0), - mSelfTimeCounter(0), - mLastCaller(NULL), - mMoveUpTree(false) + mNeedsSorting(false) { setCollapsed(!open); @@ -171,13 +171,13 @@ LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open, Decl memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); } -LLFastTimer::DeclareTimer::~DeclareTimer() +BlockTimer::~BlockTimer() { delete[] mCountHistory; delete[] mCallHistory; } -void LLFastTimer::DeclareTimer::setParent(DeclareTimer* parent) +void BlockTimer::setParent(BlockTimer* parent) { llassert_always(parent != this); llassert_always(parent != NULL); @@ -193,8 +193,8 @@ void LLFastTimer::DeclareTimer::setParent(DeclareTimer* parent) // subtract average timing from previous parent mParent->mCountAverage -= mCountAverage; - std::vector<DeclareTimer*>& children = mParent->getChildren(); - std::vector<DeclareTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); + std::vector<BlockTimer*>& children = mParent->getChildren(); + std::vector<BlockTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); if (found_it != children.end()) { children.erase(found_it); @@ -209,10 +209,10 @@ void LLFastTimer::DeclareTimer::setParent(DeclareTimer* parent) } } -S32 LLFastTimer::DeclareTimer::getDepth() +S32 BlockTimer::getDepth() { S32 depth = 0; - DeclareTimer* timerp = mParent; + BlockTimer* timerp = mParent; while(timerp) { depth++; @@ -223,9 +223,9 @@ S32 LLFastTimer::DeclareTimer::getDepth() } // static -void LLFastTimer::DeclareTimer::processTimes() +void BlockTimer::processTimes() { - if (sCurFrameIndex < 0) return; + if (Time::getCurFrameIndex() < 0) return; buildHierarchy(); accumulateTimings(); @@ -234,27 +234,27 @@ void LLFastTimer::DeclareTimer::processTimes() // sort child timers by name struct SortTimerByName { - bool operator()(const LLFastTimer::DeclareTimer* i1, const LLFastTimer::DeclareTimer* i2) + bool operator()(const BlockTimer* i1, const BlockTimer* i2) { return i1->getName() < i2->getName(); } }; //static -void LLFastTimer::DeclareTimer::buildHierarchy() +void BlockTimer::buildHierarchy() { - if (sCurFrameIndex < 0 ) return; + if (Time::getCurFrameIndex() < 0 ) return; // set up initial tree { - for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) + for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), end_it = LLInstanceTracker<BlockTimer>::endInstances(); it != end_it; ++it) { - DeclareTimer& timer = *it; - if (&timer == &DeclareTimer::getRootTimer()) continue; + BlockTimer& timer = *it; + if (&timer == &BlockTimer::getRootTimer()) continue; // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.mLastCaller && timer.mParent == &DeclareTimer::getRootTimer()) + if (timer.mLastCaller && timer.mParent == &BlockTimer::getRootTimer()) { timer.setParent(timer.mLastCaller); // no need to push up tree on first use, flag can be set spuriously @@ -266,13 +266,13 @@ void LLFastTimer::DeclareTimer::buildHierarchy() // bump timers up tree if they've been flagged as being in the wrong place // do this in a bottom up order to promote descendants first before promoting ancestors // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(DeclareTimer::getRootTimer()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimer::getRootTimer()); it != end_timer_tree_bottom_up(); ++it) { - DeclareTimer* timerp = *it; + BlockTimer* timerp = *it; // skip root timer - if (timerp == &DeclareTimer::getRootTimer()) continue; + if (timerp == &BlockTimer::getRootTimer()) continue; if (timerp->mMoveUpTree) { @@ -289,11 +289,11 @@ void LLFastTimer::DeclareTimer::buildHierarchy() } // sort timers by time last called, so call graph makes sense - for(timer_tree_dfs_iterator_t it = begin_timer_tree(DeclareTimer::getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(BlockTimer::getRootTimer()); it != end_timer_tree(); ++it) { - DeclareTimer* timerp = (*it); + BlockTimer* timerp = (*it); if (timerp->mNeedsSorting) { std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); @@ -303,12 +303,12 @@ void LLFastTimer::DeclareTimer::buildHierarchy() } //static -void LLFastTimer::DeclareTimer::accumulateTimings() +void BlockTimer::accumulateTimings() { U32 cur_time = getCPUClockCount32(); // walk up stack of active timers and accumulate current time while leaving timing structures active - LLFastTimer* cur_timer = sCurTimerData.mCurTimer; + Time* cur_timer = sCurTimerData.mCurTimer; // root defined by parent pointing to self CurTimerData* cur_data = &sCurTimerData; while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) @@ -328,11 +328,11 @@ void LLFastTimer::DeclareTimer::accumulateTimings() } // traverse tree in DFS post order, or bottom up - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(DeclareTimer::getRootTimer()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimer::getRootTimer()); it != end_timer_tree_bottom_up(); ++it) { - DeclareTimer* timerp = (*it); + BlockTimer* timerp = (*it); timerp->mTreeTimeCounter = timerp->mSelfTimeCounter; for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) { @@ -354,7 +354,7 @@ void LLFastTimer::DeclareTimer::accumulateTimings() } // static -void LLFastTimer::DeclareTimer::resetFrame() +void BlockTimer::resetFrame() { if (sLog) { //output current frame counts to performance log @@ -379,7 +379,7 @@ void LLFastTimer::DeclareTimer::resetFrame() { for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - DeclareTimer& timer = *it; + BlockTimer& timer = *it; sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq); sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls; @@ -401,7 +401,7 @@ void LLFastTimer::DeclareTimer::resetFrame() // reset for next frame for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - DeclareTimer& timer = *it; + BlockTimer& timer = *it; timer.mSelfTimeCounter = 0; timer.mCalls = 0; timer.mLastCaller = NULL; @@ -410,7 +410,7 @@ void LLFastTimer::DeclareTimer::resetFrame() } //static -void LLFastTimer::DeclareTimer::reset() +void BlockTimer::reset() { resetFrame(); // reset frame data @@ -420,7 +420,7 @@ void LLFastTimer::DeclareTimer::reset() // root defined by parent pointing to self CurTimerData* cur_data = &sCurTimerData; - LLFastTimer* cur_timer = cur_data->mCurTimer; + Time* cur_timer = cur_data->mCurTimer; while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { cur_timer->mStartTime = cur_time; @@ -434,10 +434,10 @@ void LLFastTimer::DeclareTimer::reset() { for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) { - DeclareTimer& timer = *it; - if (&timer != &DeclareTimer::getRootTimer()) + BlockTimer& timer = *it; + if (&timer != &BlockTimer::getRootTimer()) { - timer.setParent(&DeclareTimer::getRootTimer()); + timer.setParent(&BlockTimer::getRootTimer()); } timer.mCountAverage = 0; @@ -451,35 +451,35 @@ void LLFastTimer::DeclareTimer::reset() sCurFrameIndex = 0; } -U32 LLFastTimer::DeclareTimer::getHistoricalCount(S32 history_index) const +U32 BlockTimer::getHistoricalCount(S32 history_index) const { - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::DeclareTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM; return mCountHistory[history_idx]; } -U32 LLFastTimer::DeclareTimer::getHistoricalCalls(S32 history_index ) const +U32 BlockTimer::getHistoricalCalls(S32 history_index ) const { - S32 history_idx = (getLastFrameIndex() + history_index) % LLFastTimer::DeclareTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM; return mCallHistory[history_idx]; } -std::vector<LLFastTimer::DeclareTimer*>::const_iterator LLFastTimer::DeclareTimer::beginChildren() +std::vector<BlockTimer*>::const_iterator BlockTimer::beginChildren() { return mChildren.begin(); } -std::vector<LLFastTimer::DeclareTimer*>::const_iterator LLFastTimer::DeclareTimer::endChildren() +std::vector<BlockTimer*>::const_iterator BlockTimer::endChildren() { return mChildren.end(); } -std::vector<LLFastTimer::DeclareTimer*>& LLFastTimer::DeclareTimer::getChildren() +std::vector<BlockTimer*>& BlockTimer::getChildren() { return mChildren; } //static -void LLFastTimer::nextFrame() +void Time::nextFrame() { countsPerSecond(); // good place to calculate clock frequency U64 frame_time = getCPUClockCount64(); @@ -490,30 +490,30 @@ void LLFastTimer::nextFrame() if (!sPauseHistory) { - DeclareTimer::processTimes(); + BlockTimer::processTimes(); sLastFrameIndex = sCurFrameIndex++; } // get ready for next frame - DeclareTimer::resetFrame(); + BlockTimer::resetFrame(); sLastFrameTime = frame_time; } //static -void LLFastTimer::dumpCurTimes() +void Time::dumpCurTimes() { // accumulate timings, etc. - DeclareTimer::processTimes(); + BlockTimer::processTimes(); F64 clock_freq = (F64)countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(DeclareTimer::getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(BlockTimer::getRootTimer()); it != end_timer_tree(); ++it) { - DeclareTimer* timerp = (*it); + BlockTimer* timerp = (*it); F64 total_time_ms = ((F64)timerp->getHistoricalCount(0) * iclock_freq); // Don't bother with really brief times, keep output concise if (total_time_ms < 0.1) continue; @@ -534,14 +534,14 @@ void LLFastTimer::dumpCurTimes() } //static -void LLFastTimer::reset() +void Time::reset() { - DeclareTimer::reset(); + BlockTimer::reset(); } //static -void LLFastTimer::writeLog(std::ostream& os) +void Time::writeLog(std::ostream& os) { while (!sLogQueue.empty()) { @@ -552,3 +552,25 @@ void LLFastTimer::writeLog(std::ostream& os) } } + +void LLTrace::TimerAccumulator::addSamples( const LLTrace::TimerAccumulator& other ) +{ + mSelfTimeCounter += other.mSelfTimeCounter; + mTotalTimeCounter += other.mTotalTimeCounter; + mCalls += other.mCalls; + if (!mLastCaller) + { + mLastCaller = other.mLastCaller; + } + + //mActiveCount stays the same; + mMoveUpTree |= other.mMoveUpTree; +} + +void LLTrace::TimerAccumulator::reset( const LLTrace::TimerAccumulator* other ) +{ + mTotalTimeCounter = 0; + mSelfTimeCounter = 0; + mCalls = 0; +} +} diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 40c2af34e8..f5e6d874a2 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -33,131 +33,26 @@ class LLMutex; -#include <queue> -#include "llsd.h" +#include "lltrace.h" #define LL_FASTTIMER_USE_RDTSC 1 -class LL_COMMON_API LLFastTimer +namespace LLTrace { -public: - // stores a "named" timer instance to be reused via multiple LLFastTimer stack instances - class LL_COMMON_API DeclareTimer - : public LLInstanceTracker<DeclareTimer> - { - public: - DeclareTimer(const std::string& name, bool open = false, DeclareTimer* parent = &getRootTimer()); - ~DeclareTimer(); - - enum { HISTORY_NUM = 300 }; - - const std::string& getName() const { return mName; } - DeclareTimer* getParent() const { return mParent; } - void setParent(DeclareTimer* parent); - S32 getDepth(); - - typedef std::vector<DeclareTimer*>::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); - std::vector<DeclareTimer*>& getChildren(); - - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U32 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; - - static DeclareTimer& getRootTimer(); - - private: - friend class LLFastTimer; - - // recursive call to gather total time from children - static void accumulateTimings(); - - // updates cumulative times and hierarchy, - // can be called multiple times in a frame, at any point - static void processTimes(); - - static void buildHierarchy(); - static void resetFrame(); - static void reset(); - - // - // members - // - U32 mSelfTimeCounter; - U32 mTotalTimeCounter; - U32 mCalls; - DeclareTimer* mLastCaller; // used to bootstrap tree construction - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - - std::string mName; - - // sum of recored self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; - - U32 mCountAverage; - U32 mCallAverage; - - U32* mCountHistory; - U32* mCallHistory; - - // tree structure - DeclareTimer* mParent; // DeclareTimer of caller(parent) - std::vector<DeclareTimer*> mChildren; - bool mCollapsed; // don't show children - bool mNeedsSorting; // sort children whenever child added - }; +class Time +{ public: - LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer) - { -#if FAST_TIMER_ON - mStartTime = getCPUClockCount32(); - - timer.mActiveCount++; - timer.mCalls++; - // keep current parent as long as it is active when we are - timer.mMoveUpTree |= (timer.mParent->mActiveCount == 0); - - LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; - mLastTimerData = *cur_timer_data; - cur_timer_data->mCurTimer = this; - cur_timer_data->mTimerData = &timer; - cur_timer_data->mChildTime = 0; -#endif - } - - LL_FORCE_INLINE ~LLFastTimer() - { -#if FAST_TIMER_ON - U32 total_time = getCPUClockCount32() - mStartTime; - DeclareTimer* timer_data = LLFastTimer::sCurTimerData.mTimerData; - timer_data->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; - timer_data->mTotalTimeCounter += total_time; - timer_data->mActiveCount--; - - // store last caller to bootstrap tree creation - // do this in the destructor in case of recursion to get topmost caller - timer_data->mLastCaller = mLastTimerData.mTimerData; - - // we are only tracking self time, so subtract our total time delta from parents - mLastTimerData.mChildTime += total_time; + typedef Time self_t; + typedef class BlockTimer DeclareTimer; - LLFastTimer::sCurTimerData = mLastTimerData; -#endif - } +public: + Time(BlockTimer& timer); + ~Time(); public: - static LLMutex* sLogLock; - static std::queue<LLSD> sLogQueue; - static BOOL sLog; - static BOOL sMetricLog; + static bool sLog; + static bool sMetricLog; static std::string sLogName; static bool sPauseHistory; static bool sResetHistory; @@ -180,11 +75,11 @@ public: struct CurTimerData { - LLFastTimer* mCurTimer; - DeclareTimer* mTimerData; - U32 mChildTime; + Time* mCurTimer; + BlockTimer* mTimerData; + U64 mChildTime; }; - static CurTimerData sCurTimerData; + static LLThreadLocalPointer<CurTimerData> sCurTimerData; private: @@ -211,14 +106,14 @@ private: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 LLFastTimer::getCPUClockCount32() + //inline U32 Time::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 LLFastTimer::getCPUClockCount64() + //inline U64 Time::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -258,7 +153,7 @@ private: } #else - //LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp + //U64 get_clock_count(); // in lltimer.cpp // These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures. static U32 getCPUClockCount32() { @@ -330,10 +225,131 @@ private: static S32 sLastFrameIndex; static U64 sLastFrameTime; - U32 mStartTime; - LLFastTimer::CurTimerData mLastTimerData; + U64 mStartTime; + Time::CurTimerData mLastTimerData; +}; + +struct TimerAccumulator +{ + void addSamples(const TimerAccumulator& other); + void reset(const TimerAccumulator* other); + + // + // members + // + U64 mSelfTimeCounter, + mTotalTimeCounter; + U32 mCalls; + BlockTimer* mLastCaller; // used to bootstrap tree construction + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame +}; + +// stores a "named" timer instance to be reused via multiple Time stack instances +class BlockTimer +: public TraceType<TimerAccumulator>, + public LLInstanceTracker<BlockTimer> +{ +public: + BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); + ~BlockTimer(); + + enum { HISTORY_NUM = 300 }; + + BlockTimer* getParent() const { return mParent; } + void setParent(BlockTimer* parent); + S32 getDepth(); + + typedef std::vector<BlockTimer*>::const_iterator child_const_iter; + child_const_iter beginChildren(); + child_const_iter endChildren(); + std::vector<BlockTimer*>& getChildren(); + + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } + + U32 getCountAverage() const { return mCountAverage; } + U32 getCallAverage() const { return mCallAverage; } + + U32 getHistoricalCount(S32 history_index = 0) const; + U32 getHistoricalCalls(S32 history_index = 0) const; + + static BlockTimer& getRootTimer(); + +private: + friend class Time; + + // recursive call to gather total time from children + static void accumulateTimings(); + + // updates cumulative times and hierarchy, + // can be called multiple times in a frame, at any point + static void processTimes(); + + static void buildHierarchy(); + static void resetFrame(); + static void reset(); + + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete + U32 mTreeTimeCounter; + + U32 mCountAverage; + U32 mCallAverage; + + U32* mCountHistory; + U32* mCallHistory; + + // tree structure + BlockTimer* mParent; // BlockTimer of caller(parent) + std::vector<BlockTimer*> mChildren; + bool mCollapsed; // don't show children + bool mNeedsSorting; // sort children whenever child added }; -typedef class LLFastTimer LLFastTimer; +LL_FORCE_INLINE Time::Time(BlockTimer& timer) +{ +#if FAST_TIMER_ON + mStartTime = getCPUClockCount64(); + + TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); + accumulator.mActiveCount++; + accumulator.mCalls++; + // keep current parent as long as it is active when we are + accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); + + CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + // store top of stack + mLastTimerData = *cur_timer_data; + // push new information + cur_timer_data->mCurTimer = this; + cur_timer_data->mTimerData = &timer; + cur_timer_data->mChildTime = 0; +#endif +} + +LL_FORCE_INLINE Time::~Time() +{ +#if FAST_TIMER_ON + U64 total_time = getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; + accumulator.mTotalTimeCounter += total_time; + accumulator.mActiveCount--; + + // store last caller to bootstrap tree creation + // do this in the destructor in case of recursion to get topmost caller + accumulator.mLastCaller = mLastTimerData.mTimerData; + + // we are only tracking self time, so subtract our total time delta from parents + mLastTimerData.mChildTime += total_time; + + *sCurTimerData = mLastTimerData; +#endif +} + +} + +typedef LLTrace::Time LLFastTimer; #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 3f605f2c74..afb175c398 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -28,6 +28,7 @@ #include "lltrace.h" #include "lltracerecording.h" #include "lltracethreadrecorder.h" +#include "llfasttimer.h" namespace LLTrace { @@ -37,13 +38,15 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { gMasterThreadRecorder = new MasterThreadRecorder(); + Time::sCurTimerData = new Time::CurTimerData(); } void cleanup() { delete gMasterThreadRecorder; - LLUnitStrict<LLUnits::Seconds, F32> seconds; gMasterThreadRecorder = NULL; + delete Time::sCurTimerData.get(); + Time::sCurTimerData = NULL; } MasterThreadRecorder& getMasterThreadRecorder() @@ -59,6 +62,4 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() } -BlockTimer::Recorder::StackEntry BlockTimer::sCurRecorder; - } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 549e407822..fb9dca5e84 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -32,7 +32,6 @@ #include "llmemory.h" #include "llrefcount.h" -//#include "lltracethreadrecorder.h" #include "llunit.h" #include "llapr.h" @@ -61,8 +60,8 @@ namespace LLTrace typedef LLUnit<LLUnits::Microseconds, F64> Microseconds; typedef LLUnit<LLUnits::Nanoseconds, F64> Nanoseconds; - typedef LLUnit<LLUnits::Meters, F64> Meters; - typedef LLUnit<LLUnits::Kilometers, F64> Kilometers; + typedef LLUnit<LLUnits::Meters, F64> Meters; + typedef LLUnit<LLUnits::Kilometers, F64> Kilometers; typedef LLUnit<LLUnits::Centimeters, F64> Centimeters; typedef LLUnit<LLUnits::Millimeters, F64> Millimeters; @@ -71,11 +70,11 @@ namespace LLTrace LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); - class LL_COMMON_API MasterThreadRecorder& getMasterThreadRecorder(); + class MasterThreadRecorder& getMasterThreadRecorder(); // one per thread per type template<typename ACCUMULATOR> - class LL_COMMON_API AccumulatorBuffer : public LLRefCount + class AccumulatorBuffer : public LLRefCount { static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; private: @@ -199,7 +198,7 @@ namespace LLTrace template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; template<typename ACCUMULATOR> - class LL_COMMON_API TraceType + class TraceType : public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string> { public: @@ -218,6 +217,9 @@ namespace LLTrace size_t getIndex() const { return mAccumulatorIndex; } + std::string& getName() { return mName; } + const std::string& getName() const { return mName; } + protected: std::string mName; std::string mDescription; @@ -225,7 +227,7 @@ namespace LLTrace }; template<typename T> - class LL_COMMON_API MeasurementAccumulator + class MeasurementAccumulator { public: typedef T value_t; @@ -339,7 +341,7 @@ namespace LLTrace }; template<typename T> - class LL_COMMON_API CountAccumulator + class CountAccumulator { public: typedef CountAccumulator<T> self_t; @@ -378,11 +380,8 @@ namespace LLTrace U32 mNumSamples; }; - typedef TraceType<MeasurementAccumulator<F64> > measurement_common_float_t; - typedef TraceType<MeasurementAccumulator<S64> > measurement_common_int_t; - - template <typename T = F64, typename IS_UNIT = void> - class LL_COMMON_API Measurement + template <typename T = F64> + class Measurement : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > { public: @@ -392,37 +391,16 @@ namespace LLTrace : TraceType(name, description) {} - void sample(T value) - { - getPrimaryAccumulator().sample((storage_t)value); - } - }; - - template <typename T> - class LL_COMMON_API Measurement <T, typename T::is_unit_tag_t> - : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t> > - { - public: - typedef typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t storage_t; - - Measurement(const char* name, const char* description = NULL) - : TraceType(name, description) - {} - template<typename UNIT_T> void sample(UNIT_T value) { - T converted_value; - converted_value = value; - getPrimaryAccumulator().sample((storage_t)converted_value.value()); + T converted_value(value); + getPrimaryAccumulator().sample((storage_t)converted_value); } }; - typedef TraceType<CountAccumulator<F64> > count_common_float_t; - typedef TraceType<CountAccumulator<S64> > count_common_int_t; - - template <typename T = F64, typename IS_UNIT = void> - class LL_COMMON_API Count + template <typename T = F64> + class Count : public TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > { public: @@ -432,148 +410,12 @@ namespace LLTrace : TraceType(name) {} - void add(T value) - { - getPrimaryAccumulator().add((storage_t)value); - } - }; - - template <typename T> - class LL_COMMON_API Count <T, typename T::is_unit_tag_t> - : public TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t> > - { - public: - typedef typename LLUnits::HighestPrecisionType<typename T::storage_t>::type_t storage_t; - - Count(const char* name, const char* description = NULL) - : TraceType(name) - {} - template<typename UNIT_T> void add(UNIT_T value) { - T converted_value; - converted_value = value; - getPrimaryAccumulator().add((storage_t)converted_value.value()); - } - }; - - class LL_COMMON_API TimerAccumulator - { - public: - typedef TimerAccumulator self_t; - - U32 mTotalTimeCounter, - mChildTimeCounter, - mCalls; - - TimerAccumulator* mParent; // info for caller timer - TimerAccumulator* mLastCaller; // used to bootstrap tree construction - const class BlockTimer* mTimer; // points to block timer associated with this storage - U8 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - std::vector<TimerAccumulator*> mChildren; // currently assumed child timers - - void addSamples(const TimerAccumulator& other) - { - mTotalTimeCounter += other.mTotalTimeCounter; - mChildTimeCounter += other.mChildTimeCounter; - mCalls += other.mCalls; - } - - void reset(const self_t* other) - { - mTotalTimeCounter = 0; - mChildTimeCounter = 0; - mCalls = 0; + T converted_value(value); + getPrimaryAccumulator().add((storage_t)converted_value); } - - }; - - class LL_COMMON_API BlockTimer : public TraceType<TimerAccumulator> - { - public: - BlockTimer(const char* name) - : TraceType(name) - {} - - struct Recorder - { - struct StackEntry - { - Recorder* mRecorder; - TimerAccumulator* mAccumulator; - U32 mChildTime; - }; - - LL_FORCE_INLINE Recorder(BlockTimer& block_timer) - : mLastRecorder(sCurRecorder) - { - mStartTime = getCPUClockCount32(); - TimerAccumulator* accumulator = &block_timer.getPrimaryAccumulator(); // get per-thread accumulator - accumulator->mActiveCount++; - accumulator->mCalls++; - accumulator->mMoveUpTree |= (accumulator->mParent->mActiveCount == 0); - - // push new timer on stack - sCurRecorder.mRecorder = this; - sCurRecorder.mAccumulator = accumulator; - sCurRecorder.mChildTime = 0; - } - - LL_FORCE_INLINE ~Recorder() - { - U32 total_time = getCPUClockCount32() - mStartTime; - - TimerAccumulator* accumulator = sCurRecorder.mAccumulator; - accumulator->mTotalTimeCounter += total_time; - accumulator->mChildTimeCounter += sCurRecorder.mChildTime; - accumulator->mActiveCount--; - - accumulator->mLastCaller = mLastRecorder.mAccumulator; - mLastRecorder.mChildTime += total_time; - - // pop stack - sCurRecorder = mLastRecorder; - } - - StackEntry mLastRecorder; - U32 mStartTime; - }; - - private: - static U32 getCPUClockCount32() - { - U32 ret_val; - __asm - { - _emit 0x0f - _emit 0x31 - shr eax,8 - shl edx,24 - or eax, edx - mov dword ptr [ret_val], eax - } - return ret_val; - } - - // return full timer value, *not* shifted by 8 bits - static U64 getCPUClockCount64() - { - U64 ret_val; - __asm - { - _emit 0x0f - _emit 0x31 - mov eax,eax - mov edx,edx - mov dword ptr [ret_val+4], edx - mov dword ptr [ret_val], eax - } - return ret_val; - } - - static Recorder::StackEntry sCurRecorder; }; } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 16b80fd1d8..4dcadfdf29 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -120,7 +120,7 @@ namespace LLTrace F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const; S64 getSum(const TraceType<CountAccumulator<S64> >& stat) const; template <typename T> - T getSum(const Count<T, typename T::is_unit_tag_t>& stat) const + T getSum(const Count<T>& stat) const { return (T)getSum(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -128,7 +128,7 @@ namespace LLTrace F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat) const; F64 getPerSec(const TraceType<CountAccumulator<S64> >& stat) const; template <typename T> - T getPerSec(const Count<T, typename T::is_unit_tag_t>& stat) const + T getPerSec(const Count<T>& stat) const { return (T)getPerSec(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -141,7 +141,7 @@ namespace LLTrace F64 getSum(const TraceType<MeasurementAccumulator<F64> >& stat) const; S64 getSum(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getSum(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getSum(const Measurement<T>& stat) const { return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -149,7 +149,7 @@ namespace LLTrace F64 getPerSec(const TraceType<MeasurementAccumulator<F64> >& stat) const; F64 getPerSec(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getPerSec(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getPerSec(const Measurement<T>& stat) const { return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -157,7 +157,7 @@ namespace LLTrace F64 getMin(const TraceType<MeasurementAccumulator<F64> >& stat) const; S64 getMin(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMin(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getMin(const Measurement<T>& stat) const { return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -165,7 +165,7 @@ namespace LLTrace F64 getMax(const TraceType<MeasurementAccumulator<F64> >& stat) const; S64 getMax(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMax(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getMax(const Measurement<T>& stat) const { return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -173,7 +173,7 @@ namespace LLTrace F64 getMean(const TraceType<MeasurementAccumulator<F64> >& stat) const; F64 getMean(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getMean(Measurement<T, typename T::is_unit_tag_t>& stat) const + T getMean(Measurement<T>& stat) const { return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -181,7 +181,7 @@ namespace LLTrace F64 getStandardDeviation(const TraceType<MeasurementAccumulator<F64> >& stat) const; F64 getStandardDeviation(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getStandardDeviation(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getStandardDeviation(const Measurement<T>& stat) const { return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } @@ -189,7 +189,7 @@ namespace LLTrace F64 getLastValue(const TraceType<MeasurementAccumulator<F64> >& stat) const; S64 getLastValue(const TraceType<MeasurementAccumulator<S64> >& stat) const; template <typename T> - T getLastValue(const Measurement<T, typename T::is_unit_tag_t>& stat) const + T getLastValue(const Measurement<T>& stat) const { return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 54ba1d67db..4ac2197c11 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -209,26 +209,26 @@ private: // // operator + // -template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> -LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator + (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator + (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) { - LLUnit<STORAGE_TYPE1, UNIT_TYPE1> result(first); + LLUnit<UNIT_TYPE1, STORAGE_TYPE1> result(first); result += second; return result; } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator + (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator + (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) { - LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + LLUnit<UNIT_TYPE, STORAGE_TYPE> result(first); result += second; return result; } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator + (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator + (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) { - LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + LLUnit<UNIT_TYPE, STORAGE_TYPE> result(first); result += second; return result; } @@ -236,27 +236,27 @@ LLUnit<STORAGE_TYPE, UNIT_TYPE> operator + (SCALAR_TYPE first, LLUnit<STORAGE_TY // // operator - // -template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> -LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator - (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator - (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) { - LLUnit<STORAGE_TYPE1, UNIT_TYPE1> result(first); + LLUnit<UNIT_TYPE1, STORAGE_TYPE1> result(first); result -= second; return result; } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator - (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator - (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) { - LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + LLUnit<UNIT_TYPE, STORAGE_TYPE> result(first); result -= second; return result; } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator - (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator - (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) { - LLUnit<STORAGE_TYPE, UNIT_TYPE> result(first); + LLUnit<UNIT_TYPE, STORAGE_TYPE> result(first); result -= second; return result; } @@ -264,20 +264,20 @@ LLUnit<STORAGE_TYPE, UNIT_TYPE> operator - (SCALAR_TYPE first, LLUnit<STORAGE_TY // // operator * // -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator * (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator * (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) { - return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first * second.value()); + return LLUnit<UNIT_TYPE, STORAGE_TYPE>(first * second.value()); } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator * (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator * (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) { - return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first.value() * second); + return LLUnit<UNIT_TYPE, STORAGE_TYPE>(first.value() * second); } -template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> -void operator * (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +void operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); @@ -286,40 +286,40 @@ void operator * (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_T // // operator / // -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -SCALAR_TYPE operator / (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +SCALAR_TYPE operator / (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) { return SCALAR_TYPE(first / second.value()); } -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> -LLUnit<STORAGE_TYPE, UNIT_TYPE> operator / (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnit<UNIT_TYPE, STORAGE_TYPE> operator / (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) { - return LLUnit<STORAGE_TYPE, UNIT_TYPE>(first.value() / second); + return LLUnit<UNIT_TYPE, STORAGE_TYPE>(first.value() / second); } -template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> -void operator / (LLUnit<STORAGE_TYPE1, UNIT_TYPE1>, LLUnit<STORAGE_TYPE2, UNIT_TYPE2>) +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +void operator / (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); } #define COMPARISON_OPERATORS(op) \ -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> \ -bool operator op (SCALAR_TYPE first, LLUnit<STORAGE_TYPE, UNIT_TYPE> second) \ +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ +bool operator op (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) \ { \ return first op second.value(); \ } \ \ -template<typename STORAGE_TYPE, typename UNIT_TYPE, typename SCALAR_TYPE> \ -bool operator op (LLUnit<STORAGE_TYPE, UNIT_TYPE> first, SCALAR_TYPE second) \ +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ +bool operator op (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) \ { \ return first.value() op second; \ } \ \ -template<typename STORAGE_TYPE1, typename UNIT_TYPE1, typename STORAGE_TYPE2, typename UNIT_TYPE2> \ -bool operator op (LLUnit<STORAGE_TYPE1, UNIT_TYPE1> first, LLUnit<STORAGE_TYPE2, UNIT_TYPE2> second) \ +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> \ +bool operator op (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) \ { \ return first.value() op first.convert(second); \ } @@ -333,6 +333,12 @@ COMPARISON_OPERATORS(!=) namespace LLUnits { +template<typename UNIT_TYPE, typename STORAGE_TYPE> +struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> > +{ + typedef typename HighestPrecisionType<STORAGE_TYPE>::type_t type_t; +}; + #define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor) \ struct unit_name \ { \ diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 083da8444e..17c9c09cb2 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -100,10 +100,10 @@ private: BOOL mDisplayHistory; BOOL mDisplayMean; // If true, display mean, if false, display current value - LLTrace::count_common_float_t* mCountFloatp; - LLTrace::count_common_int_t* mCountIntp; - LLTrace::measurement_common_float_t* mMeasurementFloatp; - LLTrace::measurement_common_int_t* mMeasurementIntp; + LLTrace::TraceType<CountAccumulator<F64> >* mCountFloatp; + LLTrace::TraceType<CountAccumulator<S64> >* mCountIntp; + LLTrace::TraceType<MeasurementAccumulator<F64> >* mMeasurementFloatp; + LLTrace::TraceType<MeasurementAccumulator<S64> >* mMeasurementIntp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index f33c784262..09b34c2358 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -57,10 +57,10 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { - Alternative<LLTrace::count_common_float_t* > count_stat_float; - Alternative<LLTrace::count_common_int_t* > count_stat_int; - Alternative<LLTrace::measurement_common_float_t* > measurement_stat_float; - Alternative<LLTrace::measurement_common_int_t* > measurement_stat_int; + Alternative<LLTrace::TraceType<CountAccumulator<F64> >* > count_stat_float; + Alternative<LLTrace::TraceType<CountAccumulator<S64> >* > count_stat_int; + Alternative<LLTrace::TraceType<MeasurementAccumulator<F64> >* > measurement_stat_float; + Alternative<LLTrace::TraceType<MeasurementAccumulator<S64> >* > measurement_stat_int; }; struct Params : public LLInitParam::Block<Params, LLView::Params> -- cgit v1.2.3 From 9d77e030d9a0d23cebce616631677459eec1612c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 14 Nov 2012 23:52:27 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system cleaning up build moved most includes of windows.h to llwin32headers.h to disable min/max macros, etc streamlined Time class and consolidated functionality in BlockTimer class llfasttimer is no longer included via llstring.h, so had to add it manually in several places --- indra/llaudio/llstreamingaudio_fmod.h | 2 + indra/llcharacter/llcharacter.cpp | 1 + indra/llcharacter/lljoint.h | 1 + indra/llcharacter/llmotioncontroller.cpp | 3 +- indra/llcommon/llapr.h | 12 +- indra/llcommon/lldate.cpp | 1 + indra/llcommon/llfasttimer.cpp | 120 +++++++++------- indra/llcommon/llfasttimer.h | 165 ++++++++++------------ indra/llcommon/llfile.cpp | 2 +- indra/llcommon/llfindlocale.cpp | 2 +- indra/llcommon/llinitparam.cpp | 1 + indra/llcommon/llinitparam.h | 1 + indra/llcommon/llmemory.cpp | 1 - indra/llcommon/llmetricperformancetester.cpp | 6 +- indra/llcommon/llmortician.h | 1 + indra/llcommon/llprocess.h | 3 +- indra/llcommon/llprocessor.cpp | 4 +- indra/llcommon/llsdparam.h | 1 + indra/llcommon/llstacktrace.cpp | 2 +- indra/llcommon/llstring.cpp | 5 +- indra/llcommon/llstring.h | 3 +- indra/llcommon/llsys.cpp | 5 +- indra/llcommon/lltimer.cpp | 6 +- indra/llcommon/lltrace.cpp | 6 +- indra/llcommon/lltrace.h | 22 ++- indra/llcommon/lltracerecording.h | 8 +- indra/llcommon/lltracethreadrecorder.cpp | 1 + indra/llcommon/llunit.h | 9 +- indra/llcommon/lluuid.cpp | 4 +- indra/llcommon/llwin32headers.h | 38 +++++ indra/llcommon/llwin32headerslean.h | 37 +++++ indra/llinventory/lleconomy.h | 1 + indra/llinventory/llinventory.cpp | 1 + indra/llmessage/llfiltersd2xmlrpc.cpp | 1 + indra/llmessage/lliohttpserver.cpp | 1 + indra/llmessage/lliosocket.cpp | 1 + indra/llmessage/lliosocket.h | 1 + indra/llmessage/llioutil.cpp | 1 + indra/llmessage/llmail.cpp | 7 +- indra/llmessage/llpumpio.cpp | 1 + indra/llmessage/llsdrpcclient.cpp | 1 + indra/llmessage/llsdrpcserver.cpp | 1 + indra/llmessage/llurlrequest.cpp | 1 + indra/llmessage/net.cpp | 4 +- indra/llplugin/llpluginprocesschild.h | 1 + indra/llplugin/llpluginprocessparent.h | 2 + indra/llplugin/tests/llplugincookiestore_test.cpp | 1 + indra/llrender/llfontgl.cpp | 1 + indra/llrender/llglheaders.h | 6 +- indra/llrender/llimagegl.cpp | 1 + indra/llrender/llvertexbuffer.cpp | 2 +- indra/llui/llfloaterreg.h | 1 + indra/llui/llstatbar.h | 8 +- indra/llui/llstatgraph.h | 12 +- indra/llui/lluistring.cpp | 2 + indra/llui/llxuiparser.cpp | 2 +- indra/llvfs/llpidlock.cpp | 2 +- indra/llvfs/llvfile.cpp | 1 + indra/llwindow/llkeyboard.h | 1 + indra/llwindow/llkeyboardwin32.cpp | 5 +- indra/llwindow/llwindow.h | 1 + indra/llwindow/llwindowwin32.cpp | 1 + indra/llwindow/llwindowwin32.h | 4 +- indra/newview/llappviewer.cpp | 32 ++--- indra/newview/llfasttimerview.cpp | 117 +++++++-------- indra/newview/llfasttimerview.h | 8 +- indra/newview/llviewermenufile.h | 1 + 67 files changed, 389 insertions(+), 318 deletions(-) create mode 100644 indra/llcommon/llwin32headers.h create mode 100644 indra/llcommon/llwin32headerslean.h diff --git a/indra/llaudio/llstreamingaudio_fmod.h b/indra/llaudio/llstreamingaudio_fmod.h index 9970f0d03b..a189b548dd 100644 --- a/indra/llaudio/llstreamingaudio_fmod.h +++ b/indra/llaudio/llstreamingaudio_fmod.h @@ -30,6 +30,8 @@ #include "stdtypes.h" // from llcommon +#include <list> + #include "llstreamingaudio.h" class LLAudioStreamManagerFMOD; diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 0a6a8f9fa6..5138be0711 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -32,6 +32,7 @@ #include "llcharacter.h" #include "llstring.h" +#include "llfasttimer.h" #define SKEL_HEADER "Linden Skeleton 1.0" diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index dc3c58cf64..a9cde545f2 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -31,6 +31,7 @@ // Header Files //----------------------------------------------------------------------------- #include <string> +#include <list> #include "linked_lists.h" #include "v3math.h" diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 829dda9993..5524bba296 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -28,8 +28,9 @@ // Header Files //----------------------------------------------------------------------------- #include "linden_common.h" - #include "llmotioncontroller.h" + +#include "llfasttimer.h" #include "llkeyframemotion.h" #include "llmath.h" #include "lltimer.h" diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 510725ffc6..c77d96c1c9 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -32,16 +32,6 @@ #if LL_LINUX || LL_SOLARIS #include <sys/param.h> // Need PATH_MAX in APR headers... #endif -#if LL_WINDOWS - // Limit Windows API to small and manageable set. - // If you get undefined symbols, find the appropriate - // Windows header file and include that in your .cpp file. - #define WIN32_LEAN_AND_MEAN - #include <winsock2.h> - #include <windows.h> - #undef min - #undef max -#endif #include <boost/noncopyable.hpp> @@ -340,7 +330,7 @@ public: LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) - : LLThreadLocalPointerBase(other) + : LLThreadLocalPointerBase(other) { set(other.get()); } diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index 5569b4102d..2efe39e158 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -39,6 +39,7 @@ #include "lltimer.h" #include "llstring.h" +#include "llfasttimer.h" static const F64 DATE_EPOCH = 0.0; diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index cced0bdfa9..d007f76e5f 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -58,22 +58,22 @@ namespace LLTrace ////////////////////////////////////////////////////////////////////////////// // statics -S32 Time::sCurFrameIndex = -1; -S32 Time::sLastFrameIndex = -1; -U64 Time::sLastFrameTime = Time::getCPUClockCount64(); -bool Time::sPauseHistory = 0; -bool Time::sResetHistory = 0; -LLThreadLocalPointer<Time::CurTimerData> Time::sCurTimerData; -bool Time::sLog = FALSE; -std::string Time::sLogName = ""; -bool Time::sMetricLog = FALSE; +S32 BlockTimer::sCurFrameIndex = -1; +S32 BlockTimer::sLastFrameIndex = -1; +U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64(); +bool BlockTimer::sPauseHistory = 0; +bool BlockTimer::sResetHistory = 0; +LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData; +bool BlockTimer::sLog = false; +std::string BlockTimer::sLogName = ""; +bool BlockTimer::sMetricLog = false; static LLMutex* sLogLock = NULL; static std::queue<LLSD> sLogQueue; #if LL_LINUX || LL_SOLARIS -U64 Time::sClockResolution = 1000000000; // Nanosecond resolution +U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution #else -U64 Time::sClockResolution = 1000000; // Microsecond resolution +U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution #endif // FIXME: move these declarations to the relevant modules @@ -114,15 +114,22 @@ BlockTimer& BlockTimer::getRootTimer() return root_timer; } +void BlockTimer::pushLog(LLSD log) +{ + LLMutexLock lock(sLogLock); + + sLogQueue.push(log); +} + //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 Time::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer { return sClockResolution >> 8; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 Time::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz @@ -225,7 +232,7 @@ S32 BlockTimer::getDepth() // static void BlockTimer::processTimes() { - if (Time::getCurFrameIndex() < 0) return; + if (getCurFrameIndex() < 0) return; buildHierarchy(); accumulateTimings(); @@ -243,7 +250,7 @@ struct SortTimerByName //static void BlockTimer::buildHierarchy() { - if (Time::getCurFrameIndex() < 0 ) return; + if (getCurFrameIndex() < 0 ) return; // set up initial tree { @@ -254,11 +261,11 @@ void BlockTimer::buildHierarchy() // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.mLastCaller && timer.mParent == &BlockTimer::getRootTimer()) + if (timer.getPrimaryAccumulator().mLastCaller && timer.mParent == &BlockTimer::getRootTimer()) { - timer.setParent(timer.mLastCaller); + timer.setParent(timer.getPrimaryAccumulator().mLastCaller); // no need to push up tree on first use, flag can be set spuriously - timer.mMoveUpTree = false; + timer.getPrimaryAccumulator().mMoveUpTree = false; } } } @@ -274,14 +281,14 @@ void BlockTimer::buildHierarchy() // skip root timer if (timerp == &BlockTimer::getRootTimer()) continue; - if (timerp->mMoveUpTree) + if (timerp->getPrimaryAccumulator().mMoveUpTree) { - // since ancestors have already been visited, reparenting won't affect tree traversal + // since ancestors have already been visited, re-parenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - timerp->mMoveUpTree = false; + timerp->getPrimaryAccumulator().mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up it.skipAncestors(); @@ -308,21 +315,23 @@ void BlockTimer::accumulateTimings() U32 cur_time = getCPUClockCount32(); // walk up stack of active timers and accumulate current time while leaving timing structures active - Time* cur_timer = sCurTimerData.mCurTimer; + Time* cur_timer = sCurTimerData->mCurTimer; // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; + CurTimerData* cur_data = sCurTimerData.get(); + TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator(); while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; - cur_data->mTimerData->mSelfTimeCounter += self_time_delta; - cur_data->mTimerData->mTotalTimeCounter += cumulative_time_delta; + accumulator.mSelfTimeCounter += self_time_delta; + accumulator.mTotalTimeCounter += cumulative_time_delta; cur_timer->mStartTime = cur_time; cur_data = &cur_timer->mLastTimerData; cur_data->mChildTime += cumulative_time_delta; + accumulator = cur_data->mTimerData->getPrimaryAccumulator(); cur_timer = cur_timer->mLastTimerData.mCurTimer; } @@ -333,13 +342,14 @@ void BlockTimer::accumulateTimings() ++it) { BlockTimer* timerp = (*it); - timerp->mTreeTimeCounter = timerp->mSelfTimeCounter; + TimerAccumulator& accumulator = timerp->getPrimaryAccumulator(); + timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter; for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) { timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; } - S32 cur_frame = sCurFrameIndex; + S32 cur_frame = getCurFrameIndex(); if (cur_frame >= 0) { // update timer history @@ -347,8 +357,8 @@ void BlockTimer::accumulateTimings() timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); - timerp->mCallHistory[hidx] = timerp->mCalls; - timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->mCalls) / (cur_frame+1); + timerp->mCallHistory[hidx] = accumulator.mCalls; + timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1); } } } @@ -377,15 +387,19 @@ void BlockTimer::resetFrame() LLSD sd; { - for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) + for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), + end_it = LLInstanceTracker<BlockTimer>::endInstances(); + it != end_it; + ++it) { BlockTimer& timer = *it; - sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq); - sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls; + TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); + sd[timer.getName()]["Time"] = (LLSD::Real) (accumulator.mSelfTimeCounter*iclock_freq); + sd[timer.getName()]["Calls"] = (LLSD::Integer) accumulator.mCalls; // computing total time here because getting the root timer's getCountHistory // doesn't work correctly on the first frame - total_time = total_time + timer.mSelfTimeCounter * iclock_freq; + total_time = total_time + accumulator.mSelfTimeCounter * iclock_freq; } } @@ -399,13 +413,17 @@ void BlockTimer::resetFrame() } // reset for next frame - for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) + for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), + end_it = LLInstanceTracker<BlockTimer>::endInstances(); + it != end_it; + ++it) { BlockTimer& timer = *it; - timer.mSelfTimeCounter = 0; - timer.mCalls = 0; - timer.mLastCaller = NULL; - timer.mMoveUpTree = false; + TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); + accumulator.mSelfTimeCounter = 0; + accumulator.mCalls = 0; + accumulator.mLastCaller = NULL; + accumulator.mMoveUpTree = false; } } @@ -419,7 +437,7 @@ void BlockTimer::reset() U32 cur_time = getCPUClockCount32(); // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; + CurTimerData* cur_data = sCurTimerData.get(); Time* cur_timer = cur_data->mCurTimer; while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { @@ -432,7 +450,10 @@ void BlockTimer::reset() // reset all history { - for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it) + for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), + end_it = LLInstanceTracker<BlockTimer>::endInstances(); + it != end_it; + ++it) { BlockTimer& timer = *it; if (&timer != &BlockTimer::getRootTimer()) @@ -453,13 +474,13 @@ void BlockTimer::reset() U32 BlockTimer::getHistoricalCount(S32 history_index) const { - S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM; return mCountHistory[history_idx]; } U32 BlockTimer::getHistoricalCalls(S32 history_index ) const { - S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM; + S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM; return mCallHistory[history_idx]; } @@ -479,10 +500,10 @@ std::vector<BlockTimer*>& BlockTimer::getChildren() } //static -void Time::nextFrame() +void BlockTimer::nextFrame() { - countsPerSecond(); // good place to calculate clock frequency - U64 frame_time = getCPUClockCount64(); + BlockTimer::countsPerSecond(); // good place to calculate clock frequency + U64 frame_time = BlockTimer::getCPUClockCount64(); if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) { llinfos << "Slow frame, fast timers inaccurate" << llendl; @@ -505,7 +526,7 @@ void Time::dumpCurTimes() // accumulate timings, etc. BlockTimer::processTimes(); - F64 clock_freq = (F64)countsPerSecond(); + F64 clock_freq = (F64)BlockTimer::countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds // walk over timers in depth order and output timings @@ -533,13 +554,6 @@ void Time::dumpCurTimes() } } -//static -void Time::reset() -{ - BlockTimer::reset(); -} - - //static void Time::writeLog(std::ostream& os) { diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index f5e6d874a2..69a6773b12 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -28,60 +28,77 @@ #define LL_FASTTIMER_H #include "llinstancetracker.h" +#include "lltrace.h" #define FAST_TIMER_ON 1 +#define LL_FASTTIMER_USE_RDTSC 1 class LLMutex; -#include "lltrace.h" - -#define LL_FASTTIMER_USE_RDTSC 1 - namespace LLTrace { +struct CurTimerData +{ + class Time* mCurTimer; + class BlockTimer* mTimerData; + U64 mChildTime; +}; class Time { public: + friend class BlockTimer; typedef Time self_t; typedef class BlockTimer DeclareTimer; -public: Time(BlockTimer& timer); ~Time(); public: - static bool sLog; - static bool sMetricLog; - static std::string sLogName; - static bool sPauseHistory; - static bool sResetHistory; - - // call this once a frame to reset timers - static void nextFrame(); - // dumps current cumulative frame stats to log // call nextFrame() to reset timers static void dumpCurTimes(); - // call this to reset timer hierarchy, averages, etc. - static void reset(); + static void writeLog(std::ostream& os); - static U64 countsPerSecond(); - static S32 getLastFrameIndex() { return sLastFrameIndex; } - static S32 getCurFrameIndex() { return sCurFrameIndex; } +private: - static void writeLog(std::ostream& os); + U64 mStartTime; + CurTimerData mLastTimerData; +}; - struct CurTimerData - { - Time* mCurTimer; - BlockTimer* mTimerData; - U64 mChildTime; - }; - static LLThreadLocalPointer<CurTimerData> sCurTimerData; +// stores a "named" timer instance to be reused via multiple Time stack instances +class BlockTimer +: public TraceType<TimerAccumulator>, + public LLInstanceTracker<BlockTimer> +{ +public: + BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); + ~BlockTimer(); -private: + enum { HISTORY_NUM = 300 }; + + BlockTimer* getParent() const { return mParent; } + void setParent(BlockTimer* parent); + S32 getDepth(); + + typedef std::vector<BlockTimer*>::const_iterator child_const_iter; + child_const_iter beginChildren(); + child_const_iter endChildren(); + std::vector<BlockTimer*>& getChildren(); + + void setCollapsed(bool collapsed) { mCollapsed = collapsed; } + bool getCollapsed() const { return mCollapsed; } + + U32 getCountAverage() const { return mCountAverage; } + U32 getCallAverage() const { return mCallAverage; } + + U32 getHistoricalCount(S32 history_index = 0) const; + U32 getHistoricalCalls(S32 history_index = 0) const; + + static BlockTimer& getRootTimer(); + static void pushLog(LLSD sd); + friend class Time; ////////////////////////////////////////////////////////////////////////////// @@ -106,14 +123,14 @@ private: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 Time::getCPUClockCount32() + //inline U32 BlockTimer::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 Time::getCPUClockCount64() + //inline U64 BlockTimer::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -220,64 +237,7 @@ private: #endif - static U64 sClockResolution; - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; - static U64 sLastFrameTime; - - U64 mStartTime; - Time::CurTimerData mLastTimerData; -}; - -struct TimerAccumulator -{ - void addSamples(const TimerAccumulator& other); - void reset(const TimerAccumulator* other); - - // - // members - // - U64 mSelfTimeCounter, - mTotalTimeCounter; - U32 mCalls; - BlockTimer* mLastCaller; // used to bootstrap tree construction - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame -}; - -// stores a "named" timer instance to be reused via multiple Time stack instances -class BlockTimer -: public TraceType<TimerAccumulator>, - public LLInstanceTracker<BlockTimer> -{ -public: - BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); - ~BlockTimer(); - - enum { HISTORY_NUM = 300 }; - - BlockTimer* getParent() const { return mParent; } - void setParent(BlockTimer* parent); - S32 getDepth(); - - typedef std::vector<BlockTimer*>::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); - std::vector<BlockTimer*>& getChildren(); - - void setCollapsed(bool collapsed) { mCollapsed = collapsed; } - bool getCollapsed() const { return mCollapsed; } - - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U32 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; - - static BlockTimer& getRootTimer(); - -private: - friend class Time; + static U64 countsPerSecond(); // recursive call to gather total time from children static void accumulateTimings(); @@ -289,6 +249,12 @@ private: static void buildHierarchy(); static void resetFrame(); static void reset(); + // call this once a frame to reset timers + static void nextFrame(); + static S32 getLastFrameIndex() { return sLastFrameIndex; } + static S32 getCurFrameIndex() { return sCurFrameIndex; } + + // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete U32 mTreeTimeCounter; @@ -304,12 +270,25 @@ private: std::vector<BlockTimer*> mChildren; bool mCollapsed; // don't show children bool mNeedsSorting; // sort children whenever child added + + // statics + static std::string sLogName; + static bool sMetricLog; + static bool sLog; + static LLThreadLocalPointer<CurTimerData> sCurTimerData; + static U64 sClockResolution; + static S32 sCurFrameIndex; + static S32 sLastFrameIndex; + static U64 sLastFrameTime; + static bool sPauseHistory; + static bool sResetHistory; + }; LL_FORCE_INLINE Time::Time(BlockTimer& timer) { #if FAST_TIMER_ON - mStartTime = getCPUClockCount64(); + mStartTime = BlockTimer::getCPUClockCount64(); TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); accumulator.mActiveCount++; @@ -317,7 +296,7 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) // keep current parent as long as it is active when we are accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); - CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); // store top of stack mLastTimerData = *cur_timer_data; // push new information @@ -330,8 +309,8 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) LL_FORCE_INLINE Time::~Time() { #if FAST_TIMER_ON - U64 total_time = getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = Time::sCurTimerData.get(); + U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; @@ -344,7 +323,7 @@ LL_FORCE_INLINE Time::~Time() // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *sCurTimerData = mLastTimerData; + *BlockTimer::sCurTimerData = mLastTimerData; #endif } diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index c51d042a3d..5917d7a420 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -28,7 +28,7 @@ */ #if LL_WINDOWS -#include <windows.h> +#include "llwin32headerslean.h" #include <stdlib.h> // Windows errno #else #include <errno.h> diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp index cd7c0c7c09..f019bd0c64 100644 --- a/indra/llcommon/llfindlocale.cpp +++ b/indra/llcommon/llfindlocale.cpp @@ -33,7 +33,7 @@ #include <ctype.h> #ifdef WIN32 -#include <windows.h> +#include "llwin32headers.h" #include <winnt.h> #endif diff --git a/indra/llcommon/llinitparam.cpp b/indra/llcommon/llinitparam.cpp index 32d4eec607..d72e10d2fa 100644 --- a/indra/llcommon/llinitparam.cpp +++ b/indra/llcommon/llinitparam.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" #include "llinitparam.h" +#include "llformat.h" namespace LLInitParam diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 3d4e4331c0..502f93cbb8 100644 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -29,6 +29,7 @@ #define LL_LLPARAM_H #include <vector> +#include <list> #include <boost/function.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/unordered_map.hpp> diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index afaf366668..7c4ab6cf98 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -32,7 +32,6 @@ //#endif #if defined(LL_WINDOWS) -//# include <windows.h> # include <psapi.h> #elif defined(LL_DARWIN) # include <sys/types.h> diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index a1b0a684c5..43d98be47b 100644 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -31,6 +31,7 @@ #include "llsdserialize.h" #include "lltreeiterators.h" #include "llmetricperformancetester.h" +#include "llfasttimer.h" //---------------------------------------------------------------------------------------------- // LLMetricPerformanceTesterBasic : static methods and testers management @@ -90,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s // Return TRUE if this metric is requested or if the general default "catch all" metric is requested BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name) { - return (LLFastTimer::sMetricLog && ((LLFastTimer::sLogName == name) || (LLFastTimer::sLogName == DEFAULT_METRIC_NAME))); + return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME))); } /*static*/ @@ -193,8 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd) void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd) { - LLMutexLock lock(LLFastTimer::sLogLock); - LLFastTimer::sLogQueue.push((*sd)); + LLTrace::BlockTimer::pushLog(*sd); } void LLMetricPerformanceTesterBasic::outputTestResults() diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h index 319955ef93..9517e2db5e 100644 --- a/indra/llcommon/llmortician.h +++ b/indra/llcommon/llmortician.h @@ -28,6 +28,7 @@ #define LLMORTICIAN_H #include "stdtypes.h" +#include <list> class LL_COMMON_API LLMortician { diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h index d711ce2f74..2fe084afcd 100644 --- a/indra/llcommon/llprocess.h +++ b/indra/llcommon/llprocess.h @@ -38,8 +38,7 @@ #include <stdexcept> #if LL_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include <windows.h> // HANDLE (eye roll) +#include "llwin32headerslean.h" // for HANDLE #elif LL_LINUX #if defined(Status) #undef Status diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 87a5930c14..6fe53396ca 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -32,9 +32,7 @@ //#include <memory> #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> -# include <windows.h> +# include "llwin32headerslean.h" # define _interlockedbittestandset _renamed_interlockedbittestandset # define _interlockedbittestandreset _renamed_interlockedbittestandreset # include <intrin.h> diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 1181c2d433..7cfc265c62 100644 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -30,6 +30,7 @@ #include "llinitparam.h" #include "boost/function.hpp" +#include "llfasttimer.h" struct LL_COMMON_API LLParamSDParserUtilities { diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp index ccd7ef91c2..e0e9056380 100644 --- a/indra/llcommon/llstacktrace.cpp +++ b/indra/llcommon/llstacktrace.cpp @@ -32,7 +32,7 @@ #include <iostream> #include <sstream> -#include "windows.h" +#include "llwin32headerslean.h" #include "Dbghelp.h" typedef USHORT NTAPI RtlCaptureStackBackTrace_Function( diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index fa0eb9f72c..9600928ad5 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -28,11 +28,10 @@ #include "llstring.h" #include "llerror.h" +#include "llfasttimer.h" #if LL_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> +#include "llwin32headerslean.h" #include <winnls.h> // for WideCharToMultiByte #endif diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 119efc7957..9d81ac25dd 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -31,8 +31,9 @@ #include <cstdio> #include <locale> #include <iomanip> +#include <algorithm> #include "llsd.h" -#include "llfasttimer.h" +#include "llformat.h" #if LL_LINUX || LL_SOLARIS #include <wctype.h> diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 6073bcd0a6..00b72ce1d8 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -42,6 +42,7 @@ #include "llprocessor.h" #include "llerrorcontrol.h" #include "llevents.h" +#include "llformat.h" #include "lltimer.h" #include "llsdserialize.h" #include "llsdutil.h" @@ -58,9 +59,7 @@ using namespace llsd; #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> -# include <windows.h> +# include "llwin32headerslean.h" # include <psapi.h> // GetPerformanceInfo() et al. #elif LL_DARWIN # include <errno.h> diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 23cebf4336..26063beff0 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -31,11 +31,9 @@ #include "u64.h" #if LL_WINDOWS -# define WIN32_LEAN_AND_MEAN -# include <winsock2.h> -# include <windows.h> +# include "llwin32headerslean.h" #elif LL_LINUX || LL_SOLARIS || LL_DARWIN -# include <errno.h> +# include <errno.h> # include <sys/time.h> #else # error "architecture not supported" diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index afb175c398..9346aa7a45 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -38,15 +38,15 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { gMasterThreadRecorder = new MasterThreadRecorder(); - Time::sCurTimerData = new Time::CurTimerData(); + BlockTimer::sCurTimerData = new CurTimerData(); } void cleanup() { delete gMasterThreadRecorder; gMasterThreadRecorder = NULL; - delete Time::sCurTimerData.get(); - Time::sCurTimerData = NULL; + delete BlockTimer::sCurTimerData.get(); + BlockTimer::sCurTimerData = NULL; } MasterThreadRecorder& getMasterThreadRecorder() diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index fb9dca5e84..61fed6e7b8 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -235,8 +235,8 @@ namespace LLTrace MeasurementAccumulator() : mSum(0), - mMin(std::numeric_limits<T>::max()), - mMax(std::numeric_limits<T>::min()), + mMin((std::numeric_limits<T>::max)()), + mMax((std::numeric_limits<T>::min)()), mMean(0), mVarianceSum(0), mNumSamples(0), @@ -380,6 +380,24 @@ namespace LLTrace U32 mNumSamples; }; + class TimerAccumulator + { + public: + void addSamples(const TimerAccumulator& other); + void reset(const TimerAccumulator* other); + + // + // members + // + U64 mSelfTimeCounter, + mTotalTimeCounter; + U32 mCalls; + class BlockTimer* mLastCaller; // used to bootstrap tree construction + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + }; + + template <typename T = F64> class Measurement : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 4dcadfdf29..efc54d240f 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -273,7 +273,7 @@ namespace LLTrace template <typename T> typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const { - T min_val = std::numeric_limits<T>::max(); + T min_val = (std::numeric_limits<T>::max)(); for (S32 i = 0; i < mNumPeriods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat)); @@ -284,7 +284,7 @@ namespace LLTrace template <typename T> F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const { - F64 min_val = std::numeric_limits<F64>::max(); + F64 min_val = (std::numeric_limits<F64>::max)(); for (S32 i = 0; i < mNumPeriods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat)); @@ -295,7 +295,7 @@ namespace LLTrace template <typename T> T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const { - T max_val = std::numeric_limits<T>::min(); + T max_val = (std::numeric_limits<T>::min)(); for (S32 i = 0; i < mNumPeriods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat)); @@ -306,7 +306,7 @@ namespace LLTrace template <typename T> F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const { - F64 max_val = std::numeric_limits<F64>::min(); + F64 max_val = (std::numeric_limits<F64>::min)(); for (S32 i = 0; i < mNumPeriods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat)); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 5a6ff14f97..0f111aab59 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lltracethreadrecorder.h" +#include "llfasttimer.h" namespace LLTrace { diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 4ac2197c11..1fe492fdce 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -33,18 +33,12 @@ namespace LLUnits { -template<typename T, typename IS_UNIT = void> +template<typename T> struct HighestPrecisionType { typedef T type_t; }; -template<typename T> -struct HighestPrecisionType<T, typename T::is_unit_tag_t> -{ - typedef typename HighestPrecisionType<typename T::storage_t>::type_t type_t; -}; - template<> struct HighestPrecisionType<F32> { typedef F64 type_t; }; template<> struct HighestPrecisionType<S32> { typedef S64 type_t; }; template<> struct HighestPrecisionType<U32> { typedef S64 type_t; }; @@ -78,7 +72,6 @@ struct LLUnit { typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t; typedef typename STORAGE_TYPE storage_t; - typedef void is_unit_tag_t; LLUnit(storage_t value = storage_t()) : mValue(value) diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index db8c9c85ab..83ed987d30 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -27,9 +27,7 @@ // We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes. #if LL_WINDOWS -#undef WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> +#include "llwin32headers.h" // ugh, this is ugly. We need to straighten out our linking for this library #pragma comment(lib, "IPHLPAPI.lib") #include <iphlpapi.h> diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h new file mode 100644 index 0000000000..80fd2e1768 --- /dev/null +++ b/indra/llcommon/llwin32headers.h @@ -0,0 +1,38 @@ +/** + * @file llwindows.h + * @brief sanitized include of windows header files + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLWINDOWS_H +#define LL_LLWINDOWS_H + +#ifdef LL_WINDOWS +#define NOMINMAX +#undef WIN32_LEAN_AND_MEAN +#include <winsock2.h> +#include <windows.h> +#undef NOMINMAX +#endif + +#endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h new file mode 100644 index 0000000000..ab6e9c09e2 --- /dev/null +++ b/indra/llcommon/llwin32headerslean.h @@ -0,0 +1,37 @@ +/** + * @file llwindows.h + * @brief sanitized include of windows header files + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLWINDOWS_H +#define LL_LLWINDOWS_H + +#ifdef LL_WINDOWS +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include <winsock2.h> +#include <windows.h> +#endif + +#endif diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h index eb2ecf71ba..47fcf688a2 100644 --- a/indra/llinventory/lleconomy.h +++ b/indra/llinventory/lleconomy.h @@ -27,6 +27,7 @@ #define LL_LLECONOMY_H #include "llsingleton.h" +#include <list> class LLMessageSystem; class LLVector3; diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index fbf23bc3f0..43aa2ab799 100644 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -28,6 +28,7 @@ #include "llinventory.h" #include "lldbstrings.h" +#include "llfasttimer.h" #include "llinventorydefines.h" #include "llxorcipher.h" #include "llsd.h" diff --git a/indra/llmessage/llfiltersd2xmlrpc.cpp b/indra/llmessage/llfiltersd2xmlrpc.cpp index e0ca056a5f..dbb8c4e28d 100644 --- a/indra/llmessage/llfiltersd2xmlrpc.cpp +++ b/indra/llmessage/llfiltersd2xmlrpc.cpp @@ -80,6 +80,7 @@ #include "llbuffer.h" #include "llbufferstream.h" +#include "llfasttimer.h" #include "llmemorystream.h" #include "llsd.h" #include "llsdserialize.h" diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index 1236fc8b71..f9d37b2e39 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -33,6 +33,7 @@ #include "llapr.h" #include "llbuffer.h" #include "llbufferstream.h" +#include "llfasttimer.h" #include "llhttpnode.h" #include "lliopipe.h" #include "lliosocket.h" diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index 0287026659..1383d37f41 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -32,6 +32,7 @@ #include "llapr.h" #include "llbuffer.h" +#include "llfasttimer.h" #include "llhost.h" #include "llpumpio.h" diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index be0f7dfcc6..4e07963af8 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -39,6 +39,7 @@ #include "lliopipe.h" #include "apr_pools.h" +#include "llwin32headerslean.h" #include "apr_network_io.h" #include "llchainio.h" diff --git a/indra/llmessage/llioutil.cpp b/indra/llmessage/llioutil.cpp index 8c50fd5069..9fd49d23d4 100644 --- a/indra/llmessage/llioutil.cpp +++ b/indra/llmessage/llioutil.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" #include "llioutil.h" +#include "llfasttimer.h" /** * LLIOFlush diff --git a/indra/llmessage/llmail.cpp b/indra/llmessage/llmail.cpp index 08b31e9c7a..dc27f2ca4a 100644 --- a/indra/llmessage/llmail.cpp +++ b/indra/llmessage/llmail.cpp @@ -29,12 +29,7 @@ #include "llmail.h" // APR on Windows needs full windows headers -#ifdef LL_WINDOWS -# undef WIN32_LEAN_AND_MEAN -# include <winsock2.h> -# include <windows.h> -#endif - +#include "llwin32headers.h" #include <string> #include <sstream> diff --git a/indra/llmessage/llpumpio.cpp b/indra/llmessage/llpumpio.cpp index 0623e99f0a..e3f09f34ee 100644 --- a/indra/llmessage/llpumpio.cpp +++ b/indra/llmessage/llpumpio.cpp @@ -34,6 +34,7 @@ #include "apr_poll.h" #include "llapr.h" +#include "llfasttimer.h" #include "llstl.h" // These should not be enabled in production, but they can be diff --git a/indra/llmessage/llsdrpcclient.cpp b/indra/llmessage/llsdrpcclient.cpp index fcda0e81a3..05b27f582c 100644 --- a/indra/llmessage/llsdrpcclient.cpp +++ b/indra/llmessage/llsdrpcclient.cpp @@ -30,6 +30,7 @@ #include "llsdrpcclient.h" #include "llbufferstream.h" +#include "llfasttimer.h" #include "llfiltersd2xmlrpc.h" #include "llpumpio.h" #include "llsd.h" diff --git a/indra/llmessage/llsdrpcserver.cpp b/indra/llmessage/llsdrpcserver.cpp index f26ee52f71..2c233c1c0d 100644 --- a/indra/llmessage/llsdrpcserver.cpp +++ b/indra/llmessage/llsdrpcserver.cpp @@ -31,6 +31,7 @@ #include "llbuffer.h" #include "llbufferstream.h" +#include "llfasttimer.h" #include "llpumpio.h" #include "llsdserialize.h" #include "llstl.h" diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index 5831c3c1c1..982f4804f0 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -33,6 +33,7 @@ #include <openssl/x509_vfy.h> #include <openssl/ssl.h> #include "llcurl.h" +#include "llfasttimer.h" #include "llioutil.h" #include "llproxy.h" #include "llpumpio.h" diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp index 85aef5da00..6f8508ee8c 100644 --- a/indra/llmessage/net.cpp +++ b/indra/llmessage/net.cpp @@ -32,9 +32,7 @@ #include <stdexcept> #if LL_WINDOWS - #define WIN32_LEAN_AND_MEAN - #include <winsock2.h> - #include <windows.h> +#include "llwin32headerslean.h" #else #include <sys/types.h> #include <sys/socket.h> diff --git a/indra/llplugin/llpluginprocesschild.h b/indra/llplugin/llpluginprocesschild.h index a9d6794e40..531422e792 100644 --- a/indra/llplugin/llpluginprocesschild.h +++ b/indra/llplugin/llpluginprocesschild.h @@ -29,6 +29,7 @@ #ifndef LL_LLPLUGINPROCESSCHILD_H #define LL_LLPLUGINPROCESSCHILD_H +#include <queue> #include "llpluginmessage.h" #include "llpluginmessagepipe.h" #include "llplugininstance.h" diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h index 990fc5cbae..24be7eb148 100644 --- a/indra/llplugin/llpluginprocessparent.h +++ b/indra/llplugin/llpluginprocessparent.h @@ -29,6 +29,8 @@ #ifndef LL_LLPLUGINPROCESSPARENT_H #define LL_LLPLUGINPROCESSPARENT_H +#include <queue> + #include "llapr.h" #include "llprocess.h" #include "llpluginmessage.h" diff --git a/indra/llplugin/tests/llplugincookiestore_test.cpp b/indra/llplugin/tests/llplugincookiestore_test.cpp index aefa1ca144..c2cb236cba 100644 --- a/indra/llplugin/tests/llplugincookiestore_test.cpp +++ b/indra/llplugin/tests/llplugincookiestore_test.cpp @@ -27,6 +27,7 @@ */ #include "linden_common.h" +#include <list> #include "../test/lltut.h" #include "../llplugincookiestore.h" diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 4dc2fcd714..d2d929fbf9 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -29,6 +29,7 @@ #include "llfontgl.h" // Linden library includes +#include "llfasttimer.h" #include "llfontfreetype.h" #include "llfontbitmapcache.h" #include "llfontregistry.h" diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 605b424b35..c9ce0d5588 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -540,11 +540,7 @@ extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; // LL_WINDOWS // windows gl headers depend on things like APIENTRY, so include windows. -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> -#undef min -#undef max +#include "llwin32headerslean.h" //---------------------------------------------------------------------------- #include <GL/gl.h> diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 5361d8e7be..751309af20 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -32,6 +32,7 @@ #include "llimagegl.h" #include "llerror.h" +#include "llfasttimer.h" #include "llimage.h" #include "llmath.h" diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 11b2681e52..45baf641fb 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -26,7 +26,7 @@ #include "linden_common.h" -#include <boost/static_assert.hpp> +#include "llfasttimer.h" #include "llsys.h" #include "llvertexbuffer.h" // #include "llrender.h" diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a1e1f8a988..e3b17dcb4f 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -30,6 +30,7 @@ #include "llrect.h" #include "llsd.h" +#include <list> #include <boost/function.hpp> //******************************************************* diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 17c9c09cb2..c366fd65db 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -100,10 +100,10 @@ private: BOOL mDisplayHistory; BOOL mDisplayMean; // If true, display mean, if false, display current value - LLTrace::TraceType<CountAccumulator<F64> >* mCountFloatp; - LLTrace::TraceType<CountAccumulator<S64> >* mCountIntp; - LLTrace::TraceType<MeasurementAccumulator<F64> >* mMeasurementFloatp; - LLTrace::TraceType<MeasurementAccumulator<S64> >* mMeasurementIntp; + LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mCountFloatp; + LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mCountIntp; + LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* mMeasurementFloatp; + LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* mMeasurementIntp; LLFrameTimer mUpdateTimer; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 09b34c2358..57856ff6f2 100644 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -57,10 +57,10 @@ public: struct StatParams : public LLInitParam::ChoiceBlock<StatParams> { - Alternative<LLTrace::TraceType<CountAccumulator<F64> >* > count_stat_float; - Alternative<LLTrace::TraceType<CountAccumulator<S64> >* > count_stat_int; - Alternative<LLTrace::TraceType<MeasurementAccumulator<F64> >* > measurement_stat_float; - Alternative<LLTrace::TraceType<MeasurementAccumulator<S64> >* > measurement_stat_int; + Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* > count_stat_float; + Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* > count_stat_int; + Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* > measurement_stat_float; + Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* > measurement_stat_int; }; struct Params : public LLInitParam::Block<Params, LLView::Params> @@ -105,8 +105,8 @@ public: /*virtual*/ void setValue(const LLSD& value); private: - LLTrace::count_common_float_t* mNewStatFloatp; - LLTrace::count_common_int_t* mNewStatIntp; + LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mNewStatFloatp; + LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mNewStatIntp; BOOL mPerSec; diff --git a/indra/llui/lluistring.cpp b/indra/llui/lluistring.cpp index c4e073ccdb..23fc53ea88 100644 --- a/indra/llui/lluistring.cpp +++ b/indra/llui/lluistring.cpp @@ -26,6 +26,8 @@ #include "linden_common.h" #include "lluistring.h" + +#include "llfasttimer.h" #include "llsd.h" #include "lltrans.h" diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 0c91390bc1..903f10ce10 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -29,7 +29,7 @@ #include "llxuiparser.h" #include "llxmlnode.h" - +#include "llfasttimer.h" #ifdef LL_STANDALONE #include <expat.h> #else diff --git a/indra/llvfs/llpidlock.cpp b/indra/llvfs/llpidlock.cpp index 0424f2379e..3b83d1b9e3 100644 --- a/indra/llvfs/llpidlock.cpp +++ b/indra/llvfs/llpidlock.cpp @@ -36,7 +36,7 @@ #if LL_WINDOWS //For windows platform. -#include <windows.h> +#include "llwin32headerslean.h" namespace { inline DWORD getpid() { diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp index 7f631ef0bb..d3f5673485 100644 --- a/indra/llvfs/llvfile.cpp +++ b/indra/llvfs/llvfile.cpp @@ -32,6 +32,7 @@ #include "llthread.h" #include "llvfs.h" #include "lltimer.h" +#include "llfasttimer.h" const S32 LLVFile::READ = 0x00000001; const S32 LLVFile::WRITE = 0x00000002; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index c155c1b362..276074d4ca 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -28,6 +28,7 @@ #define LL_LLKEYBOARD_H #include <map> +#include <boost/function.hpp> #include "string_table.h" #include "lltimer.h" diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp index be3fe5deb0..b76d526c5a 100644 --- a/indra/llwindow/llkeyboardwin32.cpp +++ b/indra/llwindow/llkeyboardwin32.cpp @@ -28,10 +28,7 @@ #include "linden_common.h" -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> - +#include "llwin32headerslean.h" #include "llkeyboardwin32.h" #include "llwindowcallbacks.h" diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 4da87f4e06..f378203a88 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -31,6 +31,7 @@ #include "llcoord.h" #include "llstring.h" #include "llcursortypes.h" +#include "llinstancetracker.h" #include "llsd.h" class LLSplashScreen; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 43c0090993..6d887926fa 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -38,6 +38,7 @@ // Linden library includes #include "llerror.h" +#include "llfasttimer.h" #include "llgl.h" #include "llstring.h" #include "lldir.h" diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 54c9ac4d4d..169d264808 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -28,9 +28,7 @@ #define LL_LLWINDOWWIN32_H // Limit Windows API to small and manageable set. -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> +#include "llwin32headerslean.h" #include "llwindow.h" #include "llwindowcallbacks.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ac659c409b..c6ed8d5071 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -679,7 +679,7 @@ bool LLAppViewer::init() // into the log files during normal startup until AFTER // we run the "program crashed last time" error handler below. // - LLFastTimer::reset(); + LLTrace::BlockTimer::reset(); // initialize SSE options LLVector4a::initClass(); @@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop() while (!LLApp::isExiting()) { LLFastTimer _(FTM_FRAME); - LLFastTimer::nextFrame(); + LLTrace::BlockTimer::nextFrame(); LLTrace::getMasterThreadRecorder().pullFromSlaveThreads(); //clear call stack records @@ -1552,9 +1552,9 @@ bool LLAppViewer::cleanup() if (LLFastTimerView::sAnalyzePerformance) { llinfos << "Analyzing performance" << llendl; - std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp"; - std::string current_name = LLFastTimer::sLogName + ".slp"; - std::string report_name = LLFastTimer::sLogName + "_report.csv"; + std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp"; + std::string current_name = LLTrace::BlockTimer::sLogName + ".slp"; + std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv"; LLFastTimerView::doAnalysis( gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name), @@ -1900,9 +1900,9 @@ bool LLAppViewer::cleanup() { llinfos << "Analyzing performance" << llendl; - std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp"; - std::string current_name = LLFastTimer::sLogName + ".slp"; - std::string report_name = LLFastTimer::sLogName + "_report.csv"; + std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp"; + std::string current_name = LLTrace::BlockTimer::sLogName + ".slp"; + std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv"; LLFastTimerView::doAnalysis( gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name), @@ -2031,10 +2031,10 @@ bool LLAppViewer::initThreads() enable_threads && true, app_metrics_qa_mode); - if (LLFastTimer::sLog || LLFastTimer::sMetricLog) + if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) { - LLFastTimer::sLogLock = new LLMutex(NULL); - mFastTimerLogThread = new LLFastTimerLogThread(LLFastTimer::sLogName); + LLTrace::BlockTimer::sLogLock = new LLMutex(NULL); + mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName); mFastTimerLogThread->start(); } @@ -2445,13 +2445,13 @@ bool LLAppViewer::initConfiguration() if (clp.hasOption("logperformance")) { - LLFastTimer::sLog = TRUE; - LLFastTimer::sLogName = std::string("performance"); + LLTrace::BlockTimer::sLog = true; + LLTrace::BlockTimer::sLogName = std::string("performance"); } if (clp.hasOption("logmetrics")) { - LLFastTimer::sMetricLog = TRUE ; + LLTrace::BlockTimer::sMetricLog = true ; // '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test // In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...) std::string test_name = clp.getOption("logmetrics")[0]; @@ -2459,11 +2459,11 @@ bool LLAppViewer::initConfiguration() if (test_name == "") { llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl; - LLFastTimer::sLogName = DEFAULT_METRIC_NAME; + LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME; } else { - LLFastTimer::sLogName = test_name; + LLTrace::BlockTimer::sLogName = test_name; } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 0934028a8c..d0bb75225c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240; static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t; +typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -92,18 +92,18 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount(); + FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount(); mPrintStats = -1; } void LLFastTimerView::onPause() { - LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory; + LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory; // reset scroll to bottom when unpausing - if (!LLFastTimer::sPauseHistory) + if (!LLTrace::BlockTimer::sPauseHistory) { mScrollIndex = 0; - LLFastTimer::sResetHistory = true; + LLTrace::BlockTimer::sResetHistory = true; getChild<LLButton>("pause_btn")->setLabel(getString("pause")); } else @@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) { S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()); bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY); - mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y) +LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* idp = getLegendID(y); + LLTrace::BlockTimer* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -208,16 +208,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) gFocusMgr.setMouseCapture(this); return TRUE; } - //else - //{ - // // pause/unpause - // LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory; - // // reset scroll to bottom when unpausing - // if (!LLFastTimer::sPauseHistory) - // { - // mScrollIndex = 0; - // } - //} + return LLFloater::handleMouseDown(x, y, mask); } @@ -235,14 +226,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex()); + mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llclamp( mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); @@ -288,7 +279,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* timer_id = getLegendID(y); + LLTrace::BlockTimer* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -299,7 +290,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1) +static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) { F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); @@ -318,7 +309,7 @@ static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_ind BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -326,7 +317,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -341,7 +332,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* idp = getLegendID(y); + LLTrace::BlockTimer* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp)); @@ -356,16 +347,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLFastTimer::sPauseHistory = TRUE; + LLTrace::BlockTimer::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } -static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true); +static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true); -static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors; +static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors; void LLFastTimerView::draw() { @@ -429,7 +420,7 @@ void LLFastTimerView::draw() y -= (texth + 2); } - S32 histmax = llmin(LLFastTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); + S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); // Draw the legend xleft = margin; @@ -445,7 +436,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -465,12 +456,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map<LLFastTimer::DeclareTimer*, S32> display_line; + std::map<LLTrace::BlockTimer*, S32> display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -490,7 +481,7 @@ void LLFastTimerView::draw() S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; U64 ticks = idp->getHistoricalCount(hidx); ms = (F32)((F64)ticks * iclock_freq); calls = (S32)idp->getHistoricalCalls(hidx); @@ -528,7 +519,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::DeclareTimer* next_parent = idp->getParent(); + LLTrace::BlockTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -570,18 +561,18 @@ void LLFastTimerView::draw() barw = width - xleft - margin; // Draw the history bars - if (LLFastTimer::getLastFrameIndex() >= 0) + if (LLTrace::BlockTimer::getLastFrameIndex() >= 0) { LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); U64 totalticks; - if (!LLFastTimer::sPauseHistory) + if (!LLTrace::BlockTimer::sPauseHistory) { U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex); - if (LLFastTimer::getCurFrameIndex() >= 10) + if (LLTrace::BlockTimer::getCurFrameIndex() >= 10) { - U64 framec = LLFastTimer::getCurFrameIndex(); + U64 framec = LLTrace::BlockTimer::getCurFrameIndex(); U64 avg = (U64)mAvgCountTotal; mAvgCountTotal = (avg*framec + ticks) / (framec + 1); if (ticks > mMaxCountTotal) @@ -592,14 +583,14 @@ void LLFastTimerView::draw() if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100) { - LLFastTimer::sResetHistory = true; + LLTrace::BlockTimer::sResetHistory = true; } - if (LLFastTimer::getCurFrameIndex() < 10 || LLFastTimer::sResetHistory) + if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory) { mAvgCountTotal = ticks; mMaxCountTotal = ticks; - LLFastTimer::sResetHistory = false; + LLTrace::BlockTimer::sResetHistory = false; } } @@ -706,7 +697,7 @@ void LLFastTimerView::draw() S32 tidx; if (j >= 0) { - tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex; + tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex; } else { @@ -720,14 +711,14 @@ void LLFastTimerView::draw() std::vector<S32> deltax; xpos.push_back(xleft); - LLFastTimer::DeclareTimer* prev_id = NULL; + LLTrace::BlockTimer* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); F32 frac = tidx == -1 ? (F32)idp->getCountAverage() / (F32)totalticks : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; @@ -754,7 +745,7 @@ void LLFastTimerView::draw() { U64 sublevelticks = 0; - for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren(); + for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -796,7 +787,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::DeclareTimer* next_parent = idp->getParent(); + LLTrace::BlockTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -861,10 +852,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex; + S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -891,7 +882,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -915,8 +906,8 @@ void LLFastTimerView::draw() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); - j < LLFastTimer::DeclareTimer::HISTORY_NUM; + for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex()); + j < LLTrace::BlockTimer::HISTORY_NUM; j++) { U64 ticks = idp->getHistoricalCount(j); @@ -937,7 +928,7 @@ void LLFastTimerView::draw() //normalize to highlighted timer cur_max = llmax(cur_max, ticks); } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j; + F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j; F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); @@ -992,7 +983,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); if (!first) { @@ -1014,7 +1005,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); if (!first) { @@ -1551,13 +1542,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLFastTimer::sLog) + if(LLTrace::BlockTimer::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLFastTimer::sMetricLog) + if(LLTrace::BlockTimer::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1568,7 +1559,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer() +LLTrace::BlockTimer& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 01a3501e4b..d7f7f27cd4 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -46,7 +46,7 @@ private: static LLSD analyzePerformanceLogDefault(std::istream& is) ; static void exportCharts(const std::string& base, const std::string& target); void onPause(); - LLFastTimer::DeclareTimer& getFrameTimer(); + LLTrace::BlockTimer& getFrameTimer(); public: @@ -59,7 +59,7 @@ public: virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual void draw(); - LLFastTimer::DeclareTimer* getLegendID(S32 y); + LLTrace::BlockTimer* getLegendID(S32 y); F64 getTime(const std::string& name); protected: @@ -85,8 +85,8 @@ private: U64 mMaxCountTotal; LLRect mBarRect; S32 mScrollIndex; - LLFastTimer::DeclareTimer* mHoverID; - LLFastTimer::DeclareTimer* mHoverTimer; + LLTrace::BlockTimer* mHoverID; + LLTrace::BlockTimer* mHoverTimer; LLRect mToolTipRect; S32 mHoverBarIndex; LLFrameTimer mHighlightTimer; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 3136358b83..6bba375f50 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -31,6 +31,7 @@ #include "llassetstorage.h" #include "llinventorytype.h" #include "llfilepicker.h" +#include <queue> class LLTransactionID; -- cgit v1.2.3 From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 15 Nov 2012 19:46:09 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and max macros from windows.h got rest of viewer to compile against llfasttimer changes --- indra/cmake/00-Common.cmake | 1 + indra/llcommon/llapr.h | 1 + indra/llcommon/llfasttimer.cpp | 5 +++++ indra/llcommon/llfasttimer.h | 3 ++- indra/llcommon/llthread.h | 2 ++ indra/llcommon/lltrace.cpp | 1 - indra/llcommon/llwin32headers.h | 2 -- indra/llcommon/llwin32headerslean.h | 1 - indra/llmessage/lliopipe.h | 1 + indra/llmessage/lliosocket.h | 2 +- indra/newview/llappviewer.cpp | 2 +- indra/newview/llfasttimerview.cpp | 8 ++++---- indra/newview/llfloatermodelpreview.cpp | 2 -- indra/newview/llviewerstatsrecorder.h | 2 +- indra/newview/llxmlrpctransaction.cpp | 2 ++ indra/test/test.cpp | 4 +++- 16 files changed, 24 insertions(+), 15 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 21cb87237d..180714c9c9 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -58,6 +58,7 @@ if (WINDOWS) add_definitions( /DLL_WINDOWS=1 + /DNOMINMAX /DDOM_DYNAMIC /DUNICODE /D_UNICODE diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index c77d96c1c9..d9fe257e86 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -40,6 +40,7 @@ #include "apr_getopt.h" #include "apr_signal.h" #include "apr_atomic.h" + #include "llstring.h" #include "llinstancetracker.h" diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index d007f76e5f..4ecca12832 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -121,6 +121,11 @@ void BlockTimer::pushLog(LLSD log) sLogQueue.push(log); } +void BlockTimer::setLogLock(LLMutex* lock) +{ + sLogLock = lock; +} + //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 69a6773b12..af9b360e01 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -98,6 +98,7 @@ public: static BlockTimer& getRootTimer(); static void pushLog(LLSD sd); + static void setLogLock(LLMutex* mutex); friend class Time; @@ -329,6 +330,6 @@ LL_FORCE_INLINE Time::~Time() } -typedef LLTrace::Time LLFastTimer; +typedef LLTrace::Time LLFastTimer; #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 82ab5f47d2..93c752754d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,6 +32,8 @@ #include "apr_thread_cond.h" #include "llmutex.h" +LL_COMMON_API void assert_main_thread(); + class LL_COMMON_API LLThread { private: diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9346aa7a45..9bf9ae6c8e 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -59,7 +59,6 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() { static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; return s_thread_recorder; - } } diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index 80fd2e1768..9c89b6b280 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,11 +28,9 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS -#define NOMINMAX #undef WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> -#undef NOMINMAX #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h index ab6e9c09e2..d3fb90d4b1 100644 --- a/indra/llcommon/llwin32headerslean.h +++ b/indra/llcommon/llwin32headerslean.h @@ -28,7 +28,6 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS -#define NOMINMAX #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> diff --git a/indra/llmessage/lliopipe.h b/indra/llmessage/lliopipe.h index cbd17b5a3d..9a0a427efd 100644 --- a/indra/llmessage/lliopipe.h +++ b/indra/llmessage/lliopipe.h @@ -31,6 +31,7 @@ #include <boost/intrusive_ptr.hpp> #include <boost/shared_ptr.hpp> +#include "llwin32headerslean.h" #include "apr_poll.h" #include "llsd.h" diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index 4e07963af8..ec998552d0 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -38,8 +38,8 @@ */ #include "lliopipe.h" -#include "apr_pools.h" #include "llwin32headerslean.h" +#include "apr_pools.h" #include "apr_network_io.h" #include "llchainio.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c6ed8d5071..9d4ed833b8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2033,7 +2033,7 @@ bool LLAppViewer::initThreads() if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) { - LLTrace::BlockTimer::sLogLock = new LLMutex(NULL); + LLTrace::BlockTimer::setLogLock(new LLMutex(NULL)); mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName); mFastTimerLogThread->start(); } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index d0bb75225c..7a5c9dba46 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount(); + FTV_NUM_TIMERS = LLInstanceTracker<LLTrace::BlockTimer>::instanceCount(); mPrintStats = -1; } @@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, + mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -292,7 +292,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) { - F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); std::string tooltip; if (history_index < 0) @@ -364,7 +364,7 @@ void LLFastTimerView::draw() std::string tdesc; - F64 clock_freq = (F64)LLFastTimer::countsPerSecond(); + F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; S32 margin = 10; diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index a071f338ba..a5e3cd404d 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -113,8 +113,6 @@ #include "llviewernetwork.h" #include "llviewershadermgr.h" #include "glod/glod.h" -#include <boost/algorithm/string.hpp> - const S32 SLM_SUPPORTED_VERSION = 3; diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h index ce6dd63ec5..d1744f4910 100644 --- a/indra/newview/llviewerstatsrecorder.h +++ b/indra/newview/llviewerstatsrecorder.h @@ -32,7 +32,7 @@ // for analysis. // This is normally 0. Set to 1 to enable viewer stats recording -#define LL_RECORD_VIEWER_STATS 1 +#define LL_RECORD_VIEWER_STATS 0 #include "llframetimer.h" diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 0da70d398b..583196fb7a 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -25,6 +25,8 @@ */ #include "llviewerprecompiledheaders.h" +// include this to get winsock2 because openssl attempts to include winsock1 +#include "llwin32headerslean.h" #include <openssl/x509_vfy.h> #include <openssl/ssl.h> #include "llsecapi.h" diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 2b66c6aa26..8bd302ce7a 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -40,6 +40,7 @@ #include "tests/wrapllerrs.h" // RecorderProxy #include "stringize.h" #include "namedtempfile.h" +#include "lltrace.h" #include "apr_pools.h" #include "apr_getopt.h" @@ -513,7 +514,8 @@ int main(int argc, char **argv) #endif ll_init_apr(); - + LLTrace::init(); + apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { -- cgit v1.2.3 From 6db6cb39f41e921e75970d1570a74cf35d353a35 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 16 Nov 2012 23:02:53 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system got new fast timer code to compile and run --- indra/llcommon/llfasttimer.cpp | 13 +++++++++++- indra/llcommon/lltrace.cpp | 12 ++++++++--- indra/llcommon/lltrace.h | 6 ++++++ indra/llcommon/lltracethreadrecorder.cpp | 4 ++++ indra/llmessage/llurlrequest.cpp | 4 ++-- indra/newview/llagentcamera.cpp | 5 +++-- indra/newview/llappviewer.cpp | 8 ++++---- indra/newview/llinventorypanel.cpp | 3 ++- indra/newview/llstartup.cpp | 2 +- indra/newview/llviewerobjectlist.cpp | 6 +++--- indra/newview/llviewerwindow.cpp | 3 ++- indra/newview/pipeline.cpp | 35 ++++---------------------------- 12 files changed, 52 insertions(+), 49 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 4ecca12832..e1549b4bff 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -336,7 +336,10 @@ void BlockTimer::accumulateTimings() cur_data = &cur_timer->mLastTimerData; cur_data->mChildTime += cumulative_time_delta; - accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + if (cur_data->mTimerData) + { + accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + } cur_timer = cur_timer->mLastTimerData.mCurTimer; } @@ -572,6 +575,14 @@ void Time::writeLog(std::ostream& os) } +LLTrace::TimerAccumulator::TimerAccumulator() : mSelfTimeCounter(0), + mTotalTimeCounter(0), + mCalls(0), + mLastCaller(NULL), + mActiveCount(0), + mMoveUpTree(false) +{} + void LLTrace::TimerAccumulator::addSamples( const LLTrace::TimerAccumulator& other ) { mSelfTimeCounter += other.mSelfTimeCounter; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9bf9ae6c8e..e11e39a1a2 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,6 +30,8 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" +static bool sInitialized; + namespace LLTrace { @@ -38,15 +40,18 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { gMasterThreadRecorder = new MasterThreadRecorder(); - BlockTimer::sCurTimerData = new CurTimerData(); + sInitialized = true; +} + +bool isInitialized() +{ + return sInitialized; } void cleanup() { delete gMasterThreadRecorder; gMasterThreadRecorder = NULL; - delete BlockTimer::sCurTimerData.get(); - BlockTimer::sCurTimerData = NULL; } MasterThreadRecorder& getMasterThreadRecorder() @@ -62,3 +67,4 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() } } + diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 61fed6e7b8..61d14569cd 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -67,6 +67,7 @@ namespace LLTrace void init(); void cleanup(); + bool isInitialized(); LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); @@ -162,6 +163,10 @@ namespace LLTrace // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned size_t reserveSlot() { + if (LLTrace::isInitialized()) + { + llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; + } size_t next_slot = mNextStorageSlot++; if (next_slot >= mStorageSize) { @@ -383,6 +388,7 @@ namespace LLTrace class TimerAccumulator { public: + TimerAccumulator(); void addSamples(const TimerAccumulator& other); void reset(const TimerAccumulator* other); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 0f111aab59..c2fefe2957 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -40,6 +40,8 @@ ThreadRecorder::ThreadRecorder() { get_thread_recorder() = this; mFullRecording.start(); + + BlockTimer::sCurTimerData = new CurTimerData(); } ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) @@ -52,6 +54,8 @@ ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) ThreadRecorder::~ThreadRecorder() { get_thread_recorder() = NULL; + delete BlockTimer::sCurTimerData.get(); + BlockTimer::sCurTimerData = NULL; } void ThreadRecorder::activate( Recording* recording ) diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index 982f4804f0..0e5fe1de08 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -281,6 +281,8 @@ LLIOPipe::EStatus LLURLRequest::handleError( static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST("URL Request"); static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result"); static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform"); +static LLFastTimer::DeclareTimer FTM_PROCESS_URL_PUMP_RESPOND("Pump Respond"); +static LLFastTimer::DeclareTimer FTM_URL_ADJUST_TIMEOUT("Adjust Timeout"); // virtual LLIOPipe::EStatus LLURLRequest::process_impl( @@ -300,7 +302,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl( const S32 MIN_ACCUMULATION = 100000; if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION)) { - static LLFastTimer::DeclareTimer FTM_URL_ADJUST_TIMEOUT("Adjust Timeout"); LLFastTimer t(FTM_URL_ADJUST_TIMEOUT); // This is a pretty sloppy calculation, but this // tries to make the gross assumption that if data @@ -398,7 +399,6 @@ LLIOPipe::EStatus LLURLRequest::process_impl( link.mChannels = LLBufferArray::makeChannelConsumer( channels); chain.push_back(link); - static LLFastTimer::DeclareTimer FTM_PROCESS_URL_PUMP_RESPOND("Pump Respond"); { LLFastTimer t(FTM_PROCESS_URL_PUMP_RESPOND); pump->respond(chain, buffer, context); diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 8d80e3aa0a..4e6079e3f2 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1137,13 +1137,14 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) } } +static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Camera"); + //----------------------------------------------------------------------------- // updateCamera() //----------------------------------------------------------------------------- void LLAgentCamera::updateCamera() { - static LLFastTimer::DeclareTimer ftm("Camera"); - LLFastTimer t(ftm); + LLFastTimer t(FTM_UPDATE_CAMERA); // - changed camera_skyward to the new global "mCameraUpVector" mCameraUpVector = LLVector3::z_axis; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 9d4ed833b8..547eb2fefe 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4126,6 +4126,8 @@ static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World"); static LLFastTimer::DeclareTimer FTM_NETWORK("Network"); static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network"); static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager"); +static LLFastTimer::DeclareTimer FTM_AGENT_POSITION("Agent Position"); +static LLFastTimer::DeclareTimer FTM_HUD_EFFECTS("HUD Effects"); /////////////////////////////////////////////////////// // idle() @@ -4362,8 +4364,7 @@ void LLAppViewer::idle() { // Handle pending gesture processing - static LLFastTimer::DeclareTimer ftm("Agent Position"); - LLFastTimer t(ftm); + LLFastTimer t(FTM_AGENT_POSITION); LLGestureMgr::instance().update(); gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY); @@ -4410,8 +4411,7 @@ void LLAppViewer::idle() // { - static LLFastTimer::DeclareTimer ftm("HUD Effects"); - LLFastTimer t(ftm); + LLFastTimer t(FTM_HUD_EFFECTS); LLSelectMgr::getInstance()->updateEffects(); LLHUDManager::getInstance()->cleanupEffects(); LLHUDManager::getInstance()->sendEffects(); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index f7567baa2b..4c10717ce8 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -396,9 +396,10 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState() return getFilter()->getShowFolderState(); } +static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh"); + void LLInventoryPanel::modelChanged(U32 mask) { - static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh"); LLFastTimer t2(FTM_REFRESH); bool handled = false; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index bf47bd44c3..5f6772bf0b 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2184,7 +2184,7 @@ bool idle_startup() LLAppViewer::instance()->handleLoginComplete(); // reset timers now that we are running "logged in" logic - LLFastTimer::reset(); + LLTrace::BlockTimer::reset(); LLAgentPicksInfo::getInstance()->requestNumberOfPicks(); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 9c6045943f..1bd028688a 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -850,6 +850,8 @@ private: LLSD mObjectIDs; }; +static LLFastTimer::DeclareTimer FTM_IDLE_COPY("Idle Copy"); + void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { // Update globals @@ -900,10 +902,8 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) U32 idle_count = 0; - static LLFastTimer::DeclareTimer idle_copy("Idle Copy"); - { - LLFastTimer t(idle_copy); + LLFastTimer t(FTM_IDLE_COPY); for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin(); active_iter != mActiveObjects.end(); active_iter++) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8e72ca1d74..dea55fd0b0 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2760,11 +2760,12 @@ void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params) } } +static LLFastTimer::DeclareTimer ftm("Update UI"); + // Update UI based on stored mouse position from mouse-move // event processing. void LLViewerWindow::updateUI() { - static LLFastTimer::DeclareTimer ftm("Update UI"); LLFastTimer t(ftm); static std::string last_handle_msg; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5ac5ae892a..acf3a4e74c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1886,6 +1886,8 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list) static LLFastTimer::DeclareTimer FTM_OCTREE_BALANCE("Balance Octree"); static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move"); +static LLFastTimer::DeclareTimer FTM_RETEXTURE("Retexture"); +static LLFastTimer::DeclareTimer FTM_MOVED_LIST("Moved List"); void LLPipeline::updateMove() { @@ -1899,8 +1901,7 @@ void LLPipeline::updateMove() assertInitialized(); { - static LLFastTimer::DeclareTimer ftm("Retexture"); - LLFastTimer t(ftm); + LLFastTimer t(FTM_RETEXTURE); for (LLDrawable::drawable_set_t::iterator iter = mRetexturedList.begin(); iter != mRetexturedList.end(); ++iter) @@ -1915,8 +1916,7 @@ void LLPipeline::updateMove() } { - static LLFastTimer::DeclareTimer ftm("Moved List"); - LLFastTimer t(ftm); + LLFastTimer t(FTM_MOVED_LIST); updateMovedList(mMovedList); } @@ -3688,33 +3688,6 @@ void LLPipeline::postSort(LLCamera& camera) } } - /*static LLFastTimer::DeclareTimer FTM_TRANSFORM_WAIT("Transform Fence"); - static LLFastTimer::DeclareTimer FTM_TRANSFORM_DO_WORK("Transform Work"); - if (use_transform_feedback) - { //using transform feedback, wait for transform feedback to complete - LLFastTimer t(FTM_TRANSFORM_WAIT); - - S32 done = 0; - //glGetQueryivARB(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_CURRENT_QUERY, &count); - - glGetQueryObjectivARB(mMeshDirtyQueryObject, GL_QUERY_RESULT_AVAILABLE, &done); - - while (!done) - { - { - LLFastTimer t(FTM_TRANSFORM_DO_WORK); - F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f); - //do some useful work while we wait - LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread - LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread - LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread - } - glGetQueryObjectivARB(mMeshDirtyQueryObject, GL_QUERY_RESULT_AVAILABLE, &done); - } - - mTransformFeedbackPrimitives = 0; - }*/ - //LLSpatialGroup::sNoDelete = FALSE; llpushcallstacks ; } -- cgit v1.2.3 From 5d51175cd79b15cf036cd7e6bd646a1a0777eb7f Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 20 Nov 2012 15:55:04 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixes to merge --- indra/llcommon/llmemory.h | 2 +- indra/llcommon/llmutex.cpp | 49 +------------ indra/llcommon/llmutex.h | 67 ----------------- indra/llcommon/llthread.cpp | 153 +-------------------------------------- indra/llcommon/llthread.h | 2 +- indra/llcommon/llunit.h | 40 +++++----- indra/llmath/llvolume.cpp | 4 + indra/newview/gpu_table.txt | 10 --- indra/newview/lltexturefetch.cpp | 12 +-- indra/newview/lltexturefetch.h | 2 +- indra/newview/lltextureview.cpp | 4 +- 11 files changed, 42 insertions(+), 303 deletions(-) diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 3744e68956..e725bdd9fa 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -26,7 +26,7 @@ #ifndef LLMEMORY_H #define LLMEMORY_H -#include "llmemtype.h" +#include "linden_common.h" class LLMutex ; diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index 2ce14b3a2e..e6beb9e680 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -86,7 +86,7 @@ void LLMutex::lock() #if LL_DARWIN mLockingThread = LLThread::currentID(); #else - mLockingThread = LLThread::sThreadIndex; + mLockingThread = LLThread::sThreadID; #endif } @@ -129,7 +129,7 @@ bool LLMutex::isSelfLocked() #if LL_DARWIN return mLockingThread == LLThread::currentID(); #else - return mLockingThread == LLThread::sThreadIndex; + return mLockingThread == LLThread::sThreadID; #endif } @@ -181,49 +181,4 @@ void LLCondition::broadcast() } -//============================================================================ - -//---------------------------------------------------------------------------- - -//static -LLMutex* LLThreadSafeRefCount::sMutex = 0; - -//static -void LLThreadSafeRefCount::initThreadSafeRefCount() -{ - if (!sMutex) - { - sMutex = new LLMutex(0); - } -} - -//static -void LLThreadSafeRefCount::cleanupThreadSafeRefCount() -{ - delete sMutex; - sMutex = NULL; -} - - -//---------------------------------------------------------------------------- - -LLThreadSafeRefCount::LLThreadSafeRefCount() : -mRef(0) -{ -} - -LLThreadSafeRefCount::~LLThreadSafeRefCount() -{ - if (mRef != 0) - { - llerrs << "deleting non-zero reference" << llendl; - } -} - -//============================================================================ - -LLResponder::~LLResponder() -{ -} - //============================================================================ diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index bd0a59b577..cbde4c47a9 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -98,71 +98,4 @@ private: LLMutex* mMutex; }; - -//============================================================================ - -// see llmemory.h for LLPointer<> definition - -class LL_COMMON_API LLThreadSafeRefCount -{ -public: - static void initThreadSafeRefCount(); // creates sMutex - static void cleanupThreadSafeRefCount(); // destroys sMutex - -private: - static LLMutex* sMutex; - -private: - LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented - LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - - void ref() - { - if (sMutex) sMutex->lock(); - mRef++; - if (sMutex) sMutex->unlock(); - } - - S32 unref() - { - llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) - { - delete this; - return 0; - } - return res; - } - S32 getNumRefs() const - { - return mRef; - } - -private: - S32 mRef; -}; - - -//============================================================================ - -// Simple responder for self destructing callbacks -// Pure virtual class -class LL_COMMON_API LLResponder : public LLThreadSafeRefCount -{ -protected: - virtual ~LLResponder(); -public: - virtual void completed(bool success) = 0; -}; - - #endif // LL_LLTHREAD_H diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 1c86eb4f06..8ce739bf23 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -62,7 +62,7 @@ #if LL_DARWIN // statically allocated thread local storage not supported in Darwin executable formats #elif LL_WINDOWS -U32 __declspec(thread) LLThread::sThreadIndex = 0; +U32 __declspec(thread) LLThread::sThreadID = 0; #elif LL_LINUX U32 __thread LLThread::sThreadID = 0; #endif @@ -96,7 +96,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap LLTrace::ThreadRecorder* thread_recorder = new LLTrace::SlaveThreadRecorder(); #if !LL_DARWIN - sThreadIndex = threadp->mID; + sThreadID = threadp->mID; #endif // Run the user supplied function @@ -327,155 +327,6 @@ void LLThread::wakeLocked() //============================================================================ -LLMutex::LLMutex(apr_pool_t *poolp) : - mAPRMutexp(NULL), mCount(0), mLockingThread(NO_THREAD) -{ - //if (poolp) - //{ - // mIsLocalPool = FALSE; - // mAPRPoolp = poolp; - //} - //else - { - mIsLocalPool = TRUE; - apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread - } - apr_thread_mutex_create(&mAPRMutexp, APR_THREAD_MUTEX_UNNESTED, mAPRPoolp); -} - - -LLMutex::~LLMutex() -{ -#if MUTEX_DEBUG - //bad assertion, the subclass LLSignal might be "locked", and that's OK - //llassert_always(!isLocked()); // better not be locked! -#endif - apr_thread_mutex_destroy(mAPRMutexp); - mAPRMutexp = NULL; - if (mIsLocalPool) - { - apr_pool_destroy(mAPRPoolp); - } -} - - -void LLMutex::lock() -{ - if(isSelfLocked()) - { //redundant lock - mCount++; - return; - } - - apr_thread_mutex_lock(mAPRMutexp); - -#if MUTEX_DEBUG - // Have to have the lock before we can access the debug info - U32 id = LLThread::currentID(); - if (mIsLocked[id] != FALSE) - llerrs << "Already locked in Thread: " << id << llendl; - mIsLocked[id] = TRUE; -#endif - -#if LL_DARWIN - mLockingThread = LLThread::currentID(); -#else - mLockingThread = sThreadID; -#endif -} - -void LLMutex::unlock() -{ - if (mCount > 0) - { //not the root unlock - mCount--; - return; - } - -#if MUTEX_DEBUG - // Access the debug info while we have the lock - U32 id = LLThread::currentID(); - if (mIsLocked[id] != TRUE) - llerrs << "Not locked in Thread: " << id << llendl; - mIsLocked[id] = FALSE; -#endif - - mLockingThread = NO_THREAD; - apr_thread_mutex_unlock(mAPRMutexp); -} - -bool LLMutex::isLocked() -{ - apr_status_t status = apr_thread_mutex_trylock(mAPRMutexp); - if (APR_STATUS_IS_EBUSY(status)) - { - return true; - } - else - { - apr_thread_mutex_unlock(mAPRMutexp); - return false; - } -} - -bool LLMutex::isSelfLocked() -{ -#if LL_DARWIN - return mLockingThread == LLThread::currentID(); -#else - return mLockingThread == sThreadID; -#endif -} - -U32 LLMutex::lockingThread() const -{ - return mLockingThread; -} - -//============================================================================ - -LLCondition::LLCondition(apr_pool_t *poolp) : - LLMutex(poolp) -{ - // base class (LLMutex) has already ensured that mAPRPoolp is set up. - - apr_thread_cond_create(&mAPRCondp, mAPRPoolp); -} - - -LLCondition::~LLCondition() -{ - apr_thread_cond_destroy(mAPRCondp); - mAPRCondp = NULL; -} - - -void LLCondition::wait() -{ - if (!isLocked()) - { //mAPRMutexp MUST be locked before calling apr_thread_cond_wait - apr_thread_mutex_lock(mAPRMutexp); -#if MUTEX_DEBUG - // avoid asserts on destruction in non-release builds - U32 id = LLThread::currentID(); - mIsLocked[id] = TRUE; -#endif - } - apr_thread_cond_wait(mAPRCondp, mAPRMutexp); -} - -void LLCondition::signal() -{ - apr_thread_cond_signal(mAPRCondp); -} - -void LLCondition::broadcast() -{ - apr_thread_cond_broadcast(mAPRCondp); -} - -//============================================================================ - //---------------------------------------------------------------------------- //static diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 94b6b6d682..75222c83f9 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -42,7 +42,7 @@ private: #if LL_DARWIN // statically allocated thread local storage not supported in Darwin executable formats #elif LL_WINDOWS - static U32 __declspec(thread) LLThread::sThreadIndex; + static U32 __declspec(thread) LLThread::sThreadID; #elif LL_LINUX static U32 __thread LLThread::sThreadID ; #endif diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 1fe492fdce..53570779fc 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -109,9 +109,9 @@ struct LLUnit return mValue; } - template<typename NEW_UNIT_TYPE> LLUnit<NEW_UNIT_TYPE, STORAGE_TYPE> as() + template<typename NEW_UNIT_TYPE, typename NEW_STORAGE_TYPE> LLUnit<NEW_UNIT_TYPE, NEW_STORAGE_TYPE> as() { - return LLUnit<NEW_UNIT_TYPE, STORAGE_TYPE>(*this); + return LLUnit<NEW_UNIT_TYPE, NEW_STORAGE_TYPE>(*this); } void operator += (storage_t value) @@ -332,21 +332,27 @@ struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> > typedef typename HighestPrecisionType<STORAGE_TYPE>::type_t type_t; }; -#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor) \ -struct unit_name \ -{ \ - typedef base_unit_name base_unit_t; \ -}; \ -template<typename STORAGE_TYPE> \ -struct ConversionFactor<unit_name, base_unit_name, STORAGE_TYPE> \ -{ \ - static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() { return typename HighestPrecisionType<STORAGE_TYPE>::type_t(conversion_factor); } \ -}; \ - \ -template<typename STORAGE_TYPE> \ -struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \ -{ \ - static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() { return typename HighestPrecisionType<STORAGE_TYPE>::type_t(1.0 / (conversion_factor)); } \ +#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor) \ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ +}; \ +template<typename STORAGE_TYPE> \ +struct ConversionFactor<unit_name, base_unit_name, STORAGE_TYPE> \ +{ \ + static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() \ + { \ + return typename HighestPrecisionType<STORAGE_TYPE>::type_t(conversion_factor); \ + } \ +}; \ + \ +template<typename STORAGE_TYPE> \ +struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \ +{ \ + static typename HighestPrecisionType<STORAGE_TYPE>::type_t get() \ + { \ + return typename HighestPrecisionType<STORAGE_TYPE>::type_t(1.0 / (conversion_factor)); \ + } \ } struct Bytes { typedef Bytes base_unit_t; }; diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 02c8d2b86f..54b67832ea 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -6667,6 +6667,10 @@ void LLVolumeFace::resizeVertices(S32 num_verts) mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); ll_assert_aligned(mPositions, 16); mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); + if ( ((int)mNormals & 0xF) != 0 ) + { + __debugbreak(); + } ll_assert_aligned(mNormals, 16); //pad texture coordinate block end to allow for QWORD reads diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt index 2a07b5ed70..5e8189caa5 100644 --- a/indra/newview/gpu_table.txt +++ b/indra/newview/gpu_table.txt @@ -371,17 +371,10 @@ NVIDIA GTX 690M .*NVIDIA .*GTX *69*M.* 5 1 0 0 NVIDIA G100 .*NVIDIA .*G10.* 3 1 1 4.2 NVIDIA GT 120 .*NVIDIA .*GT *12.* 2 1 0 0 NVIDIA GT 130 .*NVIDIA .*GT *13.* 2 1 0 0 -NVIDIA GT 140 .*NVIDIA .*GT *140.* 2 1 0 0 -NVIDIA GT 150 .*NVIDIA .*GT *150.* 2 1 0 0 -NVIDIA GT 160 .*NVIDIA .*GT *160.* 2 1 0 0 NVIDIA GTS 150 .*NVIDIA .*GTS *15.* 2 1 0 0 NVIDIA 205 .*NVIDIA .*GeForce 205.* 2 1 1 3.3 NVIDIA 210 .*NVIDIA .*GeForce 210.* 3 1 1 3.3 NVIDIA GT 220 .*NVIDIA .*GT *22.* 2 1 1 3.3 -NVIDIA GT 230 .*NVIDIA .*GT *230.* 2 1 1 3.3 -NVIDIA GT 240 .*NVIDIA .*GT *240.* 2 1 1 3.3 -NVIDIA GT 250 .*NVIDIA .*GT *250.* 2 1 1 3.3 -NVIDIA GT 260 .*NVIDIA .*GT *260.* 2 1 1 3.3 NVIDIA GTS 240 .*NVIDIA .*GTS *24.* 4 1 1 3.3 NVIDIA GTS 250 .*NVIDIA .*GTS *25.* 4 1 1 3.3 NVIDIA GTX 260 .*NVIDIA .*GTX *26.* 4 1 1 3.3 @@ -394,11 +387,9 @@ NVIDIA GT 320 .*NVIDIA .*GT *32.* 3 1 0 0 NVIDIA GT 330 .*NVIDIA .*GT *33.* 3 1 0 0 NVIDIA GT 340 .*NVIDIA .*GT *34.* 3 1 0 0 NVIDIA 405 .*NVIDIA .* 405.* 3 1 0 0 -NVIDIA GT 415 .*NVIDIA .*GT *415.* 3 1 1 4.2 NVIDIA GT 420 .*NVIDIA .*GT *42.* 3 1 1 4.2 NVIDIA GT 430 .*NVIDIA .*GT *43.* 3 1 1 4.1 NVIDIA GT 440 .*NVIDIA .*GT *44.* 4 1 0 0 -NVIDIA GT 450 .*NVIDIA .*GT *45.* 4 1 0 0 NVIDIA GTS 450 .*NVIDIA .*GTS *45.* 4 1 1 4.2 NVIDIA GTX 460 .*NVIDIA .*GTX *46.* 5 1 1 4.2 NVIDIA GTX 470 .*NVIDIA .*GTX *47.* 5 1 1 4.2 @@ -407,7 +398,6 @@ NVIDIA 510 .*NVIDIA .* 510.* 3 1 0 0 NVIDIA GT 520 .*NVIDIA .*GT *52.* 3 1 1 4.2 NVIDIA GT 530 .*NVIDIA .*GT *53.* 3 1 1 4.2 NVIDIA GT 540 .*NVIDIA .*GT *54.* 3 1 1 4.2 -NVIDIA GT 550 .*NVIDIA .*GT *55.* 3 1 1 4.2 NVIDIA GTX 550 .*NVIDIA .*GTX *55.* 5 1 1 4.2 NVIDIA GTX 560 .*NVIDIA .*GTX *56.* 5 1 1 4.2 NVIDIA GTX 570 .*NVIDIA .*GTX *57.* 5 1 1 4.2 diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 885292131f..9f1c7855be 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2280,7 +2280,7 @@ void LLTextureFetchWorker::recordTextureStart(bool is_http) { mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp(); } - LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, + LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, is_http, LLImageBase::TYPE_AVATAR_BAKE == mType); } @@ -2291,13 +2291,13 @@ void LLTextureFetchWorker::recordTextureDone(bool is_http) { if (mMetricsStartTime) { - LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE, + LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE, is_http, LLImageBase::TYPE_AVATAR_BAKE == mType, LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime); mMetricsStartTime = 0; } - LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE, + LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, is_http, LLImageBase::TYPE_AVATAR_BAKE == mType); } @@ -2826,9 +2826,9 @@ S32 LLTextureFetch::update(F32 max_time_ms) { mNetworkQueueMutex.lock(); // +Mfnq - mMaxBandwidth = band_width ; + mMaxBandwidth = band_width ; - gTextureList.sTextureBits += mHTTPTextureBits; + LLStatViewer::TEXTURE_KBIT.add(mHTTPTextureBits); mHTTPTextureBits = 0; mNetworkQueueMutex.unlock(); // -Mfnq @@ -3702,7 +3702,7 @@ AssetReportHandler stats_handler; bool TFReqSetRegion::doWork(LLTextureFetch *) { - LLViewerAssetStatsFF::set_region_thread1(mRegionHandle); + LLViewerAssetStatsFF::set_region(mRegionHandle); return true; } diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 90d0c7e04b..2c1e7502e5 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -329,7 +329,7 @@ private: LLTextureInfo mTextureInfo; // XXX possible delete - U32 mHTTPTextureBits; // Mfnq + LLUnit<LLUnits::Bits, U32> mHTTPTextureBits; // Mfnq // XXX possible delete //debug use diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 5331bb03cb..1d54e50bb9 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -514,8 +514,8 @@ void LLGLTexMemBar::draw() F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); - F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); - F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024); + LLUnit<LLUnits::Bytes, F32> total_texture_downloaded = gTotalTextureData; + LLUnit<LLUnits::Bytes, F32> total_object_downloaded = gTotalObjectData; U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; -- cgit v1.2.3 From 1c894c05c10ef37be6507ee4bc4e9173506adfb6 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 27 Nov 2012 17:26:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system hunting down bad values and crashes --- indra/llcommon/llfasttimer.cpp | 24 ++++++++++++++---------- indra/llcommon/llfasttimer.h | 8 ++++---- indra/llcommon/lltrace.h | 1 + indra/llcommon/lltracerecording.cpp | 5 ++++- indra/llcommon/lltracethreadrecorder.cpp | 4 ++++ indra/newview/app_settings/logcontrol.xml | 1 + indra/newview/llappviewer.cpp | 3 ++- indra/newview/llviewerassetstats.cpp | 25 ++++++++++++++++++++++++- indra/newview/llviewerassetstats.h | 7 ++++++- 9 files changed, 60 insertions(+), 18 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index e1549b4bff..16dd21332c 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -177,8 +177,8 @@ BlockTimer::BlockTimer(const char* name, bool open, BlockTimer* parent) mParent = this; } - mCountHistory = new U32[HISTORY_NUM]; - memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM); + mCountHistory = new U64[HISTORY_NUM]; + memset(mCountHistory, 0, sizeof(U64) * HISTORY_NUM); mCallHistory = new U32[HISTORY_NUM]; memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); } @@ -266,9 +266,12 @@ void BlockTimer::buildHierarchy() // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.getPrimaryAccumulator().mLastCaller && timer.mParent == &BlockTimer::getRootTimer()) + if (timer.mParent == &BlockTimer::getRootTimer()) { - timer.setParent(timer.getPrimaryAccumulator().mLastCaller); + if (timer.getPrimaryAccumulator().mLastCaller) + { + timer.setParent(timer.getPrimaryAccumulator().mLastCaller); + } // no need to push up tree on first use, flag can be set spuriously timer.getPrimaryAccumulator().mMoveUpTree = false; } @@ -317,7 +320,7 @@ void BlockTimer::buildHierarchy() //static void BlockTimer::accumulateTimings() { - U32 cur_time = getCPUClockCount32(); + U64 cur_time = getCPUClockCount64(); // walk up stack of active timers and accumulate current time while leaving timing structures active Time* cur_timer = sCurTimerData->mCurTimer; @@ -326,8 +329,8 @@ void BlockTimer::accumulateTimings() TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator(); while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { - U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; - U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime; + U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; + U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; accumulator.mSelfTimeCounter += self_time_delta; accumulator.mTotalTimeCounter += cumulative_time_delta; @@ -429,6 +432,7 @@ void BlockTimer::resetFrame() BlockTimer& timer = *it; TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); accumulator.mSelfTimeCounter = 0; + accumulator.mTotalTimeCounter = 0; accumulator.mCalls = 0; accumulator.mLastCaller = NULL; accumulator.mMoveUpTree = false; @@ -442,7 +446,7 @@ void BlockTimer::reset() // walk up stack of active timers and reset start times to current time // effectively zeroing out any accumulated time - U32 cur_time = getCPUClockCount32(); + U64 cur_time = getCPUClockCount64(); // root defined by parent pointing to self CurTimerData* cur_data = sCurTimerData.get(); @@ -471,7 +475,7 @@ void BlockTimer::reset() timer.mCountAverage = 0; timer.mCallAverage = 0; - memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM); + memset(timer.mCountHistory, 0, sizeof(U64) * HISTORY_NUM); memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM); } } @@ -480,7 +484,7 @@ void BlockTimer::reset() sCurFrameIndex = 0; } -U32 BlockTimer::getHistoricalCount(S32 history_index) const +U64 BlockTimer::getHistoricalCount(S32 history_index) const { S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM; return mCountHistory[history_idx]; diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index af9b360e01..cfe2cf5371 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -93,7 +93,7 @@ public: U32 getCountAverage() const { return mCountAverage; } U32 getCallAverage() const { return mCallAverage; } - U32 getHistoricalCount(S32 history_index = 0) const; + U64 getHistoricalCount(S32 history_index = 0) const; U32 getHistoricalCalls(S32 history_index = 0) const; static BlockTimer& getRootTimer(); @@ -258,12 +258,12 @@ public: // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U32 mTreeTimeCounter; + U64 mTreeTimeCounter; - U32 mCountAverage; + U64 mCountAverage; U32 mCallAverage; - U32* mCountHistory; + U64* mCountHistory; U32* mCallHistory; // tree structure diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 61d14569cd..11651ef953 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -107,6 +107,7 @@ namespace LLTrace //TODO pick another primary? sPrimaryStorage = NULL; } + delete[] mStorage; } LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 4252ed57dc..e7ed55e8ae 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -66,7 +66,10 @@ Recording::Recording( const Recording& other ) Recording::~Recording() -{} +{ + stop(); + llassert(isStopped()); +} void Recording::update() { diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index c2fefe2957..faaab4c8e7 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -53,6 +53,10 @@ ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) ThreadRecorder::~ThreadRecorder() { + while(mActiveRecordings.size()) + { + mActiveRecordings.front().mTargetRecording->stop(); + } get_thread_recorder() = NULL; delete BlockTimer::sCurTimerData.get(); BlockTimer::sCurTimerData = NULL; diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 92a241857e..b9ae7ebf0b 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -42,6 +42,7 @@ </array> <key>tags</key> <array> + <string>FastTimers</string> <!-- sample entry for debugging specific items <string>Avatar</string> <string>Voice</string> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index f73fc4b990..839094fc47 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -438,7 +438,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ; //---------------------------------------------------------------------------- // Metrics logging control constants //---------------------------------------------------------------------------- -static const F32 METRICS_INTERVAL_DEFAULT = 600.0; +static const F32 METRICS_INTERVAL_DEFAULT = 30.0; static const F32 METRICS_INTERVAL_QA = 30.0; static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT; static bool app_metrics_qa_mode = false; @@ -5308,6 +5308,7 @@ void LLAppViewer::metricsSend(bool enable_reporting) // Make a copy of the main stats to send into another thread. // Receiving thread takes ownership. LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats)); + main_stats->stop(); main_stats->updateStats(); diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index 73a2e24424..d79d98aaaf 100644 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -239,7 +239,7 @@ LLViewerAssetStats::LLViewerAssetStats() : mRegionHandle(U64(0)), mCurRecording(NULL) { - reset(); + start(); } @@ -252,6 +252,29 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src) mRegionRecordings = src.mRegionRecordings; mCurRecording = &mRegionRecordings[mRegionHandle]; + mCurRecording->stop(); + LLStopWatchControlsMixin::initTo(src.getPlayState()); +} + +void LLViewerAssetStats::handleStart() +{ + if (mCurRecording) + { + mCurRecording->start(); + } +} + +void LLViewerAssetStats::handleStop() +{ + if (mCurRecording) + { + mCurRecording->stop(); + } +} + +void LLViewerAssetStats::handleReset() +{ + reset(); } diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h index 835df89149..5b25d791a9 100644 --- a/indra/newview/llviewerassetstats.h +++ b/indra/newview/llviewerassetstats.h @@ -74,7 +74,7 @@ * LLViewerAssetStatsFF is provided for conditional test-and-call * operations. */ -class LLViewerAssetStats +class LLViewerAssetStats : public LLStopWatchControlsMixin<LLViewerAssetStats> { public: /** @@ -177,6 +177,7 @@ public: public: LLViewerAssetStats(); LLViewerAssetStats(const LLViewerAssetStats &); + // Default destructor is correct. LLViewerAssetStats & operator=(const LLViewerAssetStats &); // Not defined @@ -202,6 +203,10 @@ public: LLSD asLLSD(bool compact_output); protected: + void handleStart(); + void handleStop(); + void handleReset(); + typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer; // Region of the currently-active region. Always valid but may -- cgit v1.2.3 From 93aca485ba08a82a6bd3a2fc31deca18af0d1478 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 27 Nov 2012 20:17:37 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed precision of fast timer counts --- indra/llcommon/llfasttimer.cpp | 10 +++++----- indra/newview/llappviewer.cpp | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index e1549b4bff..9701a41dc5 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -317,7 +317,7 @@ void BlockTimer::buildHierarchy() //static void BlockTimer::accumulateTimings() { - U32 cur_time = getCPUClockCount32(); + U64 cur_time = getCPUClockCount64(); // walk up stack of active timers and accumulate current time while leaving timing structures active Time* cur_timer = sCurTimerData->mCurTimer; @@ -389,7 +389,7 @@ void BlockTimer::resetFrame() } call_count++; - F64 iclock_freq = 1000.0 / countsPerSecond(); // good place to calculate clock frequency + F64 iclock_freq = 1000.0 / get_clock_count(); // good place to calculate clock frequency F64 total_time = 0; LLSD sd; @@ -442,7 +442,7 @@ void BlockTimer::reset() // walk up stack of active timers and reset start times to current time // effectively zeroing out any accumulated time - U32 cur_time = getCPUClockCount32(); + U64 cur_time = getCPUClockCount64(); // root defined by parent pointing to self CurTimerData* cur_data = sCurTimerData.get(); @@ -510,7 +510,7 @@ std::vector<BlockTimer*>& BlockTimer::getChildren() //static void BlockTimer::nextFrame() { - BlockTimer::countsPerSecond(); // good place to calculate clock frequency + get_clock_count(); // good place to calculate clock frequency U64 frame_time = BlockTimer::getCPUClockCount64(); if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) { @@ -534,7 +534,7 @@ void Time::dumpCurTimes() // accumulate timings, etc. BlockTimer::processTimes(); - F64 clock_freq = (F64)BlockTimer::countsPerSecond(); + F64 clock_freq = (F64)get_clock_count(); F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds // walk over timers in depth order and output timings diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 547eb2fefe..1ecbc00257 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1341,6 +1341,7 @@ bool LLAppViewer::mainLoop() gGLActive = FALSE; } + LLTrace::get_frame_recording().nextPeriod(); } pingMainloopTimeout("Main:Sleep"); @@ -4307,9 +4308,6 @@ void LLAppViewer::idle() update_statistics(); } - LLTrace::get_frame_recording().nextPeriod(); - - //////////////////////////////////////// // // Handle the regular UI idle callbacks as well as -- cgit v1.2.3 From 02d503bf8f8890c6d4b57dd09a1fde2973715b75 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 29 Nov 2012 00:43:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system moved runtime timer tree topology information to separate array instead of recording stack --- indra/llcommon/llfasttimer.cpp | 85 +++++++++++++++++--------------- indra/llcommon/llfasttimer.h | 34 +++++++------ indra/llcommon/lltrace.h | 13 ++++- indra/llcommon/lltracethreadrecorder.cpp | 20 +++++--- indra/llcommon/lltracethreadrecorder.h | 4 +- 5 files changed, 91 insertions(+), 65 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index e88a5a9ed1..1b3498cce3 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -58,24 +58,27 @@ namespace LLTrace ////////////////////////////////////////////////////////////////////////////// // statics -S32 BlockTimer::sCurFrameIndex = -1; -S32 BlockTimer::sLastFrameIndex = -1; -U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64(); -bool BlockTimer::sPauseHistory = 0; -bool BlockTimer::sResetHistory = 0; -LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData; -bool BlockTimer::sLog = false; -std::string BlockTimer::sLogName = ""; -bool BlockTimer::sMetricLog = false; -static LLMutex* sLogLock = NULL; -static std::queue<LLSD> sLogQueue; +S32 BlockTimer::sCurFrameIndex = -1; +S32 BlockTimer::sLastFrameIndex = -1; +U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64(); +bool BlockTimer::sPauseHistory = 0; +bool BlockTimer::sResetHistory = 0; +bool BlockTimer::sLog = false; +std::string BlockTimer::sLogName = ""; +bool BlockTimer::sMetricLog = false; #if LL_LINUX || LL_SOLARIS -U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution +U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution #else -U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution +U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution #endif +LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData; + +static LLMutex* sLogLock = NULL; +static std::queue<LLSD> sLogQueue; + + // FIXME: move these declarations to the relevant modules // helper functions @@ -108,6 +111,7 @@ static timer_tree_dfs_iterator_t end_timer_tree() return timer_tree_dfs_iterator_t(); } + BlockTimer& BlockTimer::getRootTimer() { static BlockTimer root_timer("root", true, NULL); @@ -142,7 +146,7 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer // we drop the low-order byte in our timers, so report a lower frequency #else - // If we're not using RDTSC, each fasttimer tick is just a performance counter tick. + // If we're not using RDTSC, each fast timer tick is just a performance counter tick. // Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency()) // since that would change displayed MHz stats for CPUs static bool firstcall = true; @@ -268,17 +272,19 @@ void BlockTimer::buildHierarchy() // when this timer was called if (timer.mParent == &BlockTimer::getRootTimer()) { - if (timer.getPrimaryAccumulator().mLastCaller) - { - timer.setParent(timer.getPrimaryAccumulator().mLastCaller); + TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + + if (tree_node.mLastCaller) + { + timer.setParent(tree_node.mLastCaller); } // no need to push up tree on first use, flag can be set spuriously - timer.getPrimaryAccumulator().mMoveUpTree = false; + tree_node.mMoveUpTree = false; } } } - // bump timers up tree if they've been flagged as being in the wrong place + // bump timers up tree if they have been flagged as being in the wrong place // do this in a bottom up order to promote descendants first before promoting ancestors // this preserves partial order derived from current frame's observations for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimer::getRootTimer()); @@ -288,15 +294,16 @@ void BlockTimer::buildHierarchy() BlockTimer* timerp = *it; // skip root timer if (timerp == &BlockTimer::getRootTimer()) continue; + TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timerp->getIndex()]; - if (timerp->getPrimaryAccumulator().mMoveUpTree) + if (tree_node.mMoveUpTree) { // since ancestors have already been visited, re-parenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - timerp->getPrimaryAccumulator().mMoveUpTree = false; + tree_node.mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up it.skipAncestors(); @@ -322,11 +329,11 @@ void BlockTimer::accumulateTimings() { U64 cur_time = getCPUClockCount64(); - // walk up stack of active timers and accumulate current time while leaving timing structures active - Time* cur_timer = sCurTimerData->mCurTimer; // root defined by parent pointing to self CurTimerData* cur_data = sCurTimerData.get(); - TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator(); + // walk up stack of active timers and accumulate current time while leaving timing structures active + Time* cur_timer = cur_data->mCurTimer; + TimerAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; @@ -431,11 +438,13 @@ void BlockTimer::resetFrame() { BlockTimer& timer = *it; TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + accumulator.mSelfTimeCounter = 0; accumulator.mTotalTimeCounter = 0; accumulator.mCalls = 0; - accumulator.mLastCaller = NULL; - accumulator.mMoveUpTree = false; + tree_node.mLastCaller = NULL; + tree_node.mMoveUpTree = false; } } @@ -579,32 +588,28 @@ void Time::writeLog(std::ostream& os) } -LLTrace::TimerAccumulator::TimerAccumulator() : mSelfTimeCounter(0), +TimerAccumulator::TimerAccumulator() : mSelfTimeCounter(0), mTotalTimeCounter(0), - mCalls(0), - mLastCaller(NULL), - mActiveCount(0), - mMoveUpTree(false) + mCalls(0) {} -void LLTrace::TimerAccumulator::addSamples( const LLTrace::TimerAccumulator& other ) +void TimerAccumulator::addSamples( const TimerAccumulator& other ) { mSelfTimeCounter += other.mSelfTimeCounter; mTotalTimeCounter += other.mTotalTimeCounter; mCalls += other.mCalls; - if (!mLastCaller) - { - mLastCaller = other.mLastCaller; - } - - //mActiveCount stays the same; - mMoveUpTree |= other.mMoveUpTree; } -void LLTrace::TimerAccumulator::reset( const LLTrace::TimerAccumulator* other ) +void TimerAccumulator::reset( const TimerAccumulator* other ) { mTotalTimeCounter = 0; mSelfTimeCounter = 0; mCalls = 0; } + +TimerTreeNode::TimerTreeNode() +: mLastCaller(NULL), + mActiveCount(0), + mMoveUpTree(false) +{} } diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index cfe2cf5371..9f981480f2 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -37,11 +37,13 @@ class LLMutex; namespace LLTrace { + struct CurTimerData { class Time* mCurTimer; class BlockTimer* mTimerData; U64 mChildTime; + TimerTreeNode* mTimerTreeData; }; class Time @@ -269,20 +271,20 @@ public: // tree structure BlockTimer* mParent; // BlockTimer of caller(parent) std::vector<BlockTimer*> mChildren; - bool mCollapsed; // don't show children - bool mNeedsSorting; // sort children whenever child added + bool mCollapsed, // don't show children + mNeedsSorting; // sort children whenever child added // statics static std::string sLogName; - static bool sMetricLog; - static bool sLog; + static bool sMetricLog, + sLog; static LLThreadLocalPointer<CurTimerData> sCurTimerData; static U64 sClockResolution; - static S32 sCurFrameIndex; - static S32 sLastFrameIndex; + static S32 sCurFrameIndex, + sLastFrameIndex; static U64 sLastFrameTime; - static bool sPauseHistory; - static bool sResetHistory; + static bool sPauseHistory, + sResetHistory; }; @@ -291,13 +293,12 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) #if FAST_TIMER_ON mStartTime = BlockTimer::getCPUClockCount64(); - TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); - accumulator.mActiveCount++; - accumulator.mCalls++; + CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); + TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; + tree_node.mActiveCount++; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0); + tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); // store top of stack mLastTimerData = *cur_timer_data; // push new information @@ -313,13 +314,16 @@ LL_FORCE_INLINE Time::~Time() U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; + + accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; - accumulator.mActiveCount--; + tree_node.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator.mLastCaller = mLastTimerData.mTimerData; + tree_node.mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 11651ef953..ad9f170aae 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -189,6 +189,11 @@ namespace LLTrace delete[] old_storage; } + size_t size() + { + return mNextStorageSlot; + } + static AccumulatorBuffer<ACCUMULATOR>& getDefaultBuffer() { static AccumulatorBuffer sBuffer(STATIC_ALLOC); @@ -216,7 +221,7 @@ namespace LLTrace mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } - LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() + LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const { return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; } @@ -399,6 +404,12 @@ namespace LLTrace U64 mSelfTimeCounter, mTotalTimeCounter; U32 mCalls; + }; + + class TimerTreeNode + { + public: + TimerTreeNode(); class BlockTimer* mLastCaller; // used to bootstrap tree construction U16 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index faaab4c8e7..0a2d79cf3a 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -41,25 +41,29 @@ ThreadRecorder::ThreadRecorder() get_thread_recorder() = this; mFullRecording.start(); - BlockTimer::sCurTimerData = new CurTimerData(); -} + mRootTimerData = new CurTimerData(); + mRootTimerData->mTimerData = &BlockTimer::getRootTimer(); + mRootTimerData->mTimerTreeData = new TimerTreeNode[AccumulatorBuffer<TimerAccumulator>::getDefaultBuffer().size()]; + BlockTimer::sCurTimerData = mRootTimerData; -ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) -: mFullRecording(other.mFullRecording) -{ - get_thread_recorder() = this; - mFullRecording.start(); + mRootTimer = new Time(BlockTimer::getRootTimer()); + mRootTimerData->mCurTimer = mRootTimer; + + mRootTimerData->mTimerTreeData[BlockTimer::getRootTimer().getIndex()].mActiveCount = 1; } ThreadRecorder::~ThreadRecorder() { + delete mRootTimer; + while(mActiveRecordings.size()) { mActiveRecordings.front().mTargetRecording->stop(); } get_thread_recorder() = NULL; - delete BlockTimer::sCurTimerData.get(); BlockTimer::sCurTimerData = NULL; + delete [] mRootTimerData->mTimerTreeData; + delete mRootTimerData; } void ThreadRecorder::activate( Recording* recording ) diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 44fe67384b..277a468a40 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -41,7 +41,6 @@ namespace LLTrace struct ActiveRecording; public: ThreadRecorder(); - ThreadRecorder(const ThreadRecorder& other); virtual ~ThreadRecorder(); @@ -63,6 +62,9 @@ namespace LLTrace }; Recording mFullRecording; std::list<ActiveRecording> mActiveRecordings; + + struct CurTimerData* mRootTimerData; + class Time* mRootTimer; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder -- cgit v1.2.3 From ca37317a1473bb79ef8de4f683231700cb9e062c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 30 Nov 2012 15:48:22 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed crash when sending viewer asset stats --- indra/llcommon/lltracerecording.cpp | 13 +++++++++---- indra/llcommon/lltracerecording.h | 2 ++ indra/newview/llappviewer.cpp | 2 +- indra/newview/llviewerassetstats.cpp | 11 ++++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e7ed55e8ae..e31e36cb27 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -58,10 +58,6 @@ Recording::Recording( const Recording& other ) mStackTimers = other.mStackTimers; LLStopWatchControlsMixin::initTo(other.getPlayState()); - if (other.isStarted()) - { - handleStart(); - } } @@ -127,6 +123,15 @@ bool Recording::isPrimary() const return mCounts->isPrimary(); } +void Recording::makeUnique() +{ + mCountsFloat.makeUnique(); + mMeasurementsFloat.makeUnique(); + mCounts.makeUnique(); + mMeasurements.makeUnique(); + mStackTimers.makeUnique(); +} + void Recording::appendRecording( const Recording& other ) { mCountsFloat.write()->addSamples(*other.mCountsFloat); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index efc54d240f..e5a21a2d38 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -112,6 +112,8 @@ namespace LLTrace void makePrimary(); bool isPrimary() const; + void makeUnique(); + void appendRecording(const Recording& other); void update(); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 713ae789a7..fb95c9ec5b 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -438,7 +438,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ; //---------------------------------------------------------------------------- // Metrics logging control constants //---------------------------------------------------------------------------- -static const F32 METRICS_INTERVAL_DEFAULT = 30.0; +static const F32 METRICS_INTERVAL_DEFAULT = 600.0; static const F32 METRICS_INTERVAL_QA = 30.0; static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT; static bool app_metrics_qa_mode = false; diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index d79d98aaaf..58936c3220 100644 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -250,9 +250,18 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src) { src.mCurRecording->update(); mRegionRecordings = src.mRegionRecordings; - + mCurRecording = &mRegionRecordings[mRegionHandle]; mCurRecording->stop(); + + // assume this is being passed to another thread, so make sure we have unique copies of recording data + for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end(); + it != end_it; + ++it) + { + it->second.makeUnique(); + } + LLStopWatchControlsMixin::initTo(src.getPlayState()); } -- cgit v1.2.3 From ca2207bd35c33b13b122f875a5a7d218f94ca3fc Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sat, 1 Dec 2012 00:17:04 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed scale of reported times moved reset calls to happen at same time so we don't show partial results --- indra/llcommon/llfasttimer.cpp | 6 ++---- indra/llcommon/lltrace.h | 3 ++- indra/llcommon/llunit.h | 2 +- indra/newview/llappviewer.cpp | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 1b3498cce3..19676cc0c6 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -144,7 +144,6 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz static LLUnit<LLUnits::Hertz, U64> sCPUClockFrequency = LLProcessorInfo().getCPUFrequency(); - // we drop the low-order byte in our timers, so report a lower frequency #else // If we're not using RDTSC, each fast timer tick is just a performance counter tick. // Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency()) @@ -157,7 +156,7 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer firstcall = false; } #endif - return sCPUClockFrequency >> 8; + return sCPUClockFrequency; } #endif @@ -390,8 +389,7 @@ void BlockTimer::resetFrame() static S32 call_count = 0; if (call_count % 100 == 0) { - LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL; - LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << LL_ENDL; + LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL; LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index ad9f170aae..3e43a85e80 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -223,7 +223,8 @@ namespace LLTrace LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const { - return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex]; + ACCUMULATOR* accumulator_storage = AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage(); + return accumulator_storage[mAccumulatorIndex]; } size_t getIndex() const { return mAccumulatorIndex; } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 53570779fc..fc1347b59f 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -71,7 +71,7 @@ template<typename UNIT_TYPE, typename STORAGE_TYPE> struct LLUnit { typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t; - typedef typename STORAGE_TYPE storage_t; + typedef STORAGE_TYPE storage_t; LLUnit(storage_t value = storage_t()) : mValue(value) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index fb95c9ec5b..b9bdb7cd08 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1235,6 +1235,8 @@ bool LLAppViewer::mainLoop() { LLFastTimer _(FTM_FRAME); LLTrace::BlockTimer::nextFrame(); + LLTrace::get_frame_recording().nextPeriod(); + LLTrace::getMasterThreadRecorder().pullFromSlaveThreads(); //clear call stack records @@ -1352,8 +1354,6 @@ bool LLAppViewer::mainLoop() LLFloaterSnapshot::update(); // take snapshots gGLActive = FALSE; } - - LLTrace::get_frame_recording().nextPeriod(); } pingMainloopTimeout("Main:Sleep"); -- cgit v1.2.3 From 4f9a5d0554c16a81625574a7a4ad6d5070e649e3 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sat, 1 Dec 2012 12:49:01 -0800 Subject: fix for gcc compile errors --- indra/llcommon/llapr.h | 4 ++-- indra/llcommon/llunit.h | 1 + indra/newview/app_settings/logcontrol.xml | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 7ca0f505ef..199b5291dd 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -249,7 +249,7 @@ public: //******************************************************************************************************************************* }; -class LLThreadLocalPointerBase : LLInstanceTracker<LLThreadLocalPointerBase> +class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase> { public: LLThreadLocalPointerBase() @@ -331,7 +331,7 @@ public: LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) - : LLThreadLocalPointerBase(other) + : LLThreadLocalPointerBase(other) { set(other.get()); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index fc1347b59f..54902b6322 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -177,6 +177,7 @@ template<typename UNIT_TYPE, typename STORAGE_TYPE> struct LLUnitStrict : public LLUnit<UNIT_TYPE, STORAGE_TYPE> { typedef LLUnitStrict<UNIT_TYPE, STORAGE_TYPE> self_t; + typedef typename LLUnit<UNIT_TYPE, STORAGE_TYPE>::storage_t storage_t; explicit LLUnitStrict(storage_t value = storage_t()) : LLUnit(value) diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index b9ae7ebf0b..92a241857e 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -42,7 +42,6 @@ </array> <key>tags</key> <array> - <string>FastTimers</string> <!-- sample entry for debugging specific items <string>Avatar</string> <string>Voice</string> -- cgit v1.2.3 From 13e4edf1cd664864afa585bc83bbe99d4f743326 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sun, 2 Dec 2012 23:00:36 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system started moving fast timer historical stats over to LLTrace periodic recording --- indra/llcommon/llfasttimer.cpp | 6 +++--- indra/llcommon/lltracerecording.cpp | 11 +++++++++++ indra/llcommon/lltracerecording.h | 22 +++++++++++++--------- indra/newview/llfasttimerview.cpp | 6 ++++-- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 19676cc0c6..e33cb76eff 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -133,12 +133,12 @@ void BlockTimer::setLogLock(LLMutex* lock) //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer { - return sClockResolution >> 8; + return sClockResolution; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e31e36cb27..ff3ae1e553 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lltrace.h" +#include "llfasttimer.h" #include "lltracerecording.h" #include "lltracethreadrecorder.h" #include "llthread.h" @@ -142,6 +143,16 @@ void Recording::appendRecording( const Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } +LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimerAccumulator>& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond(); +} + +LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimerAccumulator>& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds); +} + F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const { return (*mCountsFloat)[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index e5a21a2d38..0adea2663b 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -118,6 +118,10 @@ namespace LLTrace void update(); + // Timer accessors + LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimerAccumulator>& stat) const; + LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimerAccumulator>& stat) const; + // Count accessors F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const; S64 getSum(const TraceType<CountAccumulator<S64> >& stat) const; @@ -273,18 +277,18 @@ namespace LLTrace Recording& getTotalRecording(); template <typename T> - typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const + typename T::value_t getPeriodMin(const TraceType<T>& stat) const { - T min_val = (std::numeric_limits<T>::max)(); + typename T::value_t min_val = (std::numeric_limits<typename T::value_t>::max)(); for (S32 i = 0; i < mNumPeriods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat)); } - return (T)min_val; + return min_val; } template <typename T> - F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const + F64 getPeriodMinPerSec(const TraceType<T>& stat) const { F64 min_val = (std::numeric_limits<F64>::max)(); for (S32 i = 0; i < mNumPeriods; i++) @@ -295,9 +299,9 @@ namespace LLTrace } template <typename T> - T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const + typename T::value_t getPeriodMax(const TraceType<T>& stat) const { - T max_val = (std::numeric_limits<T>::min)(); + typename T::value_t max_val = (std::numeric_limits<typename T::value_t>::min)(); for (S32 i = 0; i < mNumPeriods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat)); @@ -306,7 +310,7 @@ namespace LLTrace } template <typename T> - F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const + F64 getPeriodMaxPerSec(const TraceType<T>& stat) const { F64 max_val = (std::numeric_limits<F64>::min)(); for (S32 i = 0; i < mNumPeriods; i++) @@ -317,7 +321,7 @@ namespace LLTrace } template <typename T> - F64 getPeriodMean(const TraceType<CountAccumulator<T> >& stat) const + F64 getPeriodMean(const TraceType<T>& stat) const { F64 mean = 0.0; F64 count = 0; @@ -334,7 +338,7 @@ namespace LLTrace } template <typename T> - F64 getPeriodMeanPerSec(const TraceType<CountAccumulator<T> >& stat) const + F64 getPeriodMeanPerSec(const TraceType<T>& stat) const { F64 mean = 0.0; F64 count = 0; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7a5c9dba46..6aca8f4426 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -294,15 +294,17 @@ static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = - { F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); + LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording(); + std::string tooltip; if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage()); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage()); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); } return tooltip; } -- cgit v1.2.3 From 407e5013f3845208e0a60e26e8f0a7fad997df5d Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Mon, 3 Dec 2012 19:54:53 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system converted fast timer view over to new lltrace mechanisms --- indra/llcommon/llfasttimer.cpp | 538 ++++++++---------- indra/llcommon/llfasttimer.h | 111 ++-- indra/llcommon/llmetricperformancetester.cpp | 4 +- indra/llcommon/lltrace.h | 39 +- indra/llcommon/lltracerecording.cpp | 21 +- indra/llcommon/lltracerecording.h | 8 +- indra/llcommon/lltracethreadrecorder.cpp | 12 +- indra/llcommon/lltracethreadrecorder.h | 2 +- indra/llcommon/llunit.h | 8 +- indra/newview/llappviewer.cpp | 33 +- indra/newview/llfasttimerview.cpp | 778 +++++++++++++-------------- indra/newview/llfasttimerview.h | 32 +- indra/newview/llstartup.cpp | 2 +- indra/newview/llviewermenu.cpp | 2 +- 14 files changed, 737 insertions(+), 853 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index e33cb76eff..cf7655acf7 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -34,6 +34,7 @@ #include "llsdserialize.h" #include "llunit.h" #include "llsd.h" +#include "lltracerecording.h" #include <boost/bind.hpp> #include <queue> @@ -58,22 +59,22 @@ namespace LLTrace ////////////////////////////////////////////////////////////////////////////// // statics -S32 BlockTimer::sCurFrameIndex = -1; -S32 BlockTimer::sLastFrameIndex = -1; -U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64(); -bool BlockTimer::sPauseHistory = 0; -bool BlockTimer::sResetHistory = 0; -bool BlockTimer::sLog = false; -std::string BlockTimer::sLogName = ""; -bool BlockTimer::sMetricLog = false; +S32 TimeBlock::sCurFrameIndex = -1; +S32 TimeBlock::sLastFrameIndex = -1; +U64 TimeBlock::sLastFrameTime = TimeBlock::getCPUClockCount64(); +bool TimeBlock::sPauseHistory = 0; +bool TimeBlock::sResetHistory = 0; +bool TimeBlock::sLog = false; +std::string TimeBlock::sLogName = ""; +bool TimeBlock::sMetricLog = false; #if LL_LINUX || LL_SOLARIS -U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution +U64 TimeBlock::sClockResolution = 1000000000; // Nanosecond resolution #else -U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution +U64 TimeBlock::sClockResolution = 1000000; // Microsecond resolution #endif -LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData; +LLThreadLocalPointer<CurTimerData> TimeBlock::sCurTimerData; static LLMutex* sLogLock = NULL; static std::queue<LLSD> sLogQueue; @@ -82,13 +83,13 @@ static std::queue<LLSD> sLogQueue; // FIXME: move these declarations to the relevant modules // helper functions -typedef LLTreeDFSPostIter<BlockTimer, BlockTimer::child_const_iter> timer_tree_bottom_up_iterator_t; +typedef LLTreeDFSPostIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_bottom_up_iterator_t; -static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(BlockTimer& id) +static timer_tree_bottom_up_iterator_t begin_timer_tree_bottom_up(TimeBlock& id) { return timer_tree_bottom_up_iterator_t(&id, - boost::bind(boost::mem_fn(&BlockTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&BlockTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); } static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() @@ -96,14 +97,14 @@ static timer_tree_bottom_up_iterator_t end_timer_tree_bottom_up() return timer_tree_bottom_up_iterator_t(); } -typedef LLTreeDFSIter<BlockTimer, BlockTimer::child_const_iter> timer_tree_dfs_iterator_t; +typedef LLTreeDFSIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_dfs_iterator_t; -static timer_tree_dfs_iterator_t begin_timer_tree(BlockTimer& id) +static timer_tree_dfs_iterator_t begin_timer_tree(TimeBlock& id) { return timer_tree_dfs_iterator_t(&id, - boost::bind(boost::mem_fn(&BlockTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&BlockTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); } static timer_tree_dfs_iterator_t end_timer_tree() @@ -112,20 +113,29 @@ static timer_tree_dfs_iterator_t end_timer_tree() } -BlockTimer& BlockTimer::getRootTimer() +// sort child timers by name +struct SortTimerByName { - static BlockTimer root_timer("root", true, NULL); + bool operator()(const TimeBlock* i1, const TimeBlock* i2) + { + return i1->getName() < i2->getName(); + } +}; + +TimeBlock& TimeBlock::getRootTimer() +{ + static TimeBlock root_timer("root", true, NULL); return root_timer; } -void BlockTimer::pushLog(LLSD log) +void TimeBlock::pushLog(LLSD log) { LLMutexLock lock(sLogLock); sLogQueue.push(log); } -void BlockTimer::setLogLock(LLMutex* lock) +void TimeBlock::setLogLock(LLMutex* lock) { sLogLock = lock; } @@ -133,12 +143,12 @@ void BlockTimer::setLogLock(LLMutex* lock) //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer +U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer { return sClockResolution; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer +U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz @@ -160,13 +170,10 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer } #endif -BlockTimer::BlockTimer(const char* name, bool open, BlockTimer* parent) +TimeBlock::TimeBlock(const char* name, bool open, TimeBlock* parent) : TraceType(name), mCollapsed(true), mParent(NULL), - mTreeTimeCounter(0), - mCountAverage(0), - mCallAverage(0), mNeedsSorting(false) { setCollapsed(!open); @@ -179,37 +186,26 @@ BlockTimer::BlockTimer(const char* name, bool open, BlockTimer* parent) { mParent = this; } - - mCountHistory = new U64[HISTORY_NUM]; - memset(mCountHistory, 0, sizeof(U64) * HISTORY_NUM); - mCallHistory = new U32[HISTORY_NUM]; - memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM); } -BlockTimer::~BlockTimer() -{ - delete[] mCountHistory; - delete[] mCallHistory; -} - -void BlockTimer::setParent(BlockTimer* parent) +void TimeBlock::setParent(TimeBlock* parent) { llassert_always(parent != this); llassert_always(parent != NULL); if (mParent) { - // subtract our accumulated from previous parent - for (S32 i = 0; i < HISTORY_NUM; i++) - { - mParent->mCountHistory[i] -= mCountHistory[i]; - } + //// subtract our accumulated from previous parent + //for (S32 i = 0; i < HISTORY_NUM; i++) + //{ + // mParent->mCountHistory[i] -= mCountHistory[i]; + //} - // subtract average timing from previous parent - mParent->mCountAverage -= mCountAverage; + //// subtract average timing from previous parent + //mParent->mCountAverage -= mCountAverage; - std::vector<BlockTimer*>& children = mParent->getChildren(); - std::vector<BlockTimer*>::iterator found_it = std::find(children.begin(), children.end(), this); + std::vector<TimeBlock*>& children = mParent->getChildren(); + std::vector<TimeBlock*>::iterator found_it = std::find(children.begin(), children.end(), this); if (found_it != children.end()) { children.erase(found_it); @@ -224,10 +220,10 @@ void BlockTimer::setParent(BlockTimer* parent) } } -S32 BlockTimer::getDepth() +S32 TimeBlock::getDepth() { S32 depth = 0; - BlockTimer* timerp = mParent; + TimeBlock* timerp = mParent; while(timerp) { depth++; @@ -238,291 +234,152 @@ S32 BlockTimer::getDepth() } // static -void BlockTimer::processTimes() +void TimeBlock::processTimes() { - if (getCurFrameIndex() < 0) return; - - buildHierarchy(); - accumulateTimings(); -} - -// sort child timers by name -struct SortTimerByName -{ - bool operator()(const BlockTimer* i1, const BlockTimer* i2) - { - return i1->getName() < i2->getName(); - } -}; - -//static -void BlockTimer::buildHierarchy() -{ - if (getCurFrameIndex() < 0 ) return; - - // set up initial tree + //void TimeBlock::buildHierarchy() { - for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), end_it = LLInstanceTracker<BlockTimer>::endInstances(); it != end_it; ++it) + // set up initial tree { - BlockTimer& timer = *it; - if (&timer == &BlockTimer::getRootTimer()) continue; - - // bootstrap tree construction by attaching to last timer to be on stack - // when this timer was called - if (timer.mParent == &BlockTimer::getRootTimer()) + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); it != end_it; ++it) { - TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + TimeBlock& timer = *it; + if (&timer == &TimeBlock::getRootTimer()) continue; - if (tree_node.mLastCaller) + // bootstrap tree construction by attaching to last timer to be on stack + // when this timer was called + if (timer.mParent == &TimeBlock::getRootTimer()) { - timer.setParent(tree_node.mLastCaller); + TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + + if (tree_node.mLastCaller) + { + timer.setParent(tree_node.mLastCaller); + } + // no need to push up tree on first use, flag can be set spuriously + tree_node.mMoveUpTree = false; } - // no need to push up tree on first use, flag can be set spuriously - tree_node.mMoveUpTree = false; } } - } - - // bump timers up tree if they have been flagged as being in the wrong place - // do this in a bottom up order to promote descendants first before promoting ancestors - // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimer::getRootTimer()); - it != end_timer_tree_bottom_up(); - ++it) - { - BlockTimer* timerp = *it; - // skip root timer - if (timerp == &BlockTimer::getRootTimer()) continue; - TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timerp->getIndex()]; - if (tree_node.mMoveUpTree) + // bump timers up tree if they have been flagged as being in the wrong place + // do this in a bottom up order to promote descendants first before promoting ancestors + // this preserves partial order derived from current frame's observations + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); + it != end_timer_tree_bottom_up(); + ++it) { - // since ancestors have already been visited, re-parenting won't affect tree traversal - //step up tree, bringing our descendants with us - LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << - " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; - timerp->setParent(timerp->getParent()->getParent()); - tree_node.mMoveUpTree = false; + TimeBlock* timerp = *it; + // skip root timer + if (timerp == &TimeBlock::getRootTimer()) continue; + TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timerp->getIndex()]; - // don't bubble up any ancestors until descendants are done bubbling up - it.skipAncestors(); - } - } + if (tree_node.mMoveUpTree) + { + // since ancestors have already been visited, re-parenting won't affect tree traversal + //step up tree, bringing our descendants with us + LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << + " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; + timerp->setParent(timerp->getParent()->getParent()); + tree_node.mMoveUpTree = false; - // sort timers by time last called, so call graph makes sense - for(timer_tree_dfs_iterator_t it = begin_timer_tree(BlockTimer::getRootTimer()); - it != end_timer_tree(); - ++it) - { - BlockTimer* timerp = (*it); - if (timerp->mNeedsSorting) - { - std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); + // don't bubble up any ancestors until descendants are done bubbling up + it.skipAncestors(); + } } - timerp->mNeedsSorting = false; - } -} - -//static -void BlockTimer::accumulateTimings() -{ - U64 cur_time = getCPUClockCount64(); - - // root defined by parent pointing to self - CurTimerData* cur_data = sCurTimerData.get(); - // walk up stack of active timers and accumulate current time while leaving timing structures active - Time* cur_timer = cur_data->mCurTimer; - TimerAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); - while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) - { - U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; - U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; - cur_data->mChildTime = 0; - accumulator.mSelfTimeCounter += self_time_delta; - accumulator.mTotalTimeCounter += cumulative_time_delta; - - cur_timer->mStartTime = cur_time; - cur_data = &cur_timer->mLastTimerData; - cur_data->mChildTime += cumulative_time_delta; - if (cur_data->mTimerData) + // sort timers by time last called, so call graph makes sense + for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimer()); + it != end_timer_tree(); + ++it) { - accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + TimeBlock* timerp = (*it); + if (timerp->mNeedsSorting) + { + std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); + } + timerp->mNeedsSorting = false; } - - cur_timer = cur_timer->mLastTimerData.mCurTimer; } - - // traverse tree in DFS post order, or bottom up - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(BlockTimer::getRootTimer()); - it != end_timer_tree_bottom_up(); - ++it) + + //void TimeBlock::accumulateTimings() { - BlockTimer* timerp = (*it); - TimerAccumulator& accumulator = timerp->getPrimaryAccumulator(); - timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter; - for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) - { - timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; - } - - S32 cur_frame = getCurFrameIndex(); - if (cur_frame >= 0) + U64 cur_time = getCPUClockCount64(); + + // root defined by parent pointing to self + CurTimerData* cur_data = sCurTimerData.get(); + // walk up stack of active timers and accumulate current time while leaving timing structures active + BlockTimer* cur_timer = cur_data->mCurTimer; + TimeBlockAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { - // update timer history - int hidx = cur_frame % HISTORY_NUM; + U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; + U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; + cur_data->mChildTime = 0; + accumulator.mSelfTimeCounter += self_time_delta; + accumulator.mTotalTimeCounter += cumulative_time_delta; - timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; - timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); - timerp->mCallHistory[hidx] = accumulator.mCalls; - timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1); - } - } -} + cur_timer->mStartTime = cur_time; -// static -void BlockTimer::resetFrame() -{ - if (sLog) - { //output current frame counts to performance log - - static S32 call_count = 0; - if (call_count % 100 == 0) - { - LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL; - LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; - LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL; - } - call_count++; - - F64 iclock_freq = 1000.0 / get_clock_count(); // good place to calculate clock frequency - - F64 total_time = 0; - LLSD sd; - - { - for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), - end_it = LLInstanceTracker<BlockTimer>::endInstances(); - it != end_it; - ++it) + cur_data = &cur_timer->mLastTimerData; + cur_data->mChildTime += cumulative_time_delta; + if (cur_data->mTimerData) { - BlockTimer& timer = *it; - TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); - sd[timer.getName()]["Time"] = (LLSD::Real) (accumulator.mSelfTimeCounter*iclock_freq); - sd[timer.getName()]["Calls"] = (LLSD::Integer) accumulator.mCalls; - - // computing total time here because getting the root timer's getCountHistory - // doesn't work correctly on the first frame - total_time = total_time + accumulator.mSelfTimeCounter * iclock_freq; + accumulator = cur_data->mTimerData->getPrimaryAccumulator(); } - } - sd["Total"]["Time"] = (LLSD::Real) total_time; - sd["Total"]["Calls"] = (LLSD::Integer) 1; - - { - LLMutexLock lock(sLogLock); - sLogQueue.push(sd); + cur_timer = cur_timer->mLastTimerData.mCurTimer; } - } - - // reset for next frame - for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), - end_it = LLInstanceTracker<BlockTimer>::endInstances(); - it != end_it; - ++it) - { - BlockTimer& timer = *it; - TimerAccumulator& accumulator = timer.getPrimaryAccumulator(); - TimerTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; - - accumulator.mSelfTimeCounter = 0; - accumulator.mTotalTimeCounter = 0; - accumulator.mCalls = 0; - tree_node.mLastCaller = NULL; - tree_node.mMoveUpTree = false; - } -} - -//static -void BlockTimer::reset() -{ - resetFrame(); // reset frame data - - // walk up stack of active timers and reset start times to current time - // effectively zeroing out any accumulated time - U64 cur_time = getCPUClockCount64(); - - // root defined by parent pointing to self - CurTimerData* cur_data = sCurTimerData.get(); - Time* cur_timer = cur_data->mCurTimer; - while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) - { - cur_timer->mStartTime = cur_time; - cur_data->mChildTime = 0; - - cur_data = &cur_timer->mLastTimerData; - cur_timer = cur_data->mCurTimer; - } - // reset all history - { - for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(), - end_it = LLInstanceTracker<BlockTimer>::endInstances(); - it != end_it; - ++it) - { - BlockTimer& timer = *it; - if (&timer != &BlockTimer::getRootTimer()) - { - timer.setParent(&BlockTimer::getRootTimer()); - } - - timer.mCountAverage = 0; - timer.mCallAverage = 0; - memset(timer.mCountHistory, 0, sizeof(U64) * HISTORY_NUM); - memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM); - } + // traverse tree in DFS post order, or bottom up + //for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); + // it != end_timer_tree_bottom_up(); + // ++it) + //{ + // TimeBlock* timerp = (*it); + // TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); + // timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter; + // for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) + // { + // timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; + // } + + //S32 cur_frame = getCurFrameIndex(); + //if (cur_frame >= 0) + //{ + // // update timer history + + // int hidx = getCurFrameIndex() % HISTORY_NUM; + + // timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; + // timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); + // timerp->mCallHistory[hidx] = accumulator.mCalls; + // timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1); + //} + //} } - - sLastFrameIndex = 0; - sCurFrameIndex = 0; } -U64 BlockTimer::getHistoricalCount(S32 history_index) const -{ - S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM; - return mCountHistory[history_idx]; -} - -U32 BlockTimer::getHistoricalCalls(S32 history_index ) const -{ - S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM; - return mCallHistory[history_idx]; -} -std::vector<BlockTimer*>::const_iterator BlockTimer::beginChildren() +std::vector<TimeBlock*>::const_iterator TimeBlock::beginChildren() { return mChildren.begin(); } -std::vector<BlockTimer*>::const_iterator BlockTimer::endChildren() +std::vector<TimeBlock*>::const_iterator TimeBlock::endChildren() { return mChildren.end(); } -std::vector<BlockTimer*>& BlockTimer::getChildren() +std::vector<TimeBlock*>& TimeBlock::getChildren() { return mChildren; } //static -void BlockTimer::nextFrame() +void TimeBlock::nextFrame() { get_clock_count(); // good place to calculate clock frequency - U64 frame_time = BlockTimer::getCPUClockCount64(); + U64 frame_time = TimeBlock::getCPUClockCount64(); if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) { llinfos << "Slow frame, fast timers inaccurate" << llendl; @@ -530,31 +387,88 @@ void BlockTimer::nextFrame() if (!sPauseHistory) { - BlockTimer::processTimes(); + TimeBlock::processTimes(); sLastFrameIndex = sCurFrameIndex++; } // get ready for next frame - BlockTimer::resetFrame(); + //void TimeBlock::resetFrame() + { + if (sLog) + { //output current frame counts to performance log + + static S32 call_count = 0; + if (call_count % 100 == 0) + { + LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL; + LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; + LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL; + } + call_count++; + + LLUnit<LLUnits::Seconds, F64> total_time = 0; + LLSD sd; + + { + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), + end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) + { + TimeBlock& timer = *it; + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecordingPeriod().getSum(timer).value()); + sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecordingPeriod().getSum(timer.callCount())); + + // computing total time here because getting the root timer's getCountHistory + // doesn't work correctly on the first frame + total_time += frame_recording.getLastRecordingPeriod().getSum(timer); + } + } + + sd["Total"]["Time"] = (LLSD::Real) total_time.value(); + sd["Total"]["Calls"] = (LLSD::Integer) 1; + + { + LLMutexLock lock(sLogLock); + sLogQueue.push(sd); + } + } + + // reset for next frame + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), + end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) + { + TimeBlock& timer = *it; + TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + + tree_node.mLastCaller = NULL; + tree_node.mMoveUpTree = false; + } + } sLastFrameTime = frame_time; } //static -void Time::dumpCurTimes() +void TimeBlock::dumpCurTimes() { // accumulate timings, etc. - BlockTimer::processTimes(); + processTimes(); - F64 clock_freq = (F64)get_clock_count(); - F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds - // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(BlockTimer::getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimer()); it != end_timer_tree(); ++it) { - BlockTimer* timerp = (*it); - F64 total_time_ms = ((F64)timerp->getHistoricalCount(0) * iclock_freq); + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + TimeBlock* timerp = (*it); + LLUnit<LLUnits::Seconds, F64> total_time_ms = frame_recording.getLastRecordingPeriod().getSum(*timerp); + U32 num_calls = frame_recording.getLastRecordingPeriod().getSum(timerp->callCount()); + // Don't bother with really brief times, keep output concise if (total_time_ms < 0.1) continue; @@ -564,17 +478,16 @@ void Time::dumpCurTimes() out_str << "\t"; } - out_str << timerp->getName() << " " - << std::setprecision(3) << total_time_ms << " ms, " - << timerp->getHistoricalCalls(0) << " calls"; + << std::setprecision(3) << total_time_ms.as<LLUnits::Milliseconds, F32>() << " ms, " + << num_calls << " calls"; llinfos << out_str.str() << llendl; } } //static -void Time::writeLog(std::ostream& os) +void TimeBlock::writeLog(std::ostream& os) { while (!sLogQueue.empty()) { @@ -585,29 +498,34 @@ void Time::writeLog(std::ostream& os) } } +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TimeBlockAccumulator +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -TimerAccumulator::TimerAccumulator() : mSelfTimeCounter(0), +TimeBlockAccumulator::TimeBlockAccumulator() +: mSelfTimeCounter(0), mTotalTimeCounter(0), mCalls(0) {} -void TimerAccumulator::addSamples( const TimerAccumulator& other ) +void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other ) { mSelfTimeCounter += other.mSelfTimeCounter; mTotalTimeCounter += other.mTotalTimeCounter; mCalls += other.mCalls; } -void TimerAccumulator::reset( const TimerAccumulator* other ) +void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other ) { mTotalTimeCounter = 0; mSelfTimeCounter = 0; mCalls = 0; } -TimerTreeNode::TimerTreeNode() +TimeBlockTreeNode::TimeBlockTreeNode() : mLastCaller(NULL), mActiveCount(0), mMoveUpTree(false) {} -} + +} // namespace LLTrace diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 9f981480f2..e3d99a9e4b 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -40,28 +40,21 @@ namespace LLTrace struct CurTimerData { - class Time* mCurTimer; - class BlockTimer* mTimerData; + class BlockTimer* mCurTimer; + class TimeBlock* mTimerData; U64 mChildTime; - TimerTreeNode* mTimerTreeData; + TimeBlockTreeNode* mTimerTreeData; }; -class Time +class BlockTimer { public: - friend class BlockTimer; - typedef Time self_t; - typedef class BlockTimer DeclareTimer; + friend class TimeBlock; + typedef BlockTimer self_t; + typedef class TimeBlock DeclareTimer; - Time(BlockTimer& timer); - ~Time(); - -public: - // dumps current cumulative frame stats to log - // call nextFrame() to reset timers - static void dumpCurTimes(); - - static void writeLog(std::ostream& os); + BlockTimer(TimeBlock& timer); + ~BlockTimer(); private: @@ -69,40 +62,41 @@ private: CurTimerData mLastTimerData; }; -// stores a "named" timer instance to be reused via multiple Time stack instances -class BlockTimer -: public TraceType<TimerAccumulator>, - public LLInstanceTracker<BlockTimer> +// stores a "named" timer instance to be reused via multiple BlockTimer stack instances +class TimeBlock +: public TraceType<TimeBlockAccumulator>, + public LLInstanceTracker<TimeBlock> { public: - BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer()); - ~BlockTimer(); + TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); enum { HISTORY_NUM = 300 }; - BlockTimer* getParent() const { return mParent; } - void setParent(BlockTimer* parent); + TimeBlock* getParent() const { return mParent; } + void setParent(TimeBlock* parent); S32 getDepth(); - typedef std::vector<BlockTimer*>::const_iterator child_const_iter; + typedef std::vector<TimeBlock*>::const_iterator child_const_iter; child_const_iter beginChildren(); child_const_iter endChildren(); - std::vector<BlockTimer*>& getChildren(); + std::vector<TimeBlock*>& getChildren(); void setCollapsed(bool collapsed) { mCollapsed = collapsed; } bool getCollapsed() const { return mCollapsed; } - U32 getCountAverage() const { return mCountAverage; } - U32 getCallAverage() const { return mCallAverage; } - - U64 getHistoricalCount(S32 history_index = 0) const; - U32 getHistoricalCalls(S32 history_index = 0) const; + TraceType<TimeBlockAccumulator::CallCountAspect>& callCount() + { + return static_cast<TraceType<TimeBlockAccumulator::CallCountAspect>&>(*(TraceType<TimeBlockAccumulator>*)this); + } - static BlockTimer& getRootTimer(); + static TimeBlock& getRootTimer(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); - friend class Time; + static void writeLog(std::ostream& os); + // dumps current cumulative frame stats to log + // call nextFrame() to reset timers + static void dumpCurTimes(); ////////////////////////////////////////////////////////////////////////////// // @@ -126,14 +120,14 @@ public: //#undef _interlockedbittestandset //#undef _interlockedbittestandreset - //inline U32 BlockTimer::getCPUClockCount32() + //inline U32 TimeBlock::getCPUClockCount32() //{ // U64 time_stamp = __rdtsc(); // return (U32)(time_stamp >> 8); //} // //// return full timer value, *not* shifted by 8 bits - //inline U64 BlockTimer::getCPUClockCount64() + //inline U64 TimeBlock::getCPUClockCount64() //{ // return __rdtsc(); //} @@ -242,35 +236,16 @@ public: static U64 countsPerSecond(); - // recursive call to gather total time from children - static void accumulateTimings(); - // updates cumulative times and hierarchy, // can be called multiple times in a frame, at any point static void processTimes(); - static void buildHierarchy(); - static void resetFrame(); - static void reset(); // call this once a frame to reset timers static void nextFrame(); - static S32 getLastFrameIndex() { return sLastFrameIndex; } - static S32 getCurFrameIndex() { return sCurFrameIndex; } - - - - // sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete - U64 mTreeTimeCounter; - - U64 mCountAverage; - U32 mCallAverage; - - U64* mCountHistory; - U32* mCallHistory; - // tree structure - BlockTimer* mParent; // BlockTimer of caller(parent) - std::vector<BlockTimer*> mChildren; + // tree structure, only updated from master trace thread + TimeBlock* mParent; // TimeBlock of caller(parent) + std::vector<TimeBlock*> mChildren; bool mCollapsed, // don't show children mNeedsSorting; // sort children whenever child added @@ -288,13 +263,13 @@ public: }; -LL_FORCE_INLINE Time::Time(BlockTimer& timer) +LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) { #if FAST_TIMER_ON - mStartTime = BlockTimer::getCPUClockCount64(); + mStartTime = TimeBlock::getCPUClockCount64(); - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); - TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; + CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); + TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; tree_node.mActiveCount++; // keep current parent as long as it is active when we are tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); @@ -308,13 +283,13 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer) #endif } -LL_FORCE_INLINE Time::~Time() +LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if FAST_TIMER_ON - U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get(); - TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - TimerTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; + U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; + CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; @@ -328,12 +303,12 @@ LL_FORCE_INLINE Time::~Time() // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *BlockTimer::sCurTimerData = mLastTimerData; + *TimeBlock::sCurTimerData = mLastTimerData; #endif } } -typedef LLTrace::Time LLFastTimer; +typedef LLTrace::BlockTimer LLFastTimer; #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index 43d98be47b..aaacbfb599 100644 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -91,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s // Return TRUE if this metric is requested or if the general default "catch all" metric is requested BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name) { - return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME))); + return (LLTrace::TimeBlock::sMetricLog && ((LLTrace::TimeBlock::sLogName == name) || (LLTrace::TimeBlock::sLogName == DEFAULT_METRIC_NAME))); } /*static*/ @@ -194,7 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd) void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd) { - LLTrace::BlockTimer::pushLog(*sd); + LLTrace::TimeBlock::pushLog(*sd); } void LLMetricPerformanceTesterBasic::outputTestResults() diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3e43a85e80..9e275da647 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -37,7 +37,7 @@ #include <list> -#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer); +#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::TimeBlock::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer); namespace LLTrace { @@ -213,10 +213,10 @@ namespace LLTrace : public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string> { public: - TraceType(const char* name, const char* description = NULL) + TraceType(const char* name, const char* description = "") : LLInstanceTracker(name), mName(name), - mDescription(description ? description : "") + mDescription(description) { mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } @@ -392,26 +392,43 @@ namespace LLTrace U32 mNumSamples; }; - class TimerAccumulator + class TimeBlockAccumulator { public: - TimerAccumulator(); - void addSamples(const TimerAccumulator& other); - void reset(const TimerAccumulator* other); + typedef LLUnit<LLUnits::Seconds, F64> value_t; + + // fake class that allows us to view call count aspect of timeblock accumulator + struct CallCountAspect + { + typedef U32 value_t; + }; + + TimeBlockAccumulator(); + void addSamples(const TimeBlockAccumulator& other); + void reset(const TimeBlockAccumulator* other); // // members // U64 mSelfTimeCounter, mTotalTimeCounter; - U32 mCalls; + U32 mCalls; + }; + + template<> + class TraceType<TimeBlockAccumulator::CallCountAspect> + : public TraceType<TimeBlockAccumulator> + { + TraceType(const char* name, const char* description = "") + : TraceType<TimeBlockAccumulator>(name, description) + {} }; - class TimerTreeNode + class TimeBlockTreeNode { public: - TimerTreeNode(); - class BlockTimer* mLastCaller; // used to bootstrap tree construction + TimeBlockTreeNode(); + class TimeBlock* mLastCaller; // used to bootstrap tree construction U16 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame }; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ff3ae1e553..0d4d07faf6 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,7 +44,7 @@ Recording::Recording() mMeasurementsFloat(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), mCounts(new AccumulatorBuffer<CountAccumulator<S64> >()), mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<S64> >()), - mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) + mStackTimers(new AccumulatorBuffer<TimeBlockAccumulator>()) {} Recording::Recording( const Recording& other ) @@ -143,16 +143,27 @@ void Recording::appendRecording( const Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimerAccumulator>& stat) const +LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator>& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond(); + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); } -LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimerAccumulator>& stat) const +U32 Recording::getSum(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const { - return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds); + return (*mStackTimers)[stat.getIndex()].mCalls; } +LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); +} + +F32 Recording::getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const +{ + return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; +} + + F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const { return (*mCountsFloat)[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 0adea2663b..efed3f662e 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -119,8 +119,10 @@ namespace LLTrace void update(); // Timer accessors - LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimerAccumulator>& stat) const; - LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimerAccumulator>& stat) const; + LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimeBlockAccumulator>& stat) const; + U32 getSum(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const; + LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimeBlockAccumulator>& stat) const; + F32 getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const; // Count accessors F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const; @@ -221,7 +223,7 @@ namespace LLTrace LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurementsFloat; LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > > mCounts; LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > > mMeasurements; - LLCopyOnWritePointer<AccumulatorBuffer<TimerAccumulator> > mStackTimers; + LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> > mStackTimers; LLTimer mSamplingTimer; F64 mElapsedSeconds; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 0a2d79cf3a..16235473ee 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -42,14 +42,14 @@ ThreadRecorder::ThreadRecorder() mFullRecording.start(); mRootTimerData = new CurTimerData(); - mRootTimerData->mTimerData = &BlockTimer::getRootTimer(); - mRootTimerData->mTimerTreeData = new TimerTreeNode[AccumulatorBuffer<TimerAccumulator>::getDefaultBuffer().size()]; - BlockTimer::sCurTimerData = mRootTimerData; + mRootTimerData->mTimerData = &TimeBlock::getRootTimer(); + mRootTimerData->mTimerTreeData = new TimeBlockTreeNode[AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer().size()]; + TimeBlock::sCurTimerData = mRootTimerData; - mRootTimer = new Time(BlockTimer::getRootTimer()); + mRootTimer = new BlockTimer(TimeBlock::getRootTimer()); mRootTimerData->mCurTimer = mRootTimer; - mRootTimerData->mTimerTreeData[BlockTimer::getRootTimer().getIndex()].mActiveCount = 1; + mRootTimerData->mTimerTreeData[TimeBlock::getRootTimer().getIndex()].mActiveCount = 1; } ThreadRecorder::~ThreadRecorder() @@ -61,7 +61,7 @@ ThreadRecorder::~ThreadRecorder() mActiveRecordings.front().mTargetRecording->stop(); } get_thread_recorder() = NULL; - BlockTimer::sCurTimerData = NULL; + TimeBlock::sCurTimerData = NULL; delete [] mRootTimerData->mTimerTreeData; delete mRootTimerData; } diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 277a468a40..102b980e44 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -64,7 +64,7 @@ namespace LLTrace std::list<ActiveRecording> mActiveRecordings; struct CurTimerData* mRootTimerData; - class Time* mRootTimer; + class BlockTimer* mRootTimer; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 54902b6322..01e9eb751d 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -180,23 +180,23 @@ struct LLUnitStrict : public LLUnit<UNIT_TYPE, STORAGE_TYPE> typedef typename LLUnit<UNIT_TYPE, STORAGE_TYPE>::storage_t storage_t; explicit LLUnitStrict(storage_t value = storage_t()) - : LLUnit(value) + : LLUnit<UNIT_TYPE, STORAGE_TYPE>(value) {} template<typename OTHER_UNIT, typename OTHER_STORAGE> LLUnitStrict(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) - : LLUnit(convert(other)) + : LLUnit<UNIT_TYPE, STORAGE_TYPE>(convert(other)) {} LLUnitStrict(self_t& other) - : LLUnit(other) + : LLUnit<UNIT_TYPE, STORAGE_TYPE>(other) {} private: operator storage_t() const { - return value(); + return LLUnit<UNIT_TYPE, STORAGE_TYPE>::value(); } }; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index b9bdb7cd08..c986954867 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -592,7 +592,7 @@ public: while (!LLAppViewer::instance()->isQuitting()) { - LLFastTimer::writeLog(os); + LLTrace::TimeBlock::writeLog(os); os.flush(); ms_sleep(32); } @@ -680,7 +680,6 @@ bool LLAppViewer::init() // into the log files during normal startup until AFTER // we run the "program crashed last time" error handler below. // - LLTrace::BlockTimer::reset(); // initialize SSE options LLVector4a::initClass(); @@ -1234,7 +1233,7 @@ bool LLAppViewer::mainLoop() while (!LLApp::isExiting()) { LLFastTimer _(FTM_FRAME); - LLTrace::BlockTimer::nextFrame(); + LLTrace::TimeBlock::nextFrame(); LLTrace::get_frame_recording().nextPeriod(); LLTrace::getMasterThreadRecorder().pullFromSlaveThreads(); @@ -1565,9 +1564,9 @@ bool LLAppViewer::cleanup() if (LLFastTimerView::sAnalyzePerformance) { llinfos << "Analyzing performance" << llendl; - std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp"; - std::string current_name = LLTrace::BlockTimer::sLogName + ".slp"; - std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv"; + std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp"; + std::string current_name = LLTrace::TimeBlock::sLogName + ".slp"; + std::string report_name = LLTrace::TimeBlock::sLogName + "_report.csv"; LLFastTimerView::doAnalysis( gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name), @@ -1926,9 +1925,9 @@ bool LLAppViewer::cleanup() { llinfos << "Analyzing performance" << llendl; - std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp"; - std::string current_name = LLTrace::BlockTimer::sLogName + ".slp"; - std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv"; + std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp"; + std::string current_name = LLTrace::TimeBlock::sLogName + ".slp"; + std::string report_name = LLTrace::TimeBlock::sLogName + "_report.csv"; LLFastTimerView::doAnalysis( gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name), @@ -2051,10 +2050,10 @@ bool LLAppViewer::initThreads() enable_threads && true, app_metrics_qa_mode); - if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) + if (LLTrace::TimeBlock::sLog || LLTrace::TimeBlock::sMetricLog) { - LLTrace::BlockTimer::setLogLock(new LLMutex(NULL)); - mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName); + LLTrace::TimeBlock::setLogLock(new LLMutex(NULL)); + mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::TimeBlock::sLogName); mFastTimerLogThread->start(); } @@ -2463,13 +2462,13 @@ bool LLAppViewer::initConfiguration() if (clp.hasOption("logperformance")) { - LLTrace::BlockTimer::sLog = true; - LLTrace::BlockTimer::sLogName = std::string("performance"); + LLTrace::TimeBlock::sLog = true; + LLTrace::TimeBlock::sLogName = std::string("performance"); } if (clp.hasOption("logmetrics")) { - LLTrace::BlockTimer::sMetricLog = true ; + LLTrace::TimeBlock::sMetricLog = true ; // '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test // In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...) std::string test_name = clp.getOption("logmetrics")[0]; @@ -2477,11 +2476,11 @@ bool LLAppViewer::initConfiguration() if (test_name == "") { llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl; - LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME; + LLTrace::TimeBlock::sLogName = DEFAULT_METRIC_NAME; } else { - LLTrace::BlockTimer::sLogName = test_name; + LLTrace::TimeBlock::sLogName = test_name; } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6aca8f4426..acf3799f27 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -57,21 +57,19 @@ static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; -//static const int FTV_DISPLAY_NUM = (sizeof(ft_display_table)/sizeof(ft_display_table[0])); -static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t; +typedef LLTreeDFSIter<LLTrace::TimeBlock, LLTrace::TimeBlock::child_const_iter> timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -81,29 +79,25 @@ static timer_tree_iterator_t end_timer_tree() LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), - mHoverTimer(NULL) -{ - mDisplayMode = 0; - mAvgCountTotal = 0; - mMaxCountTotal = 0; - mDisplayCenter = ALIGN_CENTER; - mDisplayCalls = 0; - mDisplayHz = 0; - mScrollIndex = 0; - mHoverID = NULL; - mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLInstanceTracker<LLTrace::BlockTimer>::instanceCount(); - mPrintStats = -1; -} + mHoverTimer(NULL), + mDisplayMode(0), + mDisplayCenter(ALIGN_CENTER), + mDisplayCalls(false), + mDisplayHz(false), + mScrollIndex(0), + mHoverID(NULL), + mHoverBarIndex(-1), + mPrintStats(-1) +{} void LLFastTimerView::onPause() { - LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory; + LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory; // reset scroll to bottom when unpausing - if (!LLTrace::BlockTimer::sPauseHistory) + if (!LLTrace::TimeBlock::sPauseHistory) { mScrollIndex = 0; - LLTrace::BlockTimer::sResetHistory = true; + LLTrace::TimeBlock::sResetHistory = true; getChild<LLButton>("pause_btn")->setLabel(getString("pause")); } else @@ -139,13 +133,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) { S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()); bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY); - mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y) +LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +166,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* idp = getLegendID(y); + LLTrace::TimeBlock* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -223,19 +217,21 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex()); + mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llclamp( mScrollIndex, 0, frame_recording.getNumPeriods()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, + mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -279,7 +275,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* timer_id = getLegendID(y); + LLTrace::TimeBlock* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -290,28 +286,28 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) +static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1) { - F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond(); - LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording(); + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); std::string tooltip; if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage()); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); } return tooltip; } BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -319,7 +315,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -334,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* idp = getLegendID(y); + LLTrace::TimeBlock* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp)); @@ -349,26 +345,27 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLTrace::BlockTimer::sPauseHistory = TRUE; + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + + LLTrace::TimeBlock::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } -static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true); +static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true); -static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors; +static std::map<LLTrace::TimeBlock*, LLColor4> sTimerColors; void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - + + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + std::string tdesc; - F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond(); - F64 iclock_freq = 1000.0 / clock_freq; - S32 margin = 10; S32 height = getRect().getHeight(); S32 width = getRect().getWidth(); @@ -422,7 +419,7 @@ void LLFastTimerView::draw() y -= (texth + 2); } - S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); + S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY); // Draw the legend xleft = margin; @@ -438,7 +435,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -458,12 +455,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map<LLTrace::BlockTimer*, S32> display_line; + std::map<LLTrace::TimeBlock*, S32> display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -479,20 +476,18 @@ void LLFastTimerView::draw() } gl_rect_2d(left - scale_offset, top + scale_offset, right + scale_offset, bottom - scale_offset, sTimerColors[idp]); - F32 ms = 0; + LLUnit<LLUnits::Milliseconds, F32> ms = 0; S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; - U64 ticks = idp->getHistoricalCount(hidx); - ms = (F32)((F64)ticks * iclock_freq); - calls = (S32)idp->getHistoricalCalls(hidx); + S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp); + calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount()); } else { - U64 ticks = idp->getCountAverage(); - ms = (F32)((F64)ticks * iclock_freq); - calls = (S32)idp->getCallAverage(); + ms = frame_recording.getPeriodMean(*idp); + calls = frame_recording.getPeriodMean(idp->callCount()); } if (mDisplayCalls) @@ -521,7 +516,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::BlockTimer* next_parent = idp->getParent(); + LLTrace::TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -563,419 +558,386 @@ void LLFastTimerView::draw() barw = width - xleft - margin; // Draw the history bars - if (LLTrace::BlockTimer::getLastFrameIndex() >= 0) - { - LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - - U64 totalticks; - if (!LLTrace::BlockTimer::sPauseHistory) - { - U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex); - - if (LLTrace::BlockTimer::getCurFrameIndex() >= 10) - { - U64 framec = LLTrace::BlockTimer::getCurFrameIndex(); - U64 avg = (U64)mAvgCountTotal; - mAvgCountTotal = (avg*framec + ticks) / (framec + 1); - if (ticks > mMaxCountTotal) - { - mMaxCountTotal = ticks; - } - } - - if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100) - { - LLTrace::BlockTimer::sResetHistory = true; - } + LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory) - { - mAvgCountTotal = ticks; - mMaxCountTotal = ticks; - LLTrace::BlockTimer::sResetHistory = false; - } - } + LLUnit<LLUnits::Seconds, F64> total_time; - if (mDisplayMode == 0) - { - totalticks = mAvgCountTotal*2; - } - else if (mDisplayMode == 1) - { - totalticks = mMaxCountTotal; - } - else if (mDisplayMode == 2) - { - // Calculate the max total ticks for the current history - totalticks = 0; - for (S32 j=0; j<histmax; j++) - { - U64 ticks = getFrameTimer().getHistoricalCount(j); + mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); - if (ticks > totalticks) - totalticks = ticks; - } - } - else - { - totalticks = (U64)(clock_freq * .1); // 100 ms - } + if (mDisplayMode == 0) + { + total_time = frame_recording.getPeriodMean(getFrameTimer())*2; + } + else if (mDisplayMode == 1) + { + total_time = mAllTimeMax; + } + else if (mDisplayMode == 2) + { + // Calculate the max total ticks for the current history + total_time = frame_recording.getPeriodMax(getFrameTimer()); + } + else + { + total_time = LLUnit<LLUnits::Milliseconds, F32>(100); + } - // Draw MS ticks - { - U32 ms = (U32)((F64)totalticks * iclock_freq) ; + // Draw MS ticks + { + LLUnit<LLUnits::Milliseconds, U32> ms = total_time; - tdesc = llformat("%.1f ms |", (F32)ms*.25f); - x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.25f); + x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.50f); - x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.50f); + x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.75f); - x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.75f); + x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", ms); - x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - } + tdesc = llformat( "%d ms |", (U32)ms); + x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + } - // Draw borders - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f(0.5f,0.5f,0.5f,0.5f); + // Draw borders + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f(0.5f,0.5f,0.5f,0.5f); - S32 by = y + 2; + S32 by = y + 2; - y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); - //heading - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); + //heading + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); - //tree view - gl_rect_2d(5, by, xleft-10, 5, FALSE); + //tree view + gl_rect_2d(5, by, xleft-10, 5, FALSE); - by = y + 5; - //average bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); + by = y + 5; + //average bar + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); - by -= barh*2+dy; + by -= barh*2+dy; - //current frame bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); + //current frame bar + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); - by -= barh+dy+1; + by -= barh+dy+1; - //history bars - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); + //history bars + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); - by = LINE_GRAPH_HEIGHT-barh-dy-7; + by = LINE_GRAPH_HEIGHT-barh-dy-7; - //line graph - mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); + //line graph + mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); - gl_rect_2d(mGraphRect, FALSE); - } + gl_rect_2d(mGraphRect, FALSE); + } - mBarStart.clear(); - mBarEnd.clear(); + mBarStart.clear(); + mBarEnd.clear(); - // Draw bars for each history entry - // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); - for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++) + // Draw bars for each history entry + // Special: -1 = show running average + gGL.getTexUnit(0)->bind(box_imagep->getImage()); + for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++) + { + mBarStart.push_back(std::vector<S32>()); + mBarEnd.push_back(std::vector<S32>()); + int sublevel_dx[FTV_MAX_DEPTH]; + int sublevel_left[FTV_MAX_DEPTH]; + int sublevel_right[FTV_MAX_DEPTH]; + S32 tidx; + if (j >= 0) { - mBarStart.push_back(std::vector<S32>()); - mBarEnd.push_back(std::vector<S32>()); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx; - if (j >= 0) - { - tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex; - } - else - { - tidx = -1; - } + tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex; + } + else + { + tidx = -1; + } - x = xleft; + x = xleft; - // draw the bars for each stat - std::vector<S32> xpos; - std::vector<S32> deltax; - xpos.push_back(xleft); + // draw the bars for each stat + std::vector<S32> xpos; + std::vector<S32> deltax; + xpos.push_back(xleft); - LLTrace::BlockTimer* prev_id = NULL; + LLTrace::TimeBlock* prev_id = NULL; - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it, ++i) - { - LLTrace::BlockTimer* idp = (*it); - F32 frac = tidx == -1 - ? (F32)idp->getCountAverage() / (F32)totalticks - : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; + S32 i = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it, ++i) + { + LLTrace::TimeBlock* idp = (*it); + F32 frac = tidx == -1 + ? (frame_recording.getPeriodMean(*idp) / total_time) + : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - dx = llround(frac * (F32)barw); - S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); - deltax.push_back(dx); + dx = llround(frac * (F32)barw); + S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); + deltax.push_back(dx); + + int level = idp->getDepth() - 1; - int level = idp->getDepth() - 1; + while ((S32)xpos.size() > level + 1) + { + xpos.pop_back(); + } + left = xpos.back(); - while ((S32)xpos.size() > level + 1) + if (level == 0) + { + sublevel_left[level] = xleft; + sublevel_dx[level] = dx; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + else if (prev_id && prev_id->getDepth() < idp->getDepth()) + { + U64 sublevelticks = 0; + + for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + it != prev_id->endChildren(); + ++it) { - xpos.pop_back(); + sublevelticks += (tidx == -1) + ? frame_recording.getPeriodMean(**it) + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it); } - left = xpos.back(); - - if (level == 0) + + F32 subfrac = (F32)sublevelticks / (F32)total_time; + sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); + + if (mDisplayCenter == ALIGN_CENTER) { - sublevel_left[level] = xleft; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + left += (prev_delta_x - sublevel_dx[level])/2; } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) + else if (mDisplayCenter == ALIGN_RIGHT) { - U64 sublevelticks = 0; - - for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) - { - sublevelticks += (tidx == -1) - ? (*it)->getCountAverage() - : (*it)->getHistoricalCount(tidx); - } - - F32 subfrac = (F32)sublevelticks / (F32)totalticks; - sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); - - if (mDisplayCenter == ALIGN_CENTER) - { - left += (prev_delta_x - sublevel_dx[level])/2; - } - else if (mDisplayCenter == ALIGN_RIGHT) - { - left += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = left; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - - right = left + dx; - xpos.back() = right; - xpos.push_back(left); + left += (prev_delta_x - sublevel_dx[level]); + } + + sublevel_left[level] = left; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + + right = left + dx; + xpos.back() = right; + xpos.push_back(left); - mBarStart.back().push_back(left); - mBarEnd.back().push_back(right); + mBarStart.back().push_back(left); + mBarEnd.back().push_back(right); - top = y; - bottom = y - barh; + top = y; + bottom = y - barh; - if (right > left) - { - //U32 rounded_edges = 0; - LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; - S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::BlockTimer* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } - - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); - } - else if (mHoverID != NULL && !is_child_of_hover_item) - { - color = lerp(color, LLColor4::grey, 0.8f); - } - - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); + if (right > left) + { + //U32 rounded_edges = 0; + LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; + S32 scale_offset = 0; + BOOL is_child_of_hover_item = (idp == mHoverID); + LLTrace::TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); } - if ((*it)->getCollapsed()) + if (idp == mHoverID) { - it.skipDescendants(); + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + //color = lerp(color, LLColor4::black, -0.4f); } - - prev_id = idp; + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } + + gGL.color4fv(color.mV); + F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); + } - y -= (barh + dy); - if (j < 0) - y -= barh; + + if ((*it)->getCollapsed()) + { + it.skipDescendants(); + } + + prev_id = idp; } + y -= (barh + dy); + if (j < 0) + y -= barh; + } - //draw line graph history - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLLocalClipRect clip(mGraphRect); + //draw line graph history + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLLocalClipRect clip(mGraphRect); - //normalize based on last frame's maximum - static U64 last_max = 0; - static F32 alpha_interp = 0.f; - U64 max_ticks = llmax(last_max, (U64) 1); - F32 ms = (F32)((F64)max_ticks * iclock_freq); + //normalize based on last frame's maximum + static LLUnit<LLUnits::Seconds, F32> max_time = 0.000001; + static U32 max_calls = 0; + static F32 alpha_interp = 0.f; - //display y-axis range - std::string tdesc; - if (mDisplayCalls) - tdesc = llformat("%d calls", (int)max_ticks); - else if (mDisplayHz) - tdesc = llformat("%d Hz", (int)max_ticks); - else - tdesc = llformat("%4.2f ms", ms); + //display y-axis range + std::string tdesc; + if (mDisplayCalls) + tdesc = llformat("%d calls", (int)max_calls); + else if (mDisplayHz) + tdesc = llformat("%d Hz", (int)(1.f / max_time.value())); + else + tdesc = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value()); - x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; - y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); + x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; + y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - //highlight visible range - { - S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex; - S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; + //highlight visible range + { + S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex; + S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1); - F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; - F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; + F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; + F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; - gGL.color4f(0.5f,0.5f,0.5f,0.3f); - gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); + gGL.color4f(0.5f,0.5f,0.5f,0.3f); + gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); - if (mHoverBarIndex >= 0) - { - S32 bar_frame = first_frame - mHoverBarIndex; - F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; + if (mHoverBarIndex >= 0) + { + S32 bar_frame = first_frame - mHoverBarIndex; + F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; - gGL.color4f(0.5f,0.5f,0.5f,1); + gGL.color4f(0.5f,0.5f,0.5f,1); - gGL.begin(LLRender::LINES); - gGL.vertex2i((S32)bar, mGraphRect.mBottom); - gGL.vertex2i((S32)bar, mGraphRect.mTop); - gGL.end(); - } + gGL.begin(LLRender::LINES); + gGL.vertex2i((S32)bar, mGraphRect.mBottom); + gGL.vertex2i((S32)bar, mGraphRect.mTop); + gGL.end(); } + } - U64 cur_max = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it) - { - LLTrace::BlockTimer* idp = (*it); + LLUnit<LLUnits::Seconds, F32> cur_max = 0; + U32 cur_max_calls = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it) + { + LLTrace::TimeBlock* idp = (*it); - //fatten highlighted timer - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(3); - } + //fatten highlighted timer + if (mHoverID == idp) + { + gGL.flush(); + glLineWidth(3); + } - const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; + const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; - F32 alpha = 1.f; + F32 alpha = 1.f; - if (mHoverID != NULL && - idp != mHoverID) - { //fade out non-highlighted timers - if (idp->getParent() != mHoverID) - { - alpha = alpha_interp; - } - } - - gGL.color4f(col[0], col[1], col[2], alpha); - gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex()); - j < LLTrace::BlockTimer::HISTORY_NUM; - j++) + if (mHoverID != NULL && + idp != mHoverID) + { //fade out non-highlighted timers + if (idp->getParent() != mHoverID) { - U64 ticks = idp->getHistoricalCount(j); - - if (mDisplayHz) - { - F64 tc = (F64) (ticks+1) * iclock_freq; - tc = 1000.f/tc; - ticks = llmin((U64) tc, (U64) 1024); - } - else if (mDisplayCalls) - { - ticks = (S32)idp->getHistoricalCalls(j); - } - - if (alpha == 1.f) - { - //normalize to highlighted timer - cur_max = llmax(cur_max, ticks); - } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j; - F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; - gGL.vertex2f(x,y); - gGL.vertex2f(x,mGraphRect.mBottom); - } - gGL.end(); - - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(1); + alpha = alpha_interp; } + } - if (idp->getCollapsed()) - { - //skip hidden timers - it.skipDescendants(); + gGL.color4f(col[0], col[1], col[2], alpha); + gGL.begin(LLRender::TRIANGLE_STRIP); + for (U32 j = frame_recording.getNumPeriods(); + j < LLTrace::TimeBlock::HISTORY_NUM; + j++) + { + LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001)); + U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount()); + + if (alpha == 1.f) + { + //normalize to highlighted timer + cur_max = llmax(cur_max, time); + cur_max_calls = llmax(cur_max_calls, calls); } + F32 x = mGraphRect.mLeft + j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 y = mDisplayHz + ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) + : mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time); + gGL.vertex2f(x,y); + gGL.vertex2f(x,mGraphRect.mBottom); } - - //interpolate towards new maximum - last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); - if (last_max - cur_max <= 1 || cur_max - last_max <= 1) + gGL.end(); + + if (mHoverID == idp) { - last_max = cur_max; + gGL.flush(); + glLineWidth(1); } - F32 alpha_target = last_max > cur_max ? - llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) : - llmin((F32) cur_max/ (F32) last_max - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); - if (mHoverID != NULL) - { - x = (mGraphRect.mRight + mGraphRect.mLeft)/2; - y = mGraphRect.mBottom + 8; - - LLFontGL::getFontMonospace()->renderUTF8( - mHoverID->getName(), - 0, - x, y, - LLColor4::white, - LLFontGL::LEFT, LLFontGL::BOTTOM); - } + if (idp->getCollapsed()) + { + //skip hidden timers + it.skipDescendants(); + } + } + + //interpolate towards new maximum + max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); + if (max_time - cur_max <= 1 || cur_max - max_time <= 1) + { + max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max)); + } + + max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)); + if (llabs(max_calls - cur_max) <= 1) + { + max_calls = cur_max_calls; } + + // TODO: make sure alpha is correct in DisplayHz mode + F32 alpha_target = (max_time > cur_max) + ? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) + : llmin((F32) cur_max/ (F32) max_time - 1.f,1.f); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); + + if (mHoverID != NULL) + { + x = (mGraphRect.mRight + mGraphRect.mLeft)/2; + y = mGraphRect.mBottom + 8; + + LLFontGL::getFontMonospace()->renderUTF8( + mHoverID->getName(), + 0, + x, y, + LLColor4::white, + LLFontGL::LEFT, LLFontGL::BOTTOM); + } } + // Output stats for clicked bar to log if (mPrintStats >= 0) { @@ -985,7 +947,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); if (!first) { @@ -1007,7 +969,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); if (!first) { @@ -1015,16 +977,16 @@ void LLFastTimerView::draw() } first = false; - U64 ticks; + LLUnit<LLUnits::Seconds, F32> ticks; if (mPrintStats > 0) { - ticks = idp->getHistoricalCount(mPrintStats); + ticks = frame_recording.getPrevRecordingPeriod(mPrintStats).getSum(*idp); } else { - ticks = idp->getCountAverage(); + ticks = frame_recording.getPeriodMean(*idp); } - F32 ms = (F32)((F64)ticks * iclock_freq); + LLUnit<LLUnits::Milliseconds, F32> ms = ticks; timer_stat += llformat("%.1f",ms); @@ -1544,13 +1506,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLTrace::BlockTimer::sLog) + if(LLTrace::TimeBlock::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLTrace::BlockTimer::sMetricLog) + if(LLTrace::TimeBlock::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1561,7 +1523,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLTrace::BlockTimer& LLFastTimerView::getFrameTimer() +LLTrace::TimeBlock& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index d7f7f27cd4..55adae4147 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -29,6 +29,7 @@ #include "llfloater.h" #include "llfasttimer.h" +#include "llunit.h" class LLFastTimerView : public LLFloater { @@ -46,7 +47,7 @@ private: static LLSD analyzePerformanceLogDefault(std::istream& is) ; static void exportCharts(const std::string& base, const std::string& target); void onPause(); - LLTrace::BlockTimer& getFrameTimer(); + LLTrace::TimeBlock& getFrameTimer(); public: @@ -59,7 +60,7 @@ public: virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual void draw(); - LLTrace::BlockTimer* getLegendID(S32 y); + LLTrace::TimeBlock* getLegendID(S32 y); F64 getTime(const std::string& name); protected: @@ -78,20 +79,19 @@ private: ALIGN_COUNT } ChildAlignment; - ChildAlignment mDisplayCenter; - S32 mDisplayCalls; - S32 mDisplayHz; - U64 mAvgCountTotal; - U64 mMaxCountTotal; - LLRect mBarRect; - S32 mScrollIndex; - LLTrace::BlockTimer* mHoverID; - LLTrace::BlockTimer* mHoverTimer; - LLRect mToolTipRect; - S32 mHoverBarIndex; - LLFrameTimer mHighlightTimer; - S32 mPrintStats; - LLRect mGraphRect; + ChildAlignment mDisplayCenter; + bool mDisplayCalls, + mDisplayHz; + LLUnit<LLUnits::Seconds, F64> mAllTimeMax; + LLRect mBarRect; + S32 mScrollIndex; + LLTrace::TimeBlock* mHoverID; + LLTrace::TimeBlock* mHoverTimer; + LLRect mToolTipRect; + S32 mHoverBarIndex; + LLFrameTimer mHighlightTimer; + S32 mPrintStats; + LLRect mGraphRect; }; #endif diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 511e6ec2ab..69999071e7 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2184,7 +2184,7 @@ bool idle_startup() LLAppViewer::instance()->handleLoginComplete(); // reset timers now that we are running "logged in" logic - LLTrace::BlockTimer::reset(); + LLTrace::TimeBlock::reset(); LLAgentPicksInfo::getInstance()->requestNumberOfPicks(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 1ba78f18d3..781a420648 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7296,7 +7296,7 @@ void handle_dump_avatar_local_textures(void*) void handle_dump_timers() { - LLFastTimer::dumpCurTimes(); + LLTrace::TimeBlock::dumpCurTimes(); } void handle_debug_avatar_textures(void*) -- cgit v1.2.3 From 6c7825107f6ebb3dd8697a52aeb5d29a93060dc4 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 4 Dec 2012 19:10:02 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added copy constructor to periodic recording to allow snapshot generation in fast timer view fixed build errors --- indra/llcommon/lltrace.h | 4 ++-- indra/llcommon/lltracerecording.cpp | 14 +++++++++++ indra/llcommon/lltracerecording.h | 3 +++ indra/newview/llfasttimerview.cpp | 47 ++++++++++++++++++++++++------------- indra/newview/llfasttimerview.h | 3 +++ indra/newview/llstartup.cpp | 3 --- 6 files changed, 53 insertions(+), 21 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 9e275da647..a6b1b227c9 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -213,10 +213,10 @@ namespace LLTrace : public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string> { public: - TraceType(const char* name, const char* description = "") + TraceType(const char* name, const char* description = NULL) : LLInstanceTracker(name), mName(name), - mDescription(description) + mDescription(description ? description : "") { mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); } diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0d4d07faf6..7ed7e57570 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -305,6 +305,20 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state) initTo(state); } +PeriodicRecording::PeriodicRecording(PeriodicRecording& other) +: mNumPeriods(other.mNumPeriods), + mCurPeriod(other.mCurPeriod), + mTotalValid(other.mTotalValid), + mTotalRecording(other.mTotalRecording) +{ + mRecordingPeriods = new Recording[mNumPeriods]; + for (S32 i = 0; i < mNumPeriods; i++) + { + mRecordingPeriods[i] = other.mRecordingPeriods[i]; + } +} + + PeriodicRecording::~PeriodicRecording() { delete[] mRecordingPeriods; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index efed3f662e..a3af215dd3 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -234,6 +234,7 @@ namespace LLTrace { public: PeriodicRecording(S32 num_periods, EStopWatchState state = STOPPED); + PeriodicRecording(PeriodicRecording& recording); ~PeriodicRecording(); void nextPeriod(); @@ -261,11 +262,13 @@ namespace LLTrace Recording& getPrevRecordingPeriod(S32 offset) { + offset = llclamp(offset, 0, mNumPeriods - 1); return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; } const Recording& getPrevRecordingPeriod(S32 offset) const { + offset = llclamp(offset, 0, mNumPeriods - 1); return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods]; } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index acf3799f27..a06fac6bb6 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -87,21 +87,38 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex(0), mHoverID(NULL), mHoverBarIndex(-1), - mPrintStats(-1) + mPrintStats(-1), + mRecording(&LLTrace::get_frame_recording()) {} +LLFastTimerView::~LLFastTimerView() +{ + if (mRecording != &LLTrace::get_frame_recording()) + { + delete mRecording; + } + mRecording = NULL; +} + void LLFastTimerView::onPause() { LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory; // reset scroll to bottom when unpausing if (!LLTrace::TimeBlock::sPauseHistory) { + mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording()); mScrollIndex = 0; LLTrace::TimeBlock::sResetHistory = true; getChild<LLButton>("pause_btn")->setLabel(getString("pause")); } else { + if (mRecording != &LLTrace::get_frame_recording()) + { + delete mRecording; + } + mRecording = &LLTrace::get_frame_recording(); + getChild<LLButton>("pause_btn")->setLabel(getString("run")); } } @@ -133,7 +150,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) { S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()); bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY); - mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = mScrollIndex + bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); @@ -217,7 +234,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::PeriodicRecording& frame_recording = *mRecording; if (hasMouseCapture()) { @@ -231,7 +248,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1, + mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -286,12 +303,10 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1) +static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording) { F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond(); - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); - std::string tooltip; if (history_index < 0) { @@ -315,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + std::string tooltip = get_tooltip(*mHoverTimer, mScrollIndex + mHoverBarIndex, *mRecording); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -333,7 +348,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLTrace::TimeBlock* idp = getLegendID(y); if (idp) { - LLToolTipMgr::instance().show(get_tooltip(*idp)); + LLToolTipMgr::instance().show(get_tooltip(*idp, -1, *mRecording)); return TRUE; } @@ -345,7 +360,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::PeriodicRecording& frame_recording = *mRecording; LLTrace::TimeBlock::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, @@ -362,7 +377,7 @@ void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::PeriodicRecording& frame_recording = *mRecording; std::string tdesc; @@ -480,7 +495,7 @@ void LLFastTimerView::draw() S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + S32 hidx = mScrollIndex + mHoverBarIndex; ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp); calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount()); } @@ -660,7 +675,7 @@ void LLFastTimerView::draw() S32 tidx; if (j >= 0) { - tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex; + tidx = j + 1 + mScrollIndex; } else { @@ -870,8 +885,8 @@ void LLFastTimerView::draw() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); for (U32 j = frame_recording.getNumPeriods(); - j < LLTrace::TimeBlock::HISTORY_NUM; - j++) + j > 0; + j--) { LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001)); U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount()); @@ -882,7 +897,7 @@ void LLFastTimerView::draw() cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } - F32 x = mGraphRect.mLeft + j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) : mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time); diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 55adae4147..6474c2f524 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -30,11 +30,13 @@ #include "llfloater.h" #include "llfasttimer.h" #include "llunit.h" +#include "lltracerecording.h" class LLFastTimerView : public LLFloater { public: LLFastTimerView(const LLSD&); + ~LLFastTimerView(); BOOL postBuild(); static BOOL sAnalyzePerformance; @@ -92,6 +94,7 @@ private: LLFrameTimer mHighlightTimer; S32 mPrintStats; LLRect mGraphRect; + LLTrace::PeriodicRecording* mRecording; }; #endif diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 69999071e7..648fb0f7b7 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2183,9 +2183,6 @@ bool idle_startup() LLAppViewer::instance()->handleLoginComplete(); - // reset timers now that we are running "logged in" logic - LLTrace::TimeBlock::reset(); - LLAgentPicksInfo::getInstance()->requestNumberOfPicks(); LLIMFloater::initIMFloater(); -- cgit v1.2.3 From 68967e7b2b9416ff66cb49ae755fb33d7b81d129 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Wed, 5 Dec 2012 14:22:18 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system changed thread id declaration to be local to llthread.cpp and use currentID() uniformly across platforms --- indra/llcommon/llmutex.cpp | 8 -------- indra/llcommon/llthread.cpp | 10 ++++++++-- indra/llcommon/llthread.h | 7 ------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index e6beb9e680..b685bb4d60 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -83,11 +83,7 @@ void LLMutex::lock() mIsLocked[id] = TRUE; #endif -#if LL_DARWIN mLockingThread = LLThread::currentID(); -#else - mLockingThread = LLThread::sThreadID; -#endif } void LLMutex::unlock() @@ -126,11 +122,7 @@ bool LLMutex::isLocked() bool LLMutex::isSelfLocked() { -#if LL_DARWIN return mLockingThread == LLThread::currentID(); -#else - return mLockingThread == LLThread::sThreadID; -#endif } U32 LLMutex::lockingThread() const diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 8ce739bf23..6374b5398b 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -62,9 +62,9 @@ #if LL_DARWIN // statically allocated thread local storage not supported in Darwin executable formats #elif LL_WINDOWS -U32 __declspec(thread) LLThread::sThreadID = 0; +U32 __declspec(thread) sThreadID = 0; #elif LL_LINUX -U32 __thread LLThread::sThreadID = 0; +U32 __thread sThreadID = 0; #endif U32 LLThread::sIDIter = 0; @@ -294,7 +294,13 @@ void LLThread::setQuitting() // static U32 LLThread::currentID() { +#if LL_DARWIN + // statically allocated thread local storage not supported in Darwin executable formats return (U32)apr_os_thread_current(); +#else + return sThreadID; +#endif + } // static diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 75222c83f9..92323f5fda 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -39,13 +39,6 @@ class LL_COMMON_API LLThread private: friend class LLMutex; static U32 sIDIter; -#if LL_DARWIN - // statically allocated thread local storage not supported in Darwin executable formats -#elif LL_WINDOWS - static U32 __declspec(thread) LLThread::sThreadID; -#elif LL_LINUX - static U32 __thread LLThread::sThreadID ; -#endif public: typedef enum e_thread_status -- cgit v1.2.3 From 60800dacdd7e9b66ed654af471f2b9e9680cd981 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Dec 2012 00:37:15 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed gcc compile error made LLCopyOnWritePointer contain an LLPointer, not derive from it added type trait to control periodicrecording mean value type --- indra/llcommon/llpointer.h | 50 ++++++++++++++++++------------------- indra/llcommon/lltrace.h | 22 +++++++++++++--- indra/llcommon/lltracerecording.cpp | 2 +- indra/llcommon/lltracerecording.h | 16 +++++------- indra/newview/llfasttimerview.cpp | 4 +-- 5 files changed, 53 insertions(+), 41 deletions(-) diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 6a3bbeb768..f03551045e 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -166,52 +166,52 @@ protected: }; template<typename Type> -class LLCopyOnWritePointer : public LLPointer<Type> +class LLCopyOnWritePointer { public: - typedef LLPointer<Type> ref_pointer_t; typedef LLCopyOnWritePointer<Type> self_t; LLCopyOnWritePointer() - { - } + {} LLCopyOnWritePointer(Type* ptr) - : LLPointer(ptr) - { - } + : mPointer(ptr) + {} + + LLCopyOnWritePointer(LLPointer<Type>& ptr) + : mPointer(ptr) + {} Type* write() { makeUnique(); - return mPointer; + return mPointer.get(); } void makeUnique() { - if (mPointer && mPointer->getNumRefs() > 1) + if (mPointer.notNull() && mPointer.get()->getNumRefs() > 1) { - ref_pointer_t::assign(new Type(*mPointer)); + mPointer = new Type(*mPointer.get()); } } - using ref_pointer_t::operator BOOL; - using ref_pointer_t::operator bool; - using ref_pointer_t::operator!; - - using ref_pointer_t::operator !=; - using ref_pointer_t::operator ==; - using LLPointer<Type>::operator =; + operator BOOL() const { return (BOOL)mPointer; } + operator bool() const { return (bool)mPointer; } + bool operator!() const { return !mPointer; } + bool isNull() const { return mPointer.isNull(); } + bool notNull() const { return mPointer.notNull(); } - using LLPointer<Type>::operator <; - using LLPointer<Type>::operator >; - - - operator Type*() { return mPointer; } - operator const Type*() const { return mPointer; } - Type* operator->() { return mPointer; } - const Type* operator->() const { return mPointer; } + bool operator !=(Type* ptr) const { return (mPointer.get() != ptr); } + bool operator ==(Type* ptr) const { return (mPointer.get() == ptr); } + bool operator ==(const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer == ptr.mPointer); } + bool operator < (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer < ptr.mPointer); } + bool operator > (const LLCopyOnWritePointer<Type>& ptr) const { return (mPointer > ptr.mPointer); } + operator const Type*() const { return mPointer.get(); } + const Type* operator->() const { return mPointer.get(); } +protected: + LLPointer<Type> mPointer; }; #endif diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index a6b1b227c9..6e6bb51e47 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -201,18 +201,27 @@ namespace LLTrace } private: - ACCUMULATOR* mStorage; - size_t mStorageSize; - size_t mNextStorageSlot; + ACCUMULATOR* mStorage; + size_t mStorageSize; + size_t mNextStorageSlot; static LLThreadLocalPointer<ACCUMULATOR> sPrimaryStorage; }; template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; + //TODO: replace with decltype when C++11 is enabled + template<typename T> + struct MeanValueType + { + typedef F64 type; + }; + template<typename ACCUMULATOR> class TraceType : public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string> { public: + typedef typename MeanValueType<TraceType<ACCUMULATOR> >::type mean_t; + TraceType(const char* name, const char* description = NULL) : LLInstanceTracker(name), mName(name), @@ -415,6 +424,13 @@ namespace LLTrace U32 mCalls; }; + + template<> + struct MeanValueType<TraceType<TimeBlockAccumulator> > + { + typedef LLUnit<LLUnits::Seconds, F64> type; + }; + template<> class TraceType<TimeBlockAccumulator::CallCountAspect> : public TraceType<TimeBlockAccumulator> diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 7ed7e57570..e9b3376dae 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -49,7 +49,7 @@ Recording::Recording() Recording::Recording( const Recording& other ) { - llassert(other.mCountsFloat.get() != NULL); + llassert(other.mCountsFloat.notNull()); mSamplingTimer = other.mSamplingTimer; mElapsedSeconds = other.mElapsedSeconds; mCountsFloat = other.mCountsFloat; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index a3af215dd3..6fd1a105d3 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -326,36 +326,32 @@ namespace LLTrace } template <typename T> - F64 getPeriodMean(const TraceType<T>& stat) const + typename TraceType<T>::mean_t getPeriodMean(const TraceType<T>& stat) const { - F64 mean = 0.0; - F64 count = 0; + typename TraceType<T>::mean_t mean = 0.0; for (S32 i = 0; i < mNumPeriods; i++) { if (mRecordingPeriods[i].getDuration() > 0.f) { - count++; mean += mRecordingPeriods[i].getSum(stat); } } - mean /= (F64)mNumPeriods; + mean /= mNumPeriods; return mean; } template <typename T> - F64 getPeriodMeanPerSec(const TraceType<T>& stat) const + typename TraceType<T>::mean_t getPeriodMeanPerSec(const TraceType<T>& stat) const { - F64 mean = 0.0; - F64 count = 0; + typename TraceType<T>::mean_t mean = 0.0; for (S32 i = 0; i < mNumPeriods; i++) { if (mRecordingPeriods[i].getDuration() > 0.f) { - count++; mean += mRecordingPeriods[i].getPerSec(stat); } } - mean /= count; + mean /= mNumPeriods; return mean; } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index a06fac6bb6..704b914b78 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -501,7 +501,7 @@ void LLFastTimerView::draw() } else { - ms = frame_recording.getPeriodMean(*idp); + ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp)); calls = frame_recording.getPeriodMean(idp->callCount()); } @@ -511,7 +511,7 @@ void LLFastTimerView::draw() } else { - tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms); + tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); } dx = (texth+4) + idp->getDepth()*8; -- cgit v1.2.3 From 2facd6374517d88f03e3f06b1ccc02565da26b45 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Dec 2012 14:30:56 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved LLUnit compile time errors removed cassert in favor of llstatic_assert --- indra/llcommon/llevents.cpp | 1 - indra/llcommon/llmd5.cpp | 1 - indra/llcommon/llskipmap.h | 6 ++---- indra/llcommon/llunit.h | 7 ++++--- indra/llui/llview.cpp | 1 - 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index 0855180dcd..1c928b3db8 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -41,7 +41,6 @@ #include <algorithm> // std headers #include <typeinfo> -#include <cassert> #include <cmath> #include <cctype> // external library headers diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index 1409c55d1c..ed80af36d8 100644 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -76,7 +76,6 @@ documentation and/or software. #include "llmd5.h" -#include <cassert> #include <iostream> // cerr // how many bytes to grab at a time when checking files diff --git a/indra/llcommon/llskipmap.h b/indra/llcommon/llskipmap.h index 49ff2928d1..ed53973baa 100644 --- a/indra/llcommon/llskipmap.h +++ b/indra/llcommon/llskipmap.h @@ -210,8 +210,7 @@ inline LLSkipMap<INDEX_TYPE, DATA_TYPE, BINARY_DEPTH>::LLSkipMap() : mInsertFirst(NULL), mEquals(defaultEquals) { - // Skipmaps must have binary depth of at least 2 - cassert(BINARY_DEPTH >= 2); + llstatic_assert(BINARY_DEPTH >= 2, "Skipmaps must have binary depth of at least 2"); S32 i; for (i = 0; i < BINARY_DEPTH; i++) @@ -229,8 +228,7 @@ inline LLSkipMap<INDEX_TYPE, DATA_TYPE, BINARY_DEPTH>::LLSkipMap(BOOL (*insert_f : mInsertFirst(insert_first), mEquals(equals) { - // Skipmaps must have binary depth of at least 2 - cassert(BINARY_DEPTH >= 2); + llstatic_assert(BINARY_DEPTH >= 2, "Skipmaps must have binary depth of at least 2"); mLevel = 1; S32 i; diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 01e9eb751d..e57974c429 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -271,10 +271,11 @@ LLUnit<UNIT_TYPE, STORAGE_TYPE> operator * (LLUnit<UNIT_TYPE, STORAGE_TYPE> firs } template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> -void operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) +LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); + return LLUnit<UNIT_TYPE1, STORAGE_TYPE1>(); } // @@ -293,10 +294,10 @@ LLUnit<UNIT_TYPE, STORAGE_TYPE> operator / (LLUnit<UNIT_TYPE, STORAGE_TYPE> firs } template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> -void operator / (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) +STORAGE_TYPE1 operator / (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); + return STORAGE_TYPE1(first.value() / second.value()); } #define COMPARISON_OPERATORS(op) \ diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index ad9bec9f61..59577e95ac 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -30,7 +30,6 @@ #define LLVIEW_CPP #include "llview.h" -#include <cassert> #include <sstream> #include <boost/tokenizer.hpp> #include <boost/foreach.hpp> -- cgit v1.2.3 From 3745d1254acc386acaadd20016123c9a47b8d10c Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 6 Dec 2012 17:24:41 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added unit tests for LLUnit --- indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/llunit.h | 40 ++++----- indra/llcommon/tests/llunit_test.cpp | 156 +++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 20 deletions(-) create mode 100644 indra/llcommon/tests/llunit_test.cpp diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 0f5ded86ed..e1f2eb44fd 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -342,6 +342,7 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(llstring "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lluri "" "${test_libs}") + LL_ADD_INTEGRATION_TEST(llunit "" "${test_libs}") LL_ADD_INTEGRATION_TEST(reflection "" "${test_libs}") LL_ADD_INTEGRATION_TEST(stringize "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}") diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index e57974c429..1f3ed0237c 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -334,7 +334,7 @@ struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> > typedef typename HighestPrecisionType<STORAGE_TYPE>::type_t type_t; }; -#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor) \ +#define LL_DECLARE_DERIVED_UNIT(conversion_factor, base_unit_name, unit_name) \ struct unit_name \ { \ typedef base_unit_name base_unit_t; \ @@ -358,30 +358,30 @@ struct ConversionFactor<base_unit_name, unit_name, STORAGE_TYPE> \ } struct Bytes { typedef Bytes base_unit_t; }; -LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); -LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); -LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); -LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.0 / 8.0)); -LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); -LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); -LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); +LL_DECLARE_DERIVED_UNIT(1024, Bytes, Kilobytes); +LL_DECLARE_DERIVED_UNIT(1024 * 1024, Bytes, Megabytes); +LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024, Bytes, Gigabytes); +LL_DECLARE_DERIVED_UNIT((1.0 / 8.0), Bytes, Bits); +LL_DECLARE_DERIVED_UNIT((1024 / 8), Bytes, Kilobits); +LL_DECLARE_DERIVED_UNIT((1024 / 8), Bytes, Megabits); +LL_DECLARE_DERIVED_UNIT((1024 * 1024 * 1024 / 8), Bytes, Gigabits); struct Seconds { typedef Seconds base_unit_t; }; -LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); -LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); -LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.0 / 1000.0)); -LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.0 / (1000000.0))); -LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.0 / (1000000000.0))); +LL_DECLARE_DERIVED_UNIT(60, Seconds, Minutes); +LL_DECLARE_DERIVED_UNIT(60 * 60, Seconds, Hours); +LL_DECLARE_DERIVED_UNIT((1.0 / 1000.0), Seconds, Milliseconds); +LL_DECLARE_DERIVED_UNIT((1.0 / (1000000.0)), Seconds, Microseconds); +LL_DECLARE_DERIVED_UNIT((1.0 / (1000000000.0)), Seconds, Nanoseconds); struct Meters { typedef Meters base_unit_t; }; -LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); -LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, (1.0 / 100.0)); -LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, (1.0 / 1000.0)); +LL_DECLARE_DERIVED_UNIT(1000, Meters, Kilometers); +LL_DECLARE_DERIVED_UNIT((1.0 / 100.0), Meters, Centimeters); +LL_DECLARE_DERIVED_UNIT((1.0 / 1000.0), Meters, Millimeters); struct Hertz { typedef Hertz base_unit_t; }; -LL_DECLARE_DERIVED_UNIT(Hertz, Kilohertz, 1000); -LL_DECLARE_DERIVED_UNIT(Hertz, Megahertz, 1000 * 1000); -LL_DECLARE_DERIVED_UNIT(Hertz, Gigahertz, 1000 * 1000 * 1000); -} +LL_DECLARE_DERIVED_UNIT(1000, Hertz, Kilohertz); +LL_DECLARE_DERIVED_UNIT(1000 * 1000, Hertz, Megahertz); +LL_DECLARE_DERIVED_UNIT(1000 * 1000 * 1000, Hertz, Gigahertz); +} // namespace LLUnits #endif // LL_LLUNIT_H diff --git a/indra/llcommon/tests/llunit_test.cpp b/indra/llcommon/tests/llunit_test.cpp new file mode 100644 index 0000000000..a7e9c00740 --- /dev/null +++ b/indra/llcommon/tests/llunit_test.cpp @@ -0,0 +1,156 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llunit.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + struct Quatloos { typedef Quatloos base_unit_t; }; + LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); + LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); +} + +namespace tut +{ + using namespace LLUnits; + struct units + { + }; + + typedef test_group<units> units_t; + typedef units_t::object units_object_t; + tut::units_t tut_singleton("LLUnit"); + + // storage type conversions + template<> template<> + void units_object_t::test<1>() + { + LLUnit<Quatloos, F32> float_quatloos; + ensure(float_quatloos.value() == 0.f); + + LLUnit<Quatloos, S32> int_quatloos; + ensure(int_quatloos.value() == 0); + + int_quatloos = 42; + ensure(int_quatloos.value() == 42); + float_quatloos = int_quatloos; + ensure(float_quatloos.value() == 42.f); + + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + + float_quatloos = 42.1f; + ensure(float_quatloos == 42.1f); + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + LLUnit<Quatloos, U32> unsigned_int_quatloos(float_quatloos); + ensure(unsigned_int_quatloos.value() == 42); + } + + // conversions to/from base unit + template<> template<> + void units_object_t::test<2>() + { + LLUnit<Quatloos, F32> quatloos(1.f); + ensure(quatloos.value() == 1.f); + LLUnit<Latinum, F32> latinum_bars(quatloos); + ensure(latinum_bars.value() == 1.f / 4.f); + + latinum_bars = 256; + quatloos = latinum_bars; + ensure(quatloos.value() == 1024); + + LLUnit<Solari, F32> solari(quatloos); + ensure(solari.value() == 4096); + } + + // conversions across non-base units + template<> template<> + void units_object_t::test<3>() + { + LLUnit<Solari, F32> solari = 4.f; + LLUnit<Latinum, F32> latinum_bars = solari; + ensure(latinum_bars.value() == 0.25f); + } + + // math operations + template<> template<> + void units_object_t::test<4>() + { + LLUnit<Quatloos, F32> quatloos = 1.f; + quatloos *= 4.f; + ensure(quatloos.value() == 4); + quatloos = quatloos * 2; + ensure(quatloos.value() == 8); + quatloos = 2.f * quatloos; + ensure(quatloos.value() == 16); + + quatloos += 4.f; + ensure(quatloos.value() == 20); + quatloos += 4; + ensure(quatloos.value() == 24); + quatloos = quatloos + 4; + ensure(quatloos.value() == 28); + quatloos = 4 + quatloos; + ensure(quatloos.value() == 32); + quatloos += quatloos * 3; + ensure(quatloos.value() == 128); + + quatloos -= quatloos / 4 * 3; + ensure(quatloos.value() == 32); + quatloos = quatloos - 8; + ensure(quatloos.value() == 24); + quatloos -= 4; + ensure(quatloos.value() == 20); + quatloos -= 4.f; + ensure(quatloos.value() == 16); + + quatloos *= 2.f; + ensure(quatloos.value() == 32); + quatloos = quatloos * 2.f; + ensure(quatloos.value() == 64); + quatloos = 0.5f * quatloos; + ensure(quatloos.value() == 32); + + quatloos /= 2.f; + ensure(quatloos.value() == 16); + quatloos = quatloos / 4; + ensure(quatloos.value() == 4); + + F32 ratio = quatloos / LLUnit<Quatloos, F32>(4.f); + ensure(ratio == 1); + + quatloos += LLUnit<Solari, F32>(4.f); + ensure(quatloos.value() == 5); + quatloos -= LLUnit<Latinum, F32>(1.f); + ensure(quatloos.value() == 1); + } +} -- cgit v1.2.3 From c99886d94389babc78e92bbfa5084fdd785915af Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 7 Dec 2012 15:20:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved unit tests for LLUnit renamed LLUnit to LLUnitImplicit with LLUnit being reserved for explicit units --- indra/llcommon/CMakeLists.txt | 2 +- indra/llcommon/llfasttimer.cpp | 6 +- indra/llcommon/llleap.cpp | 2 +- indra/llcommon/llprocessor.cpp | 2 +- indra/llcommon/llprocessor.h | 2 +- indra/llcommon/lltimer.cpp | 14 +-- indra/llcommon/lltimer.h | 16 +-- indra/llcommon/lltrace.h | 7 +- indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/llunit.h | 193 ++++++++++++++++++++++--------- indra/llcommon/tests/llunit_test.cpp | 156 ------------------------- indra/llcommon/tests/llunits_test.cpp | 208 ++++++++++++++++++++++++++++++++++ indra/newview/llfasttimerview.cpp | 30 ++--- indra/newview/pipeline.cpp | 2 +- 14 files changed, 392 insertions(+), 250 deletions(-) delete mode 100644 indra/llcommon/tests/llunit_test.cpp create mode 100644 indra/llcommon/tests/llunits_test.cpp diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index e1f2eb44fd..5b76703af7 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -342,7 +342,7 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(llstring "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lluri "" "${test_libs}") - LL_ADD_INTEGRATION_TEST(llunit "" "${test_libs}") + LL_ADD_INTEGRATION_TEST(llunits "" "${test_libs}") LL_ADD_INTEGRATION_TEST(reflection "" "${test_libs}") LL_ADD_INTEGRATION_TEST(stringize "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}") diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index cf7655acf7..37e0fbac0a 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -166,7 +166,7 @@ U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer firstcall = false; } #endif - return sCPUClockFrequency; + return sCPUClockFrequency.value(); } #endif @@ -408,7 +408,7 @@ void TimeBlock::nextFrame() } call_count++; - LLUnit<LLUnits::Seconds, F64> total_time = 0; + LLUnit<LLUnits::Seconds, F64> total_time(0); LLSD sd; { @@ -479,7 +479,7 @@ void TimeBlock::dumpCurTimes() } out_str << timerp->getName() << " " - << std::setprecision(3) << total_time_ms.as<LLUnits::Milliseconds, F32>() << " ms, " + << std::setprecision(3) << total_time_ms.as<LLUnits::Milliseconds, F32>().value() << " ms, " << num_calls << " calls"; llinfos << out_str.str() << llendl; diff --git a/indra/llcommon/llleap.cpp b/indra/llcommon/llleap.cpp index 0a57ef1c48..84d2a12f65 100644 --- a/indra/llcommon/llleap.cpp +++ b/indra/llcommon/llleap.cpp @@ -394,7 +394,7 @@ public: LLProcess::WritePipe& childin(mChild->getWritePipe(LLProcess::STDIN)); LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop")); LLSD nop; - F64 until(LLTimer::getElapsedSeconds() + 2); + F64 until = (LLTimer::getElapsedSeconds() + 2).value(); while (childin.size() && LLTimer::getElapsedSeconds() < until) { mainloop.post(nop); diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 6fe53396ca..5ddfa6fcef 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -875,7 +875,7 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL) LLProcessorInfo::~LLProcessorInfo() {} -LLUnit<LLUnits::Megahertz, F64> LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } +LLUnitImplicit<LLUnits::Megahertz, F64> LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } bool LLProcessorInfo::hasSSE() const { return mImpl->hasSSE(); } bool LLProcessorInfo::hasSSE2() const { return mImpl->hasSSE2(); } bool LLProcessorInfo::hasAltivec() const { return mImpl->hasAltivec(); } diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index 2a21a5c115..fbd427f484 100644 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -37,7 +37,7 @@ public: LLProcessorInfo(); ~LLProcessorInfo(); - LLUnit<LLUnits::Megahertz, F64> getCPUFrequency() const; + LLUnitImplicit<LLUnits::Megahertz, F64> getCPUFrequency() const; bool hasSSE() const; bool hasSSE2() const; bool hasAltivec() const; diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 26063beff0..838155d54d 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -285,14 +285,14 @@ LLTimer::~LLTimer() } // static -LLUnit<LLUnits::Microseconds, U64> LLTimer::getTotalTime() +LLUnitImplicit<LLUnits::Microseconds, U64> LLTimer::getTotalTime() { // simply call into the implementation function. return totalTime(); } // static -LLUnit<LLUnits::Seconds, F64> LLTimer::getTotalSeconds() +LLUnitImplicit<LLUnits::Seconds, F64> LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -341,23 +341,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -LLUnit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeF64() const +LLUnitImplicit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -LLUnit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeF32() const +LLUnitImplicit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -LLUnit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeAndResetF64() +LLUnitImplicit<LLUnits::Seconds, F64> LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -LLUnit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeAndResetF32() +LLUnitImplicit<LLUnits::Seconds, F32> LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -370,7 +370,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -LLUnit<LLUnits::Seconds, F32> LLTimer::getRemainingTimeF32() const +LLUnitImplicit<LLUnits::Seconds, F32> LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 5cb2b18111..0ba87d1e15 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -67,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static LLUnit<LLUnits::Seconds, F64> getElapsedSeconds() + static LLUnitImplicit<LLUnits::Seconds, F64> getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static LLUnit<LLUnits::Microseconds, U64> getTotalTime(); + static LLUnitImplicit<LLUnits::Microseconds, U64> getTotalTime(); // Return a high precision seconds since epoch - static LLUnit<LLUnits::Seconds, F64> getTotalSeconds(); + static LLUnitImplicit<LLUnits::Seconds, F64> getTotalSeconds(); // MANIPULATORS @@ -87,16 +87,16 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - LLUnit<LLUnits::Seconds, F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - LLUnit<LLUnits::Seconds, F64> getElapsedTimeAndResetF64(); + LLUnitImplicit<LLUnits::Seconds, F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnitImplicit<LLUnits::Seconds, F64> getElapsedTimeAndResetF64(); - LLUnit<LLUnits::Seconds, F32> getRemainingTimeF32() const; + LLUnitImplicit<LLUnits::Seconds, F32> getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - LLUnit<LLUnits::Seconds, F32> getElapsedTimeF32() const; // Returns elapsed time in seconds - LLUnit<LLUnits::Seconds, F64> getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnitImplicit<LLUnits::Seconds, F32> getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnitImplicit<LLUnits::Seconds, F64> getElapsedTimeF64() const; // Returns elapsed time in seconds bool getStarted() const { return mStarted; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 6e6bb51e47..25d95d9670 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -435,6 +435,9 @@ namespace LLTrace class TraceType<TimeBlockAccumulator::CallCountAspect> : public TraceType<TimeBlockAccumulator> { + public: + typedef F32 mean_t; + TraceType(const char* name, const char* description = "") : TraceType<TimeBlockAccumulator>(name, description) {} @@ -465,7 +468,7 @@ namespace LLTrace void sample(UNIT_T value) { T converted_value(value); - getPrimaryAccumulator().sample((storage_t)converted_value); + getPrimaryAccumulator().sample(LLUnits::rawValue(converted_value)); } }; @@ -484,7 +487,7 @@ namespace LLTrace void add(UNIT_T value) { T converted_value(value); - getPrimaryAccumulator().add((storage_t)converted_value); + getPrimaryAccumulator().add(LLUnits::rawValue(converted_value)); } }; } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 6fd1a105d3..f92281cea8 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -205,7 +205,7 @@ namespace LLTrace U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const; U32 getSampleCount(const TraceType<MeasurementAccumulator<S64> >& stat) const; - LLUnit<LLUnits::Seconds, F64> getDuration() const { return mElapsedSeconds; } + LLUnit<LLUnits::Seconds, F64> getDuration() const { return LLUnit<LLUnits::Seconds, F64>(mElapsedSeconds); } private: friend class ThreadRecorder; diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 1f3ed0237c..6b023f8287 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -65,6 +65,7 @@ struct ConversionFactor<BASE_UNITS_TAG, BASE_UNITS_TAG, VALUE_TYPE> return 1; } }; + } template<typename UNIT_TYPE, typename STORAGE_TYPE> @@ -73,25 +74,25 @@ struct LLUnit typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t; typedef STORAGE_TYPE storage_t; + // value initialization LLUnit(storage_t value = storage_t()) : mValue(value) {} + // unit initialization and conversion template<typename OTHER_UNIT, typename OTHER_STORAGE> LLUnit(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) : mValue(convert(other)) {} - - LLUnit(self_t& other) - : mValue(other.mValue) - {} - + + // value assignment self_t& operator = (storage_t value) { mValue = value; return *this; } + // unit assignment template<typename OTHER_UNIT, typename OTHER_STORAGE> self_t& operator = (LLUnit<OTHER_UNIT, OTHER_STORAGE> other) { @@ -99,11 +100,6 @@ struct LLUnit return *this; } - operator storage_t() const - { - return value(); - } - storage_t value() const { return mValue; @@ -157,7 +153,7 @@ struct LLUnit void operator /= (LLUnit<OTHER_UNIT, OTHER_STORAGE> divisor) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(OTHER_UNIT) == 0, "Division of unit types not supported."); + llstatic_assert(sizeof(OTHER_UNIT) == 0, "Illegal in-place division of unit types."); } template<typename SOURCE_UNITS, typename SOURCE_STORAGE> @@ -169,34 +165,30 @@ struct LLUnit } protected: - storage_t mValue; }; template<typename UNIT_TYPE, typename STORAGE_TYPE> -struct LLUnitStrict : public LLUnit<UNIT_TYPE, STORAGE_TYPE> +struct LLUnitImplicit : public LLUnit<UNIT_TYPE, STORAGE_TYPE> { - typedef LLUnitStrict<UNIT_TYPE, STORAGE_TYPE> self_t; + typedef LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> self_t; typedef typename LLUnit<UNIT_TYPE, STORAGE_TYPE>::storage_t storage_t; + typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> base_t; - explicit LLUnitStrict(storage_t value = storage_t()) - : LLUnit<UNIT_TYPE, STORAGE_TYPE>(value) + LLUnitImplicit(storage_t value = storage_t()) + : base_t(value) {} template<typename OTHER_UNIT, typename OTHER_STORAGE> - LLUnitStrict(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) - : LLUnit<UNIT_TYPE, STORAGE_TYPE>(convert(other)) + LLUnitImplicit(LLUnit<OTHER_UNIT, OTHER_STORAGE> other) + : base_t(convert(other)) {} - LLUnitStrict(self_t& other) - : LLUnit<UNIT_TYPE, STORAGE_TYPE>(other) - {} - - -private: + // unlike LLUnit, LLUnitImplicit is *implicitly* convertable to a POD scalar (F32, S32, etc) + // this allows for interoperability with legacy code operator storage_t() const { - return LLUnit<UNIT_TYPE, STORAGE_TYPE>::value(); + return value(); } }; @@ -204,7 +196,7 @@ private: // operator + // template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> -LLUnit<STORAGE_TYPE1, UNIT_TYPE1> operator + (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) +LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator + (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) { LLUnit<UNIT_TYPE1, STORAGE_TYPE1> result(first); result += second; @@ -227,6 +219,30 @@ LLUnit<UNIT_TYPE, STORAGE_TYPE> operator + (SCALAR_TYPE first, LLUnit<UNIT_TYPE, return result; } +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator + (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) +{ + LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> result(first); + result += second; + return result; +} + +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator + (LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) +{ + LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> result(first); + result += second; + return result; +} + +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator + (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2> second) +{ + LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> result(first); + result += second; + return result; +} + // // operator - // @@ -238,7 +254,6 @@ LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator - (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> return result; } - template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> LLUnit<UNIT_TYPE, STORAGE_TYPE> operator - (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) { @@ -255,6 +270,30 @@ LLUnit<UNIT_TYPE, STORAGE_TYPE> operator - (SCALAR_TYPE first, LLUnit<UNIT_TYPE, return result; } +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator - (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2> second) +{ + LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> result(first); + result -= second; + return result; +} + +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator - (LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) +{ + LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> result(first); + result -= second; + return result; +} + +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator - (SCALAR_TYPE first, LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> second) +{ + LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> result(first); + result -= second; + return result; +} + // // operator * // @@ -278,6 +317,26 @@ LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, return LLUnit<UNIT_TYPE1, STORAGE_TYPE1>(); } +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator * (SCALAR_TYPE first, LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> second) +{ + return LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE>(first * second.value()); +} + +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator * (LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) +{ + return LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE>(first.value() * second); +} + +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2>) +{ + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); + return LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>(); +} + // // operator / // @@ -300,23 +359,42 @@ STORAGE_TYPE1 operator / (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_T return STORAGE_TYPE1(first.value() / second.value()); } -#define COMPARISON_OPERATORS(op) \ -template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ -bool operator op (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) \ -{ \ - return first op second.value(); \ -} \ - \ -template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ -bool operator op (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) \ -{ \ - return first.value() op second; \ -} \ - \ -template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> \ -bool operator op (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) \ -{ \ - return first.value() op first.convert(second); \ +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> +LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> operator / (LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) +{ + return LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE>(first.value() / second); +} + +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> +STORAGE_TYPE1 operator / (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2> second) +{ + // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template + return STORAGE_TYPE1(first.value() / second.value()); +} + +#define COMPARISON_OPERATORS(op) \ +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ +bool operator op (SCALAR_TYPE first, LLUnit<UNIT_TYPE, STORAGE_TYPE> second) \ +{ \ + return first op second.value(); \ +} \ + \ +template<typename UNIT_TYPE, typename STORAGE_TYPE, typename SCALAR_TYPE> \ +bool operator op (LLUnit<UNIT_TYPE, STORAGE_TYPE> first, SCALAR_TYPE second) \ +{ \ + return first.value() op second; \ +} \ + \ +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> \ +bool operator op (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2> second) \ +{ \ + return first.value() op first.convert(second); \ +} \ + \ +template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typename STORAGE_TYPE2> \ + bool operator op (LLUnit<UNIT_TYPE1, STORAGE_TYPE1> first, LLUnit<UNIT_TYPE2, STORAGE_TYPE2> second) \ +{ \ + return first.value() op first.convert(second); \ } COMPARISON_OPERATORS(<) @@ -328,6 +406,15 @@ COMPARISON_OPERATORS(!=) namespace LLUnits { +template<typename T> +T rawValue(T val) { return val; } + +template<typename UNIT_TYPE, typename STORAGE_TYPE> +STORAGE_TYPE rawValue(LLUnit<UNIT_TYPE, STORAGE_TYPE> val) { return val.value(); } + +template<typename UNIT_TYPE, typename STORAGE_TYPE> +STORAGE_TYPE rawValue(LLUnitImplicit<UNIT_TYPE, STORAGE_TYPE> val) { return val.value(); } + template<typename UNIT_TYPE, typename STORAGE_TYPE> struct HighestPrecisionType<LLUnit<UNIT_TYPE, STORAGE_TYPE> > { @@ -361,22 +448,22 @@ struct Bytes { typedef Bytes base_unit_t; }; LL_DECLARE_DERIVED_UNIT(1024, Bytes, Kilobytes); LL_DECLARE_DERIVED_UNIT(1024 * 1024, Bytes, Megabytes); LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024, Bytes, Gigabytes); -LL_DECLARE_DERIVED_UNIT((1.0 / 8.0), Bytes, Bits); -LL_DECLARE_DERIVED_UNIT((1024 / 8), Bytes, Kilobits); -LL_DECLARE_DERIVED_UNIT((1024 / 8), Bytes, Megabits); -LL_DECLARE_DERIVED_UNIT((1024 * 1024 * 1024 / 8), Bytes, Gigabits); +LL_DECLARE_DERIVED_UNIT(1.0 / 8.0, Bytes, Bits); +LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Kilobits); +LL_DECLARE_DERIVED_UNIT(1024 / 8, Bytes, Megabits); +LL_DECLARE_DERIVED_UNIT(1024 * 1024 * 1024 / 8, Bytes, Gigabits); struct Seconds { typedef Seconds base_unit_t; }; LL_DECLARE_DERIVED_UNIT(60, Seconds, Minutes); LL_DECLARE_DERIVED_UNIT(60 * 60, Seconds, Hours); -LL_DECLARE_DERIVED_UNIT((1.0 / 1000.0), Seconds, Milliseconds); -LL_DECLARE_DERIVED_UNIT((1.0 / (1000000.0)), Seconds, Microseconds); -LL_DECLARE_DERIVED_UNIT((1.0 / (1000000000.0)), Seconds, Nanoseconds); +LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Seconds, Milliseconds); +LL_DECLARE_DERIVED_UNIT(1.0 / 1000000.0, Seconds, Microseconds); +LL_DECLARE_DERIVED_UNIT(1.0 / 1000000000.0, Seconds, Nanoseconds); struct Meters { typedef Meters base_unit_t; }; LL_DECLARE_DERIVED_UNIT(1000, Meters, Kilometers); -LL_DECLARE_DERIVED_UNIT((1.0 / 100.0), Meters, Centimeters); -LL_DECLARE_DERIVED_UNIT((1.0 / 1000.0), Meters, Millimeters); +LL_DECLARE_DERIVED_UNIT(1.0 / 100.0, Meters, Centimeters); +LL_DECLARE_DERIVED_UNIT(1.0 / 1000.0, Meters, Millimeters); struct Hertz { typedef Hertz base_unit_t; }; LL_DECLARE_DERIVED_UNIT(1000, Hertz, Kilohertz); diff --git a/indra/llcommon/tests/llunit_test.cpp b/indra/llcommon/tests/llunit_test.cpp deleted file mode 100644 index a7e9c00740..0000000000 --- a/indra/llcommon/tests/llunit_test.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file llsingleton_test.cpp - * @date 2011-08-11 - * @brief Unit test for the LLSingleton class - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llunit.h" -#include "../test/lltut.h" - -namespace LLUnits -{ - // using powers of 2 to allow strict floating point equality - struct Quatloos { typedef Quatloos base_unit_t; }; - LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); - LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); -} - -namespace tut -{ - using namespace LLUnits; - struct units - { - }; - - typedef test_group<units> units_t; - typedef units_t::object units_object_t; - tut::units_t tut_singleton("LLUnit"); - - // storage type conversions - template<> template<> - void units_object_t::test<1>() - { - LLUnit<Quatloos, F32> float_quatloos; - ensure(float_quatloos.value() == 0.f); - - LLUnit<Quatloos, S32> int_quatloos; - ensure(int_quatloos.value() == 0); - - int_quatloos = 42; - ensure(int_quatloos.value() == 42); - float_quatloos = int_quatloos; - ensure(float_quatloos.value() == 42.f); - - int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); - - float_quatloos = 42.1f; - ensure(float_quatloos == 42.1f); - int_quatloos = float_quatloos; - ensure(int_quatloos.value() == 42); - LLUnit<Quatloos, U32> unsigned_int_quatloos(float_quatloos); - ensure(unsigned_int_quatloos.value() == 42); - } - - // conversions to/from base unit - template<> template<> - void units_object_t::test<2>() - { - LLUnit<Quatloos, F32> quatloos(1.f); - ensure(quatloos.value() == 1.f); - LLUnit<Latinum, F32> latinum_bars(quatloos); - ensure(latinum_bars.value() == 1.f / 4.f); - - latinum_bars = 256; - quatloos = latinum_bars; - ensure(quatloos.value() == 1024); - - LLUnit<Solari, F32> solari(quatloos); - ensure(solari.value() == 4096); - } - - // conversions across non-base units - template<> template<> - void units_object_t::test<3>() - { - LLUnit<Solari, F32> solari = 4.f; - LLUnit<Latinum, F32> latinum_bars = solari; - ensure(latinum_bars.value() == 0.25f); - } - - // math operations - template<> template<> - void units_object_t::test<4>() - { - LLUnit<Quatloos, F32> quatloos = 1.f; - quatloos *= 4.f; - ensure(quatloos.value() == 4); - quatloos = quatloos * 2; - ensure(quatloos.value() == 8); - quatloos = 2.f * quatloos; - ensure(quatloos.value() == 16); - - quatloos += 4.f; - ensure(quatloos.value() == 20); - quatloos += 4; - ensure(quatloos.value() == 24); - quatloos = quatloos + 4; - ensure(quatloos.value() == 28); - quatloos = 4 + quatloos; - ensure(quatloos.value() == 32); - quatloos += quatloos * 3; - ensure(quatloos.value() == 128); - - quatloos -= quatloos / 4 * 3; - ensure(quatloos.value() == 32); - quatloos = quatloos - 8; - ensure(quatloos.value() == 24); - quatloos -= 4; - ensure(quatloos.value() == 20); - quatloos -= 4.f; - ensure(quatloos.value() == 16); - - quatloos *= 2.f; - ensure(quatloos.value() == 32); - quatloos = quatloos * 2.f; - ensure(quatloos.value() == 64); - quatloos = 0.5f * quatloos; - ensure(quatloos.value() == 32); - - quatloos /= 2.f; - ensure(quatloos.value() == 16); - quatloos = quatloos / 4; - ensure(quatloos.value() == 4); - - F32 ratio = quatloos / LLUnit<Quatloos, F32>(4.f); - ensure(ratio == 1); - - quatloos += LLUnit<Solari, F32>(4.f); - ensure(quatloos.value() == 5); - quatloos -= LLUnit<Latinum, F32>(1.f); - ensure(quatloos.value() == 1); - } -} diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp new file mode 100644 index 0000000000..2a941e8229 --- /dev/null +++ b/indra/llcommon/tests/llunits_test.cpp @@ -0,0 +1,208 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llunit.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + struct Quatloos { typedef Quatloos base_unit_t; }; + LL_DECLARE_DERIVED_UNIT(4, Quatloos, Latinum); + LL_DECLARE_DERIVED_UNIT((1.0 / 4.0), Quatloos, Solari); +} + +namespace tut +{ + using namespace LLUnits; + struct units + { + }; + + typedef test_group<units> units_t; + typedef units_t::object units_object_t; + tut::units_t tut_singleton("LLUnit"); + + // storage type conversions + template<> template<> + void units_object_t::test<1>() + { + LLUnit<Quatloos, F32> float_quatloos; + ensure(float_quatloos.value() == 0.f); + + LLUnit<Quatloos, S32> int_quatloos; + ensure(int_quatloos.value() == 0); + + int_quatloos = 42; + ensure(int_quatloos.value() == 42); + float_quatloos = int_quatloos; + ensure(float_quatloos.value() == 42.f); + + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + + float_quatloos = 42.1f; + ensure(float_quatloos.value() == 42.1f); + int_quatloos = float_quatloos; + ensure(int_quatloos.value() == 42); + LLUnit<Quatloos, U32> unsigned_int_quatloos(float_quatloos); + ensure(unsigned_int_quatloos.value() == 42); + } + + // conversions to/from base unit + template<> template<> + void units_object_t::test<2>() + { + LLUnit<Quatloos, F32> quatloos(1.f); + ensure(quatloos.value() == 1.f); + LLUnit<Latinum, F32> latinum_bars(quatloos); + ensure(latinum_bars.value() == 1.f / 4.f); + + latinum_bars = 256; + quatloos = latinum_bars; + ensure(quatloos.value() == 1024); + + LLUnit<Solari, F32> solari(quatloos); + ensure(solari.value() == 4096); + } + + // conversions across non-base units + template<> template<> + void units_object_t::test<3>() + { + LLUnit<Solari, F32> solari = 4.f; + LLUnit<Latinum, F32> latinum_bars = solari; + ensure(latinum_bars.value() == 0.25f); + } + + // math operations + template<> template<> + void units_object_t::test<4>() + { + LLUnit<Quatloos, F32> quatloos = 1.f; + quatloos *= 4.f; + ensure(quatloos.value() == 4); + quatloos = quatloos * 2; + ensure(quatloos.value() == 8); + quatloos = 2.f * quatloos; + ensure(quatloos.value() == 16); + + quatloos += 4.f; + ensure(quatloos.value() == 20); + quatloos += 4; + ensure(quatloos.value() == 24); + quatloos = quatloos + 4; + ensure(quatloos.value() == 28); + quatloos = 4 + quatloos; + ensure(quatloos.value() == 32); + quatloos += quatloos * 3; + ensure(quatloos.value() == 128); + + quatloos -= quatloos / 4 * 3; + ensure(quatloos.value() == 32); + quatloos = quatloos - 8; + ensure(quatloos.value() == 24); + quatloos -= 4; + ensure(quatloos.value() == 20); + quatloos -= 4.f; + ensure(quatloos.value() == 16); + + quatloos *= 2.f; + ensure(quatloos.value() == 32); + quatloos = quatloos * 2.f; + ensure(quatloos.value() == 64); + quatloos = 0.5f * quatloos; + ensure(quatloos.value() == 32); + + quatloos /= 2.f; + ensure(quatloos.value() == 16); + quatloos = quatloos / 4; + ensure(quatloos.value() == 4); + + F32 ratio = quatloos / LLUnit<Quatloos, F32>(4.f); + ensure(ratio == 1); + + quatloos += LLUnit<Solari, F32>(4.f); + ensure(quatloos.value() == 5); + quatloos -= LLUnit<Latinum, F32>(1.f); + ensure(quatloos.value() == 1); + } + + // implicit units + template<> template<> + void units_object_t::test<5>() + { + // 0-initialized + LLUnit<Quatloos, F32> quatloos(0); + // initialize implicit unit from explicit + LLUnitImplicit<Quatloos, F32> quatloos_implicit = quatloos + 1; + ensure(quatloos_implicit.value() == 1); + + // assign implicit to explicit, or perform math operations + quatloos = quatloos_implicit; + ensure(quatloos.value() == 1); + quatloos += quatloos_implicit; + ensure(quatloos.value() == 2); + + // math operations on implicits + quatloos_implicit = 1; + ensure(quatloos_implicit == 1); + + quatloos_implicit += 2; + ensure(quatloos_implicit == 3); + + quatloos_implicit *= 2; + ensure(quatloos_implicit == 6); + + quatloos_implicit -= 1; + ensure(quatloos_implicit == 5); + + quatloos_implicit /= 5; + ensure(quatloos_implicit == 1); + + quatloos_implicit = quatloos_implicit + 3 + quatloos_implicit; + ensure(quatloos_implicit == 5); + + quatloos_implicit = 10 - quatloos_implicit - 1; + ensure(quatloos_implicit == 4); + + quatloos_implicit = 2 * quatloos_implicit * 2; + ensure(quatloos_implicit == 16); + + F32 one_half = quatloos_implicit / (quatloos_implicit * 2); + ensure(one_half == 0.5f); + + // implicit conversion to POD + F32 float_val = quatloos_implicit; + ensure(float_val == 16); + + S32 int_val = quatloos_implicit; + ensure(int_val == 16); + } +} diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 704b914b78..1c63022527 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -311,11 +311,11 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); } return tooltip; } @@ -601,22 +601,22 @@ void LLFastTimerView::draw() { LLUnit<LLUnits::Milliseconds, U32> ms = total_time; - tdesc = llformat("%.1f ms |", (F32)ms*.25f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.50f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.75f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", (U32)ms); + tdesc = llformat( "%d ms |", (U32)ms.value()); x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); @@ -728,11 +728,11 @@ void LLFastTimerView::draw() ++it) { sublevelticks += (tidx == -1) - ? frame_recording.getPeriodMean(**it) - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it); + ? frame_recording.getPeriodMean(**it).value() + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); } - F32 subfrac = (F32)sublevelticks / (F32)total_time; + F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); if (mDisplayCenter == ALIGN_CENTER) @@ -819,7 +819,7 @@ void LLFastTimerView::draw() else if (mDisplayHz) tdesc = llformat("%d Hz", (int)(1.f / max_time.value())); else - tdesc = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value()); + tdesc = llformat("%4.2f ms", max_time.value()); x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); @@ -900,7 +900,7 @@ void LLFastTimerView::draw() F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) - : mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time); + : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); } @@ -920,22 +920,22 @@ void LLFastTimerView::draw() } //interpolate towards new maximum - max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); + max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); if (max_time - cur_max <= 1 || cur_max - max_time <= 1) { max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max)); } max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)); - if (llabs(max_calls - cur_max) <= 1) + if (llabs((S32)(max_calls - cur_max_calls)) <= 1) { max_calls = cur_max_calls; } // TODO: make sure alpha is correct in DisplayHz mode F32 alpha_target = (max_time > cur_max) - ? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) - : llmin((F32) cur_max/ (F32) max_time - 1.f,1.f); + ? llmin(max_time / cur_max - 1.f,1.f) + : llmin(cur_max/ max_time - 1.f,1.f); alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); if (mHoverID != NULL) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 813fc7db6a..3be19c3920 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2747,7 +2747,7 @@ void LLPipeline::updateGeom(F32 max_dtime) S32 count = 0; - max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnit<LLUnits::Seconds, F32>(max_dtime)); + max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnitImplicit<LLUnits::Seconds, F32>(max_dtime)); LLSpatialGroup* last_group = NULL; LLSpatialBridge* last_bridge = NULL; -- cgit v1.2.3 From c8c14ac72db3374cbd43893e5a97d98817cde0a3 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 7 Dec 2012 15:26:59 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system potential fixes for gcc builds --- indra/llcommon/lltrace.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 25d95d9670..0cb6a84aec 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -223,7 +223,7 @@ namespace LLTrace typedef typename MeanValueType<TraceType<ACCUMULATOR> >::type mean_t; TraceType(const char* name, const char* description = NULL) - : LLInstanceTracker(name), + : LLInstanceTracker<TraceType<ACCUMULATOR>, std::string>(name), mName(name), mDescription(description ? description : "") { @@ -459,16 +459,17 @@ namespace LLTrace { public: typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t; + typedef TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > trace_t; Measurement(const char* name, const char* description = NULL) - : TraceType(name, description) + : trace_t(name, description) {} template<typename UNIT_T> void sample(UNIT_T value) { T converted_value(value); - getPrimaryAccumulator().sample(LLUnits::rawValue(converted_value)); + trace_t::getPrimaryAccumulator().sample(LLUnits::rawValue(converted_value)); } }; @@ -478,16 +479,17 @@ namespace LLTrace { public: typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t; + typedef TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > trace_t; Count(const char* name, const char* description = NULL) - : TraceType(name) + : trace_t(name) {} template<typename UNIT_T> void add(UNIT_T value) { T converted_value(value); - getPrimaryAccumulator().add(LLUnits::rawValue(converted_value)); + trace_t::getPrimaryAccumulator().add(LLUnits::rawValue(converted_value)); } }; } -- cgit v1.2.3 From b44c8593a34961f82fb523e42ad13b7e3da00ab6 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 7 Dec 2012 19:00:13 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system further fixes for gcc builds --- indra/llcommon/llunit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 6b023f8287..72a6020ff8 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -188,7 +188,7 @@ struct LLUnitImplicit : public LLUnit<UNIT_TYPE, STORAGE_TYPE> // this allows for interoperability with legacy code operator storage_t() const { - return value(); + return base_t::value(); } }; -- cgit v1.2.3 From 8c2e3bea71ea15b805a9e2a288744f10d195d803 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sun, 9 Dec 2012 23:19:11 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added ability to query self time of block timers indepedently --- indra/llcommon/llfasttimer.h | 5 + indra/llcommon/lltrace.h | 17 ++ indra/llcommon/lltracerecording.cpp | 11 + indra/llcommon/lltracerecording.h | 3 + indra/newview/llfasttimerview.cpp | 428 ++++++++++++++++++------------------ 5 files changed, 246 insertions(+), 218 deletions(-) diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index e3d99a9e4b..b5b4a8d0b4 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -89,6 +89,11 @@ public: return static_cast<TraceType<TimeBlockAccumulator::CallCountAspect>&>(*(TraceType<TimeBlockAccumulator>*)this); } + TraceType<TimeBlockAccumulator::SelfTimeAspect>& selfTime() + { + return static_cast<TraceType<TimeBlockAccumulator::SelfTimeAspect>&>(*(TraceType<TimeBlockAccumulator>*)this); + } + static TimeBlock& getRootTimer(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 0cb6a84aec..d29d43a92c 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -412,6 +412,11 @@ namespace LLTrace typedef U32 value_t; }; + struct SelfTimeAspect + { + typedef LLUnit<LLUnits::Seconds, F64> value_t; + }; + TimeBlockAccumulator(); void addSamples(const TimeBlockAccumulator& other); void reset(const TimeBlockAccumulator* other); @@ -443,6 +448,18 @@ namespace LLTrace {} }; + template<> + class TraceType<TimeBlockAccumulator::SelfTimeAspect> + : public TraceType<TimeBlockAccumulator> + { + public: + typedef F32 mean_t; + + TraceType(const char* name, const char* description = "") + : TraceType<TimeBlockAccumulator>(name, description) + {} + }; + class TimeBlockTreeNode { public: diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e9b3376dae..3ea511ff3c 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -144,16 +144,27 @@ void Recording::appendRecording( const Recording& other ) } LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator>& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); +} + +LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); } + U32 Recording::getSum(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const { return (*mStackTimers)[stat.getIndex()].mCalls; } LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator>& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); +} + +LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f92281cea8..f4841214e8 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -120,8 +120,11 @@ namespace LLTrace // Timer accessors LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimeBlockAccumulator>& stat) const; + LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const; U32 getSum(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const; + LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimeBlockAccumulator>& stat) const; + LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const; F32 getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const; // Count accessors diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 1c63022527..8014b5712b 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -381,9 +381,9 @@ void LLFastTimerView::draw() std::string tdesc; - S32 margin = 10; - S32 height = getRect().getHeight(); - S32 width = getRect().getWidth(); + const S32 margin = 10; + const S32 height = getRect().getHeight(); + const S32 width = getRect().getWidth(); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); @@ -391,22 +391,17 @@ void LLFastTimerView::draw() S32 left, top, right, bottom; S32 x, y, barw, barh, dx, dy; - S32 texth, textw; + const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square"); // Draw the window background gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); - S32 xleft = margin; - S32 ytop = margin; - // Draw some help { - - x = xleft; - y = height - ytop; - texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); + x = margin; + y = height - margin; char modedesc[][32] = { "2 x Average ", @@ -422,9 +417,8 @@ void LLFastTimerView::draw() tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - textw = LLFontGL::getFontMonospace()->getWidth(tdesc); - x = xleft, y -= (texth + 2); + x = margin, y -= (texth + 2); tdesc = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); @@ -436,36 +430,38 @@ void LLFastTimerView::draw() S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY); - // Draw the legend - xleft = margin; - ytop = y; - + const S32 ytop = y; y -= (texth + 2); - sTimerColors[&getFrameTimer()] = LLColor4::grey; + // generate unique colors + { + sTimerColors[&getFrameTimer()] = LLColor4::grey; - F32 hue = 0.f; + F32 hue = 0.f; - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != timer_tree_iterator_t(); - ++it) - { - LLTrace::TimeBlock* idp = (*it); + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != timer_tree_iterator_t(); + ++it) + { + LLTrace::TimeBlock* idp = (*it); - const F32 HUE_INCREMENT = 0.23f; - hue = fmodf(hue + HUE_INCREMENT, 1.f); - // saturation increases with depth - F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); - // lightness alternates with depth - F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; + const F32 HUE_INCREMENT = 0.23f; + hue = fmodf(hue + HUE_INCREMENT, 1.f); + // saturation increases with depth + F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); + // lightness alternates with depth + F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; - LLColor4 child_color; - child_color.setHSL(hue, saturation, lightness); + LLColor4 child_color; + child_color.setHSL(hue, saturation, lightness); - sTimerColors[idp] = child_color; + sTimerColors[idp] = child_color; + } } + // draw legend const S32 LEGEND_WIDTH = 220; + const S32 x_start = margin + LEGEND_WIDTH + 8; { LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; @@ -480,7 +476,7 @@ void LLFastTimerView::draw() ft_display_idx.push_back(idp); cur_line++; - x = xleft; + x = margin; left = x; right = x + texth; top = y; bottom = y - texth; @@ -547,8 +543,6 @@ void LLFastTimerView::draw() y -= (texth + 2); - textw = dx + LLFontGL::getFontMonospace()->getWidth(idp->getName()) + 40; - if (idp->getCollapsed()) { it.skipDescendants(); @@ -556,11 +550,8 @@ void LLFastTimerView::draw() } } - xleft += LEGEND_WIDTH + 8; - // ytop = ytop; - // update rectangle that includes timer bars - mBarRect.mLeft = xleft; + mBarRect.mLeft = x_start; mBarRect.mRight = getRect().getWidth(); mBarRect.mTop = ytop - (LLFontGL::getFontMonospace()->getLineHeight() + 4); mBarRect.mBottom = margin + LINE_GRAPH_HEIGHT; @@ -570,238 +561,239 @@ void LLFastTimerView::draw() dy = barh>>2; // spacing between bars if (dy < 1) dy = 1; barh -= dy; - barw = width - xleft - margin; + barw = width - x_start - margin; // Draw the history bars - LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - LLUnit<LLUnits::Seconds, F64> total_time; - - mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); - - if (mDisplayMode == 0) + switch(mDisplayMode) { + case 0: total_time = frame_recording.getPeriodMean(getFrameTimer())*2; - } - else if (mDisplayMode == 1) - { + break; + case 1: total_time = mAllTimeMax; - } - else if (mDisplayMode == 2) - { + break; + case 2: // Calculate the max total ticks for the current history total_time = frame_recording.getPeriodMax(getFrameTimer()); - } - else - { + break; + default: total_time = LLUnit<LLUnits::Milliseconds, F32>(100); + break; } - - // Draw MS ticks + + if (total_time > 0) { - LLUnit<LLUnits::Milliseconds, U32> ms = total_time; + LLLocalClipRect clip(LLRect(x_start, ytop, getRect().getWidth() - margin, margin)); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); - x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); + + // Draw MS ticks + { + LLUnit<LLUnits::Milliseconds, U32> ms = total_time; + + tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); + x = x_start + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); - x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); + x = x_start + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); - x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); + x = x_start + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", (U32)ms.value()); - x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - } + tdesc = llformat( "%d ms |", (U32)ms.value()); + x = x_start + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + } - // Draw borders - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f(0.5f,0.5f,0.5f,0.5f); + // Draw borders + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f(0.5f,0.5f,0.5f,0.5f); - S32 by = y + 2; + S32 by = y + 2; - y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); - //heading - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); + //heading + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, FALSE); - //tree view - gl_rect_2d(5, by, xleft-10, 5, FALSE); + //tree view + gl_rect_2d(5, by, x_start-10, 5, FALSE); - by = y + 5; - //average bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); + by = y + 5; + //average bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); - by -= barh*2+dy; + by -= barh*2+dy; - //current frame bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); + //current frame bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); - by -= barh+dy+1; + by -= barh+dy+1; - //history bars - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); + //history bars + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); - by = LINE_GRAPH_HEIGHT-barh-dy-7; + by = LINE_GRAPH_HEIGHT-barh-dy-7; - //line graph - mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); + //line graph + mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); - gl_rect_2d(mGraphRect, FALSE); - } + gl_rect_2d(mGraphRect, FALSE); + } - mBarStart.clear(); - mBarEnd.clear(); + mBarStart.clear(); + mBarEnd.clear(); - // Draw bars for each history entry - // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); - for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++) - { - mBarStart.push_back(std::vector<S32>()); - mBarEnd.push_back(std::vector<S32>()); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx; - if (j >= 0) + // Draw bars for each history entry + // Special: -1 = show running average + gGL.getTexUnit(0)->bind(box_imagep->getImage()); + for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++) { - tidx = j + 1 + mScrollIndex; - } - else - { - tidx = -1; - } + mBarStart.push_back(std::vector<S32>()); + mBarEnd.push_back(std::vector<S32>()); + int sublevel_dx[FTV_MAX_DEPTH]; + int sublevel_left[FTV_MAX_DEPTH]; + int sublevel_right[FTV_MAX_DEPTH]; + S32 tidx; + if (j >= 0) + { + tidx = j + 1 + mScrollIndex; + } + else + { + tidx = -1; + } - x = xleft; + x = x_start; - // draw the bars for each stat - std::vector<S32> xpos; - std::vector<S32> deltax; - xpos.push_back(xleft); + // draw the bars for each stat + std::vector<S32> xpos; + std::vector<S32> deltax; + xpos.push_back(x_start); - LLTrace::TimeBlock* prev_id = NULL; + LLTrace::TimeBlock* prev_id = NULL; - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it, ++i) - { - LLTrace::TimeBlock* idp = (*it); - F32 frac = tidx == -1 - ? (frame_recording.getPeriodMean(*idp) / total_time) - : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); + S32 i = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it, ++i) + { + LLTrace::TimeBlock* idp = (*it); + F32 frac = tidx == -1 + ? (frame_recording.getPeriodMean(*idp) / total_time) + : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - dx = llround(frac * (F32)barw); - S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); - deltax.push_back(dx); + dx = llround(frac * (F32)barw); + S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); + deltax.push_back(dx); - int level = idp->getDepth() - 1; + int level = idp->getDepth() - 1; - while ((S32)xpos.size() > level + 1) - { - xpos.pop_back(); - } - left = xpos.back(); - - if (level == 0) - { - sublevel_left[level] = xleft; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) - { - U64 sublevelticks = 0; - - for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) + while ((S32)xpos.size() > level + 1) { - sublevelticks += (tidx == -1) - ? frame_recording.getPeriodMean(**it).value() - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + xpos.pop_back(); } - - F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); - sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); - - if (mDisplayCenter == ALIGN_CENTER) + left = xpos.back(); + + if (level == 0) { - left += (prev_delta_x - sublevel_dx[level])/2; + sublevel_left[level] = x_start; + sublevel_dx[level] = dx; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (mDisplayCenter == ALIGN_RIGHT) + else if (prev_id && prev_id->getDepth() < idp->getDepth()) { - left += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = left; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - - right = left + dx; - xpos.back() = right; - xpos.push_back(left); + U64 sublevelticks = 0; + + for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + it != prev_id->endChildren(); + ++it) + { + sublevelticks += (tidx == -1) + ? frame_recording.getPeriodMean(**it).value() + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + } + + F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); + sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); + + if (mDisplayCenter == ALIGN_CENTER) + { + left += (prev_delta_x - sublevel_dx[level])/2; + } + else if (mDisplayCenter == ALIGN_RIGHT) + { + left += (prev_delta_x - sublevel_dx[level]); + } + + sublevel_left[level] = left; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + + right = left + dx; + xpos.back() = right; + xpos.push_back(left); - mBarStart.back().push_back(left); - mBarEnd.back().push_back(right); + mBarStart.back().push_back(left); + mBarEnd.back().push_back(right); - top = y; - bottom = y - barh; + top = y; + bottom = y - barh; - if (right > left) - { - //U32 rounded_edges = 0; - LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; - S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) + if (right > left) { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } + //U32 rounded_edges = 0; + LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; + S32 scale_offset = 0; + + BOOL is_child_of_hover_item = (idp == mHoverID); + LLTrace::TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } + + if (idp == mHoverID) + { + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + //color = lerp(color, LLColor4::black, -0.4f); + } + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } + + gGL.color4fv(color.mV); + F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); } - else if (mHoverID != NULL && !is_child_of_hover_item) + + if ((*it)->getCollapsed()) { - color = lerp(color, LLColor4::grey, 0.8f); + it.skipDescendants(); } - - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); - - } - - if ((*it)->getCollapsed()) - { - it.skipDescendants(); - } - prev_id = idp; + prev_id = idp; + } + y -= (barh + dy); + if (j < 0) + y -= barh; } - y -= (barh + dy); - if (j < 0) - y -= barh; } - + //draw line graph history { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -- cgit v1.2.3 From 1f56e57008f5a50c9e75fc0b4512c483ac359a52 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 18 Dec 2012 00:58:26 -0800 Subject: SH-3468 WIP add memory tracking base class created memory tracking trace type instrumented a few classes with memory tracking --- indra/llcommon/lltrace.h | 270 ++++++++++++++++++++++++++++++++++++++++- indra/llimage/llimage.cpp | 8 +- indra/llimage/llimage.h | 5 +- indra/llui/lltextbase.cpp | 17 ++- indra/llui/lltextbase.h | 5 +- indra/llui/lluictrl.cpp | 21 ++-- indra/llui/llview.h | 3 +- indra/llui/llviewmodel.cpp | 5 + indra/llui/llviewmodel.h | 4 +- indra/newview/lldrawable.h | 35 +++--- indra/newview/llface.h | 10 +- indra/newview/llviewerobject.h | 6 +- 12 files changed, 344 insertions(+), 45 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index d29d43a92c..d4fc93342d 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -424,9 +424,9 @@ namespace LLTrace // // members // - U64 mSelfTimeCounter, - mTotalTimeCounter; - U32 mCalls; + U64 mSelfTimeCounter, + mTotalTimeCounter; + U32 mCalls; }; @@ -509,6 +509,268 @@ namespace LLTrace trace_t::getPrimaryAccumulator().add(LLUnits::rawValue(converted_value)); } }; -} +struct MemStatAccumulator +{ + MemStatAccumulator() + : mSize(0), + mChildSize(0), + mAllocatedCount(0), + mDeallocatedCount(0) + {} + + void addSamples(const MemStatAccumulator& other) + { + mSize += other.mSize; + mChildSize += other.mChildSize; + mAllocatedCount += other.mAllocatedCount; + mDeallocatedCount += other.mDeallocatedCount; + } + + void reset(const MemStatAccumulator* other) + { + mSize = 0; + mChildSize = 0; + mAllocatedCount = 0; + mDeallocatedCount = 0; + } + + size_t mSize, + mChildSize; + int mAllocatedCount, + mDeallocatedCount; +}; + +class MemStat : public TraceType<MemStatAccumulator> +{ +public: + typedef TraceType<MemStatAccumulator> trace_t; + MemStat(const char* name) + : trace_t(name) + {} +}; + +// measures effective memory footprint of specified type +// specialize to cover different types + +template<typename T> +struct MemFootprint +{ + static size_t measure(const T& value) + { + return sizeof(T); + } + + static size_t measure() + { + return sizeof(T); + } +}; + +template<typename T> +struct MemFootprint<T*> +{ + static size_t measure(const T* value) + { + if (!value) + { + return 0; + } + return MemFootprint<T>::measure(*value); + } + + static size_t measure() + { + return MemFootPrint<T>::measure(); + } +}; + +template<typename T> +struct MemFootprint<std::basic_string<T> > +{ + static size_t measure(const std::basic_string<T>& value) + { + return value.capacity() * sizeof(T); + } + + static size_t measure() + { + return sizeof(std::basic_string<T>); + } +}; + +template<typename T> +struct MemFootprint<std::vector<T> > +{ + static size_t measure(const std::vector<T>& value) + { + return value.capacity() * MemFootPrint<T>::measure(); + } + + static size_t measure() + { + return sizeof(std::vector<T>); + } +}; + +template<typename T> +struct MemFootprint<std::list<T> > +{ + static size_t measure(const std::list<T>& value) + { + return value.size() * (MemFootPrint<T>::measure() + sizeof(void*) * 2); + } + + static size_t measure() + { + return sizeof(std::list<T>); + } +}; + +template<typename T> +class MemTrackable +{ + template<typename TRACKED, typename TRACKED_IS_TRACKER> + struct TrackMemImpl; + + typedef MemTrackable<T> mem_trackable_t; + +public: + typedef void mem_trackable_tag_t; + + ~MemTrackable() + { + memDisclaim(mMemFootprint); + } + + void* operator new(size_t allocation_size) + { + // reserve 8 bytes for allocation size (and preserving 8 byte alignment of structs) + void* allocation = ::operator new(allocation_size + 8); + *(size_t*)allocation = allocation_size; + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mSize += allocation_size; + accumulator.mAllocatedCount++; + return (void*)((char*)allocation + 8); + } + + void operator delete(void* ptr) + { + size_t* allocation_size = (size_t*)((char*)ptr - 8); + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mSize -= *allocation_size; + accumulator.mAllocatedCount--; + accumulator.mDeallocatedCount++; + ::delete((char*)ptr - 8); + } + + void *operator new [](size_t size) + { + size_t* result = (size_t*)malloc(size + 8); + *result = size; + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mSize += size; + accumulator.mAllocatedCount++; + return (void*)((char*)result + 8); + } + + void operator delete[](void* ptr) + { + size_t* allocation_size = (size_t*)((char*)ptr - 8); + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mSize -= *allocation_size; + accumulator.mAllocatedCount--; + accumulator.mDeallocatedCount++; + ::delete[]((char*)ptr - 8); + } + + // claim memory associated with other objects/data as our own, adding to our calculated footprint + template<typename T> + T& memClaim(T& value) + { + TrackMemImpl<T>::claim(*this, value); + return value; + } + + template<typename T> + const T& memClaim(const T& value) + { + TrackMemImpl<T>::claim(*this, value); + return value; + } + + + void memClaim(size_t size) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + mMemFootprint += size; + accumulator.mSize += size; + } + + // remove memory we had claimed from our calculated footprint + template<typename T> + T& memDisclaim(T& value) + { + TrackMemImpl<T>::disclaim(*this, value); + return value; + } + + template<typename T> + const T& memDisclaim(const T& value) + { + TrackMemImpl<T>::disclaim(*this, value); + return value; + } + + void memDisclaim(size_t size) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mSize -= size; + mMemFootprint -= size; + } + +private: + size_t mMemFootprint; + + template<typename TRACKED, typename TRACKED_IS_TRACKER = void> + struct TrackMemImpl + { + static void claim(mem_trackable_t& tracker, const TRACKED& tracked) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + size_t footprint = MemFootprint<TRACKED>::measure(tracked); + accumulator.mSize += footprint; + tracker.mMemFootprint += footprint; + } + + static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + size_t footprint = MemFootprint<TRACKED>::measure(tracked); + accumulator.mSize -= footprint; + tracker.mMemFootprint -= footprint; + } + }; + + template<typename TRACKED> + struct TrackMemImpl<TRACKED, typename TRACKED::mem_trackable_tag_t> + { + static void claim(mem_trackable_t& tracker, TRACKED& tracked) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mChildSize += MemFootprint<TRACKED>::measure(tracked); + } + + static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) + { + MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + accumulator.mChildSize -= MemFootprint<TRACKED>::measure(tracked); + } + }; + static MemStat sStat; +}; + +template<typename T> MemStat MemTrackable<T>::sStat(typeid(T).name()); + +} #endif // LL_LLTRACE_H diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 914bf836c1..22dd809ef3 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -157,7 +157,8 @@ void LLImageBase::sanityCheck() // virtual void LLImageBase::deleteData() { - FREE_MEM(sPrivatePoolp, mData) ; + FREE_MEM(sPrivatePoolp, mData); + memDisclaim(mDataSize); mData = NULL; mDataSize = 0; } @@ -201,6 +202,7 @@ U8* LLImageBase::allocateData(S32 size) mBadBufferAllocation = true ; } mDataSize = size; + memClaim(mDataSize); } return mData; @@ -222,7 +224,9 @@ U8* LLImageBase::reallocateData(S32 size) FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; + memDisclaim(mDataSize); mDataSize = size; + memClaim(mDataSize); return mData; } @@ -1584,7 +1588,9 @@ static void avg4_colors2(const U8* a, const U8* b, const U8* c, const U8* d, U8* void LLImageBase::setDataAndSize(U8 *data, S32 size) { ll_assert_aligned(data, 16); + memDisclaim(mDataSize); mData = data; mDataSize = size; + memClaim(mDataSize); } //static diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index b87ce6f060..d945d54404 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -30,6 +30,7 @@ #include "lluuid.h" #include "llstring.h" #include "llthread.h" +#include "lltrace.h" const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 const S32 MAX_IMAGE_MIP = 11; // 2048x2048 @@ -110,7 +111,9 @@ protected: //============================================================================ // Image base class -class LLImageBase : public LLThreadSafeRefCount +class LLImageBase +: public LLThreadSafeRefCount, + public LLTrace::MemTrackable<LLImageBase> { protected: virtual ~LLImageBase(); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 3815eec447..31d67a9e08 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -561,7 +561,7 @@ void LLTextBase::drawText() if ( (mSpellCheckStart != start) || (mSpellCheckEnd != end) ) { const LLWString& wstrText = getWText(); - mMisspellRanges.clear(); + memDisclaim(mMisspellRanges).clear(); segment_set_t::const_iterator seg_it = getSegIterContaining(start); while (mSegments.end() != seg_it) @@ -632,6 +632,7 @@ void LLTextBase::drawText() mSpellCheckStart = start; mSpellCheckEnd = end; + memClaim(mMisspellRanges); } } @@ -890,10 +891,12 @@ void LLTextBase::createDefaultSegment() // ensures that there is always at least one segment if (mSegments.empty()) { + memDisclaim(mSegments); LLStyleConstSP sp(new LLStyle(getDefaultStyleParams())); LLTextSegmentPtr default_segment = new LLNormalTextSegment( sp, 0, getLength() + 1, *this); mSegments.insert(default_segment); default_segment->linkToDocument(this); + memClaim(mSegments); } } @@ -904,6 +907,8 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) return; } + memDisclaim(mSegments); + segment_set_t::iterator cur_seg_iter = getSegIterContaining(segment_to_insert->getStart()); S32 reflow_start_index = 0; @@ -976,6 +981,7 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) // layout potentially changed needsReflow(reflow_start_index); + memClaim(mSegments); } BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask) @@ -1271,8 +1277,11 @@ void LLTextBase::replaceWithSuggestion(U32 index) removeStringNoUndo(it->first, it->second - it->first); // Insert the suggestion in its place + memDisclaim(mSuggestionList); LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); insertStringNoUndo(it->first, utf8str_to_wstring(mSuggestionList[index])); + memClaim(mSuggestionList); + setCursorPos(it->first + (S32)suggestion.length()); break; @@ -1334,7 +1343,7 @@ bool LLTextBase::isMisspelledWord(U32 pos) const void LLTextBase::onSpellCheckSettingsChange() { // Recheck the spelling on every change - mMisspellRanges.clear(); + memDisclaim(mMisspellRanges).clear(); mSpellCheckStart = mSpellCheckEnd = -1; } @@ -1593,7 +1602,7 @@ LLRect LLTextBase::getTextBoundingRect() void LLTextBase::clearSegments() { - mSegments.clear(); + memDisclaim(mSegments).clear(); createDefaultSegment(); } @@ -3057,7 +3066,9 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) llwarns << "LLTextSegment::setToolTip: cannot replace keyword tooltip." << llendl; return; } + memDisclaim(mTooltip); mTooltip = tooltip; + memClaim(mTooltip); } bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 90b147cee1..966dd93888 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -50,7 +50,10 @@ class LLUrlMatch; /// includes a start/end offset from the start of the string, a /// style to render with, an optional tooltip, etc. /// -class LLTextSegment : public LLRefCount, public LLMouseHandler +class LLTextSegment +: public LLRefCount, + public LLMouseHandler, + public LLTrace::MemTrackable<LLTextSegment> { public: LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index b9c843e931..08358484ef 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -118,6 +118,7 @@ LLUICtrl::LLUICtrl(const LLUICtrl::Params& p, const LLViewModelPtr& viewmodel) mDoubleClickSignal(NULL), mTransparencyType(TT_DEFAULT) { + memClaim(viewmodel.get()); } void LLUICtrl::initFromParams(const Params& p) @@ -940,7 +941,7 @@ boost::signals2::connection LLUICtrl::setCommitCallback( boost::function<void (L } boost::signals2::connection LLUICtrl::setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb ) { - if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + if (!mValidateSignal) mValidateSignal = memClaim(new enable_signal_t()); return mValidateSignal->connect(boost::bind(cb, _2)); } @@ -1003,55 +1004,55 @@ boost::signals2::connection LLUICtrl::setValidateCallback(const EnableCallbackPa boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { - if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + if (!mCommitSignal) mCommitSignal = memClaim(new commit_signal_t()); return mCommitSignal->connect(cb); } boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) { - if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + if (!mValidateSignal) mValidateSignal = memClaim(new enable_signal_t()); return mValidateSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + if (!mMouseEnterSignal) mMouseEnterSignal = memClaim(new commit_signal_t()); return mMouseEnterSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + if (!mMouseLeaveSignal) mMouseLeaveSignal = memClaim(new commit_signal_t()); return mMouseLeaveSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + if (!mMouseDownSignal) mMouseDownSignal = memClaim(new mouse_signal_t()); return mMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + if (!mMouseUpSignal) mMouseUpSignal = memClaim(new mouse_signal_t()); return mMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + if (!mRightMouseDownSignal) mRightMouseDownSignal = memClaim(new mouse_signal_t()); return mRightMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + if (!mRightMouseUpSignal) mRightMouseUpSignal = memClaim(new mouse_signal_t()); return mRightMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { - if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + if (!mDoubleClickSignal) mDoubleClickSignal = memClaim(new mouse_signal_t()); return mDoubleClickSignal->connect(cb); } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 1c35349510..29ee2125f9 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -101,7 +101,8 @@ class LLView : public LLMouseHandler, // handles mouse events public LLFocusableElement, // handles keyboard events public LLMortician, // lazy deletion - public LLHandleProvider<LLView> // passes out weak references to self + public LLHandleProvider<LLView>, // passes out weak references to self + public LLTrace::MemTrackable<LLView> // track memory usage { public: struct Follows : public LLInitParam::ChoiceBlock<Follows> diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index a9f8acc440..dff0dcb2fd 100644 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -80,7 +80,10 @@ LLTextViewModel::LLTextViewModel(const LLSD& value) void LLTextViewModel::setValue(const LLSD& value) { LLViewModel::setValue(value); + memDisclaim(mDisplay); mDisplay = utf8str_to_wstring(value.asString()); + memClaim(mDisplay); + // mDisplay and mValue agree mUpdateFromDisplay = false; } @@ -91,7 +94,9 @@ void LLTextViewModel::setDisplay(const LLWString& value) // and do the utf8str_to_wstring() to get the corresponding mDisplay // value. But a text editor might want to edit the display string // directly, then convert back to UTF8 on commit. + memDisclaim(mDisplay); mDisplay = value; + memClaim(mDisplay); mDirty = true; // Don't immediately convert to UTF8 -- do it lazily -- we expect many // more setDisplay() calls than getValue() calls. Just flag that it needs diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index ef2e314799..cec0368460 100644 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -60,7 +60,9 @@ typedef LLPointer<LLListViewModel> LLListViewModelPtr; * LLViewModel data. This way, the LLViewModel is quietly deleted when the * last referencing widget is destroyed. */ -class LLViewModel: public LLRefCount +class LLViewModel +: public LLRefCount, + public LLTrace::MemTrackable<LLViewModel> { public: LLViewModel(); diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 4608d16fec..f15090fb87 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -59,7 +59,9 @@ const U32 SILHOUETTE_HIGHLIGHT = 0; // All data for new renderer goes into this class. LL_ALIGN_PREFIX(16) -class LLDrawable : public LLRefCount +class LLDrawable +: public LLRefCount, + public LLTrace::MemTrackable<LLDrawable> { public: LLDrawable(const LLDrawable& rhs) @@ -316,24 +318,23 @@ public: private: typedef std::vector<LLFace*> face_list_t; - U32 mState; - S32 mRenderType; - LLPointer<LLViewerObject> mVObjp; - face_list_t mFaces; - LLSpatialGroup* mSpatialGroupp; - LLPointer<LLDrawable> mSpatialBridge; + U32 mState; + S32 mRenderType; + LLPointer<LLViewerObject> mVObjp; + face_list_t mFaces; + LLSpatialGroup* mSpatialGroupp; + LLPointer<LLDrawable> mSpatialBridge; - mutable U32 mVisible; - F32 mRadius; - F32 mBinRadius; - mutable S32 mBinIndex; - S32 mGeneration; - - LLVector3 mCurrentScale; - - static U32 sCurVisible; // Counter for what value of mVisible means currently visible + mutable U32 mVisible; + F32 mRadius; + F32 mBinRadius; + mutable S32 mBinIndex; + S32 mGeneration; - static U32 sNumZombieDrawables; + LLVector3 mCurrentScale; + + static U32 sCurVisible; // Counter for what value of mVisible means currently visible + static U32 sNumZombieDrawables; static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList; } LL_ALIGN_POSTFIX(16); diff --git a/indra/newview/llface.h b/indra/newview/llface.h index de4d03351c..15c9e7856f 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -262,11 +262,11 @@ public: LLVector2 mTexExtents[2]; F32 mDistance; - F32 mLastUpdateTime; - F32 mLastSkinTime; - F32 mLastMoveTime; - LLMatrix4* mTextureMatrix; - LLDrawInfo* mDrawInfo; + F32 mLastUpdateTime; + F32 mLastSkinTime; + F32 mLastMoveTime; + LLMatrix4* mTextureMatrix; + LLDrawInfo* mDrawInfo; private: LLPointer<LLVertexBuffer> mVertexBuffer; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 97cf0a4850..14ea8ded38 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -107,7 +107,11 @@ struct PotentialReturnableObject //============================================================================ -class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate +class LLViewerObject +: public LLPrimitive, + public LLRefCount, + public LLGLUpdate, + public LLTrace::MemTrackable<LLViewerObject> { protected: ~LLViewerObject(); // use unref() -- cgit v1.2.3 From c219282f5de753a044cecb53bd806145f68add9a Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Tue, 18 Dec 2012 20:07:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed some potential data races got memory stats recording in trace system --- indra/llcommon/llapr.h | 51 +++-- indra/llcommon/llfasttimer.cpp | 326 +++++++++++++------------------ indra/llcommon/llfasttimer.h | 27 +-- indra/llcommon/lltrace.h | 56 +++--- indra/llcommon/lltracerecording.cpp | 21 +- indra/llcommon/lltracerecording.h | 11 +- indra/llcommon/lltracethreadrecorder.cpp | 14 +- indra/llui/llviewmodel.h | 1 + indra/newview/llappviewer.cpp | 2 +- indra/newview/llfasttimerview.cpp | 52 +++-- indra/newview/llfasttimerview.h | 1 + 11 files changed, 274 insertions(+), 288 deletions(-) diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 199b5291dd..f8f94263e4 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -48,6 +48,19 @@ extern LL_COMMON_API apr_thread_mutex_t* gLogMutexp; extern apr_thread_mutex_t* gCallStacksLogMutexp; struct apr_dso_handle_t; +/** + * @brief Function which appropriately logs error or remains quiet on + * APR_SUCCESS. + * @return Returns <code>true</code> if status is an error condition. + */ +bool LL_COMMON_API ll_apr_warn_status(apr_status_t status); +/// There's a whole other APR error-message function if you pass a DSO handle. +bool LL_COMMON_API ll_apr_warn_status(apr_status_t status, apr_dso_handle_t* handle); + +void LL_COMMON_API ll_apr_assert_status(apr_status_t status); +void LL_COMMON_API ll_apr_assert_status(apr_status_t status, apr_dso_handle_t* handle); + +extern "C" LL_COMMON_API apr_pool_t* gAPRPoolp; // Global APR memory pool /** * @brief initialize the common apr constructs -- apr itself, the @@ -285,26 +298,26 @@ protected: { llassert(sInitialized); void* ptr; - //apr_status_t result = + apr_status_t result = apr_threadkey_private_get(&ptr, mThreadKey); - //if (result != APR_SUCCESS) - //{ - // ll_apr_warn_status(s); - // llerrs << "Failed to get thread local data" << llendl; - //} + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to get thread local data" << llendl; + } return ptr; } LL_FORCE_INLINE const void* get() const { void* ptr; - //apr_status_t result = + apr_status_t result = apr_threadkey_private_get(&ptr, mThreadKey); - //if (result != APR_SUCCESS) - //{ - // ll_apr_warn_status(s); - // llerrs << "Failed to get thread local data" << llendl; - //} + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to get thread local data" << llendl; + } return ptr; } @@ -379,18 +392,4 @@ public: } }; -/** - * @brief Function which appropriately logs error or remains quiet on - * APR_SUCCESS. - * @return Returns <code>true</code> if status is an error condition. - */ -bool LL_COMMON_API ll_apr_warn_status(apr_status_t status); -/// There's a whole other APR error-message function if you pass a DSO handle. -bool LL_COMMON_API ll_apr_warn_status(apr_status_t status, apr_dso_handle_t* handle); - -void LL_COMMON_API ll_apr_assert_status(apr_status_t status); -void LL_COMMON_API ll_apr_assert_status(apr_status_t status, apr_dso_handle_t* handle); - -extern "C" LL_COMMON_API apr_pool_t* gAPRPoolp; // Global APR memory pool - #endif // LL_LLAPR_H diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 37e0fbac0a..f4fa8f1e61 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -59,11 +59,6 @@ namespace LLTrace ////////////////////////////////////////////////////////////////////////////// // statics -S32 TimeBlock::sCurFrameIndex = -1; -S32 TimeBlock::sLastFrameIndex = -1; -U64 TimeBlock::sLastFrameTime = TimeBlock::getCPUClockCount64(); -bool TimeBlock::sPauseHistory = 0; -bool TimeBlock::sResetHistory = 0; bool TimeBlock::sLog = false; std::string TimeBlock::sLogName = ""; bool TimeBlock::sMetricLog = false; @@ -220,143 +215,126 @@ void TimeBlock::setParent(TimeBlock* parent) } } -S32 TimeBlock::getDepth() -{ - S32 depth = 0; - TimeBlock* timerp = mParent; - while(timerp) - { - depth++; - if (timerp->getParent() == timerp) break; - timerp = timerp->mParent; - } - return depth; -} - // static void TimeBlock::processTimes() { - //void TimeBlock::buildHierarchy() + get_clock_count(); // good place to calculate clock frequency + U64 cur_time = getCPUClockCount64(); + CurTimerData* cur_data = sCurTimerData.get(); + + // set up initial tree + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) { - // set up initial tree + TimeBlock& timer = *it; + if (&timer == &TimeBlock::getRootTimer()) continue; + + // bootstrap tree construction by attaching to last timer to be on stack + // when this timer was called + if (timer.mParent == &TimeBlock::getRootTimer()) { - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); it != end_it; ++it) + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + + if (accumulator.mLastCaller) { - TimeBlock& timer = *it; - if (&timer == &TimeBlock::getRootTimer()) continue; - - // bootstrap tree construction by attaching to last timer to be on stack - // when this timer was called - if (timer.mParent == &TimeBlock::getRootTimer()) - { - TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; - - if (tree_node.mLastCaller) - { - timer.setParent(tree_node.mLastCaller); - } - // no need to push up tree on first use, flag can be set spuriously - tree_node.mMoveUpTree = false; - } + timer.setParent(accumulator.mLastCaller); + accumulator.mParent = accumulator.mLastCaller; } + // no need to push up tree on first use, flag can be set spuriously + accumulator.mMoveUpTree = false; } + } - // bump timers up tree if they have been flagged as being in the wrong place - // do this in a bottom up order to promote descendants first before promoting ancestors - // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); - it != end_timer_tree_bottom_up(); - ++it) + // bump timers up tree if they have been flagged as being in the wrong place + // do this in a bottom up order to promote descendants first before promoting ancestors + // this preserves partial order derived from current frame's observations + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); + it != end_timer_tree_bottom_up(); + ++it) + { + TimeBlock* timerp = *it; + + // sort timers by time last called, so call graph makes sense + if (timerp->mNeedsSorting) { - TimeBlock* timerp = *it; - // skip root timer - if (timerp == &TimeBlock::getRootTimer()) continue; - TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timerp->getIndex()]; + std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); + } + + // skip root timer + if (timerp != &TimeBlock::getRootTimer()) + { + TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); - if (tree_node.mMoveUpTree) + if (accumulator.mMoveUpTree) { // since ancestors have already been visited, re-parenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - tree_node.mMoveUpTree = false; + accumulator.mParent = timerp->mParent; + accumulator.mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up + // as ancestors may call this timer only on certain paths, so we want to resolve + // child-most block locations before their parents it.skipAncestors(); } } - - // sort timers by time last called, so call graph makes sense - for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimer()); - it != end_timer_tree(); - ++it) - { - TimeBlock* timerp = (*it); - if (timerp->mNeedsSorting) - { - std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); - } - timerp->mNeedsSorting = false; - } } - - //void TimeBlock::accumulateTimings() - { - U64 cur_time = getCPUClockCount64(); - - // root defined by parent pointing to self - CurTimerData* cur_data = sCurTimerData.get(); - // walk up stack of active timers and accumulate current time while leaving timing structures active - BlockTimer* cur_timer = cur_data->mCurTimer; - TimeBlockAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); - while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) - { - U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; - U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; - cur_data->mChildTime = 0; - accumulator.mSelfTimeCounter += self_time_delta; - accumulator.mTotalTimeCounter += cumulative_time_delta; - cur_timer->mStartTime = cur_time; + // walk up stack of active timers and accumulate current time while leaving timing structures active + BlockTimer* cur_timer = cur_data->mCurTimer; + TimeBlockAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + // root defined by parent pointing to self + while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) + { + U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; + U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; + cur_data->mChildTime = 0; + accumulator.mSelfTimeCounter += self_time_delta; + accumulator.mTotalTimeCounter += cumulative_time_delta; - cur_data = &cur_timer->mLastTimerData; - cur_data->mChildTime += cumulative_time_delta; - if (cur_data->mTimerData) - { - accumulator = cur_data->mTimerData->getPrimaryAccumulator(); - } + cur_timer->mStartTime = cur_time; - cur_timer = cur_timer->mLastTimerData.mCurTimer; + cur_data = &cur_timer->mLastTimerData; + cur_data->mChildTime += cumulative_time_delta; + if (cur_data->mTimerData) + { + accumulator = cur_data->mTimerData->getPrimaryAccumulator(); } - // traverse tree in DFS post order, or bottom up - //for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); - // it != end_timer_tree_bottom_up(); - // ++it) - //{ - // TimeBlock* timerp = (*it); - // TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); - // timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter; - // for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) - // { - // timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; - // } - - //S32 cur_frame = getCurFrameIndex(); - //if (cur_frame >= 0) - //{ - // // update timer history + cur_timer = cur_timer->mLastTimerData.mCurTimer; + } - // int hidx = getCurFrameIndex() % HISTORY_NUM; - // timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter; - // timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1); - // timerp->mCallHistory[hidx] = accumulator.mCalls; - // timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1); - //} - //} + // reset for next frame + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), + end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) + { + TimeBlock& timer = *it; + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + + accumulator.mLastCaller = NULL; + accumulator.mMoveUpTree = false; } + + // traverse tree in DFS post order, or bottom up + //for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); + // it != end_timer_tree_bottom_up(); + // ++it) + //{ + // TimeBlock* timerp = (*it); + // TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); + // timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter; + // for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it) + // { + // timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter; + // } + //} } @@ -376,106 +354,78 @@ std::vector<TimeBlock*>& TimeBlock::getChildren() } //static -void TimeBlock::nextFrame() +void TimeBlock::logStats() { - get_clock_count(); // good place to calculate clock frequency - U64 frame_time = TimeBlock::getCPUClockCount64(); - if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff) - { - llinfos << "Slow frame, fast timers inaccurate" << llendl; - } - - if (!sPauseHistory) - { - TimeBlock::processTimes(); - sLastFrameIndex = sCurFrameIndex++; - } - // get ready for next frame - //void TimeBlock::resetFrame() - { - if (sLog) - { //output current frame counts to performance log + if (sLog) + { //output current frame counts to performance log - static S32 call_count = 0; - if (call_count % 100 == 0) - { - LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL; - LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; - LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; - LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL; - } - call_count++; + static S32 call_count = 0; + if (call_count % 100 == 0) + { + LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL; + LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL; + LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL; + LL_DEBUGS("FastTimers") << "elapsed sec " << ((F64)getCPUClockCount64()) / (LLUnit<LLUnits::Hertz, F64>(LLProcessorInfo().getCPUFrequency())) << LL_ENDL; + } + call_count++; - LLUnit<LLUnits::Seconds, F64> total_time(0); - LLSD sd; + LLUnit<LLUnits::Seconds, F64> total_time(0); + LLSD sd; + { + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), + end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) { - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), - end_it = LLInstanceTracker<TimeBlock>::endInstances(); - it != end_it; - ++it) - { - TimeBlock& timer = *it; - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); - sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecordingPeriod().getSum(timer).value()); - sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecordingPeriod().getSum(timer.callCount())); - - // computing total time here because getting the root timer's getCountHistory - // doesn't work correctly on the first frame - total_time += frame_recording.getLastRecordingPeriod().getSum(timer); - } - } - - sd["Total"]["Time"] = (LLSD::Real) total_time.value(); - sd["Total"]["Calls"] = (LLSD::Integer) 1; + TimeBlock& timer = *it; + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + sd[timer.getName()]["Time"] = (LLSD::Real) (frame_recording.getLastRecordingPeriod().getSum(timer).value()); + sd[timer.getName()]["Calls"] = (LLSD::Integer) (frame_recording.getLastRecordingPeriod().getSum(timer.callCount())); - { - LLMutexLock lock(sLogLock); - sLogQueue.push(sd); + // computing total time here because getting the root timer's getCountHistory + // doesn't work correctly on the first frame + total_time += frame_recording.getLastRecordingPeriod().getSum(timer); } } - // reset for next frame - for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), - end_it = LLInstanceTracker<TimeBlock>::endInstances(); - it != end_it; - ++it) - { - TimeBlock& timer = *it; - TimeBlockTreeNode& tree_node = sCurTimerData->mTimerTreeData[timer.getIndex()]; + sd["Total"]["Time"] = (LLSD::Real) total_time.value(); + sd["Total"]["Calls"] = (LLSD::Integer) 1; - tree_node.mLastCaller = NULL; - tree_node.mMoveUpTree = false; + { + LLMutexLock lock(sLogLock); + sLogQueue.push(sd); } } - sLastFrameTime = frame_time; + } //static void TimeBlock::dumpCurTimes() { - // accumulate timings, etc. - processTimes(); - + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + // walk over timers in depth order and output timings for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimer()); it != end_timer_tree(); ++it) { - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); TimeBlock* timerp = (*it); - LLUnit<LLUnits::Seconds, F64> total_time_ms = frame_recording.getLastRecordingPeriod().getSum(*timerp); - U32 num_calls = frame_recording.getLastRecordingPeriod().getSum(timerp->callCount()); + LLUnit<LLUnits::Seconds, F64> total_time_ms = last_frame_recording.getSum(*timerp); + U32 num_calls = last_frame_recording.getSum(timerp->callCount()); // Don't bother with really brief times, keep output concise if (total_time_ms < 0.1) continue; std::ostringstream out_str; - for (S32 i = 0; i < timerp->getDepth(); i++) + TimeBlock* parent_timerp = timerp; + while(parent_timerp && parent_timerp != parent_timerp->getParent()) { out_str << "\t"; + parent_timerp = parent_timerp->getParent(); } out_str << timerp->getName() << " " @@ -505,7 +455,11 @@ void TimeBlock::writeLog(std::ostream& os) TimeBlockAccumulator::TimeBlockAccumulator() : mSelfTimeCounter(0), mTotalTimeCounter(0), - mCalls(0) + mCalls(0), + mLastCaller(NULL), + mActiveCount(0), + mMoveUpTree(false), + mParent(NULL) {} void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other ) @@ -513,6 +467,10 @@ void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other ) mSelfTimeCounter += other.mSelfTimeCounter; mTotalTimeCounter += other.mTotalTimeCounter; mCalls += other.mCalls; + mLastCaller = other.mLastCaller; + mActiveCount = other.mActiveCount; + mMoveUpTree = other.mMoveUpTree; + mParent = other.mParent; } void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other ) @@ -522,10 +480,4 @@ void TimeBlockAccumulator::reset( const TimeBlockAccumulator* other ) mCalls = 0; } -TimeBlockTreeNode::TimeBlockTreeNode() -: mLastCaller(NULL), - mActiveCount(0), - mMoveUpTree(false) -{} - } // namespace LLTrace diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index b5b4a8d0b4..1e2e4b590f 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -43,7 +43,6 @@ struct CurTimerData class BlockTimer* mCurTimer; class TimeBlock* mTimerData; U64 mChildTime; - TimeBlockTreeNode* mTimerTreeData; }; class BlockTimer @@ -70,11 +69,8 @@ class TimeBlock public: TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); - enum { HISTORY_NUM = 300 }; - TimeBlock* getParent() const { return mParent; } void setParent(TimeBlock* parent); - S32 getDepth(); typedef std::vector<TimeBlock*>::const_iterator child_const_iter; child_const_iter beginChildren(); @@ -245,12 +241,12 @@ public: // can be called multiple times in a frame, at any point static void processTimes(); - // call this once a frame to reset timers - static void nextFrame(); + // call this once a frame to periodically log timers + static void logStats(); // tree structure, only updated from master trace thread TimeBlock* mParent; // TimeBlock of caller(parent) - std::vector<TimeBlock*> mChildren; + std::vector<TimeBlock*> mChildren; // TimeBlock of callees bool mCollapsed, // don't show children mNeedsSorting; // sort children whenever child added @@ -260,12 +256,6 @@ public: sLog; static LLThreadLocalPointer<CurTimerData> sCurTimerData; static U64 sClockResolution; - static S32 sCurFrameIndex, - sLastFrameIndex; - static U64 sLastFrameTime; - static bool sPauseHistory, - sResetHistory; - }; LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) @@ -274,10 +264,10 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) mStartTime = TimeBlock::getCPUClockCount64(); CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[timer.getIndex()]; - tree_node.mActiveCount++; + TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator.mActiveCount++; // keep current parent as long as it is active when we are - tree_node.mMoveUpTree |= (cur_timer_data->mTimerTreeData[timer.mParent->getIndex()].mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); // store top of stack mLastTimerData = *cur_timer_data; @@ -294,16 +284,15 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - TimeBlockTreeNode& tree_node = cur_timer_data->mTimerTreeData[cur_timer_data->mTimerData->getIndex()]; accumulator.mCalls++; accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; accumulator.mTotalTimeCounter += total_time; - tree_node.mActiveCount--; + accumulator.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - tree_node.mLastCaller = mLastTimerData.mTimerData; + accumulator.mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index d4fc93342d..5b5e2b7879 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -82,18 +82,21 @@ namespace LLTrace enum StaticAllocationMarker { STATIC_ALLOC }; AccumulatorBuffer(StaticAllocationMarker m) - : mStorageSize(64), - mNextStorageSlot(0), - mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE]) - {} + : mStorageSize(0), + mStorage(NULL), + mNextStorageSlot(0) + { + resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); + } public: AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) - : mStorageSize(other.mStorageSize), - mStorage(new ACCUMULATOR[other.mStorageSize]), + : mStorageSize(0), + mStorage(NULL), mNextStorageSlot(other.mNextStorageSlot) { + resize(other.mStorageSize); for (S32 i = 0; i < mNextStorageSlot; i++) { mStorage[i] = other.mStorage[i]; @@ -181,9 +184,12 @@ namespace LLTrace { ACCUMULATOR* old_storage = mStorage; mStorage = new ACCUMULATOR[new_size]; - for (S32 i = 0; i < mStorageSize; i++) + if (old_storage) { - mStorage[i] = old_storage[i]; + for (S32 i = 0; i < mStorageSize; i++) + { + mStorage[i] = old_storage[i]; + } } mStorageSize = new_size; delete[] old_storage; @@ -300,14 +306,14 @@ namespace LLTrace mNumSamples += other.mNumSamples; mMean = mMean * weight + other.mMean * (1.f - weight); + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm F64 n_1 = (F64)mNumSamples, n_2 = (F64)other.mNumSamples; F64 m_1 = mMean, m_2 = other.mMean; F64 sd_1 = getStandardDeviation(), sd_2 = other.getStandardDeviation(); - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm if (n_1 == 0) { mVarianceSum = other.mVarianceSum; @@ -405,6 +411,7 @@ namespace LLTrace { public: typedef LLUnit<LLUnits::Seconds, F64> value_t; + typedef TimeBlockAccumulator self_t; // fake class that allows us to view call count aspect of timeblock accumulator struct CallCountAspect @@ -418,15 +425,20 @@ namespace LLTrace }; TimeBlockAccumulator(); - void addSamples(const TimeBlockAccumulator& other); - void reset(const TimeBlockAccumulator* other); + void addSamples(const self_t& other); + void reset(const self_t* other); // // members // - U64 mSelfTimeCounter, - mTotalTimeCounter; - U32 mCalls; + U64 mSelfTimeCounter, + mTotalTimeCounter; + U32 mCalls; + class TimeBlock* mParent; // last acknowledged parent of this time block + class TimeBlock* mLastCaller; // used to bootstrap tree construction + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + }; @@ -460,16 +472,6 @@ namespace LLTrace {} }; - class TimeBlockTreeNode - { - public: - TimeBlockTreeNode(); - class TimeBlock* mLastCaller; // used to bootstrap tree construction - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame - }; - - template <typename T = F64> class Measurement : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > @@ -604,7 +606,7 @@ struct MemFootprint<std::vector<T> > { static size_t measure(const std::vector<T>& value) { - return value.capacity() * MemFootPrint<T>::measure(); + return value.capacity() * MemFootprint<T>::measure(); } static size_t measure() @@ -618,7 +620,7 @@ struct MemFootprint<std::list<T> > { static size_t measure(const std::list<T>& value) { - return value.size() * (MemFootPrint<T>::measure() + sizeof(void*) * 2); + return value.size() * (MemFootprint<T>::measure() + sizeof(void*) * 2); } static size_t measure() diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 3ea511ff3c..40079f40f1 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,7 +44,8 @@ Recording::Recording() mMeasurementsFloat(new AccumulatorBuffer<MeasurementAccumulator<F64> >()), mCounts(new AccumulatorBuffer<CountAccumulator<S64> >()), mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<S64> >()), - mStackTimers(new AccumulatorBuffer<TimeBlockAccumulator>()) + mStackTimers(new AccumulatorBuffer<TimeBlockAccumulator>()), + mMemStats(new AccumulatorBuffer<MemStatAccumulator>()) {} Recording::Recording( const Recording& other ) @@ -57,6 +58,7 @@ Recording::Recording( const Recording& other ) mCounts = other.mCounts; mMeasurements = other.mMeasurements; mStackTimers = other.mStackTimers; + mMemStats = other.mMemStats; LLStopWatchControlsMixin::initTo(other.getPlayState()); } @@ -84,6 +86,7 @@ void Recording::handleReset() mCounts.write()->reset(); mMeasurements.write()->reset(); mStackTimers.write()->reset(); + mMemStats.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -98,6 +101,7 @@ void Recording::handleStart() void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + LLTrace::TimeBlock::processTimes(); LLTrace::get_thread_recorder()->deactivate(this); } @@ -107,9 +111,9 @@ void Recording::handleSplitTo(Recording& other) other.restart(); other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); other.mMeasurements.write()->reset(mMeasurements); + //TODO: figure out how to get seamless handoff of timing stats } - void Recording::makePrimary() { mCountsFloat.write()->makePrimary(); @@ -117,6 +121,7 @@ void Recording::makePrimary() mCounts.write()->makePrimary(); mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); + mMemStats.write()->makePrimary(); } bool Recording::isPrimary() const @@ -131,6 +136,7 @@ void Recording::makeUnique() mCounts.makeUnique(); mMeasurements.makeUnique(); mStackTimers.makeUnique(); + mMemStats.makeUnique(); } void Recording::appendRecording( const Recording& other ) @@ -140,6 +146,7 @@ void Recording::appendRecording( const Recording& other ) mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); mStackTimers.write()->addSamples(*other.mStackTimers); + mMemStats.write()->addSamples(*other.mMemStats); mElapsedSeconds += other.mElapsedSeconds; } @@ -174,6 +181,16 @@ F32 Recording::getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& return (F32)(*mStackTimers)[stat.getIndex()].mCalls / mElapsedSeconds; } +LLUnit<LLUnits::Bytes, U32> Recording::getSum(const TraceType<MemStatAccumulator>& stat) const +{ + return (*mMemStats)[stat.getIndex()].mAllocatedCount; +} + +LLUnit<LLUnits::Bytes, F32> Recording::getPerSec(const TraceType<MemStatAccumulator>& stat) const +{ + return (F32)(*mMemStats)[stat.getIndex()].mAllocatedCount / mElapsedSeconds; +} + F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const { diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f4841214e8..8e5f1125ec 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -34,7 +34,7 @@ #include "lltimer.h" #include "lltrace.h" -class LL_COMMON_API LLStopWatchControlsMixinCommon +class LLStopWatchControlsMixinCommon { public: virtual ~LLStopWatchControlsMixinCommon() {} @@ -101,7 +101,7 @@ private: namespace LLTrace { - class LL_COMMON_API Recording : public LLStopWatchControlsMixin<Recording> + class Recording : public LLStopWatchControlsMixin<Recording> { public: Recording(); @@ -127,6 +127,10 @@ namespace LLTrace LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimeBlockAccumulator::SelfTimeAspect>& stat) const; F32 getPerSec(const TraceType<TimeBlockAccumulator::CallCountAspect>& stat) const; + // Memory accessors + LLUnit<LLUnits::Bytes, U32> getSum(const TraceType<MemStatAccumulator>& stat) const; + LLUnit<LLUnits::Bytes, F32> getPerSec(const TraceType<MemStatAccumulator>& stat) const; + // Count accessors F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const; S64 getSum(const TraceType<CountAccumulator<S64> >& stat) const; @@ -226,7 +230,8 @@ namespace LLTrace LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<F64> > > mMeasurementsFloat; LLCopyOnWritePointer<AccumulatorBuffer<CountAccumulator<S64> > > mCounts; LLCopyOnWritePointer<AccumulatorBuffer<MeasurementAccumulator<S64> > > mMeasurements; - LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> > mStackTimers; + LLCopyOnWritePointer<AccumulatorBuffer<TimeBlockAccumulator> > mStackTimers; + LLCopyOnWritePointer<AccumulatorBuffer<MemStatAccumulator> > mMemStats; LLTimer mSamplingTimer; F64 mElapsedSeconds; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 16235473ee..c4144b4999 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -43,13 +43,20 @@ ThreadRecorder::ThreadRecorder() mRootTimerData = new CurTimerData(); mRootTimerData->mTimerData = &TimeBlock::getRootTimer(); - mRootTimerData->mTimerTreeData = new TimeBlockTreeNode[AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer().size()]; + TimeBlock::sCurTimerData = mRootTimerData; + TimeBlock::getRootTimer().getPrimaryAccumulator().mActiveCount = 1; + + // initialize parent pointers in time blocks + for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); + it != end_it; + ++it) + { + it->getPrimaryAccumulator().mParent = it->mParent; + } mRootTimer = new BlockTimer(TimeBlock::getRootTimer()); mRootTimerData->mCurTimer = mRootTimer; - - mRootTimerData->mTimerTreeData[TimeBlock::getRootTimer().getIndex()].mActiveCount = 1; } ThreadRecorder::~ThreadRecorder() @@ -62,7 +69,6 @@ ThreadRecorder::~ThreadRecorder() } get_thread_recorder() = NULL; TimeBlock::sCurTimerData = NULL; - delete [] mRootTimerData->mTimerTreeData; delete mRootTimerData; } diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index cec0368460..a2ca20c739 100644 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -39,6 +39,7 @@ #include "llrefcount.h" #include "stdenums.h" #include "llstring.h" +#include "lltrace.h" #include <string> class LLScrollListItem; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c986954867..4209e6612e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1233,8 +1233,8 @@ bool LLAppViewer::mainLoop() while (!LLApp::isExiting()) { LLFastTimer _(FTM_FRAME); - LLTrace::TimeBlock::nextFrame(); LLTrace::get_frame_recording().nextPeriod(); + LLTrace::TimeBlock::logStats(); LLTrace::getMasterThreadRecorder().pullFromSlaveThreads(); diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 8014b5712b..2cf7939e5c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -58,6 +58,7 @@ static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; const S32 FTV_MAX_DEPTH = 8; +const S32 HISTORY_NUM = 300; std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse) @@ -77,6 +78,19 @@ static timer_tree_iterator_t end_timer_tree() return timer_tree_iterator_t(); } +S32 get_depth(const TimeBlock* blockp) +{ + S32 depth = 0; + TimeBlock* timerp = blockp->mParent; + while(timerp) + { + depth++; + if (timerp->getParent() == timerp) break; + timerp = timerp->mParent; + } + return depth; +} + LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), mHoverTimer(NULL), @@ -88,7 +102,8 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mHoverID(NULL), mHoverBarIndex(-1), mPrintStats(-1), - mRecording(&LLTrace::get_frame_recording()) + mRecording(&LLTrace::get_frame_recording()), + mPauseHistory(false) {} LLFastTimerView::~LLFastTimerView() @@ -102,13 +117,12 @@ LLFastTimerView::~LLFastTimerView() void LLFastTimerView::onPause() { - LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory; + mPauseHistory = !mPauseHistory; // reset scroll to bottom when unpausing - if (!LLTrace::TimeBlock::sPauseHistory) + if (!mPauseHistory) { mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording()); mScrollIndex = 0; - LLTrace::TimeBlock::sResetHistory = true; getChild<LLButton>("pause_btn")->setLabel(getString("pause")); } else @@ -239,14 +253,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, frame_recording.getNumPeriods()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) + if(mPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); @@ -322,7 +336,7 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) + if(mPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -362,10 +376,10 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { LLTrace::PeriodicRecording& frame_recording = *mRecording; - LLTrace::TimeBlock::sPauseHistory = TRUE; + mPauseHistory = true; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(frame_recording.getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -448,9 +462,9 @@ void LLFastTimerView::draw() const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); // saturation increases with depth - F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); + F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f); // lightness alternates with depth - F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; + F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f; LLColor4 child_color; child_color.setHSL(hue, saturation, lightness); @@ -509,15 +523,15 @@ void LLFastTimerView::draw() { tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); } - dx = (texth+4) + idp->getDepth()*8; + dx = (texth+4) + get_depth(idp)*8; LLColor4 color = LLColor4::white; - if (idp->getDepth() > 0) + if (get_depth(idp) > 0) { S32 line_start_y = (top + bottom) / 2; S32 line_end_y = line_start_y + ((texth + 2) * (cur_line - display_line[idp->getParent()])) - texth; gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color); - S32 line_x = x + (texth + 4) + ((idp->getDepth() - 1) * 8); + S32 line_x = x + (texth + 4) + ((get_depth(idp) - 1) * 8); gl_line_2d(line_x, line_start_y, line_x, line_end_y, color); if (idp->getCollapsed() && !idp->getChildren().empty()) { @@ -696,7 +710,7 @@ void LLFastTimerView::draw() S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); deltax.push_back(dx); - int level = idp->getDepth() - 1; + int level = get_depth(idp) - 1; while ((S32)xpos.size() > level + 1) { @@ -710,7 +724,7 @@ void LLFastTimerView::draw() sublevel_dx[level] = dx; sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) + else if (prev_id && prev_id->getDepth() < get_depth(idp)) { U64 sublevelticks = 0; @@ -821,10 +835,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex; + S32 first_frame = HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -889,7 +903,7 @@ void LLFastTimerView::draw() cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } - F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 6474c2f524..07662bb795 100644 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -95,6 +95,7 @@ private: S32 mPrintStats; LLRect mGraphRect; LLTrace::PeriodicRecording* mRecording; + bool mPauseHistory; }; #endif -- cgit v1.2.3 From 013f04cabec8e110ee659d9b3f75a4d25f114b7b Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 21 Dec 2012 00:13:21 -0800 Subject: SH-3468 WIP add memory tracking base class improvements on lifetime of lltrace core data structures tweaks to thread local pointer handling so that static constructors/destructors can safely call functions that use lltrace --- indra/llcommon/llapr.cpp | 12 +-- indra/llcommon/llapr.h | 2 +- indra/llcommon/llfasttimer.cpp | 93 ++++++------------- indra/llcommon/llfasttimer.h | 34 ++++--- indra/llcommon/lltrace.cpp | 29 ++++++ indra/llcommon/lltrace.h | 150 ++++++++++++++++++++++--------- indra/llcommon/lltracerecording.cpp | 24 ++++- indra/llcommon/lltracerecording.h | 4 + indra/llcommon/lltracethreadrecorder.cpp | 71 ++++++++++++--- indra/llcommon/lltracethreadrecorder.h | 13 ++- indra/newview/llfasttimerview.cpp | 78 ++++++++-------- 11 files changed, 326 insertions(+), 184 deletions(-) diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 1db3aa9e89..6affdad61b 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -542,12 +542,12 @@ void LLThreadLocalPointerBase::destroyAllThreadLocalStorage() { if (sInitialized) { - for (LLInstanceTracker<LLThreadLocalPointerBase>::instance_iter it = beginInstances(), end_it = endInstances(); - it != end_it; - ++it) - { - (*it).destroyStorage(); - } + //for (LLInstanceTracker<LLThreadLocalPointerBase>::instance_iter it = beginInstances(), end_it = endInstances(); + // it != end_it; + // ++it) + //{ + // (*it).destroyStorage(); + //} sInitialized = false; } } diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index f8f94263e4..2faf4aad2d 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -296,7 +296,7 @@ protected: LL_FORCE_INLINE void* get() { - llassert(sInitialized); + // llassert(sInitialized); void* ptr; apr_status_t result = apr_threadkey_private_get(&ptr, mThreadKey); diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index f4fa8f1e61..7c90b946af 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -35,6 +35,7 @@ #include "llunit.h" #include "llsd.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" #include <boost/bind.hpp> #include <queue> @@ -167,52 +168,16 @@ U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer TimeBlock::TimeBlock(const char* name, bool open, TimeBlock* parent) : TraceType(name), - mCollapsed(true), - mParent(NULL), - mNeedsSorting(false) + mCollapsed(true) { setCollapsed(!open); - - if (parent) - { - setParent(parent); - } - else - { - mParent = this; - } } -void TimeBlock::setParent(TimeBlock* parent) +TimeBlockTreeNode& TimeBlock::getTreeNode() const { - llassert_always(parent != this); - llassert_always(parent != NULL); - - if (mParent) - { - //// subtract our accumulated from previous parent - //for (S32 i = 0; i < HISTORY_NUM; i++) - //{ - // mParent->mCountHistory[i] -= mCountHistory[i]; - //} - - //// subtract average timing from previous parent - //mParent->mCountAverage -= mCountAverage; - - std::vector<TimeBlock*>& children = mParent->getChildren(); - std::vector<TimeBlock*>::iterator found_it = std::find(children.begin(), children.end(), this); - if (found_it != children.end()) - { - children.erase(found_it); - } - } - - mParent = parent; - if (parent) - { - parent->getChildren().push_back(this); - parent->mNeedsSorting = true; - } + TimeBlockTreeNode* nodep = LLTrace::get_thread_recorder()->getTimeBlockTreeNode(getIndex()); + llassert(nodep); + return *nodep; } // static @@ -232,17 +197,17 @@ void TimeBlock::processTimes() // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.mParent == &TimeBlock::getRootTimer()) + if (timer.getParent() == &TimeBlock::getRootTimer()) { - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); - if (accumulator.mLastCaller) + if (accumulator->mLastCaller) { - timer.setParent(accumulator.mLastCaller); - accumulator.mParent = accumulator.mLastCaller; + timer.setParent(accumulator->mLastCaller); + accumulator->mParent = accumulator->mLastCaller; } // no need to push up tree on first use, flag can be set spuriously - accumulator.mMoveUpTree = false; + accumulator->mMoveUpTree = false; } } @@ -256,25 +221,25 @@ void TimeBlock::processTimes() TimeBlock* timerp = *it; // sort timers by time last called, so call graph makes sense - if (timerp->mNeedsSorting) + if (timerp->getTreeNode().mNeedsSorting) { - std::sort(timerp->getChildren().begin(), timerp->getChildren().end(), SortTimerByName()); + std::sort(timerp->beginChildren(), timerp->endChildren(), SortTimerByName()); } // skip root timer if (timerp != &TimeBlock::getRootTimer()) { - TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = timerp->getPrimaryAccumulator(); - if (accumulator.mMoveUpTree) + if (accumulator->mMoveUpTree) { // since ancestors have already been visited, re-parenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - accumulator.mParent = timerp->mParent; - accumulator.mMoveUpTree = false; + accumulator->mParent = timerp->getParent(); + accumulator->mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up // as ancestors may call this timer only on certain paths, so we want to resolve @@ -286,15 +251,15 @@ void TimeBlock::processTimes() // walk up stack of active timers and accumulate current time while leaving timing structures active BlockTimer* cur_timer = cur_data->mCurTimer; - TimeBlockAccumulator& accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = cur_data->mTimerData->getPrimaryAccumulator(); // root defined by parent pointing to self while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) { U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; cur_data->mChildTime = 0; - accumulator.mSelfTimeCounter += self_time_delta; - accumulator.mTotalTimeCounter += cumulative_time_delta; + accumulator->mSelfTimeCounter += self_time_delta; + accumulator->mTotalTimeCounter += cumulative_time_delta; cur_timer->mStartTime = cur_time; @@ -316,10 +281,10 @@ void TimeBlock::processTimes() ++it) { TimeBlock& timer = *it; - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); - accumulator.mLastCaller = NULL; - accumulator.mMoveUpTree = false; + accumulator->mLastCaller = NULL; + accumulator->mMoveUpTree = false; } // traverse tree in DFS post order, or bottom up @@ -338,19 +303,19 @@ void TimeBlock::processTimes() } -std::vector<TimeBlock*>::const_iterator TimeBlock::beginChildren() +std::vector<TimeBlock*>::iterator TimeBlock::beginChildren() { - return mChildren.begin(); + return getTreeNode().mChildren.begin(); } -std::vector<TimeBlock*>::const_iterator TimeBlock::endChildren() +std::vector<TimeBlock*>::iterator TimeBlock::endChildren() { - return mChildren.end(); + return getTreeNode().mChildren.end(); } std::vector<TimeBlock*>& TimeBlock::getChildren() { - return mChildren; + return getTreeNode().mChildren; } //static diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 1e2e4b590f..4d820d0664 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -69,12 +69,14 @@ class TimeBlock public: TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); - TimeBlock* getParent() const { return mParent; } - void setParent(TimeBlock* parent); + TimeBlockTreeNode& getTreeNode() const; + TimeBlock* getParent() const { return getTreeNode().getParent(); } + void setParent(TimeBlock* parent) { getTreeNode().setParent(parent); } + typedef std::vector<TimeBlock*>::iterator child_iter; typedef std::vector<TimeBlock*>::const_iterator child_const_iter; - child_const_iter beginChildren(); - child_const_iter endChildren(); + child_iter beginChildren(); + child_iter endChildren(); std::vector<TimeBlock*>& getChildren(); void setCollapsed(bool collapsed) { mCollapsed = collapsed; } @@ -244,11 +246,7 @@ public: // call this once a frame to periodically log timers static void logStats(); - // tree structure, only updated from master trace thread - TimeBlock* mParent; // TimeBlock of caller(parent) - std::vector<TimeBlock*> mChildren; // TimeBlock of callees - bool mCollapsed, // don't show children - mNeedsSorting; // sort children whenever child added + bool mCollapsed; // don't show children // statics static std::string sLogName; @@ -264,10 +262,10 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) mStartTime = TimeBlock::getCPUClockCount64(); CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - accumulator.mActiveCount++; + TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + accumulator->mActiveCount++; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); + accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); // store top of stack mLastTimerData = *cur_timer_data; @@ -283,16 +281,16 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() #if FAST_TIMER_ON U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); - accumulator.mCalls++; - accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; - accumulator.mTotalTimeCounter += total_time; - accumulator.mActiveCount--; + accumulator->mCalls++; + accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; + accumulator->mTotalTimeCounter += total_time; + accumulator->mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator.mLastCaller = mLastTimerData.mTimerData; + accumulator->mLastCaller = mLastTimerData.mTimerData; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index e11e39a1a2..9d0c93b352 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -66,5 +66,34 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() return s_thread_recorder; } +TimeBlockTreeNode::TimeBlockTreeNode() +: mBlock(NULL), + mParent(NULL), + mNeedsSorting(false) +{} + +void TimeBlockTreeNode::setParent( TimeBlock* parent ) +{ + llassert_always(parent != mBlock); + llassert_always(parent != NULL); + + TimeBlockTreeNode* parent_tree_node = get_thread_recorder()->getTimeBlockTreeNode(parent->getIndex()); + if (!parent_tree_node) return; + + if (mParent) + { + std::vector<TimeBlock*>& children = mParent->getChildren(); + std::vector<TimeBlock*>::iterator found_it = std::find(children.begin(), children.end(), mBlock); + if (found_it != children.end()) + { + children.erase(found_it); + } + } + + mParent = parent; + mBlock->getPrimaryAccumulator()->mParent = parent; + parent_tree_node->mChildren.push_back(mBlock); + parent_tree_node->mNeedsSorting = true; } +} diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 5b5e2b7879..4bb19f6070 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -77,21 +77,21 @@ namespace LLTrace template<typename ACCUMULATOR> class AccumulatorBuffer : public LLRefCount { + typedef AccumulatorBuffer<ACCUMULATOR> self_t; static const U32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 64; private: - enum StaticAllocationMarker { STATIC_ALLOC }; + struct StaticAllocationMarker { }; AccumulatorBuffer(StaticAllocationMarker m) : mStorageSize(0), mStorage(NULL), mNextStorageSlot(0) { - resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); } public: - AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer()) + AccumulatorBuffer(const AccumulatorBuffer& other = *getDefaultBuffer()) : mStorageSize(0), mStorage(NULL), mNextStorageSlot(other.mNextStorageSlot) @@ -107,8 +107,7 @@ namespace LLTrace { if (sPrimaryStorage == mStorage) { - //TODO pick another primary? - sPrimaryStorage = NULL; + sPrimaryStorage = getDefaultBuffer()->mStorage; } delete[] mStorage; } @@ -182,6 +181,8 @@ namespace LLTrace void resize(size_t new_size) { + if (new_size <= mStorageSize) return; + ACCUMULATOR* old_storage = mStorage; mStorage = new ACCUMULATOR[new_size]; if (old_storage) @@ -193,16 +194,33 @@ namespace LLTrace } mStorageSize = new_size; delete[] old_storage; + + self_t* default_buffer = getDefaultBuffer(); + if (this != default_buffer + && new_size > default_buffer->size()) + { + //NB: this is not thread safe, but we assume that all resizing occurs during static initialization + default_buffer->resize(new_size); + } } - size_t size() + size_t size() const { return mNextStorageSlot; } - static AccumulatorBuffer<ACCUMULATOR>& getDefaultBuffer() + static self_t* getDefaultBuffer() { - static AccumulatorBuffer sBuffer(STATIC_ALLOC); + // this buffer is allowed to leak so that trace calls from global destructors have somewhere to put their data + // so as not to trigger an access violation + //TODO: make this thread local but need to either demand-init apr or remove apr dependency + static self_t* sBuffer = new AccumulatorBuffer(StaticAllocationMarker()); + static bool sInitialized = false; + if (!sInitialized) + { + sBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); + sInitialized = true; + } return sBuffer; } @@ -233,13 +251,13 @@ namespace LLTrace mName(name), mDescription(description ? description : "") { - mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot(); + mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot(); } - LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const + LL_FORCE_INLINE ACCUMULATOR* getPrimaryAccumulator() const { ACCUMULATOR* accumulator_storage = AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage(); - return accumulator_storage[mAccumulatorIndex]; + return &accumulator_storage[mAccumulatorIndex]; } size_t getIndex() const { return mAccumulatorIndex; } @@ -472,6 +490,22 @@ namespace LLTrace {} }; + class TimeBlock; + class TimeBlockTreeNode + { + public: + TimeBlockTreeNode(); + + void setParent(TimeBlock* parent); + TimeBlock* getParent() { return mParent; } + + TimeBlock* mBlock; + TimeBlock* mParent; + std::vector<TimeBlock*> mChildren; + bool mNeedsSorting; + }; + + template <typename T = F64> class Measurement : public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > @@ -488,7 +522,7 @@ namespace LLTrace void sample(UNIT_T value) { T converted_value(value); - trace_t::getPrimaryAccumulator().sample(LLUnits::rawValue(converted_value)); + trace_t::getPrimaryAccumulator()->sample(LLUnits::rawValue(converted_value)); } }; @@ -508,7 +542,7 @@ namespace LLTrace void add(UNIT_T value) { T converted_value(value); - trace_t::getPrimaryAccumulator().add(LLUnits::rawValue(converted_value)); + trace_t::getPrimaryAccumulator()->add(LLUnits::rawValue(converted_value)); } }; @@ -650,19 +684,25 @@ public: // reserve 8 bytes for allocation size (and preserving 8 byte alignment of structs) void* allocation = ::operator new(allocation_size + 8); *(size_t*)allocation = allocation_size; - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mSize += allocation_size; - accumulator.mAllocatedCount++; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mSize += allocation_size; + accumulator->mAllocatedCount++; + } return (void*)((char*)allocation + 8); } void operator delete(void* ptr) { size_t* allocation_size = (size_t*)((char*)ptr - 8); - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mSize -= *allocation_size; - accumulator.mAllocatedCount--; - accumulator.mDeallocatedCount++; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mSize -= *allocation_size; + accumulator->mAllocatedCount--; + accumulator->mDeallocatedCount++; + } ::delete((char*)ptr - 8); } @@ -670,19 +710,25 @@ public: { size_t* result = (size_t*)malloc(size + 8); *result = size; - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mSize += size; - accumulator.mAllocatedCount++; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mSize += size; + accumulator->mAllocatedCount++; + } return (void*)((char*)result + 8); } void operator delete[](void* ptr) { size_t* allocation_size = (size_t*)((char*)ptr - 8); - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mSize -= *allocation_size; - accumulator.mAllocatedCount--; - accumulator.mDeallocatedCount++; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mSize -= *allocation_size; + accumulator->mAllocatedCount--; + accumulator->mDeallocatedCount++; + } ::delete[]((char*)ptr - 8); } @@ -704,9 +750,12 @@ public: void memClaim(size_t size) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); mMemFootprint += size; - accumulator.mSize += size; + if (accumulator) + { + accumulator->mSize += size; + } } // remove memory we had claimed from our calculated footprint @@ -726,8 +775,11 @@ public: void memDisclaim(size_t size) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mSize -= size; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mSize -= size; + } mMemFootprint -= size; } @@ -739,18 +791,24 @@ private: { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - size_t footprint = MemFootprint<TRACKED>::measure(tracked); - accumulator.mSize += footprint; - tracker.mMemFootprint += footprint; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + size_t footprint = MemFootprint<TRACKED>::measure(tracked); + accumulator->mSize += footprint; + tracker.mMemFootprint += footprint; + } } static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - size_t footprint = MemFootprint<TRACKED>::measure(tracked); - accumulator.mSize -= footprint; - tracker.mMemFootprint -= footprint; + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + size_t footprint = MemFootprint<TRACKED>::measure(tracked); + accumulator->mSize -= footprint; + tracker.mMemFootprint -= footprint; + } } }; @@ -759,14 +817,20 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mChildSize += MemFootprint<TRACKED>::measure(tracked); + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mChildSize += MemFootprint<TRACKED>::measure(tracked); + } } static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = sStat.getPrimaryAccumulator(); - accumulator.mChildSize -= MemFootprint<TRACKED>::measure(tracked); + MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + if (accumulator) + { + accumulator->mChildSize -= MemFootprint<TRACKED>::measure(tracked); + } } }; static MemStat sStat; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 40079f40f1..9dbafc4e82 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -122,6 +122,18 @@ void Recording::makePrimary() mMeasurements.write()->makePrimary(); mStackTimers.write()->makePrimary(); mMemStats.write()->makePrimary(); + + ThreadRecorder* thread_recorder = get_thread_recorder().get(); + AccumulatorBuffer<TimeBlockAccumulator>& timer_accumulator_buffer = *mStackTimers.write(); + // update stacktimer parent pointers + for (S32 i = 0, end_i = mStackTimers->size(); i < end_i; i++) + { + TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); + if (tree_node) + { + timer_accumulator_buffer[i].mParent = tree_node->mParent; + } + } } bool Recording::isPrimary() const @@ -145,11 +157,21 @@ void Recording::appendRecording( const Recording& other ) mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); mCounts.write()->addSamples(*other.mCounts); mMeasurements.write()->addSamples(*other.mMeasurements); - mStackTimers.write()->addSamples(*other.mStackTimers); mMemStats.write()->addSamples(*other.mMemStats); + + mStackTimers.write()->addSamples(*other.mStackTimers); mElapsedSeconds += other.mElapsedSeconds; } +void Recording::mergeRecording( const Recording& other) +{ + mCountsFloat.write()->addSamples(*other.mCountsFloat); + mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); + mCounts.write()->addSamples(*other.mCounts); + mMeasurements.write()->addSamples(*other.mMeasurements); + mMemStats.write()->addSamples(*other.mMemStats); +} + LLUnit<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimeBlockAccumulator>& stat) const { return (F64)(*mStackTimers)[stat.getIndex()].mTotalTimeCounter / (F64)LLTrace::TimeBlock::countsPerSecond(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 8e5f1125ec..f2d7d42211 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -114,8 +114,12 @@ namespace LLTrace void makeUnique(); + // accumulate data from subsequent, non-overlapping recording void appendRecording(const Recording& other); + // gather data from recording, ignoring time relationship (for example, pulling data from slave threads) + void mergeRecording(const Recording& other); + void update(); // Timer accessors diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index c4144b4999..156b0ef26b 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -38,25 +38,37 @@ namespace LLTrace ThreadRecorder::ThreadRecorder() { + //NB: the ordering of initialization in this function is very fragile due to a large number of implicit dependencies get_thread_recorder() = this; - mFullRecording.start(); mRootTimerData = new CurTimerData(); mRootTimerData->mTimerData = &TimeBlock::getRootTimer(); - TimeBlock::sCurTimerData = mRootTimerData; - TimeBlock::getRootTimer().getPrimaryAccumulator().mActiveCount = 1; - // initialize parent pointers in time blocks + mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size(); + mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes]; + + mFullRecording.start(); + + TimeBlock& root_timer = TimeBlock::getRootTimer(); + + // initialize time block parent pointers for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); it != end_it; ++it) { - it->getPrimaryAccumulator().mParent = it->mParent; + TimeBlock& time_block = *it; + TimeBlockTreeNode& tree_node = mTimeBlockTreeNodes[it->getIndex()]; + tree_node.mBlock = &time_block; + tree_node.mParent = &root_timer; + + it->getPrimaryAccumulator()->mParent = &root_timer; } - mRootTimer = new BlockTimer(TimeBlock::getRootTimer()); + mRootTimer = new BlockTimer(root_timer); mRootTimerData->mCurTimer = mRootTimer; + + TimeBlock::getRootTimer().getPrimaryAccumulator()->mActiveCount = 1; } ThreadRecorder::~ThreadRecorder() @@ -70,8 +82,19 @@ ThreadRecorder::~ThreadRecorder() get_thread_recorder() = NULL; TimeBlock::sCurTimerData = NULL; delete mRootTimerData; + delete[] mTimeBlockTreeNodes; } +TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode(S32 index) +{ + if (0 <= index && index < mNumTimeBlockTreeNodes) + { + return &mTimeBlockTreeNodes[index]; + } + return NULL; +} + + void ThreadRecorder::activate( Recording* recording ) { mActiveRecordings.push_front(ActiveRecording(recording)); @@ -113,6 +136,13 @@ std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Rec return it; } +AccumulatorBuffer<CountAccumulator<F64> > gCountsFloat; +AccumulatorBuffer<MeasurementAccumulator<F64> > gMeasurementsFloat; +AccumulatorBuffer<CountAccumulator<S64> > gCounts; +AccumulatorBuffer<MeasurementAccumulator<S64> > gMeasurements; +AccumulatorBuffer<TimeBlockAccumulator> gStackTimers; +AccumulatorBuffer<MemStatAccumulator> gMemStats; + void ThreadRecorder::deactivate( Recording* recording ) { std::list<ActiveRecording>::iterator it = update(recording); @@ -169,23 +199,42 @@ void SlaveThreadRecorder::pushToMaster() mFullRecording.stop(); { LLMutexLock(getMasterThreadRecorder().getSlaveListMutex()); - mSharedData.copyFrom(mFullRecording); + mSharedData.appendFrom(mFullRecording); } mFullRecording.start(); } -void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source ) +void SlaveThreadRecorder::SharedData::appendFrom( const Recording& source ) { LLMutexLock lock(&mRecordingMutex); mRecording.appendRecording(source); } -void SlaveThreadRecorder::SharedData::copyTo( Recording& sink ) +void SlaveThreadRecorder::SharedData::appendTo( Recording& sink ) { LLMutexLock lock(&mRecordingMutex); sink.appendRecording(mRecording); } +void SlaveThreadRecorder::SharedData::mergeFrom( const Recording& source ) +{ + LLMutexLock lock(&mRecordingMutex); + mRecording.mergeRecording(source); +} + +void SlaveThreadRecorder::SharedData::mergeTo( Recording& sink ) +{ + LLMutexLock lock(&mRecordingMutex); + sink.mergeRecording(mRecording); +} + +void SlaveThreadRecorder::SharedData::reset() +{ + LLMutexLock lock(&mRecordingMutex); + mRecording.reset(); +} + + /////////////////////////////////////////////////////////////////////// // MasterThreadRecorder /////////////////////////////////////////////////////////////////////// @@ -203,7 +252,9 @@ void MasterThreadRecorder::pullFromSlaveThreads() it != end_it; ++it) { - (*it)->mSharedData.copyTo(target_recording); + // ignore block timing info for now + (*it)->mSharedData.mergeTo(target_recording); + (*it)->mSharedData.reset(); } } diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 102b980e44..d09527eced 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -50,6 +50,8 @@ namespace LLTrace virtual void pushToMaster() = 0; + TimeBlockTreeNode* getTimeBlockTreeNode(S32 index); + protected: struct ActiveRecording { @@ -64,7 +66,9 @@ namespace LLTrace std::list<ActiveRecording> mActiveRecordings; struct CurTimerData* mRootTimerData; - class BlockTimer* mRootTimer; + class BlockTimer* mRootTimer; + TimeBlockTreeNode* mTimeBlockTreeNodes; + size_t mNumTimeBlockTreeNodes; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder @@ -104,8 +108,11 @@ namespace LLTrace class SharedData { public: - void copyFrom(const Recording& source); - void copyTo(Recording& sink); + void appendFrom(const Recording& source); + void appendTo(Recording& sink); + void mergeFrom(const Recording& source); + void mergeTo(Recording& sink); + void reset(); private: LLMutex mRecordingMutex; Recording mRecording; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 2cf7939e5c..56e5710726 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -54,23 +54,25 @@ ////////////////////////////////////////////////////////////////////////////// +using namespace LLTrace; + static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; const S32 FTV_MAX_DEPTH = 8; const S32 HISTORY_NUM = 300; -std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter<LLTrace::TimeBlock, LLTrace::TimeBlock::child_const_iter> timer_tree_iterator_t; +typedef LLTreeDFSIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) +static timer_tree_iterator_t begin_timer_tree(TimeBlock& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), - boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1)); + boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -81,12 +83,12 @@ static timer_tree_iterator_t end_timer_tree() S32 get_depth(const TimeBlock* blockp) { S32 depth = 0; - TimeBlock* timerp = blockp->mParent; + TimeBlock* timerp = blockp->getParent(); while(timerp) { depth++; if (timerp->getParent() == timerp) break; - timerp = timerp->mParent; + timerp = timerp->getParent(); } return depth; } @@ -102,13 +104,13 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mHoverID(NULL), mHoverBarIndex(-1), mPrintStats(-1), - mRecording(&LLTrace::get_frame_recording()), + mRecording(&get_frame_recording()), mPauseHistory(false) {} LLFastTimerView::~LLFastTimerView() { - if (mRecording != &LLTrace::get_frame_recording()) + if (mRecording != &get_frame_recording()) { delete mRecording; } @@ -121,17 +123,17 @@ void LLFastTimerView::onPause() // reset scroll to bottom when unpausing if (!mPauseHistory) { - mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording()); + mRecording = new PeriodicRecording(get_frame_recording()); mScrollIndex = 0; getChild<LLButton>("pause_btn")->setLabel(getString("pause")); } else { - if (mRecording != &LLTrace::get_frame_recording()) + if (mRecording != &get_frame_recording()) { delete mRecording; } - mRecording = &LLTrace::get_frame_recording(); + mRecording = &get_frame_recording(); getChild<LLButton>("pause_btn")->setLabel(getString("run")); } @@ -170,7 +172,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLFloater::handleRightMouseDown(x, y, mask); } -LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y) +TimeBlock* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -197,7 +199,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* idp = getLegendID(y); + TimeBlock* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -248,7 +250,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; if (hasMouseCapture()) { @@ -306,7 +308,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* timer_id = getLegendID(y); + TimeBlock* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -317,9 +319,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording) +static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording) { - F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)TimeBlock::countsPerSecond(); std::string tooltip; if (history_index < 0) @@ -359,7 +361,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* idp = getLegendID(y); + TimeBlock* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp, -1, *mRecording)); @@ -374,7 +376,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; mPauseHistory = true; mScrollIndex = llclamp( mScrollIndex + clicks, @@ -383,15 +385,15 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true); +static TimeBlock FTM_RENDER_TIMER("Timers", true); -static std::map<LLTrace::TimeBlock*, LLColor4> sTimerColors; +static std::map<TimeBlock*, LLColor4> sTimerColors; void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; std::string tdesc; @@ -457,7 +459,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -480,12 +482,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map<LLTrace::TimeBlock*, S32> display_line; + std::map<TimeBlock*, S32> display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -541,7 +543,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); + TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -694,14 +696,14 @@ void LLFastTimerView::draw() std::vector<S32> deltax; xpos.push_back(x_start); - LLTrace::TimeBlock* prev_id = NULL; + TimeBlock* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); F32 frac = tidx == -1 ? (frame_recording.getPeriodMean(*idp) / total_time) : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); @@ -724,11 +726,11 @@ void LLFastTimerView::draw() sublevel_dx[level] = dx; sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (prev_id && prev_id->getDepth() < get_depth(idp)) + else if (prev_id && get_depth(prev_id) < get_depth(idp)) { U64 sublevelticks = 0; - for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + for (TimeBlock::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -770,7 +772,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); + TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -866,7 +868,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -968,7 +970,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); if (!first) { @@ -990,7 +992,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); if (!first) { @@ -1527,13 +1529,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLTrace::TimeBlock::sLog) + if(TimeBlock::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLTrace::TimeBlock::sMetricLog) + if(TimeBlock::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1544,7 +1546,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLTrace::TimeBlock& LLFastTimerView::getFrameTimer() +TimeBlock& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } -- cgit v1.2.3 From 3fd640a6e3dea7a3551c239323d782fb082e1dbd Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Sun, 23 Dec 2012 12:27:25 -0800 Subject: SH-3468 WIP add memory tracking base class fixed crash on exit by making LLInstanceTracker iterators use atomic iterator nesting count for thread safety --- indra/llcommon/llapr.cpp | 1 + indra/llcommon/llapr.h | 137 +---------------- indra/llcommon/llinstancetracker.cpp | 18 +++ indra/llcommon/llinstancetracker.h | 27 ++-- indra/llcommon/llstl.h | 1 + indra/llcommon/llthreadlocalpointer.h | 164 +++++++++++++++++++++ indra/llcommon/lltrace.h | 1 + indra/llcommon/llworkerthread.h | 5 +- .../quicktime/media_plugin_quicktime.cpp | 21 +-- 9 files changed, 221 insertions(+), 154 deletions(-) create mode 100644 indra/llcommon/llthreadlocalpointer.h diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 6affdad61b..092c276936 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -29,6 +29,7 @@ #include "linden_common.h" #include "llapr.h" #include "apr_dso.h" +#include "llthreadlocalpointer.h" apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool. diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 2faf4aad2d..b3c9bfd58c 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -42,7 +42,6 @@ #include "apr_atomic.h" #include "llstring.h" -#include "llinstancetracker.h" extern LL_COMMON_API apr_thread_mutex_t* gLogMutexp; extern apr_thread_mutex_t* gCallStacksLogMutexp; @@ -170,14 +169,17 @@ public: LLAtomic32<Type>(Type x) {apr_atomic_set32(&mData, apr_uint32_t(x)); }; ~LLAtomic32<Type>() {}; - operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); } + operator const Type() { return get(); } Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); } void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); } void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); } Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++ - Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) + Type operator ++() { apr_atomic_inc32(&mData); return get(); } // ++Type + Type operator --(int) { const Type result(get()); apr_atomic_dec32(&mData); return result; } // Type-- + Type operator --() { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) private: + const Type get() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); } apr_uint32_t mData; }; @@ -262,134 +264,5 @@ public: //******************************************************************************************************************************* }; -class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase> -{ -public: - LLThreadLocalPointerBase() - : mThreadKey(NULL) - { - if (sInitialized) - { - initStorage(); - } - } - - LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) - : mThreadKey(NULL) - { - if (sInitialized) - { - initStorage(); - } - } - - ~LLThreadLocalPointerBase() - { - destroyStorage(); - } - - static void initAllThreadLocalStorage(); - static void destroyAllThreadLocalStorage(); - -protected: - void set(void* value); - - LL_FORCE_INLINE void* get() - { - // llassert(sInitialized); - void* ptr; - apr_status_t result = - apr_threadkey_private_get(&ptr, mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to get thread local data" << llendl; - } - return ptr; - } - - LL_FORCE_INLINE const void* get() const - { - void* ptr; - apr_status_t result = - apr_threadkey_private_get(&ptr, mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to get thread local data" << llendl; - } - return ptr; - } - - void initStorage(); - void destroyStorage(); - -protected: - apr_threadkey_t* mThreadKey; - static bool sInitialized; -}; - -template <typename T> -class LLThreadLocalPointer : public LLThreadLocalPointerBase -{ -public: - - LLThreadLocalPointer() - {} - - explicit LLThreadLocalPointer(T* value) - { - set(value); - } - - - LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) - : LLThreadLocalPointerBase(other) - { - set(other.get()); - } - - LL_FORCE_INLINE T* get() - { - return (T*)LLThreadLocalPointerBase::get(); - } - - const T* get() const - { - return (const T*)LLThreadLocalPointerBase::get(); - } - - T* operator -> () - { - return (T*)get(); - } - - const T* operator -> () const - { - return (T*)get(); - } - - T& operator*() - { - return *(T*)get(); - } - - const T& operator*() const - { - return *(T*)get(); - } - - LLThreadLocalPointer<T>& operator = (T* value) - { - set((void*)value); - return *this; - } - - bool operator ==(T* other) - { - if (!sInitialized) return false; - return get() == other; - } -}; #endif // LL_LLAPR_H diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 5dc3ea5d7b..071a637cda 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -27,6 +27,8 @@ #include "linden_common.h" // associated header #include "llinstancetracker.h" +#include "llapr.h" + // STL headers // std headers // external library headers @@ -47,3 +49,19 @@ void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) InstancesMap::mapped_type())) .first->second; } + +void LLInstanceTrackerBase::StaticBase::incrementDepth() +{ + apr_atomic_inc32(&sIterationNestDepth); +} + +void LLInstanceTrackerBase::StaticBase::decrementDepth() +{ + apr_atomic_dec32(&sIterationNestDepth); +} + +U32 LLInstanceTrackerBase::StaticBase::getDepth() +{ + apr_uint32_t data = apr_atomic_read32(&sIterationNestDepth); + return data; +} diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 3a1187a4c1..9dd6d4a7ed 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -70,7 +70,12 @@ protected: StaticBase(): sIterationNestDepth(0) {} - S32 sIterationNestDepth; + + void incrementDepth(); + void decrementDepth(); + U32 getDepth(); + private: + U32 sIterationNestDepth; }; }; @@ -99,12 +104,12 @@ public: instance_iter(const typename InstanceMap::iterator& it) : mIterator(it) { - ++getStatic().sIterationNestDepth; + getStatic().incrementDepth(); } ~instance_iter() { - --getStatic().sIterationNestDepth; + getStatic().decrementDepth(); } @@ -133,18 +138,18 @@ public: key_iter(typename InstanceMap::iterator it) : mIterator(it) { - ++getStatic().sIterationNestDepth; + getStatic().incrementDepth(); } key_iter(const key_iter& other) : mIterator(other.mIterator) { - ++getStatic().sIterationNestDepth; + getStatic().incrementDepth(); } ~key_iter() { - --getStatic().sIterationNestDepth; + getStatic().decrementDepth(); } @@ -203,7 +208,7 @@ protected: virtual ~LLInstanceTracker() { // it's unsafe to delete instances of this type while all instances are being iterated over. - llassert_always(getStatic().sIterationNestDepth == 0); + llassert_always(getStatic().getDepth() == 0); remove_(); } virtual void setKey(KEY key) { remove_(); add_(key); } @@ -262,18 +267,18 @@ public: instance_iter(const typename InstanceSet::iterator& it) : mIterator(it) { - ++getStatic().sIterationNestDepth; + getStatic().incrementDepth(); } instance_iter(const instance_iter& other) : mIterator(other.mIterator) { - ++getStatic().sIterationNestDepth; + getStatic().incrementDepth(); } ~instance_iter() { - --getStatic().sIterationNestDepth; + getStatic().decrementDepth(); } private: @@ -306,7 +311,7 @@ protected: virtual ~LLInstanceTracker() { // it's unsafe to delete instances of this type while all instances are being iterated over. - llassert_always(getStatic().sIterationNestDepth == 0); + llassert_always(getStatic().getDepth() == 0); getSet_().erase(static_cast<T*>(this)); } diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index d3941e1bc9..424138dad1 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -31,6 +31,7 @@ #include <algorithm> #include <map> #include <vector> +#include <list> #include <set> #include <deque> #include <typeinfo> diff --git a/indra/llcommon/llthreadlocalpointer.h b/indra/llcommon/llthreadlocalpointer.h new file mode 100644 index 0000000000..d40a8b5a27 --- /dev/null +++ b/indra/llcommon/llthreadlocalpointer.h @@ -0,0 +1,164 @@ +/** + * @file llthreadlocalpointer.h + * @author Richard + * @brief Pointer class that manages a distinct value per thread + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTHREADLOCALPOINTER_H +#define LL_LLTHREADLOCALPOINTER_H + +#include "llinstancetracker.h" +#include "llapr.h" + +class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase> +{ +public: + LLThreadLocalPointerBase() + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + ~LLThreadLocalPointerBase() + { + destroyStorage(); + } + + static void initAllThreadLocalStorage(); + static void destroyAllThreadLocalStorage(); + +protected: + void set(void* value); + + LL_FORCE_INLINE void* get() + { + // llassert(sInitialized); + void* ptr; + apr_status_t result = + apr_threadkey_private_get(&ptr, mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to get thread local data" << llendl; + } + return ptr; + } + + LL_FORCE_INLINE const void* get() const + { + void* ptr; + apr_status_t result = + apr_threadkey_private_get(&ptr, mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to get thread local data" << llendl; + } + return ptr; + } + + void initStorage(); + void destroyStorage(); + +protected: + apr_threadkey_t* mThreadKey; + static bool sInitialized; +}; + +template <typename T> +class LLThreadLocalPointer : public LLThreadLocalPointerBase +{ +public: + + LLThreadLocalPointer() + {} + + explicit LLThreadLocalPointer(T* value) + { + set(value); + } + + + LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) + : LLThreadLocalPointerBase(other) + { + set(other.get()); + } + + LL_FORCE_INLINE T* get() + { + return (T*)LLThreadLocalPointerBase::get(); + } + + const T* get() const + { + return (const T*)LLThreadLocalPointerBase::get(); + } + + T* operator -> () + { + return (T*)get(); + } + + const T* operator -> () const + { + return (T*)get(); + } + + T& operator*() + { + return *(T*)get(); + } + + const T& operator*() const + { + return *(T*)get(); + } + + LLThreadLocalPointer<T>& operator = (T* value) + { + set((void*)value); + return *this; + } + + bool operator ==(T* other) + { + if (!sInitialized) return false; + return get() == other; + } +}; + +#endif // LL_LLTHREADLOCALPOINTER_H diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 4bb19f6070..05191cafaa 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -34,6 +34,7 @@ #include "llrefcount.h" #include "llunit.h" #include "llapr.h" +#include "llthreadlocalpointer.h" #include <list> diff --git a/indra/llcommon/llworkerthread.h b/indra/llcommon/llworkerthread.h index be46394d6e..09776816a8 100644 --- a/indra/llcommon/llworkerthread.h +++ b/indra/llcommon/llworkerthread.h @@ -26,10 +26,11 @@ #ifndef LL_LLWORKERTHREAD_H #define LL_LLWORKERTHREAD_H -#include <queue> -#include <string> +#include <list> #include <map> +#include <queue> #include <set> +#include <string> #include "llqueuedthread.h" #include "llapr.h" diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index 24328202cb..eb18a3776f 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -28,18 +28,10 @@ #include "linden_common.h" -#include "llgl.h" - -#include "llplugininstance.h" -#include "llpluginmessage.h" -#include "llpluginmessageclasses.h" -#include "media_plugin_base.h" - -#if LL_QUICKTIME_ENABLED - #if defined(LL_DARWIN) #include <QuickTime/QuickTime.h> #elif defined(LL_WINDOWS) + #include "llwin32headers.h" #include "MacTypes.h" #include "QTML.h" #include "Movies.h" @@ -48,6 +40,17 @@ #include "QTLoadLibraryUtils.h" #endif +#include "llgl.h" + +#include "llplugininstance.h" +#include "llpluginmessage.h" +#include "llpluginmessageclasses.h" +#include "media_plugin_base.h" + +#if LL_QUICKTIME_ENABLED + + + // TODO: Make sure that the only symbol exported from this library is LLPluginInitEntryPoint //////////////////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From cda2cdda511eb2f7a58e284db2c852fd4a3808ae Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Thu, 3 Jan 2013 00:30:54 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system made fast timer stack thread local added LLThreadLocalSingleton made LLThreadLocalPointer obey pointer rules for const added LLThreadLocalSingletonPointer for fast thread local pointers --- indra/llaudio/llaudiodecodemgr.cpp | 1 + indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/llapr.cpp | 2 +- indra/llcommon/llfasttimer.cpp | 41 +++-- indra/llcommon/llfasttimer.h | 45 ++++-- indra/llcommon/llsingleton.h | 52 ++++--- indra/llcommon/llthreadlocalpointer.h | 164 -------------------- indra/llcommon/llthreadlocalstorage.h | 254 +++++++++++++++++++++++++++++++ indra/llcommon/lltrace.cpp | 13 +- indra/llcommon/lltrace.h | 32 ++-- indra/llcommon/lltracethreadrecorder.cpp | 33 ++-- indra/llcommon/lltracethreadrecorder.h | 9 +- indra/llmessage/llbuffer.cpp | 1 + indra/llmessage/lldispatcher.cpp | 1 + 14 files changed, 383 insertions(+), 266 deletions(-) delete mode 100644 indra/llcommon/llthreadlocalpointer.h create mode 100644 indra/llcommon/llthreadlocalstorage.h diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index 6c97a64ed7..bcff03ceaa 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -40,6 +40,7 @@ #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" +#include <iterator> extern LLAudioEngine *gAudiop; diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 5b76703af7..6f5fe1832a 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -242,6 +242,7 @@ set(llcommon_HEADER_FILES llstringtable.h llsys.h llthread.h + llthreadlocalstorage.h llthreadsafequeue.h lltimer.h lltrace.h diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 092c276936..d911f258b6 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -29,7 +29,7 @@ #include "linden_common.h" #include "llapr.h" #include "apr_dso.h" -#include "llthreadlocalpointer.h" +#include "llthreadlocalstorage.h" apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool. diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 7c90b946af..ad8cf7296e 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -70,8 +70,6 @@ U64 TimeBlock::sClockResolution = 1000000000; // Nanosecond resolution U64 TimeBlock::sClockResolution = 1000000; // Microsecond resolution #endif -LLThreadLocalPointer<CurTimerData> TimeBlock::sCurTimerData; - static LLMutex* sLogLock = NULL; static std::queue<LLSD> sLogQueue; @@ -118,7 +116,7 @@ struct SortTimerByName } }; -TimeBlock& TimeBlock::getRootTimer() +TimeBlock& TimeBlock::getRootTimeBlock() { static TimeBlock root_timer("root", true, NULL); return root_timer; @@ -185,7 +183,7 @@ void TimeBlock::processTimes() { get_clock_count(); // good place to calculate clock frequency U64 cur_time = getCPUClockCount64(); - CurTimerData* cur_data = sCurTimerData.get(); + BlockTimerStackRecord* stack_record = ThreadTimerStack::getInstance(); // set up initial tree for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); @@ -193,11 +191,11 @@ void TimeBlock::processTimes() ++it) { TimeBlock& timer = *it; - if (&timer == &TimeBlock::getRootTimer()) continue; + if (&timer == &TimeBlock::getRootTimeBlock()) continue; // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.getParent() == &TimeBlock::getRootTimer()) + if (timer.getParent() == &TimeBlock::getRootTimeBlock()) { TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); @@ -214,20 +212,21 @@ void TimeBlock::processTimes() // bump timers up tree if they have been flagged as being in the wrong place // do this in a bottom up order to promote descendants first before promoting ancestors // this preserves partial order derived from current frame's observations - for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimer()); + for(timer_tree_bottom_up_iterator_t it = begin_timer_tree_bottom_up(TimeBlock::getRootTimeBlock()); it != end_timer_tree_bottom_up(); ++it) { TimeBlock* timerp = *it; // sort timers by time last called, so call graph makes sense - if (timerp->getTreeNode().mNeedsSorting) + TimeBlockTreeNode& tree_node = timerp->getTreeNode(); + if (tree_node.mNeedsSorting) { - std::sort(timerp->beginChildren(), timerp->endChildren(), SortTimerByName()); + std::sort(tree_node.mChildren.begin(), tree_node.mChildren.end(), SortTimerByName()); } // skip root timer - if (timerp != &TimeBlock::getRootTimer()) + if (timerp != &TimeBlock::getRootTimeBlock()) { TimeBlockAccumulator* accumulator = timerp->getPrimaryAccumulator(); @@ -250,27 +249,27 @@ void TimeBlock::processTimes() } // walk up stack of active timers and accumulate current time while leaving timing structures active - BlockTimer* cur_timer = cur_data->mCurTimer; - TimeBlockAccumulator* accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + BlockTimer* cur_timer = stack_record->mActiveTimer; + TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); // root defined by parent pointing to self - while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer) + while(cur_timer && cur_timer->mLastTimerData.mActiveTimer != cur_timer) { U64 cumulative_time_delta = cur_time - cur_timer->mStartTime; - U64 self_time_delta = cumulative_time_delta - cur_data->mChildTime; - cur_data->mChildTime = 0; + U64 self_time_delta = cumulative_time_delta - stack_record->mChildTime; + stack_record->mChildTime = 0; accumulator->mSelfTimeCounter += self_time_delta; accumulator->mTotalTimeCounter += cumulative_time_delta; cur_timer->mStartTime = cur_time; - cur_data = &cur_timer->mLastTimerData; - cur_data->mChildTime += cumulative_time_delta; - if (cur_data->mTimerData) + stack_record = &cur_timer->mLastTimerData; + stack_record->mChildTime += cumulative_time_delta; + if (stack_record->mTimeBlock) { - accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); } - cur_timer = cur_timer->mLastTimerData.mCurTimer; + cur_timer = cur_timer->mLastTimerData.mActiveTimer; } @@ -374,7 +373,7 @@ void TimeBlock::dumpCurTimes() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); // walk over timers in depth order and output timings - for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimer()); + for(timer_tree_dfs_iterator_t it = begin_timer_tree(TimeBlock::getRootTimeBlock()); it != end_timer_tree(); ++it) { diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4d820d0664..995eebd16a 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,13 +38,29 @@ class LLMutex; namespace LLTrace { -struct CurTimerData +struct BlockTimerStackRecord { - class BlockTimer* mCurTimer; - class TimeBlock* mTimerData; + class BlockTimer* mActiveTimer; + class TimeBlock* mTimeBlock; U64 mChildTime; }; +class ThreadTimerStack +: public BlockTimerStackRecord, + public LLThreadLocalSingleton<ThreadTimerStack> +{ + friend LLThreadLocalSingleton<ThreadTimerStack>; + ThreadTimerStack() + {} + +public: + ThreadTimerStack& operator=(const BlockTimerStackRecord& other) + { + BlockTimerStackRecord::operator=(other); + return *this; + } +}; + class BlockTimer { public: @@ -58,7 +74,7 @@ public: private: U64 mStartTime; - CurTimerData mLastTimerData; + BlockTimerStackRecord mLastTimerData; }; // stores a "named" timer instance to be reused via multiple BlockTimer stack instances @@ -67,7 +83,7 @@ class TimeBlock public LLInstanceTracker<TimeBlock> { public: - TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimer()); + TimeBlock(const char* name, bool open = false, TimeBlock* parent = &getRootTimeBlock()); TimeBlockTreeNode& getTreeNode() const; TimeBlock* getParent() const { return getTreeNode().getParent(); } @@ -92,7 +108,7 @@ public: return static_cast<TraceType<TimeBlockAccumulator::SelfTimeAspect>&>(*(TraceType<TimeBlockAccumulator>*)this); } - static TimeBlock& getRootTimer(); + static TimeBlock& getRootTimeBlock(); static void pushLog(LLSD sd); static void setLogLock(LLMutex* mutex); static void writeLog(std::ostream& os); @@ -252,7 +268,6 @@ public: static std::string sLogName; static bool sMetricLog, sLog; - static LLThreadLocalPointer<CurTimerData> sCurTimerData; static U64 sClockResolution; }; @@ -261,8 +276,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON mStartTime = TimeBlock::getCPUClockCount64(); - CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mActiveCount++; // keep current parent as long as it is active when we are accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); @@ -270,8 +285,8 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) // store top of stack mLastTimerData = *cur_timer_data; // push new information - cur_timer_data->mCurTimer = this; - cur_timer_data->mTimerData = &timer; + cur_timer_data->mActiveTimer = this; + cur_timer_data->mTimeBlock = &timer; cur_timer_data->mChildTime = 0; #endif } @@ -280,8 +295,8 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() { #if FAST_TIMER_ON U64 total_time = TimeBlock::getCPUClockCount64() - mStartTime; - CurTimerData* cur_timer_data = TimeBlock::sCurTimerData.get(); - TimeBlockAccumulator* accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator(); + BlockTimerStackRecord* cur_timer_data = ThreadTimerStack::getIfExists(); + TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); accumulator->mCalls++; accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; @@ -290,12 +305,12 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator->mLastCaller = mLastTimerData.mTimerData; + accumulator->mLastCaller = mLastTimerData.mTimeBlock; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - *TimeBlock::sCurTimerData = mLastTimerData; + *ThreadTimerStack::getIfExists() = mLastTimerData; #endif } diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 49d99f2cd0..f6b0a7194b 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -90,7 +90,7 @@ template <typename DERIVED_TYPE> class LLSingleton : private boost::noncopyable { -private: +protected: typedef enum e_init_state { UNINITIALIZED, @@ -124,7 +124,7 @@ private: public: virtual ~LLSingleton() { - SingletonInstanceData& data = getData(); + SingletonInstanceData& data = getSingletonData(); data.mSingletonInstance = NULL; data.mInitState = DELETED; } @@ -151,29 +151,15 @@ public: */ static void deleteSingleton() { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; - getData().mInitState = DELETED; - } - - static SingletonInstanceData& getData() - { - // this is static to cache the lookup results - static void * & registry = LLSingletonRegistry::get<DERIVED_TYPE>(); - - // *TODO - look into making this threadsafe - if(NULL == registry) - { - static SingletonInstanceData data; - registry = &data; - } - - return *static_cast<SingletonInstanceData *>(registry); + SingletonInstanceData& data = getSingletonData(); + delete data.mSingletonInstance; + data.mSingletonInstance = NULL; + data.mInitState = DELETED; } static DERIVED_TYPE* getInstance() { - SingletonInstanceData& data = getData(); + SingletonInstanceData& data = getSingletonData(); if (data.mInitState == CONSTRUCTING) { @@ -197,6 +183,12 @@ public: return data.mSingletonInstance; } + static DERIVED_TYPE* getIfExists() + { + SingletonInstanceData& data = getSingletonData(); + return data.mSingletonInstance; + } + // Reference version of getInstance() // Preferred over getInstance() as it disallows checking for NULL static DERIVED_TYPE& instance() @@ -208,17 +200,31 @@ public: // Use this to avoid accessing singletons before the can safely be constructed static bool instanceExists() { - return getData().mInitState == INITIALIZED; + return getSingletonData().mInitState == INITIALIZED; } // Has this singleton already been deleted? // Use this to avoid accessing singletons from a static object's destructor static bool destroyed() { - return getData().mInitState == DELETED; + return getSingletonData().mInitState == DELETED; } private: + static SingletonInstanceData& getSingletonData() + { + // this is static to cache the lookup results + static void * & registry = LLSingletonRegistry::get<DERIVED_TYPE>(); + + // *TODO - look into making this threadsafe + if(NULL == registry) + { + static SingletonInstanceData data; + registry = &data; + } + + return *static_cast<SingletonInstanceData *>(registry); + } virtual void initSingleton() {} }; diff --git a/indra/llcommon/llthreadlocalpointer.h b/indra/llcommon/llthreadlocalpointer.h deleted file mode 100644 index d40a8b5a27..0000000000 --- a/indra/llcommon/llthreadlocalpointer.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @file llthreadlocalpointer.h - * @author Richard - * @brief Pointer class that manages a distinct value per thread - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLTHREADLOCALPOINTER_H -#define LL_LLTHREADLOCALPOINTER_H - -#include "llinstancetracker.h" -#include "llapr.h" - -class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase> -{ -public: - LLThreadLocalPointerBase() - : mThreadKey(NULL) - { - if (sInitialized) - { - initStorage(); - } - } - - LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) - : mThreadKey(NULL) - { - if (sInitialized) - { - initStorage(); - } - } - - ~LLThreadLocalPointerBase() - { - destroyStorage(); - } - - static void initAllThreadLocalStorage(); - static void destroyAllThreadLocalStorage(); - -protected: - void set(void* value); - - LL_FORCE_INLINE void* get() - { - // llassert(sInitialized); - void* ptr; - apr_status_t result = - apr_threadkey_private_get(&ptr, mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to get thread local data" << llendl; - } - return ptr; - } - - LL_FORCE_INLINE const void* get() const - { - void* ptr; - apr_status_t result = - apr_threadkey_private_get(&ptr, mThreadKey); - if (result != APR_SUCCESS) - { - ll_apr_warn_status(result); - llerrs << "Failed to get thread local data" << llendl; - } - return ptr; - } - - void initStorage(); - void destroyStorage(); - -protected: - apr_threadkey_t* mThreadKey; - static bool sInitialized; -}; - -template <typename T> -class LLThreadLocalPointer : public LLThreadLocalPointerBase -{ -public: - - LLThreadLocalPointer() - {} - - explicit LLThreadLocalPointer(T* value) - { - set(value); - } - - - LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) - : LLThreadLocalPointerBase(other) - { - set(other.get()); - } - - LL_FORCE_INLINE T* get() - { - return (T*)LLThreadLocalPointerBase::get(); - } - - const T* get() const - { - return (const T*)LLThreadLocalPointerBase::get(); - } - - T* operator -> () - { - return (T*)get(); - } - - const T* operator -> () const - { - return (T*)get(); - } - - T& operator*() - { - return *(T*)get(); - } - - const T& operator*() const - { - return *(T*)get(); - } - - LLThreadLocalPointer<T>& operator = (T* value) - { - set((void*)value); - return *this; - } - - bool operator ==(T* other) - { - if (!sInitialized) return false; - return get() == other; - } -}; - -#endif // LL_LLTHREADLOCALPOINTER_H diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h new file mode 100644 index 0000000000..fdf0c18085 --- /dev/null +++ b/indra/llcommon/llthreadlocalstorage.h @@ -0,0 +1,254 @@ +/** + * @file llthreadlocalstorage.h + * @author Richard + * @brief Class wrappers for thread local storage + * + * $LicenseInfo:firstyear=2004&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLTHREADLOCALSTORAGE_H +#define LL_LLTHREADLOCALSTORAGE_H + +#include "llinstancetracker.h" +#include "llapr.h" + +class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase> +{ +public: + LLThreadLocalPointerBase() + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other) + : mThreadKey(NULL) + { + if (sInitialized) + { + initStorage(); + } + } + + ~LLThreadLocalPointerBase() + { + destroyStorage(); + } + + static void initAllThreadLocalStorage(); + static void destroyAllThreadLocalStorage(); + +protected: + void set(void* value); + + LL_FORCE_INLINE void* get() const + { + // llassert(sInitialized); + void* ptr; + apr_status_t result = + apr_threadkey_private_get(&ptr, mThreadKey); + if (result != APR_SUCCESS) + { + ll_apr_warn_status(result); + llerrs << "Failed to get thread local data" << llendl; + } + return ptr; + } + + void initStorage(); + void destroyStorage(); + +protected: + apr_threadkey_t* mThreadKey; + static bool sInitialized; +}; + +template <typename T> +class LLThreadLocalPointer : public LLThreadLocalPointerBase +{ +public: + + LLThreadLocalPointer() + {} + + explicit LLThreadLocalPointer(T* value) + { + set(value); + } + + + LLThreadLocalPointer(const LLThreadLocalPointer<T>& other) + : LLThreadLocalPointerBase(other) + { + set(other.get()); + } + + LL_FORCE_INLINE T* get() const + { + return (T*)LLThreadLocalPointerBase::get(); + } + + T* operator -> () const + { + return (T*)get(); + } + + T& operator*() const + { + return *(T*)get(); + } + + LLThreadLocalPointer<T>& operator = (T* value) + { + set((void*)value); + return *this; + } + + bool operator ==(const T* other) const + { + if (!sInitialized) return false; + return get() == other; + } +}; + +template<typename DERIVED_TYPE> +class LLThreadLocalSingleton +{ + typedef enum e_init_state + { + UNINITIALIZED = 0, + CONSTRUCTING, + INITIALIZING, + INITIALIZED, + DELETED + } EInitState; + +public: + LLThreadLocalSingleton() + {} + + virtual ~LLThreadLocalSingleton() + { + sInstance = NULL; + sInitState = DELETED; + } + + static void deleteSingleton() + { + delete sInstance; + sInstance = NULL; + sInitState = DELETED; + } + + static DERIVED_TYPE* getInstance() + { + if (sInitState == CONSTRUCTING) + { + llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; + } + + if (sInitState == DELETED) + { + llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; + } + + if (!sInstance) + { + sInitState = CONSTRUCTING; + sInstance = new DERIVED_TYPE(); + sInitState = INITIALIZING; + sInstance->initSingleton(); + sInitState = INITIALIZED; + } + + return sInstance; + } + + static DERIVED_TYPE* getIfExists() + { + return sInstance; + } + + // Reference version of getInstance() + // Preferred over getInstance() as it disallows checking for NULL + static DERIVED_TYPE& instance() + { + return *getInstance(); + } + + // Has this singleton been created uet? + // Use this to avoid accessing singletons before the can safely be constructed + static bool instanceExists() + { + return sInitState == INITIALIZED; + } + + // Has this singleton already been deleted? + // Use this to avoid accessing singletons from a static object's destructor + static bool destroyed() + { + return sInitState == DELETED; + } +private: + LLThreadLocalSingleton(const LLThreadLocalSingleton& other); + virtual void initSingleton() {} + + static __declspec(thread) DERIVED_TYPE* sInstance; + static __declspec(thread) EInitState sInitState; +}; + +template<typename DERIVED_TYPE> +__declspec(thread) DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL; + +template<typename DERIVED_TYPE> +__declspec(thread) typename LLThreadLocalSingleton<DERIVED_TYPE>::EInitState LLThreadLocalSingleton<DERIVED_TYPE>::sInitState = LLThreadLocalSingleton<DERIVED_TYPE>::UNINITIALIZED; + +template<typename DERIVED_TYPE> +class LLThreadLocalSingletonPointer +{ +public: + void operator =(DERIVED_TYPE* value) + { + sInstance = value; + } + + LL_FORCE_INLINE static DERIVED_TYPE* getInstance() + { + return sInstance; + } + + LL_FORCE_INLINE static void setInstance(DERIVED_TYPE* instance) + { + sInstance = instance; + } + +private: + static __declspec(thread) DERIVED_TYPE* sInstance; +}; + +template<typename DERIVED_TYPE> +__declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; + +#endif // LL_LLTHREADLOCALSTORAGE_H diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9d0c93b352..9cadd70dd8 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -60,12 +60,23 @@ MasterThreadRecorder& getMasterThreadRecorder() return *gMasterThreadRecorder; } -LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() +LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder_ptr() { static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder; return s_thread_recorder; } +const LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() +{ + return get_thread_recorder_ptr(); +} + +void set_thread_recorder(ThreadRecorder* recorder) +{ + get_thread_recorder_ptr() = recorder; +} + + TimeBlockTreeNode::TimeBlockTreeNode() : mBlock(NULL), mParent(NULL), diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 05191cafaa..285d4389af 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -34,7 +34,7 @@ #include "llrefcount.h" #include "llunit.h" #include "llapr.h" -#include "llthreadlocalpointer.h" +#include "llthreadlocalstorage.h" #include <list> @@ -70,7 +70,8 @@ namespace LLTrace void cleanup(); bool isInitialized(); - LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); + const LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); + void set_thread_recorder(class ThreadRecorder*); class MasterThreadRecorder& getMasterThreadRecorder(); @@ -106,9 +107,9 @@ namespace LLTrace ~AccumulatorBuffer() { - if (sPrimaryStorage == mStorage) + if (LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance() == mStorage) { - sPrimaryStorage = getDefaultBuffer()->mStorage; + LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(getDefaultBuffer()->mStorage); } delete[] mStorage; } @@ -151,17 +152,17 @@ namespace LLTrace void makePrimary() { - sPrimaryStorage = mStorage; + LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(mStorage); } bool isPrimary() const { - return sPrimaryStorage == mStorage; + return LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance() == mStorage; } LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage() { - return sPrimaryStorage.get(); + return LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance(); } // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned @@ -214,7 +215,6 @@ namespace LLTrace { // this buffer is allowed to leak so that trace calls from global destructors have somewhere to put their data // so as not to trigger an access violation - //TODO: make this thread local but need to either demand-init apr or remove apr dependency static self_t* sBuffer = new AccumulatorBuffer(StaticAllocationMarker()); static bool sInitialized = false; if (!sInitialized) @@ -229,9 +229,7 @@ namespace LLTrace ACCUMULATOR* mStorage; size_t mStorageSize; size_t mNextStorageSlot; - static LLThreadLocalPointer<ACCUMULATOR> sPrimaryStorage; }; - template<typename ACCUMULATOR> LLThreadLocalPointer<ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>::sPrimaryStorage; //TODO: replace with decltype when C++11 is enabled template<typename T> @@ -250,10 +248,9 @@ namespace LLTrace TraceType(const char* name, const char* description = NULL) : LLInstanceTracker<TraceType<ACCUMULATOR>, std::string>(name), mName(name), - mDescription(description ? description : "") - { - mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot(); - } + mDescription(description ? description : ""), + mAccumulatorIndex(AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot()) + {} LL_FORCE_INLINE ACCUMULATOR* getPrimaryAccumulator() const { @@ -263,13 +260,12 @@ namespace LLTrace size_t getIndex() const { return mAccumulatorIndex; } - std::string& getName() { return mName; } const std::string& getName() const { return mName; } protected: - std::string mName; - std::string mDescription; - size_t mAccumulatorIndex; + const std::string mName; + const std::string mDescription; + const size_t mAccumulatorIndex; }; template<typename T> diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 156b0ef26b..9fb789c62d 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -39,18 +39,17 @@ namespace LLTrace ThreadRecorder::ThreadRecorder() { //NB: the ordering of initialization in this function is very fragile due to a large number of implicit dependencies - get_thread_recorder() = this; + set_thread_recorder(this); + TimeBlock& root_time_block = TimeBlock::getRootTimeBlock(); - mRootTimerData = new CurTimerData(); - mRootTimerData->mTimerData = &TimeBlock::getRootTimer(); - TimeBlock::sCurTimerData = mRootTimerData; + ThreadTimerStack* timer_stack = ThreadTimerStack::getInstance(); + timer_stack->mTimeBlock = &root_time_block; + timer_stack->mActiveTimer = NULL; mNumTimeBlockTreeNodes = AccumulatorBuffer<TimeBlockAccumulator>::getDefaultBuffer()->size(); mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes]; - mFullRecording.start(); - - TimeBlock& root_timer = TimeBlock::getRootTimer(); + mThreadRecording.start(); // initialize time block parent pointers for (LLInstanceTracker<TimeBlock>::instance_iter it = LLInstanceTracker<TimeBlock>::beginInstances(), end_it = LLInstanceTracker<TimeBlock>::endInstances(); @@ -60,15 +59,15 @@ ThreadRecorder::ThreadRecorder() TimeBlock& time_block = *it; TimeBlockTreeNode& tree_node = mTimeBlockTreeNodes[it->getIndex()]; tree_node.mBlock = &time_block; - tree_node.mParent = &root_timer; + tree_node.mParent = &root_time_block; - it->getPrimaryAccumulator()->mParent = &root_timer; + it->getPrimaryAccumulator()->mParent = &root_time_block; } - mRootTimer = new BlockTimer(root_timer); - mRootTimerData->mCurTimer = mRootTimer; + mRootTimer = new BlockTimer(root_time_block); + timer_stack->mActiveTimer = mRootTimer; - TimeBlock::getRootTimer().getPrimaryAccumulator()->mActiveCount = 1; + TimeBlock::getRootTimeBlock().getPrimaryAccumulator()->mActiveCount = 1; } ThreadRecorder::~ThreadRecorder() @@ -79,9 +78,7 @@ ThreadRecorder::~ThreadRecorder() { mActiveRecordings.front().mTargetRecording->stop(); } - get_thread_recorder() = NULL; - TimeBlock::sCurTimerData = NULL; - delete mRootTimerData; + set_thread_recorder(NULL); delete[] mTimeBlockTreeNodes; } @@ -196,12 +193,12 @@ SlaveThreadRecorder::~SlaveThreadRecorder() void SlaveThreadRecorder::pushToMaster() { - mFullRecording.stop(); + mThreadRecording.stop(); { LLMutexLock(getMasterThreadRecorder().getSlaveListMutex()); - mSharedData.appendFrom(mFullRecording); + mSharedData.appendFrom(mThreadRecording); } - mFullRecording.start(); + mThreadRecording.start(); } void SlaveThreadRecorder::SharedData::appendFrom( const Recording& source ) diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index d09527eced..337035974c 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -62,13 +62,12 @@ namespace LLTrace void moveBaselineToTarget(); }; - Recording mFullRecording; + Recording mThreadRecording; std::list<ActiveRecording> mActiveRecordings; - struct CurTimerData* mRootTimerData; - class BlockTimer* mRootTimer; - TimeBlockTreeNode* mTimeBlockTreeNodes; - size_t mNumTimeBlockTreeNodes; + class BlockTimer* mRootTimer; + TimeBlockTreeNode* mTimeBlockTreeNodes; + size_t mNumTimeBlockTreeNodes; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder diff --git a/indra/llmessage/llbuffer.cpp b/indra/llmessage/llbuffer.cpp index 01da20f060..1722b48f44 100644 --- a/indra/llmessage/llbuffer.cpp +++ b/indra/llmessage/llbuffer.cpp @@ -32,6 +32,7 @@ #include "llmath.h" #include "llstl.h" #include "llthread.h" +#include <iterator> #define ASSERT_LLBUFFERARRAY_MUTEX_LOCKED llassert(!mMutexp || mMutexp->isSelfLocked()); diff --git a/indra/llmessage/lldispatcher.cpp b/indra/llmessage/lldispatcher.cpp index b2dc414a68..7ac3651a76 100644 --- a/indra/llmessage/lldispatcher.cpp +++ b/indra/llmessage/lldispatcher.cpp @@ -29,6 +29,7 @@ #include "lldispatcher.h" #include <algorithm> +#include <iterator> #include "llstl.h" #include "message.h" -- cgit v1.2.3 From 6e82bb7789c1e046dcfb97c6773150df110153f8 Mon Sep 17 00:00:00 2001 From: Andrew Meadows <andrew@lindenlab.com> Date: Thu, 3 Jan 2013 22:34:34 +0000 Subject: fixing linux compile errors for llcommon after LLTrace work --- indra/llcommon/llfasttimer.h | 2 +- indra/llcommon/llmemory.h | 1 + indra/llcommon/llthreadlocalstorage.h | 21 +++++++++++++++++++++ indra/llcommon/lltrace.h | 26 +++++++++++++------------- indra/llcommon/lltracerecording.h | 18 +++++++++--------- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 995eebd16a..fb2868ff98 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -49,7 +49,7 @@ class ThreadTimerStack : public BlockTimerStackRecord, public LLThreadLocalSingleton<ThreadTimerStack> { - friend LLThreadLocalSingleton<ThreadTimerStack>; + friend class LLThreadLocalSingleton<ThreadTimerStack>; ThreadTimerStack() {} diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index e725bdd9fa..7e73afe06a 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,6 +27,7 @@ #define LLMEMORY_H #include "linden_common.h" +#include "stdint.h" class LLMutex ; diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index fdf0c18085..5a38d54eea 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -215,15 +215,28 @@ private: LLThreadLocalSingleton(const LLThreadLocalSingleton& other); virtual void initSingleton() {} +#ifdef LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; static __declspec(thread) EInitState sInitState; +#elif LL_LINUX + static __thread DERIVED_TYPE* sInstance; + static __thread EInitState sInitState; +#endif }; +#ifdef LL_WINDOWS template<typename DERIVED_TYPE> __declspec(thread) DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL; template<typename DERIVED_TYPE> __declspec(thread) typename LLThreadLocalSingleton<DERIVED_TYPE>::EInitState LLThreadLocalSingleton<DERIVED_TYPE>::sInitState = LLThreadLocalSingleton<DERIVED_TYPE>::UNINITIALIZED; +#elif LL_LINUX +template<typename DERIVED_TYPE> +__thread DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL; + +template<typename DERIVED_TYPE> +__thread typename LLThreadLocalSingleton<DERIVED_TYPE>::EInitState LLThreadLocalSingleton<DERIVED_TYPE>::sInitState = LLThreadLocalSingleton<DERIVED_TYPE>::UNINITIALIZED; +#endif template<typename DERIVED_TYPE> class LLThreadLocalSingletonPointer @@ -245,10 +258,18 @@ public: } private: +#ifdef LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; +#elif LL_LINUX + static __thread DERIVED_TYPE* sInstance; +#endif }; template<typename DERIVED_TYPE> +#ifdef LL_WINDOWS __declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; +#elif LL_LINUX +__thread DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; +#endif #endif // LL_LLTHREADLOCALSTORAGE_H diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 285d4389af..e15cffd7d2 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -614,7 +614,7 @@ struct MemFootprint<T*> static size_t measure() { - return MemFootPrint<T>::measure(); + return MemFootprint<T>::measure(); } }; @@ -730,17 +730,17 @@ public: } // claim memory associated with other objects/data as our own, adding to our calculated footprint - template<typename T> - T& memClaim(T& value) + template<typename CLAIM_T> + CLAIM_T& memClaim(CLAIM_T& value) { - TrackMemImpl<T>::claim(*this, value); + TrackMemImpl<CLAIM_T>::claim(*this, value); return value; } - template<typename T> - const T& memClaim(const T& value) + template<typename CLAIM_T> + const CLAIM_T& memClaim(const CLAIM_T& value) { - TrackMemImpl<T>::claim(*this, value); + TrackMemImpl<CLAIM_T>::claim(*this, value); return value; } @@ -756,17 +756,17 @@ public: } // remove memory we had claimed from our calculated footprint - template<typename T> - T& memDisclaim(T& value) + template<typename CLAIM_T> + CLAIM_T& memDisclaim(CLAIM_T& value) { - TrackMemImpl<T>::disclaim(*this, value); + TrackMemImpl<CLAIM_T>::disclaim(*this, value); return value; } - template<typename T> - const T& memDisclaim(const T& value) + template<typename CLAIM_T> + const CLAIM_T& memDisclaim(const CLAIM_T& value) { - TrackMemImpl<T>::disclaim(*this, value); + TrackMemImpl<CLAIM_T>::disclaim(*this, value); return value; } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f2d7d42211..aa3200e5ad 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -141,7 +141,7 @@ namespace LLTrace template <typename T> T getSum(const Count<T>& stat) const { - return (T)getSum(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat) const; @@ -149,7 +149,7 @@ namespace LLTrace template <typename T> T getPerSec(const Count<T>& stat) const { - return (T)getPerSec(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<CountAccumulator<F64> >& stat) const; @@ -162,7 +162,7 @@ namespace LLTrace template <typename T> T getSum(const Measurement<T>& stat) const { - return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -170,7 +170,7 @@ namespace LLTrace template <typename T> T getPerSec(const Measurement<T>& stat) const { - return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMin(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -178,7 +178,7 @@ namespace LLTrace template <typename T> T getMin(const Measurement<T>& stat) const { - return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMax(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -186,7 +186,7 @@ namespace LLTrace template <typename T> T getMax(const Measurement<T>& stat) const { - return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMean(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -194,7 +194,7 @@ namespace LLTrace template <typename T> T getMean(Measurement<T>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getStandardDeviation(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -202,7 +202,7 @@ namespace LLTrace template <typename T> T getStandardDeviation(const Measurement<T>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getLastValue(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -210,7 +210,7 @@ namespace LLTrace template <typename T> T getLastValue(const Measurement<T>& stat) const { - return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const; -- cgit v1.2.3 From 019836a39667889d4347277cde82270113992bb6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows <andrew@lindenlab.com> Date: Fri, 4 Jan 2013 03:02:54 +0000 Subject: More fixes for linux build of lltrace changes --- indra/cmake/00-Common.cmake | 2 +- indra/llcommon/llerrorlegacy.h | 2 ++ indra/llcommon/llunit.h | 11 ++++++----- indra/llmath/llvolume.cpp | 13 +++++-------- indra/newview/llworldmapmessage.h | 2 ++ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index d9553b9a7e..af3689c641 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -216,7 +216,7 @@ endif (DARWIN) if (LINUX OR DARWIN) - set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs") + set(GCC_WARNINGS "-Wall -Wno-unused-but-set-variable -Wno-sign-compare -Wno-trigraphs") if (NOT GCC_DISABLE_FATAL_WARNINGS) set(GCC_WARNINGS "${GCC_WARNINGS} -Werror") diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h index 58cc2899af..097a533b1a 100644 --- a/indra/llcommon/llerrorlegacy.h +++ b/indra/llcommon/llerrorlegacy.h @@ -114,8 +114,10 @@ const int LL_ERR_PRICE_MISMATCH = -23018; #ifdef LL_WINDOWS #define llstatic_assert(func, msg) static_assert(func, msg) +#define llstatic_assert_template(type, func, msg) static_assert(func, msg) #else #define llstatic_assert(func, msg) BOOST_STATIC_ASSERT(func) +#define llstatic_assert_template(type, func, msg) BOOST_STATIC_ASSERT(sizeof(type) != 0 && func); #endif // handy compile-time assert - enforce those template parameters! diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 72a6020ff8..c600883607 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -29,6 +29,7 @@ #include "stdtypes.h" #include "llpreprocessor.h" +#include "llerrorlegacy.h" namespace LLUnits { @@ -53,7 +54,7 @@ struct ConversionFactor static typename HighestPrecisionType<VALUE_TYPE>::type_t get() { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(DERIVED_UNITS_TAG) == 0, "Cannot convert between types."); + llstatic_assert_template(DERIVED_UNITS_TAG, false, "Cannot convert between types."); } }; @@ -141,7 +142,7 @@ struct LLUnit void operator *= (LLUnit<OTHER_UNIT, OTHER_STORAGE> multiplicand) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(OTHER_UNIT) == 0, "Multiplication of unit types not supported."); + llstatic_assert_template(OTHER_UNIT, 0, "Multiplication of unit types not supported."); } void operator /= (storage_t divisor) @@ -153,7 +154,7 @@ struct LLUnit void operator /= (LLUnit<OTHER_UNIT, OTHER_STORAGE> divisor) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(OTHER_UNIT) == 0, "Illegal in-place division of unit types."); + llstatic_assert_template(OTHER_UNIT, 0, "Illegal in-place division of unit types."); } template<typename SOURCE_UNITS, typename SOURCE_STORAGE> @@ -313,7 +314,7 @@ template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typen LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); + llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported."); return LLUnit<UNIT_TYPE1, STORAGE_TYPE1>(); } @@ -333,7 +334,7 @@ template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typen LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2>) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - llstatic_assert(sizeof(STORAGE_TYPE1) == 0, "Multiplication of unit types results in new unit type - not supported."); + llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported."); return LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>(); } diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 54b67832ea..47ba0c4fc4 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -6066,12 +6066,13 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) S32 max_t = volume->getPath().mPath.size(); // S32 i; - S32 num_vertices = 0, num_indices = 0; + //S32 num_vertices = 0; + //S32 num_indices = 0; S32 grid_size = (profile.size()-1)/4; - S32 quad_count = (grid_size * grid_size); + //S32 quad_count = (grid_size * grid_size); - num_vertices = (grid_size+1)*(grid_size+1); - num_indices = quad_count * 4; + //num_vertices = (grid_size+1)*(grid_size+1); + //num_indices = quad_count * 4; LLVector4a& min = mExtents[0]; LLVector4a& max = mExtents[1]; @@ -6667,10 +6668,6 @@ void LLVolumeFace::resizeVertices(S32 num_verts) mPositions = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); ll_assert_aligned(mPositions, 16); mNormals = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*num_verts); - if ( ((int)mNormals & 0xF) != 0 ) - { - __debugbreak(); - } ll_assert_aligned(mNormals, 16); //pad texture coordinate block end to allow for QWORD reads diff --git a/indra/newview/llworldmapmessage.h b/indra/newview/llworldmapmessage.h index 12b6ef4792..ac1ea1607c 100644 --- a/indra/newview/llworldmapmessage.h +++ b/indra/newview/llworldmapmessage.h @@ -27,6 +27,8 @@ #ifndef LL_LLWORLDMAPMESSAGE_H #define LL_LLWORLDMAPMESSAGE_H +#include "boost/function.hpp" + // Handling of messages (send and process) as well as SLURL callback if necessary class LLMessageSystem; -- cgit v1.2.3 From b2197101c488de66ca9ecf71c229f5b80d1390fd Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 4 Jan 2013 13:04:09 -0800 Subject: SH-3468 WIP add memory tracking base class fix for compile error on windows ignore stdint.h even though VS2010 provides it --- indra/llcommon/llmemory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 7e73afe06a..4ead45679f 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,7 +27,9 @@ #define LLMEMORY_H #include "linden_common.h" -#include "stdint.h" +#if !LL_WINDOWS +#include <stdint.h> +#endif class LLMutex ; -- cgit v1.2.3 From cbff0e7ab8afeebb6ddab854d35ea12ef9a9930a Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 4 Jan 2013 13:48:35 -0800 Subject: SH-3468 WIP add memory tracking base class attempted fix for gcc compile errors can't use typeid() on a class that doesn't have a method defined in a translation unit fix is to force classes deriving from LLMemTrackable to use their own static member named sMemStat --- indra/llcommon/lltrace.h | 27 ++++++++++++--------------- indra/llimage/llimage.cpp | 1 + indra/llimage/llimage.h | 2 ++ indra/llui/lltextbase.cpp | 2 ++ indra/llui/lltextbase.h | 10 ++++++---- indra/llui/llview.cpp | 1 + indra/llui/llview.h | 1 + indra/llui/llviewmodel.cpp | 2 ++ indra/llui/llviewmodel.h | 2 ++ indra/newview/lldrawable.cpp | 1 + indra/newview/lldrawable.h | 1 + indra/newview/llviewerobject.cpp | 3 +++ indra/newview/llviewerobject.h | 4 ++-- 13 files changed, 36 insertions(+), 21 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index e15cffd7d2..1a156e583e 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -660,13 +660,13 @@ struct MemFootprint<std::list<T> > } }; -template<typename T> +template<typename DERIVED> class MemTrackable { template<typename TRACKED, typename TRACKED_IS_TRACKER> struct TrackMemImpl; - typedef MemTrackable<T> mem_trackable_t; + typedef MemTrackable<DERIVED> mem_trackable_t; public: typedef void mem_trackable_tag_t; @@ -681,7 +681,7 @@ public: // reserve 8 bytes for allocation size (and preserving 8 byte alignment of structs) void* allocation = ::operator new(allocation_size + 8); *(size_t*)allocation = allocation_size; - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize += allocation_size; @@ -693,7 +693,7 @@ public: void operator delete(void* ptr) { size_t* allocation_size = (size_t*)((char*)ptr - 8); - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize -= *allocation_size; @@ -707,7 +707,7 @@ public: { size_t* result = (size_t*)malloc(size + 8); *result = size; - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize += size; @@ -719,7 +719,7 @@ public: void operator delete[](void* ptr) { size_t* allocation_size = (size_t*)((char*)ptr - 8); - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize -= *allocation_size; @@ -747,7 +747,7 @@ public: void memClaim(size_t size) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); mMemFootprint += size; if (accumulator) { @@ -772,7 +772,7 @@ public: void memDisclaim(size_t size) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize -= size; @@ -788,7 +788,7 @@ private: { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint<TRACKED>::measure(tracked); @@ -799,7 +799,7 @@ private: static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint<TRACKED>::measure(tracked); @@ -814,7 +814,7 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize += MemFootprint<TRACKED>::measure(tracked); @@ -823,17 +823,14 @@ private: static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = sStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize -= MemFootprint<TRACKED>::measure(tracked); } } }; - static MemStat sStat; }; -template<typename T> MemStat MemTrackable<T>::sStat(typeid(T).name()); - } #endif // LL_LLTRACE_H diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 22dd809ef3..56f6b0964c 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -50,6 +50,7 @@ LLMutex* LLImage::sMutex = NULL; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ; +LLTrace::MemStat LLImage::sMemStat("LLImage"); //static void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index d945d54404..6eafcf1bf7 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -165,6 +165,8 @@ public: static void destroyPrivatePool() ; static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;} + static LLTrace::MemStat sMemStat; + private: U8 *mData; S32 mDataSize; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 31d67a9e08..74e966560e 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -47,6 +47,8 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; +LLTrace::MemStat LLTextSegment::sMemStat("LLTextSegment"); + LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 966dd93888..7d791ec75a 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -94,10 +94,12 @@ public: /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const; /*virtual*/ BOOL hasMouseCapture(); - S32 getStart() const { return mStart; } - void setStart(S32 start) { mStart = start; } - S32 getEnd() const { return mEnd; } - void setEnd( S32 end ) { mEnd = end; } + S32 getStart() const { return mStart; } + void setStart(S32 start) { mStart = start; } + S32 getEnd() const { return mEnd; } + void setEnd( S32 end ) { mEnd = end; } + + static LLTrace::MemStat sMemStat; protected: S32 mStart; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 59577e95ac..47bf410af6 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -67,6 +67,7 @@ LLView* LLView::sPreviewClickedElement = NULL; BOOL LLView::sDrawPreviewHighlights = FALSE; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; +LLTrace::MemStat LLView::sMemStat("LLView"); std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 29ee2125f9..256f86c00d 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -673,6 +673,7 @@ public: static S32 sLastLeftXML; static S32 sLastBottomXML; static BOOL sForceReshape; + static LLTrace::MemStat sMemStat; }; class LLCompareByTabOrder diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index dff0dcb2fd..1bd09e8086 100644 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -35,6 +35,8 @@ // external library headers // other Linden headers +LLTrace::MemStat LLViewModel::sMemStat("LLViewModel"); + /// LLViewModel::LLViewModel() : mDirty(false) diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index a2ca20c739..214780393b 100644 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -83,6 +83,8 @@ public: // void setDirty() { mDirty = true; } + static LLTrace::MemStat sMemStat; + protected: LLSD mValue; bool mDirty; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 09bbafd54a..6ef437cefb 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -58,6 +58,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f; static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); extern bool gShiftFrame; +LLTrace::MemStat LLDrawable::sMemStat("LLDrawable"); //////////////////////// diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index f15090fb87..abfdea2699 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -314,6 +314,7 @@ public: LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; } static F32 sCurPixelAngle; //current pixels per radian + static LLTrace::MemStat sMemStat; private: typedef std::vector<LLFace*> face_list_t; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index fff1875ad6..ee8bb50e4e 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -112,6 +112,9 @@ BOOL LLViewerObject::sMapDebug = TRUE; LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit S32 LLViewerObject::sAxisArrowLength(50); +LLTrace::MemStat LLViewerObject::sMemStat("LLViewerObject"); + + BOOL LLViewerObject::sPulseEnabled(FALSE); BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 14ea8ded38..153f44601c 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -670,8 +670,6 @@ protected: void deleteParticleSource(); void setParticleSource(const LLPartSysData& particle_parameters, const LLUUID& owner_id); -public: - private: void setNameValueList(const std::string& list); // clears nv pairs and then individually adds \n separated NV pairs from \0 terminated string void deleteTEImages(); // correctly deletes list of images @@ -750,6 +748,8 @@ protected: static S32 sAxisArrowLength; + static LLTrace::MemStat sMemStat; + // These two caches are only correct for non-parented objects right now! mutable LLVector3 mPositionRegion; mutable LLVector3 mPositionAgent; -- cgit v1.2.3 From 4ebd4b3616d9d69e9b6deb73aa1f1e16f5673225 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 4 Jan 2013 14:09:02 -0800 Subject: SH-3468 WIP add memory tracking base class further compile error fixes --- indra/llimage/llimage.cpp | 2 +- indra/newview/llviewerobject.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 56f6b0964c..f3452ce86a 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -50,7 +50,7 @@ LLMutex* LLImage::sMutex = NULL; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ; -LLTrace::MemStat LLImage::sMemStat("LLImage"); +LLTrace::MemStat LLImageBase::sMemStat("LLImage"); //static void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 153f44601c..bdff88f8ca 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -634,7 +634,8 @@ public: LLPointer<LLHUDText> mText; LLPointer<LLHUDIcon> mIcon; - static BOOL sUseSharedDrawables; + static BOOL sUseSharedDrawables; + static LLTrace::MemStat sMemStat; protected: // delete an item in the inventory, but don't tell the @@ -748,7 +749,6 @@ protected: static S32 sAxisArrowLength; - static LLTrace::MemStat sMemStat; // These two caches are only correct for non-parented objects right now! mutable LLVector3 mPositionRegion; -- cgit v1.2.3 From cf8fa1a958f8676a0911bac7bdb950a865b58c83 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 4 Jan 2013 15:57:28 -0800 Subject: SH-3468 WIP add memory tracking base class further compile error fixes --- indra/llcommon/llfasttimer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index ad8cf7296e..e6233a094e 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -137,12 +137,12 @@ void TimeBlock::setLogLock(LLMutex* lock) //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer +U64 TimeBlock::countsPerSecond() { return sClockResolution; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer +U64 TimeBlock::countsPerSecond() { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz @@ -165,7 +165,7 @@ U64 TimeBlock::countsPerSecond() // counts per second for the *64-bit* timer #endif TimeBlock::TimeBlock(const char* name, bool open, TimeBlock* parent) -: TraceType(name), +: TraceType<TimeBlockAccumulator>(name), mCollapsed(true) { setCollapsed(!open); -- cgit v1.2.3 From 7dbb8860373769dfca7d6c6588284866a1bf86a3 Mon Sep 17 00:00:00 2001 From: Richard Linden <none@none> Date: Fri, 4 Jan 2013 16:19:20 -0800 Subject: SH-3468 WIP add memory tracking base class further compile error fixes --- indra/llcommon/lltracerecording.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9dbafc4e82..c110e64380 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -60,7 +60,7 @@ Recording::Recording( const Recording& other ) mStackTimers = other.mStackTimers; mMemStats = other.mMemStats; - LLStopWatchControlsMixin::initTo(other.getPlayState()); + LLStopWatchControlsMixin<Recording>::initTo(other.getPlayState()); } -- cgit v1.2.3