View Issue Details

IDProjectCategoryView StatusLast Update
0005169Multi Theft Auto : San AndreasSynchronizationpublic2011-10-18 09:50
Reporterryden Assigned Toccw  
Status resolvedResolutionfixed 
Product Version1.0.3 
Target Version1.2Fixed in Version1.2 
Summary0005169: Optimize puresync and keysync broadcasting

Currently, for every received puresync packet, the player position is checked against all other players to see if it must perform a fast broadcast or a slow broadcast for bandwidth saving (i.e., syncing every 100ticks or every 1000ticks). This is a big bottleneck, specially with high player counts as it's a O(n^2) algorithm. A new method is required, and probably this is a perfect place for multithreading.

TagsNo tags attached.


related to 0005743 resolvedryden Optimize the puresync bandwidth usage for entities out of range 



2010-01-13 02:12

administrator   ~~0010966

Mutithreading shouldn't be required, and will add unnecessary complexity. Instead, write a proper Octtree implementation and use that to find nearby players. Alternatively, just check less often - check every second for example, and allow certain events to force a re-check (teleporting for example).


2011-03-27 11:41

reporter   ~~0013127

Every time someone moves, you have to re-sort him into the Octree...


2011-03-28 19:27

reporter   ~~0013135

Another one of my mental orgasms:


2011-04-23 00:19

administrator   ~~0013216

I don't really understand your verbal explanation for your algorithm. Could you perhaps do some psuedocode?


2011-04-25 20:53

reporter   ~~0013231

I'll try to code it in C or C++ for object pointers, that should be better then tuxedocode.


2011-04-29 15:37

manager   ~~0013272

Not sure if my problem is related to this but they sound similar. We've recently being having 120/128 players most days on the server and its killing our CPU and it seems to go up more and more per player with more players.

Its not our scripts, performancebrowser is reporting no more than 10% usage accross all our scripts yet MTAserver.exe is using 80% to 90% and this isn't some old CPU its an Intel Core2Duo 2x 2.33+ GHz so theres no way in hell MTA could ever manage 200+ players at its current state.


2011-07-15 23:39

reporter   ~~0013983

The problem is nuff said simple:
No matter how you see it, you always got to "check all players against all players" since there is a far syncronisation, too (unless we do it like other games - WoW par example - and DON'T sync people who are too far away).

I checked every single algorithm I could find and that popped up in my mind - some were good, some where stupid, mine were unbearable - and came to the conclusion that its best to "sync" all players once in 5 seconds, sync the 1000 units range once in 1 second and sync - depending on the weapon the both players bear - the vision range once per 100 ms.
UNLESS OF COURSE we only sync the markers for the players in a 1000 units range! Greetings from SA-MP, they are solving it that way...

If you split the "sync all" problem into five problems and sync one problem a second, or, if you split the "sync all" problem into fifty problems and sync them once per 100 ms, the server load wouldn't even jump - and also, it would definitely reduce the problem 50 fold.

Issue History

Date Modified Username Field Change