Multiplayer Friendliness

One of the main features of ACOS is multiplayer friendliness. ACOS has a number of ways for reducing server lag and improving gameplay experience.

Techniques
These are some of the techniques ACOS uses to lessen server lag.

Yielding
Since ComputerCraft machines all run in one thread and take part in execution of code, the more machines are online the more the lag for a single machine. Moreover, Lua only features cooperative multitasking. There is always only one program running on a CC machine. When a coroutine is resumed, it blocks the scheduler until it yields. ACOS addresses this issue by applying the ForceYield technology. At first, time taken for a yield of every running application or program is measured. This is an action used for general statistics, not only for multiplayer friendliness improvements. The longest time taken for a yield per application/program is used. Applications or programs that take too long to yield (usually above 1 second) are selected and iterated over, one at a time. ForceYield then iterates over all functions present in the environment of the program or application and replaces them with anonymous proxy functions that add a yield before the function call. These actions are carried out at runtime, during the program's inactivity (after it has yielded). There is a slightly different approach for applications, since they use the ACOS Runtime which is known to the system and does not have to be iterated over (it contains native ForceYield switches). ForceYield also iterates over global tables, their subtables and metatables, seeking more functions that could be replaced with a proxy.

More context switches produced by the new yields slow down the system, because all of them include function calls and add overhead. The stability improvements, however, outweigh this issue.