19275 Posts in 3161 Topics - by 6136 Members - Latest Member: pango

Author Topic: [programming] netcode and lua optimization recommendation  (Read 87 times)

Gordo

  • Newbie
  • *
  • Posts: 3
    • View Profile
[programming] netcode and lua optimization recommendation
« on: June 19, 2017, 03:11:05 AM »
I just had a minor suggestion for your net-code optimisation, as I have had a similar issue you are facing with your game.

Currently I predict your model to be this for networking
clientside-lua <-> game <-> client-socket <-> server-socket <-> server lua

if this is so, each server tick waits for all objects and entities to finish updating.

The problem is if the objects updating takes longer than a server tick, the server starts to stutter. (you know this already; i know)

Couldn't you change the model of the game to use the lua yield statements in a co-routine to exit prematurely out of expensive AI code, so that you can send client updates of model positions and other network data, before all objects are finished updating.

This would mean that you could send entity states prematurely, this would also be chunking the update.

Thus you would potentially be saving a larger portion of time.

Also, I highly recommend using LuaJIT as it's a lot faster than standard Lua. (if you use FFI properly and wrap your userdata cleverly) updating to this alone would probably save you having to manually optimise.

Gordo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: [programming] netcode and lua optimization recommendation
« Reply #1 on: June 19, 2017, 04:59:42 PM »
I just had a minor suggestion for your net-code optimisation, as I have had a similar issue you are facing with your game.

Currently I predict your model to be this for networking
clientside-lua <-> game <-> client-socket <-> server-socket <-> server lua

if this is so, each server tick waits for all objects and entities to finish updating.

The problem is if the objects updating takes longer than a server tick, the server starts to stutter. (you know this already; i know)

Couldn't you change the model of the game to use the lua yield statements in a co-routine to exit prematurely out of expensive AI code, so that you can send client updates of model positions and other network data, before all objects are finished updating.

This would mean that you could send entity states prematurely, this would also be chunking the update.

Thus you would potentially be saving a larger portion of time.

Also, I highly recommend using LuaJIT as it's a lot faster than standard Lua. (if you use FFI properly and wrap your userdata cleverly) updating to this alone would probably save you having to manually optimise.

The performance comparison to JIT compilation turned off.
http://luajit.org/performance_x86.html