Feb 2 2011, 1:36 pm
My project requires more precise ticks per second. The question I pose is, what is the latency increase by setting tick_lag variable to 100 rather than the default 10? A game that would have around 20 players on average, I'm wondering if the lag would be to much to be successfully playable. Any help with this query?
In response to Kaiochao
I'm not sure that's necessarily true. Lowering tick_lag increases the frequency at which the server can send updates to clients but doesn't necessarily change the amount of data sent to clients. If things (locations of mobs, icon states, etc.) aren't changing more frequently, a lower tick_lag shouldn't have a drastic effect on performance.
If you were making a typing game and you wanted to measure how quickly the user types a word, the default tick_lag setting only gives you precision to 0.1 seconds. Lowering the tick_lag would give you more precise timing but would not slow the game down.
It really depends on what the game is like. If you're looking to lower the tick_lag just to make animations look nicer, you shouldn't need to go much over 35 fps. A tick_lag of 0.5 (20 fps) makes things look much nicer.
world.tick_lag is 1 by default. If you set it to 0.1, you can actually sleep 10ms, instead of 100ms. However, if player holds macro with repeat, it'll send packet 100 times per second, instead of 10 times. So it can be very dangerous depending on your macros.
To sleep for 10ms, set world.tick_lag = 0.1, and use sleep(world.tick_lag), it gets rounded to 0 or something, and sleep for one tick, which is 0.01 second. If you'll need 0.05 second sleep just make own proc:
In response to Ripiz
That's not quite how it works.
"The duration of events that take some finite amount of time (like sleep) will be rounded to a whole number of ticks."
sleep() automatically rounds the duration to the nearest multiple of tick_lag. So if you set it to 0.1 (which might not be a good idea, as most lower-level C++ games can't even manage 100 FPS) it will allow sleep(0.5) without any other changes. If you set it to 0.8, and try to sleep for 1 tick, it will actually sleep for 0.8 ticks.
Lowering the tick lag gives you the ability to have events occur more than 10 times per second. Your game doesn't have to use that potential. My pixel movement demos do utilize the faster framerate and the movement event does fire 30 - 40 times per second. In spies the tick lag is 0.5 but the players aren't allowed to move 20 times per second. The game has the potential to process more events and send more updates to clients but it really doesn't. There is bound to be some difference in performance (because the screen is redrawn more), but its not like CPU and bandwidth usage will double just because tick lag was cut in half.
Why would a quad core help? I was under the impression that Daemon can only utilize one core.
You can adjust your mob's pixel_step_size to make them move more slowly between tiles. Testing at a tick_lag of 0.1 with a movement delay of 3 ticks, a pixel_step_size of 1 looks pretty good.
Also, again, I would advise against a tick_lag value as low as 0.1 for a multiplayer game.
What size would you suggest? 0.1 has what i need, but i don't want to game to lag too bad. What would you do for this, to allow the players to experience good gameplay, but still delve into the 100ths of seconds range that i need?...
I don't think it's possible to have a game hosted across the internet with a response time of 10ms--at least not without heavy client-side support.
I don't have much personal experience hosting a server with that many players at a reduced tick_lag, but I do know that on anything but a godly internet connection, Decadence struggles with 16 players, and Casual Quest struggles with 10 or so. I don't know what tick_lag they're running at, but I would guess it's a far cry from 0.1.
I'd need to know more about your game to offer good alternatives, but if it's an action game, you may have to lax your standards. If it was turn-based, or you were looking for some kind spellcasting system, you may be able to get the responsiveness you need through an embedded Flash game.
The issue you get with BYOND's server is two-fold really.
On the one hand, increasing updates as described here has the potential to increase traffic to clients. In your particular case, this is a feature you are looking to use through faster player movement, quick-cast spells and so on. This invariably increases server load, as you noted.
The second matter now comes into play. BYOND only executes your DM code on one "thread" of execution. This, in rather basic terms, means the bulk of your DM code can only use one core on a CPU. You'd see no principle major difference in performance between a single core CPU like a Pentium 4, and a quad-core CPU like an i7.
I would note I said basically, as clearly there are some other factors at work that make my statement rather iffy, however the underlying concept is you can't just double the number cores on the server CPU and expect to see a doubling of BYOND server performance.
Regarding your second question, a web server is essentially the same as your home PC, or any other server. It just has some software on it to handle giving people web-pages. What you want is something like a VPS, as I understand it. This will help, as the hardware is perhaps less loaded than someone's PC, the bandwidth is more available to BYOND to give people updates and so on.
However ultimately, there will be a crunch point, where client performance becomes untenable because the server is simply too loaded to execute everything satisfactorily. At this point, you need to start getting very clever with your code, looking to share the burden among more BYOND servers for example.
In conclusion though, try it and see. There is a certain danger that you get sufficiently bogged down with these performance woes that you never actually progress with your game, and so never release it for the world to play. If a problem does arise after you release, we can certainly help you address it here.
Mr. Stephen Badger (MEng)
Setting it to 100 or even 10 will make the game pretty much barely move at all, so you should try restating your question.