by ckitching » 30 Jun 2016, 22:18
When you give an order, the game always schedules it a certain amount in the future, not right now. (I think it's either half a second or 1 second right now, can't remember, it's tunable).
The reason for this is that for each simulation timestep to be displayed, your computer has to have received all the orders that everyone wants to make in that timestep. If you scheduled the order for right now, then the simulation would have to stop for everyone until your order has been sent to everybody. By scheduling your order a little bit in the future, the game has some time to synchronise before that order has to happen, so your simulation doesn't freeze.
When you see a game freeze and someone is "behind", that's basically what has happened: the simulation has caught up with the command stream and we're now stuck waiting for someone to tell us their orders (even if it's nothing) for this step so we can carry on.
The tradeoff is there is a delay between giving an order and anything happening (but units that were already carrying out orders don't freeze in place).
This isn't something to be "fixed", that's just how it is. Almost everything that comes out of your threads to do with "reducing UI lag by avoiding memory fragmentation" and suchlike has little to no technical merit. Would you like a tinfoil hat?