Skip to content

Commit

Permalink
tm: Add performance measurement logs for both timers
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed May 3, 2023
1 parent c6ef3a4 commit 1ec041d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions modules/tm/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,11 @@ static void unlink_timers( struct cell *t )
void timer_routine(unsigned int ticks , void *set)
{
struct timer_link *tl, *tmp_tl;
struct timespec begin;
int id;

clock_gettime(CLOCK_REALTIME, &begin);

lock_start_write( timertable[(long)set].ex_lock );

for( id=0 ; id<RT_T1_TO_1 ; id++ )
Expand All @@ -1111,15 +1114,22 @@ void timer_routine(unsigned int ticks , void *set)
}
}
lock_stop_write( timertable[(long)set].ex_lock );

clock_check_diff((double)TM_TIMER_ITV_S*1e9 * TM_TIMER_LOAD_WARN,
"now at %d%%+ capacity, inuse_transactions: %lu", (int)(TM_TIMER_LOAD_WARN*100),
(unsigned long)get_stat_val(tm_trans_inuse));
}



void utimer_routine(utime_t uticks , void *set)
{
struct timer_link *tl, *tmp_tl;
struct timespec begin;
int id;

clock_gettime(CLOCK_REALTIME, &begin);

lock_start_write( timertable[(long)set].ex_lock );

for( id=RT_T1_TO_1 ; id<NR_OF_TIMER_LISTS ; id++ )
Expand All @@ -1139,5 +1149,9 @@ void utimer_routine(utime_t uticks , void *set)
}
}
lock_stop_write( timertable[(long)set].ex_lock );

clock_check_diff((double)TM_UTIMER_ITV_US*1000 * TM_TIMER_LOAD_WARN,
"now at %d%%+ capacity, inuse_transactions: %lu", (int)(TM_TIMER_LOAD_WARN*100),
(unsigned long)get_stat_val(tm_trans_inuse));
}

4 changes: 4 additions & 0 deletions modules/tm/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "../../rw_locking.h"
#include "lock.h"

#define TM_TIMER_ITV_S 1U
#define TM_UTIMER_ITV_US (100U*1000U)
#define TM_TIMER_LOAD_WARN .75

#define MIN_TIMER_VALUE 2

/* identifiers of timer lists;*/
Expand Down
4 changes: 2 additions & 2 deletions modules/tm/tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,12 @@ static int mod_init(void)
/* register the timer functions */
for ( set=0 ; set<timer_sets ; set++ ) {
if (register_timer( "tm-timer", timer_routine,
(void*)(long)set, 1, TIMER_FLAG_DELAY_ON_DELAY) < 0 ) {
(void*)(long)set, TM_TIMER_ITV_S, TIMER_FLAG_DELAY_ON_DELAY) < 0 ) {
LM_ERR("failed to register timer for set %d\n",set);
return -1;
}
if (register_utimer( "tm-utimer", utimer_routine,
(void*)(long)set, 100*1000, TIMER_FLAG_DELAY_ON_DELAY)<0) {
(void*)(long)set, TM_UTIMER_ITV_US, TIMER_FLAG_DELAY_ON_DELAY)<0) {
LM_ERR("failed to register utimer for set %d\n",set);
return -1;
}
Expand Down

0 comments on commit 1ec041d

Please sign in to comment.