ID:151413
 
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?
tick_lag defaults to 1, which is 1/10th of a second. Setting it higher will make the game slower, and setting it lower will make it faster(but there's no guarantee that clients will actually see every frame of anything).
Setting it to 100 or even 10 will make the game pretty much barely move at all, so you should try restating your question.
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.
In response to Forum_account
Increasing the Tick lag has always increased performance in a game, faster actions can result in more accurate events or longer procedures to be carried out faster. However it does put great wear on the CPU. Using a 3.6ghz single core, I can get up to 80% with the pixel movement Demos. It looks fantastic, but it's best when run with a quad core over 3ghz which is not cheap.
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:

proc/Sleep(ticks)
for(var/i = 0; i < ticks; i++)
sleep(world.tick_lag)
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.
In response to DarkCampainger
sleep(0.5) seems to work, but it also sleeps 0.01 second with custom proc.

world
tick_lag = 0.1

proc/Sleep(tick)
for(var/i = 0; i < tick; i++)
sleep(world.tick_lag)

mob/verb/test()
spawn()
for(var/i = 1; i <= 10; i++)
sleep(1)
world << "sleep(1) [i/10] seconds passed"
spawn()
for(var/i = 0; i < 20; i++)
sleep(0.5)
world << "sleep(0.5)"
spawn()
Sleep(10)
world << "Sleep(10)"
spawn()
Sleep(30)
world << "Sleep(30)"
spawn()
Sleep(75)
world << "Sleep(75)"
spawn()
Sleep(76)
world << "Sleep(76)"
spawn()
Sleep(74)
world << "Sleep(74)"
spawn()
Sleep(71)
world << "Sleep(71)"


Result:
sleep(0.5)
sleep(1) 0.1 seconds passed
sleep(0.5)
Sleep(10)
sleep(0.5)
sleep(1) 0.2 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 0.3 seconds passed
sleep(0.5)
Sleep(30)
sleep(0.5)
sleep(1) 0.4 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 0.5 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 0.6 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 0.7 seconds passed
sleep(0.5)
Sleep(71)
Sleep(74)
sleep(0.5)
Sleep(75)
Sleep(76)
sleep(1) 0.8 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 0.9 seconds passed
sleep(0.5)
sleep(0.5)
sleep(1) 1 seconds passed
sleep(0.5)
In response to Bravo1
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.
In response to Bravo1
Why would a quad core help? I was under the impression that Daemon can only utilize one core.
In response to Forum_account
For me it did, but only when it came to the map in isometric format. When using the regular 2d model it doesn't interfere. I should have stated that before and I apologize for making pixel_movement seem like a process hog.

It only occurs in Isometric maps, it seems like redrawing for isometric is done with a much more difficult process and as a result the game can lag tremendously after a few objects are introduced to the map. I was using a 40x40 map with under 100 objects on it and my game was near unplayable due to the redraw rate being upped from the tick lag. It works fine for small maps but with the kind of project lead I am, I like to have multiple furnishings and scenery on my maps, causing them to require a lower tick lag (for isometric)

tl;dr It only happens when tick lag is lowered for isometric maps and there's a lot of objects on the map at once.
In response to Bravo1
Bravo1 wrote:
For me it did, but only when it came to the map in isometric format. When using the regular 2d model it doesn't interfere. I should have stated that before and I apologize for making pixel_movement seem like a process hog.

But it is a CPU hog =)

My point is that the server does stuff each tick. By lowering world.tick_lag there are more ticks per second, meaning there are more opportunities for the server to process things. Aside from re-drawing the screen, what will cause a performance hit is when the game uses those extra ticks to do more processing.
In response to Forum_account
Thank you so much for the comments, it's really helping me see how tick_lag actually works in and of itself. The most i ever plan to reduce tick_lag is to 0.1. Seeing as how that lets me do everything i need without globing up and stopping the system. The main point of the tick lag this low is for casting times and attack speeds. That's all i'll ever really call it for. Reading through the thread, this is a very interesting debate on how one would properly use the system, and i thank everyone involved. I have my questions answered and all i need to do is test it out and check my options at the current moment. Again, thank you for all the help, and i hope to have my project up within a month or two.

-Lily S. Deliroso

[EDIT]
While testing the tick_lag, it doesn't have any problems, except that the time to move from one tile to another is reduced by 10. I'm talking about the animation itself. I have my delay set to where they can't move to another tile until a certain amount of time has passed, but this simply results in short, choppy, and horrible movement. Can anyone help me amend this problem?

The tick _lag is set to 0.1 and does everything right. But when i move, it shifts to the entered tile in a 10th of the time, but the delay remains the same, constantly starting and stopping. Do you get what i'm trying to say?...
In response to DarkLily762
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.
In response to DarkCampainger
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?...
In response to DarkLily762
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.
In response to DarkLily762
I can understand that 0.1 second ticks aren't precise enough. But, I don't think you need 0.01 second ticks to have sufficient precision.

With the default tick lag you can have an attack delay alternate between 0.2 and 0.3 seconds. This results in a max of four attacks per second, which is like having a 0.25 second attack speed but the tick lag hasn't been lowered. The attack delays don't need to alternate, you can use different sequences of delays to create any attack speed. I don't have a link handy but I believe someone has posted a general implementation of these types of delays on the forum.
In response to DarkCampainger
The game is a Real-time Combat RPG. Think of something that uses somewhat similar mechanics to World of Warcraft. I need to be able to utilize things like for example, Haste (or in my game's case, Attack/Spell Speed). It increases your attack speed and casting speed in 0.01 second increments. More or less it's for running speed, something like mounts and speed boosts would quickly cap the movement speed delay at 0tps if it's default is 4tps (like it currently is). As i understand it's not a run-time issue, it's a server-side processing issue. It process's only as fast as the host computer can. So if that's the problem, would it be possible to set up a Web server to run my game on? Just a few questions so i can kill two birds with one stone.
In response to DarkLily762
Bump
In response to DarkLily762
I would suggest going with Forum_Account's idea.

Maybe implement it where you sleep for the delay rounded (or floored) to the nearest multiple of tick_lag, and then carry over the remainder to the next delay. It will effectively limit them to 'x' actions per minute, even if each action isn't individually delayed for an exact amount.
In response to DarkLily762
Dear Lily,

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.

Yours faithfully,
Mr. Stephen Badger (MEng)
Page: 1 2