Skip to content

Commit 1ec041d

Browse files
committed
tm: Add performance measurement logs for both timers
1 parent c6ef3a4 commit 1ec041d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

modules/tm/timer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,11 @@ static void unlink_timers( struct cell *t )
10861086
void timer_routine(unsigned int ticks , void *set)
10871087
{
10881088
struct timer_link *tl, *tmp_tl;
1089+
struct timespec begin;
10891090
int id;
10901091

1092+
clock_gettime(CLOCK_REALTIME, &begin);
1093+
10911094
lock_start_write( timertable[(long)set].ex_lock );
10921095

10931096
for( id=0 ; id<RT_T1_TO_1 ; id++ )
@@ -1111,15 +1114,22 @@ void timer_routine(unsigned int ticks , void *set)
11111114
}
11121115
}
11131116
lock_stop_write( timertable[(long)set].ex_lock );
1117+
1118+
clock_check_diff((double)TM_TIMER_ITV_S*1e9 * TM_TIMER_LOAD_WARN,
1119+
"now at %d%%+ capacity, inuse_transactions: %lu", (int)(TM_TIMER_LOAD_WARN*100),
1120+
(unsigned long)get_stat_val(tm_trans_inuse));
11141121
}
11151122

11161123

11171124

11181125
void utimer_routine(utime_t uticks , void *set)
11191126
{
11201127
struct timer_link *tl, *tmp_tl;
1128+
struct timespec begin;
11211129
int id;
11221130

1131+
clock_gettime(CLOCK_REALTIME, &begin);
1132+
11231133
lock_start_write( timertable[(long)set].ex_lock );
11241134

11251135
for( id=RT_T1_TO_1 ; id<NR_OF_TIMER_LISTS ; id++ )
@@ -1139,5 +1149,9 @@ void utimer_routine(utime_t uticks , void *set)
11391149
}
11401150
}
11411151
lock_stop_write( timertable[(long)set].ex_lock );
1152+
1153+
clock_check_diff((double)TM_UTIMER_ITV_US*1000 * TM_TIMER_LOAD_WARN,
1154+
"now at %d%%+ capacity, inuse_transactions: %lu", (int)(TM_TIMER_LOAD_WARN*100),
1155+
(unsigned long)get_stat_val(tm_trans_inuse));
11421156
}
11431157

modules/tm/timer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "../../rw_locking.h"
3333
#include "lock.h"
3434

35+
#define TM_TIMER_ITV_S 1U
36+
#define TM_UTIMER_ITV_US (100U*1000U)
37+
#define TM_TIMER_LOAD_WARN .75
38+
3539
#define MIN_TIMER_VALUE 2
3640

3741
/* identifiers of timer lists;*/

modules/tm/tm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,12 @@ static int mod_init(void)
862862
/* register the timer functions */
863863
for ( set=0 ; set<timer_sets ; set++ ) {
864864
if (register_timer( "tm-timer", timer_routine,
865-
(void*)(long)set, 1, TIMER_FLAG_DELAY_ON_DELAY) < 0 ) {
865+
(void*)(long)set, TM_TIMER_ITV_S, TIMER_FLAG_DELAY_ON_DELAY) < 0 ) {
866866
LM_ERR("failed to register timer for set %d\n",set);
867867
return -1;
868868
}
869869
if (register_utimer( "tm-utimer", utimer_routine,
870-
(void*)(long)set, 100*1000, TIMER_FLAG_DELAY_ON_DELAY)<0) {
870+
(void*)(long)set, TM_UTIMER_ITV_US, TIMER_FLAG_DELAY_ON_DELAY)<0) {
871871
LM_ERR("failed to register utimer for set %d\n",set);
872872
return -1;
873873
}

0 commit comments

Comments
 (0)