From 1dbaa19e990a4a13ed010e71d00324d613469f19 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 14 Mar 2013 14:37:20 -0500 Subject: [PATCH] Reworked control variable lookup profiling. Should practically be free, and is now enabled for relwithdebinfo. Use dumpcalls for output. --- indra/llxml/llcontrol.cpp | 34 ++++++++--------------- indra/llxml/llcontrol.h | 12 ++++++++ indra/newview/chatbar_as_cmdline.cpp | 41 +++++++++++++++++++++------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 66ac78657..06f8d04e2 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -174,7 +174,8 @@ LLControlVariable::LLControlVariable(const std::string& name, eControlType type, mValidateSignal(new validate_signal_t), mIsCOA(IsCOA), mIsCOAParent(false), - mCOAConnectedVar(NULL) + mCOAConnectedVar(NULL), + mLookupCount(0) { if (mPersist && mComment.empty()) { @@ -339,29 +340,16 @@ LLSD LLControlVariable::getSaveValue() const { //The first level of the stack is default //We assume that the second level is user preferences that should be saved - if(mValues.size() > 1) return mValues[1]; + if(mValues.size() > 1) return mValues[1]; return mValues[0]; } -#if PROF_CTRL_CALLS -std::vector> gSettingsCallMap; - -static update_gSettingsCallMap(ctrl_name_table_t::const_iterator const& iter) +#ifdef PROF_CTRL_CALLS +void LLControlGroup::updateLookupMap(ctrl_name_table_t::const_iterator iter) const { - if(iter != mNameTable.end()) + if(iter != mNameTable.end() && iter->second.notNull()) { - std::vector>::iterator iter2 = gSettingsCallMap.begin(); - std::vector>::iterator end = gSettingsCallMap.end(); - for(;iter2!=end;iter2++) - { - if(iter2->first==name) - { - iter2->second = iter2->second + 1; - break; - } - } - if(iter2 == gSettingsCallMap.end()) - gSettingsCallMap.push_back(std::pair(name.c_str(),1)); + iter->second.get()->mLookupCount++; } } #endif //PROF_CTRL_CALLS @@ -369,8 +357,8 @@ static update_gSettingsCallMap(ctrl_name_table_t::const_iterator const& iter) LLControlVariable* LLControlGroup::getControl(std::string const& name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); -#if PROF_CTRL_CALLS - update_gSettingsCallMap(iter); +#ifdef PROF_CTRL_CALLS + updateLookupMap(iter); #endif //PROF_CTRL_CALLS if(iter != mNameTable.end()) return iter->second->getCOAActive(); @@ -381,8 +369,8 @@ LLControlVariable* LLControlGroup::getControl(std::string const& name) LLControlVariable const* LLControlGroup::getControl(std::string const& name) const { ctrl_name_table_t::const_iterator iter = mNameTable.find(name); -#if PROF_CTRL_CALLS - update_gSettingsCallMap(iter); +#ifdef PROF_CTRL_CALLS + updateLookupMap(iter); #endif //PROF_CTRL_CALLS if(iter != mNameTable.end()) return iter->second->getCOAActive(); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 2816918a8..4d94deb4d 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -69,6 +69,10 @@ # endif #endif +#if LL_RELEASE_WITH_DEBUG_INFO +#define PROF_CTRL_CALLS +#endif //LL_RELEASE_WITH_DEBUG_INFO + class LLVector3; class LLVector3d; class LLColor3; @@ -179,6 +183,10 @@ public: mValidateSignal = pConnect->mValidateSignal; } } +#ifdef PROF_CTRL_CALLS +public: + U32 mLookupCount; +#endif //PROF_CTRL_CALLS private: LLSD getComparableValue(const LLSD& value); bool llsd_compare(const LLSD& a, const LLSD & b); @@ -347,6 +355,10 @@ public: void connectCOAVars(LLControlGroup &OtherGroup); void updateCOASetting(bool coa_enabled); bool handleCOASettingChange(const LLSD& newvalue); + +#ifdef PROF_CTRL_CALLS + void updateLookupMap(ctrl_name_table_t::const_iterator iter) const; +#endif //PROF_CTRL_CALLS }; diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 6d19d693c..c49deaf84 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -200,13 +200,24 @@ void invrepair() gInventory.collectDescendents(gInventory.getRootFolderID(),cats,items,FALSE);//,objectnamematches); } - -#if PROF_CTRL_CALLS -extern std::vector> gSettingsCallMap; -bool stort_calls(const std::pair& left, const std::pair& right) +#ifdef PROF_CTRL_CALLS +bool sort_calls(const std::pair& left, const std::pair& right) { - return left.second < right.second; + return left.second > right.second; } +//Structure to be passed into LLControlGroup::applyToAll. +// Doesn't actually modify control group, but rather uses the 'apply' +// vfn to add each variable in the group to a list. This essentially +// allows us to copy the private variable list without touching the controlgroup +// class. +struct ProfCtrlListAccum : public LLControlGroup::ApplyFunctor +{ + virtual void apply(const std::string& name, LLControlVariable* control) + { + mVariableList.push_back(std::make_pair(name,control->mLookupCount)); + } + std::vector > mVariableList; +}; #endif //PROF_CTRL_CALLS bool cmd_line_chat(std::string revised_text, EChatType type) { @@ -446,13 +457,23 @@ bool cmd_line_chat(std::string revised_text, EChatType type) { invrepair(); } -#if PROF_CTRL_CALLS +#ifdef PROF_CTRL_CALLS else if(command == "dumpcalls") { - llinfos << "gSavedSettings lookup count (" << gFrameCount << "frames)" << llendl; - std::sort(gSettingsCallMap.begin(),gSettingsCallMap.end(),stort_calls); - for(U32 i = 0;iapplyToAll(&list); + std::sort(list.mVariableList.begin(),list.mVariableList.end(),sort_calls); + LL_INFOS("") << *it << ": lookup count (" << gFrameCount << "frames)" << LL_ENDL; + for(U32 i = 0;i