SphereCommunity
Timerd not working properly? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Timerd not working properly? (/Thread-Timerd-not-working-properly)

Pages: 1 2


RE: Timerd not working properly? - karma - 01-18-2016 07:22 PM

The problem is that timerd is imprecise and unreliable for "precision" timing; it would be still acceptable an error of +-0.2, but right now it's bigger.
Consider this, on a vanilla sphere (default scripts, empty world) running on a i7:
Code:
10:13:(funzioni.scp,14)timerd: 6245; it should trigger at 6260
10:13:1:'dnolok' commands 'timerdtest 15'=1
10:13:(funzioni.scp,7)timerd fired: 6263
10:13:(funzioni.scp,14)timerd: 6283; it should trigger at 6298
10:13:1:'dnolok' commands 'timerdtest 15'=1
10:13:(funzioni.scp,7)timerd fired: 6303
10:13:(funzioni.scp,14)timerd: 6333; it should trigger at 6348
10:13:1:'dnolok' commands 'timerdtest 15'=1
10:13:(funzioni.scp,7)timerd fired: 6353
10:13:(funzioni.scp,14)timerd: 6361; it should trigger at 6376
10:13:1:'dnolok' commands 'timerdtest 15'=1
10:13:(funzioni.scp,7)timerd fired: 6383

In this case the problem may not be the performance.


RE: Timerd not working properly? - karma - 01-21-2016 09:47 PM

Precision is very randomic, sometimes it's very precise, but usually it is not. The issue is major when you set TIMERD = 1 or 2 rather than 12 or 15, since you expect a very close response and you can wait for it even for more than a second.

Code:
:43:(test.scp,14)timerd: 76961229; it should trigger at 76961231
12:43:1:'dnolok' commands 'timerdtest 2'=1
12:43:(test.scp,7)timerd fired: 76961231
12:43:(test.scp,14)timerd: 76961300; it should trigger at 76961302
12:43:1:'dnolok' commands 'timerdtest 2'=1
12:43:(test.scp,7)timerd fired: 76961311
12:43:(test.scp,14)timerd: 76961319; it should trigger at 76961321
12:43:1:'dnolok' commands 'timerdtest 2'=1
12:43:(test.scp,7)timerd fired: 76961321
12:43:(test.scp,14)timerd: 76961335; it should trigger at 76961336
12:43:1:'dnolok' commands 'timerdtest 1'=1
12:43:(test.scp,7)timerd fired: 76961341
12:43:(test.scp,14)timerd: 76961380; it should trigger at 76961381
12:43:1:'dnolok' commands 'timerdtest 1'=1
12:43:(test.scp,7)timerd fired: 76961381
12:43:(test.scp,14)timerd: 76961390; it should trigger at 76961391
12:43:1:'dnolok' commands 'timerdtest 1'=1
12:43:(test.scp,7)timerd fired: 76961391
12:43:(test.scp,14)timerd: 76961403; it should trigger at 76961404
12:43:1:'dnolok' commands 'timerdtest 1'=1
12:43:(test.scp,7)timerd fired: 76961411
12:43:(test.scp,14)timerd: 76961494; it should trigger at 76961495
12:43:1:'dnolok' commands 'timerdtest 1'=1
12:43:(test.scp,7)timerd fired: 76961501
12:43:(test.scp,14)timerd: 76961508; it should trigger at 76961511
12:43:1:'dnolok' commands 'timerdtest 3'=1
12:43:(test.scp,7)timerd fired: 76961511
12:43:(test.scp,14)timerd: 76961541; it should trigger at 76961543
12:43:1:'dnolok' commands 'timerdtest 2'=1
12:43:(test.scp,7)timerd fired: 76961551



RE: Timerd not working properly? - rastrero - 01-22-2016 12:51 AM

Should be nice if its fixed...

I use timerd for many functions of effect.

Anyway I can fix this by my self? Or to help u with?


RE: Timerd not working properly? - karma - 01-22-2016 02:57 AM

I don't know the source so well to be able to fix a complex thing like this ^^'


RE: Timerd not working properly? - karma - 02-07-2016 05:10 AM

Up. Is there a way to fix this?


RE: Timerd not working properly? - ForesteR - 02-07-2016 05:23 AM

and TimerCall=1 on ini run in 14-15 min... i think =1 is equal 1min.. no?


RE: Timerd not working properly? - karma - 02-07-2016 10:11 PM

Yes but this would solve what? ^^' TimerCall is the amount of minutes to call f_onserver_timer.


RE: Timerd not working properly? - ForesteR - 02-08-2016 01:42 AM

i think is the same problem on others ticks


RE: Timerd not working properly? - Coruja - 02-15-2016 10:45 AM

probably it happen because the main internal timer on sphere (including <SERV.TIME>) is based on CPU clocks (ticks per second) instead system time (miliseconds)

system time is a timestamp based on real calendar time, but system ticks is a timestamp based on CPU clocks since latest system restart, which does the job if you don't need much precision, but if you need it (like in topic example) it won't have a perfect timer because every CPU has a difference of 10~20ms between each tick

so maybe there's nothing left to do in this case, there's no way to get perfect timers or <SERV.TIME> values unless change the sphere main internal timer to use system time (miliseconds) instead CPU clock (ticks per second). It's not difficult to change it, but honestly I don't know if this will bring any advantage since ~maybe~ this could make sphere consume more CPU usage


RE: Timerd not working properly? - karma - 02-17-2016 07:30 PM

If the change isn't difficult and doesn't break anything i would give it a try (even if it would be better to read other opinions on the CPU usage).