summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorKelly Washington <kelly@lindenlab.com>2012-07-03 23:34:56 +0000
committerKelly Washington <kelly@lindenlab.com>2012-07-03 23:34:56 +0000
commit3a56fbf867194ec8fbc7d8237f9781ac9d72c8a4 (patch)
treed1bbc30df8958f6ed2032673a2f758118f2b5fa0 /indra
parentf199b298b4bbd01702ea248236d00a1e05b7bdeb (diff)
MAINT-1231 Investigate increasing MAX_CACHED_GROUPS in llgroupmgr.cpp
* increased max groups to 20 * changed cache to LRU instead of 'delete half when overfull' reviewed with Baker
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llgroupmgr.cpp55
-rw-r--r--indra/newview/llgroupmgr.h6
2 files changed, 46 insertions, 15 deletions
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index efffd0f98e..aceb7f0614 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -63,7 +63,7 @@
#pragma warning(pop) // Restore all warnings to the previous state
#endif
-const U32 MAX_CACHED_GROUPS = 10;
+const U32 MAX_CACHED_GROUPS = 20;
//
// LLRoleActionSet
@@ -234,10 +234,16 @@ LLGroupMgrGroupData::LLGroupMgrGroupData(const LLUUID& id) :
mRoleDataComplete(FALSE),
mRoleMemberDataComplete(FALSE),
mGroupPropertiesDataComplete(FALSE),
- mPendingRoleMemberRequest(FALSE)
+ mPendingRoleMemberRequest(FALSE),
+ mAccessTime(0.0f)
{
}
+void LLGroupMgrGroupData::setAccessed()
+{
+ mAccessTime = (F32)LLFrameTimer::getTotalSeconds();
+}
+
BOOL LLGroupMgrGroupData::getRoleData(const LLUUID& role_id, LLRoleData& role_data)
{
role_data_map_t::const_iterator it;
@@ -1360,7 +1366,7 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data)
LLGroupMgrGroupData* LLGroupMgr::createGroupData(const LLUUID& id)
{
- LLGroupMgrGroupData* group_datap;
+ LLGroupMgrGroupData* group_datap = NULL;
group_map_t::iterator existing_group = LLGroupMgr::getInstance()->mGroups.find(id);
if (existing_group == LLGroupMgr::getInstance()->mGroups.end())
@@ -1373,6 +1379,11 @@ LLGroupMgrGroupData* LLGroupMgr::createGroupData(const LLUUID& id)
group_datap = existing_group->second;
}
+ if (group_datap)
+ {
+ group_datap->setAccessed();
+ }
+
return group_datap;
}
@@ -1413,25 +1424,41 @@ void LLGroupMgr::notifyObservers(LLGroupChange gc)
void LLGroupMgr::addGroup(LLGroupMgrGroupData* group_datap)
{
- if (mGroups.size() > MAX_CACHED_GROUPS)
+ while (mGroups.size() >= MAX_CACHED_GROUPS)
{
- // get rid of groups that aren't observed
- for (group_map_t::iterator gi = mGroups.begin(); gi != mGroups.end() && mGroups.size() > MAX_CACHED_GROUPS / 2; )
+ // LRU: Remove the oldest un-observed group from cache until group size is small enough
+
+ F32 oldest_access = LLFrameTimer::getTotalSeconds();
+ group_map_t::iterator oldest_gi = mGroups.end();
+
+ for (group_map_t::iterator gi = mGroups.begin(); gi != mGroups.end(); ++gi )
{
observer_multimap_t::iterator oi = mObservers.find(gi->first);
if (oi == mObservers.end())
{
- // not observed
- LLGroupMgrGroupData* unobserved_groupp = gi->second;
- delete unobserved_groupp;
- mGroups.erase(gi++);
- }
- else
- {
- ++gi;
+ if (gi->second
+ && (gi->second->getAccessTime() < oldest_access))
+ {
+ oldest_access = gi->second->getAccessTime();
+ oldest_gi = gi;
+ }
}
}
+
+ if (oldest_gi != mGroups.end())
+ {
+ delete oldest_gi->second;
+ mGroups.erase(oldest_gi);
+ }
+ else
+ {
+ // All groups must be currently open, none to remove.
+ // Just add the new group anyway, but get out of this loop as it
+ // will never drop below max_cached_groups.
+ break;
+ }
}
+
mGroups[group_datap->getID()] = group_datap;
}
diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h
index faf0531c10..df3cd17e03 100644
--- a/indra/newview/llgroupmgr.h
+++ b/indra/newview/llgroupmgr.h
@@ -86,7 +86,7 @@ public:
BOOL isInRole(const LLUUID& role_id) { return (mRolesList.find(role_id) != mRolesList.end()); }
-protected:
+private:
LLUUID mID;
S32 mContribution;
U64 mAgentPowers;
@@ -233,6 +233,9 @@ public:
BOOL isRoleMemberDataComplete() { return mRoleMemberDataComplete; }
BOOL isGroupPropertiesDataComplete() { return mGroupPropertiesDataComplete; }
+ F32 getAccessTime() const { return mAccessTime; }
+ void setAccessed();
+
public:
typedef std::map<LLUUID,LLGroupMemberData*> member_list_t;
typedef std::map<LLUUID,LLGroupRoleData*> role_list_t;
@@ -280,6 +283,7 @@ private:
BOOL mGroupPropertiesDataComplete;
BOOL mPendingRoleMemberRequest;
+ F32 mAccessTime;
};
struct LLRoleAction