Author Topic: performance of SendImmediate()  (Read 2693 times)

imays

  • Not-a-newbie
  • *
  • Posts: 32
  • Karma: -1
    • View Profile
performance of SendImmediate()
« on: March 05, 2006, 01:32:33 AM »
I profiled my server with hundreds of simultaneous connections and found that SendImmediate() takes much time here:

Code: [Select]
for ( remoteSystemIndex = 0; remoteSystemIndex < remoteSystemListSize; remoteSystemIndex++ )
    {
        if ( remoteSystemList[ remoteSystemIndex ].playerId != UNASSIGNED_PLAYER_ID &&
            ( ( broadcast == false && remoteSystemList[ remoteSystemIndex ].playerId == playerId ) ||
            ( broadcast == true && remoteSystemList[ remoteSystemIndex ].playerId != playerId ) )   )
                sendList[sendListSize++]=remoteSystemIndex;
    }


There would be few cases where the case (broadcast == true) is needed on MMO game server so that it may be not so efficient in performance to iterate every remoteSystemList[] for every SendImmediate() calls, I think. I guess it will be a good way to improve it via another faster lookup collections such as hashed map or red-black tree such as std::hash_map() or std::map() for the case of broadcase==false.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: performance of SendImmediate()
« Reply #1 on: March 06, 2006, 06:32:16 PM »
The problem is both threads use that array and that only works because it's a fixed block with members that are not shifted around.  I'll look at how hard it is to have a secondary sorted array of pointers so I can do fast lookups for individual sends.