Strange behavior: Timers and the sleep variable
#1

According to this post, setting the sleep variable to a lower value should increase server performance, because the server's idle time after each "round" of processing input is decreased. It does, but there is a problem: The timers won't work correctly anymore (at least for me)...

It seems that the interval specified in SetTimer(Ex) is increased when lowering the sleep value from 5 (standard) to 1.

I tried to measure it by setting a timer to 20 seconds (20000ms), giving the timer function a start timestamp (GetTickCount() and gettime()) as arguments.
Код:
SetTimerEx("TimerFunction", 20000, 0, "ii", GetTickCount(), gettime());
The Timer function prints the difference between GetTickCount() and the old tickcount from the argument and does the same for gettime() to check how much time has passed since the timer has been started.

So I changed the sleep variable using rcon and then started the timer.
Here are the results:

Windows 7 (only I was on the server):
Код:
[12:46:37] sleep 20: ticks 20528, seconds 21
[12:46:57] sleep 19: ticks 20532, seconds 20
[12:47:18] sleep 18: ticks 20576, seconds 21
[12:47:38] sleep 17: ticks 20609, seconds 20
[12:47:59] sleep 16: ticks 20657, seconds 21
[12:48:20] sleep 15: ticks 20683, seconds 21
[12:48:40] sleep 14: ticks 20736, seconds 20
[12:49:01] sleep 13: ticks 20777, seconds 21
[12:49:22] sleep 12: ticks 20867, seconds 21
[12:49:43] sleep 11: ticks 20930, seconds 21
[12:50:04] sleep 10: ticks 21042, seconds 21
[12:50:25] sleep 9: ticks 21145, seconds 21
[12:50:47] sleep 8: ticks 21334, seconds 22
[12:51:08] sleep 7: ticks 21544, seconds 21
[12:51:30] sleep 6: ticks 21773, seconds 22
[12:51:52] sleep 5: ticks 22207, seconds 22
[12:52:15] sleep 4: ticks 22824, seconds 23
[12:52:39] sleep 3: ticks 23858, seconds 24
[12:53:05] sleep 2: ticks 26619, seconds 26
[12:53:45] sleep 1: ticks 40034, seconds 40
Debian 5 (only I was on the server; somehow the automatic sleep-value-changing-method didn't work, so I changed it manually and then started the timer):
Код:
[13:39:26] sleep 20: ticks 20055, seconds 20
[13:40:11] sleep 18: ticks 20069, seconds 20
[13:40:49] sleep 10: ticks 20146, seconds 21
[13:41:24] sleep 5: ticks 20306, seconds 21
[13:41:55] sleep 3: ticks 20480, seconds 20
[13:42:25] sleep 2: ticks 20696, seconds 21
[13:43:01] sleep 1: ticks 21459, seconds 21
Debian 5 (about 380 players):
Код:
[14:13:30] sleep 20: ticks 20401, seconds 20
[14:14:07] sleep 10: ticks 21303, seconds 21
[14:15:10] sleep 5: ticks 22537, seconds 22
[14:16:01] sleep 4: ticks 23089, seconds 23
[14:16:34] sleep 3: ticks 23872, seconds 23
[14:17:08] sleep 2: ticks 25392, seconds 26
[14:17:46] sleep 1: ticks 29690, seconds 30
Is there a way to solve this problem? Or at least an explaination for this phenomenon?
And if there is some method or formula behind this behaviour, does someone know it, so you can calculate the appropriate timer interval to circumvent the problem?

Regards,

Webflori
Reply
#2

You will not achieve anything by lowering the sleep var, fiddle with the stream_rate if you want to increase performance. That said, I have no idea why timers would screw up as they should be based on server time rather than number of ticks (which change when you fiddle with sleep). Pass ProcessTick from a plugin to pawn if you want to make a remotely accurate timer system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)