[Kamailio-Devel] Kamailio Timer Accuracy

Henning Westerholt henning.westerholt at 1und1.de
Thu Sep 25 11:09:52 CEST 2008


On Wednesday 24 September 2008, Jason Penton wrote:
> yes a 1s interval timer registered through the timer API. I then count the
> ticks corresponding to 5 mins (current ticks + (5*60)). At the end the
> stopwatch (wallclock) reads 5min and 20 secs. My question is what the
> impact on for example the Dailog module which relies on these timers for
> timeouts, etc. A timeout on a dialog of for example 3600 will be horribly
> out.

Hi Jason,

i tried to reproduce this inaccuracy with the usrloc timer on my machine this 
morning. I setup them to an 1 second interval, and let them run for 30 
minutes. I incremented a counter in the function, to keep track of the 
seconds, and also used an external stopwatch.

I could not reproduce the problem you described:

Sep 25 10:31:54 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 0
Sep 25 10:32:55 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 60
Sep 25 10:41:55 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 600
Sep 25 10:51:55 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 1200
Sep 25 10:59:56 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 1680
Sep 25 11:01:56 ca ../kamailio[16490]: ERROR:usrloc:timer: timer tick 1800

This step of about 1 seconds is probably caused from the linux timer 
resolution, wich is 1ms on 2.6 kernels. This is also more or less visible on 
the stopwatch. I think this is a reasonable accuracy, given the usage of this 
timers.

Do you use ntpc or chronyd to get a reliable time, and also sync the kernel 
clock on the test machine? Do you use a 2.6 kernel with the default HZ value? 
Perhaps you can also compare to the usrloc timer, here is the code i used:

Index: modules/usrloc/ul_mod.c
===================================================================
--- modules/usrloc/ul_mod.c     (revision 4991)
+++ modules/usrloc/ul_mod.c     (working copy)
@@ -375,12 +375,13 @@
        destroy_ulcb_list();
 }

-
+static unsigned int timer_tick = 0;
 /*! \brief
  * Timer handler
  */
 static void timer(unsigned int ticks, void* param)
 {
+       LM_ERR("timer tick %d", timer_tick++);
        if (synchronize_all_udomains() != 0) {
                LM_ERR("synchronizing cache failed\n");


Cheers,

Henning



More information about the Devel mailing list