From 819adb5eb4d7f982121f3dbd82750e05d26864d9 Mon Sep 17 00:00:00 2001 From: Richard Linden 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/llinstancetracker.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/llinstancetracker.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 +/// @NOTE: see explicit specialization below for default KEY==void case +template class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker 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 template -class LLInstanceTracker : public LLInstanceTrackerBase +class LLInstanceTracker : public LLInstanceTrackerBase { - typedef LLInstanceTracker MyT; + typedef LLInstanceTracker MyT; typedef typename std::set InstanceSet; struct StaticData: public StaticBase { -- cgit v1.2.3 From 3fd640a6e3dea7a3551c239323d782fb082e1dbd Mon Sep 17 00:00:00 2001 From: Richard Linden 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/llinstancetracker.h | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') 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(this)); } -- cgit v1.2.3 From cc7d92147c4a4502ec2ac04f150e94a4ac18f79e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 19 Apr 2013 20:09:00 -0700 Subject: SH-4080 WIP interesting: random crash on Mac removed unused dll support from llinstancetracker as it didn't appear to be thread safe --- indra/llcommon/llinstancetracker.h | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 9dd6d4a7ed..596bea548d 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -46,22 +46,6 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable { protected: - /// Get a process-unique void* pointer slot for the specified type_info - static void * & getInstances(std::type_info const & info); - - /// Find or create a STATICDATA instance for the specified TRACKED class. - /// STATICDATA must be default-constructible. - template - static STATICDATA& getStatic() - { - void *& instances = getInstances(typeid(TRACKED)); - if (! instances) - { - instances = new STATICDATA; - } - return *static_cast(instances); - } - /// It's not essential to derive your STATICDATA (for use with /// getStatic()) from StaticBase; it's just that both known /// implementations do. @@ -92,7 +76,7 @@ class LLInstanceTracker : public LLInstanceTrackerBase { InstanceMap sMap; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { static StaticData sData; return sData;} static InstanceMap& getMap_() { return getStatic().sMap; } public: @@ -240,7 +224,7 @@ class LLInstanceTracker : public LLInstanceTrackerBase { InstanceSet sSet; }; - static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic(); } + static StaticData& getStatic() { static StaticData sData; return sData; } static InstanceSet& getSet_() { return getStatic().sSet; } public: -- cgit v1.2.3 From 62c8844414b84ee9e8cc488f4e02cbaed5f67a14 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 21 Apr 2013 23:10:03 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added ExtendablePeriodicRecording and ability to append periodic recordings to each other --- indra/llcommon/llinstancetracker.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 596bea548d..a79ddd088d 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -67,6 +67,7 @@ protected: /// 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==void case +/// @NOTE: this class is not thread-safe unless used as read-only template class LLInstanceTracker : public LLInstanceTrackerBase { @@ -120,13 +121,13 @@ public: typedef boost::iterator_facade super_t; key_iter(typename InstanceMap::iterator it) - : mIterator(it) + : mIterator(it) { getStatic().incrementDepth(); } key_iter(const key_iter& other) - : mIterator(other.mIterator) + : mIterator(other.mIterator) { getStatic().incrementDepth(); } @@ -171,7 +172,10 @@ public: return instance_iter(getMap_().end()); } - static S32 instanceCount() { return getMap_().size(); } + static S32 instanceCount() + { + return getMap_().size(); + } static key_iter beginKeys() { -- cgit v1.2.3 From 075a7bcc980b0ca0d2888d344b6afa8ab5b52d85 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 18 Jul 2013 15:09:45 -0700 Subject: SH-4297 WIP interesting: viewer-interesting starts loading cached scene late dependency cleanup - removed a lot of unecessary includes --- indra/llcommon/llinstancetracker.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index c8e1d9cd84..f4e37d21fe 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -32,9 +32,6 @@ #include #include "string_table.h" -#include -#include -#include #include #include -- cgit v1.2.3 From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:13:45 -0700 Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up build times consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders --- indra/llcommon/llinstancetracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index f4e37d21fe..349ad530af 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -31,7 +31,7 @@ #include #include -#include "string_table.h" +#include "llstringtable.h" #include #include -- cgit v1.2.3 From 1beaedacadc8093c9df612992a873f9c89354bce Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Oct 2013 14:23:56 -0700 Subject: moved root timer to global variable added flag to LLInstanceTracker to allow multiple values per key made StatType allow multiple values per key to eliminate block timer related crash --- indra/llcommon/llinstancetracker.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index f2b982c4c3..1385475444 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -62,16 +62,22 @@ protected: LL_COMMON_API void assert_main_thread(); +enum EInstanceTrackerAllowKeyCollisions +{ + InstanceTrackerAllowKeyCollisions, + InstanceTrackerDisallowKeyCollisions +}; + /// 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==void case /// @NOTE: this class is not thread-safe unless used as read-only -template +template class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker self_t; - typedef typename std::map InstanceMap; + typedef typename std::multimap InstanceMap; struct StaticData: public StaticBase { InstanceMap sMap; @@ -208,7 +214,18 @@ private: void add_(KEY key) { mInstanceKey = key; - getMap_()[key] = static_cast(this); + InstanceMap& map = getMap_(); + InstanceMap::iterator insertion_point_it = map.lower_bound(key); + if (ALLOW_KEY_COLLISIONS == InstanceTrackerDisallowKeyCollisions + && insertion_point_it != map.end() + && insertion_point_it->first == key) + { + LL_ERRS() << "Key " << key << " already exists in instance map for " << typeid(T).name() << LL_ENDL; + } + else + { + map.insert(insertion_point_it, std::make_pair(key, static_cast(this))); + } } void remove_() { @@ -225,8 +242,8 @@ private: /// explicit specialization for default case where KEY is void /// use a simple std::set -template -class LLInstanceTracker : public LLInstanceTrackerBase +template +class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker self_t; typedef typename std::set InstanceSet; -- cgit v1.2.3 From 18aedf0241ba893e12140c0a3855f328d2b4eded Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 17 Oct 2013 19:18:53 -0700 Subject: fix for assert at runtime (reading stats from recording while it was active) fix for bad values returns from getPeriodMin and getPeriodMax on count stats when no counts recorded fix for gcc compile time error (typename ftw) --- indra/llcommon/llinstancetracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 1385475444..3fdb84cfd7 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -215,7 +215,7 @@ private: { mInstanceKey = key; InstanceMap& map = getMap_(); - InstanceMap::iterator insertion_point_it = map.lower_bound(key); + typename InstanceMap::iterator insertion_point_it = map.lower_bound(key); if (ALLOW_KEY_COLLISIONS == InstanceTrackerDisallowKeyCollisions && insertion_point_it != map.end() && insertion_point_it->first == key) -- cgit v1.2.3 From dc60a7564abf16cbf269e47cfc33ed00c6bb0870 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 24 Oct 2013 14:37:57 -0700 Subject: SH-4577 WIP Interesting: viewer crashed when clicking a offline Conversation containing a shared object potential fix by making instance tracker allow key collisions for LLToastNotifyPanel changed assertion macro to use original unpreprocessed source code renamed instance tracker behavior macros to use LL prefix added RestoreCameraPosOnLogin setting to optionally restore old camera positioning behavior --- indra/llcommon/llinstancetracker.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 3fdb84cfd7..3107415ccf 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -64,8 +64,8 @@ LL_COMMON_API void assert_main_thread(); enum EInstanceTrackerAllowKeyCollisions { - InstanceTrackerAllowKeyCollisions, - InstanceTrackerDisallowKeyCollisions + LLInstanceTrackerAllowKeyCollisions, + LLInstanceTrackerDisallowKeyCollisions }; /// This mix-in class adds support for tracking all instances of the specified class parameter T @@ -73,7 +73,7 @@ enum EInstanceTrackerAllowKeyCollisions /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==void case /// @NOTE: this class is not thread-safe unless used as read-only -template +template class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker self_t; @@ -216,7 +216,7 @@ private: mInstanceKey = key; InstanceMap& map = getMap_(); typename InstanceMap::iterator insertion_point_it = map.lower_bound(key); - if (ALLOW_KEY_COLLISIONS == InstanceTrackerDisallowKeyCollisions + if (ALLOW_KEY_COLLISIONS == LLInstanceTrackerDisallowKeyCollisions && insertion_point_it != map.end() && insertion_point_it->first == key) { -- cgit v1.2.3 From 391ac367d6922f30bf3a186bc15e1fc38366eecf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 19 Nov 2013 17:40:44 -0800 Subject: SH-4634 FIX Interesting: Viewer crashes when receiving teleport offer renamed fast timers to have unique names, changes instance tracker to never allow duplicates --- indra/llcommon/llinstancetracker.h | 46 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 3107415ccf..cfe690b9ec 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -64,8 +64,8 @@ LL_COMMON_API void assert_main_thread(); enum EInstanceTrackerAllowKeyCollisions { - LLInstanceTrackerAllowKeyCollisions, - LLInstanceTrackerDisallowKeyCollisions + LLInstanceTrackerErrorOnCollision, + LLInstanceTrackerReplaceOnCollision }; /// This mix-in class adds support for tracking all instances of the specified class parameter T @@ -73,7 +73,7 @@ enum EInstanceTrackerAllowKeyCollisions /// If KEY is not provided, then instances are stored in a simple set /// @NOTE: see explicit specialization below for default KEY==void case /// @NOTE: this class is not thread-safe unless used as read-only -template +template class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker self_t; @@ -192,7 +192,7 @@ public: } protected: - LLInstanceTracker(KEY key) + LLInstanceTracker(const KEY& key) { // make sure static data outlives all instances getStatic(); @@ -211,28 +211,44 @@ private: LLInstanceTracker( const LLInstanceTracker& ); const LLInstanceTracker& operator=( const LLInstanceTracker& ); - void add_(KEY key) + void add_(const KEY& key) { mInstanceKey = key; InstanceMap& map = getMap_(); typename InstanceMap::iterator insertion_point_it = map.lower_bound(key); - if (ALLOW_KEY_COLLISIONS == LLInstanceTrackerDisallowKeyCollisions - && insertion_point_it != map.end() + if (insertion_point_it != map.end() && insertion_point_it->first == key) - { - LL_ERRS() << "Key " << key << " already exists in instance map for " << typeid(T).name() << LL_ENDL; + { // found existing entry with that key + switch(KEY_COLLISION_BEHAVIOR) + { + case LLInstanceTrackerErrorOnCollision: + { + // use assert here instead of LL_ERRS(), otherwise the error will be ignored since this call is made during global object initialization + llassert_always_msg(false, "ERROR: Instance with this same key already exists!"); + break; + } + case LLInstanceTrackerReplaceOnCollision: + { + // replace pointer, but leave key (should have compared equal anyway) + insertion_point_it->second = static_cast(this); + break; + } + default: + break; + } } else - { + { // new key map.insert(insertion_point_it, std::make_pair(key, static_cast(this))); } } void remove_() { - typename InstanceMap::iterator iter = getMap_().find(mInstanceKey); - if (iter != getMap_().end()) + InstanceMap& map = getMap_(); + typename InstanceMap::iterator iter = map.find(mInstanceKey); + if (iter != map.end()) { - getMap_().erase(iter); + map.erase(iter); } } @@ -242,8 +258,8 @@ private: /// explicit specialization for default case where KEY is void /// use a simple std::set -template -class LLInstanceTracker : public LLInstanceTrackerBase +template +class LLInstanceTracker : public LLInstanceTrackerBase { typedef LLInstanceTracker self_t; typedef typename std::set InstanceSet; -- cgit v1.2.3 From 7a91ec40aae5f2908573cdf02d0394effee2c0e3 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 20 Nov 2013 16:21:03 -0800 Subject: SH-4626 FIX: [INTERESTING RC] Viewer randomly crashes when I click on links in IMs or group IMs --- indra/llcommon/llinstancetracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llinstancetracker.h') diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index cfe690b9ec..9783644e66 100755 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -224,7 +224,7 @@ private: case LLInstanceTrackerErrorOnCollision: { // use assert here instead of LL_ERRS(), otherwise the error will be ignored since this call is made during global object initialization - llassert_always_msg(false, "ERROR: Instance with this same key already exists!"); + llassert_always_msg(false, "Instance with this same key already exists!"); break; } case LLInstanceTrackerReplaceOnCollision: -- cgit v1.2.3