More on the hunt for the slow down on HGFriendsModule. - Don't requests the online friends on foreign grids. If this works, there's another way of getting that info.

bulletsim
Diva Canto 2011-06-06 19:52:50 -07:00
parent dce0e46eaa
commit 1a23d322ac
1 changed files with 71 additions and 48 deletions

View File

@ -87,6 +87,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (base.FetchFriendslist(client)) if (base.FetchFriendslist(client))
{ {
UUID agentID = client.AgentId; UUID agentID = client.AgentId;
// we do this only for the root agent
if (m_Friends[agentID].Refcount == 1)
{
// We need to preload the user management cache with the names // We need to preload the user management cache with the names
// of foreign friends, just like we do with SOPs' creators // of foreign friends, just like we do with SOPs' creators
foreach (FriendInfo finfo in m_Friends[agentID].Friends) foreach (FriendInfo finfo in m_Friends[agentID].Friends)
@ -107,12 +110,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
} }
return true; return true;
} }
}
return false; return false;
} }
public override bool SendFriendsOnlineIfNeeded(IClientAPI client) public override bool SendFriendsOnlineIfNeeded(IClientAPI client)
{ {
if (base.SendFriendsOnlineIfNeeded(client)) if (base.SendFriendsOnlineIfNeeded(client))
{
AgentCircuitData aCircuit = ((Scene)client.Scene).AuthenticateHandler.GetAgentCircuitData(client.AgentId);
if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
{ {
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId); UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
if (account == null) // foreign if (account == null) // foreign
@ -124,52 +131,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
} }
} }
} }
}
return false; return false;
} }
protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online) protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
{ {
// Let's single out the UUIs List<string> fList = new List<string>();
List<string> localFriends = new List<string>();
List<string> foreignFriends = new List<string>();
string tmp = string.Empty;
foreach (string s in friendList) foreach (string s in friendList)
{ fList.Add(s.Substring(0, 36));
UUID id;
if (UUID.TryParse(s, out id))
localFriends.Add(s);
else if (Util.ParseUniversalUserIdentifier(s, out id, out tmp, out tmp, out tmp, out tmp))
{
foreignFriends.Add(s);
// add it here too, who knows maybe the foreign friends happens to be on this grid
localFriends.Add(id.ToString());
}
}
// OK, see who's present on this grid PresenceInfo[] presence = PresenceService.GetAgents(fList.ToArray());
List<string> toBeRemoved = new List<string>();
PresenceInfo[] presence = PresenceService.GetAgents(localFriends.ToArray());
foreach (PresenceInfo pi in presence) foreach (PresenceInfo pi in presence)
{ {
UUID presenceID; UUID presenceID;
if (UUID.TryParse(pi.UserID, out presenceID)) if (UUID.TryParse(pi.UserID, out presenceID))
{
online.Add(presenceID); online.Add(presenceID);
foreach (string s in foreignFriends)
if (s.StartsWith(pi.UserID))
toBeRemoved.Add(s);
} }
} }
foreach (string s in toBeRemoved) //protected override void GetOnlineFriends(UUID userID, List<string> friendList, /*collector*/ List<UUID> online)
foreignFriends.Remove(s); //{
// // Let's single out the UUIs
// List<string> localFriends = new List<string>();
// List<string> foreignFriends = new List<string>();
// string tmp = string.Empty;
// OK, let's send this up the stack, and leave a closure here // foreach (string s in friendList)
// collecting online friends in other grids // {
Util.FireAndForget(delegate { CollectOnlineFriendsElsewhere(userID, foreignFriends); }); // UUID id;
// if (UUID.TryParse(s, out id))
// localFriends.Add(s);
// else if (Util.ParseUniversalUserIdentifier(s, out id, out tmp, out tmp, out tmp, out tmp))
// {
// foreignFriends.Add(s);
// // add it here too, who knows maybe the foreign friends happens to be on this grid
// localFriends.Add(id.ToString());
// }
// }
} // // OK, see who's present on this grid
// List<string> toBeRemoved = new List<string>();
// PresenceInfo[] presence = PresenceService.GetAgents(localFriends.ToArray());
// foreach (PresenceInfo pi in presence)
// {
// UUID presenceID;
// if (UUID.TryParse(pi.UserID, out presenceID))
// {
// online.Add(presenceID);
// foreach (string s in foreignFriends)
// if (s.StartsWith(pi.UserID))
// toBeRemoved.Add(s);
// }
// }
// foreach (string s in toBeRemoved)
// foreignFriends.Remove(s);
// // OK, let's send this up the stack, and leave a closure here
// // collecting online friends in other grids
// Util.FireAndForget(delegate { CollectOnlineFriendsElsewhere(userID, foreignFriends); });
//}
private void CollectOnlineFriendsElsewhere(UUID userID, List<string> foreignFriends) private void CollectOnlineFriendsElsewhere(UUID userID, List<string> foreignFriends)
{ {