2
0
Эх сурвалжийг харах

-bug fix: tm insert_timer used to eat too much cpu, decreasing dramatically
the performance if lots of calls per second are made (unstable test results:
~1500 cps w/o the bugfix and ~6000 with the bug fix)

Andrei Pelinescu-Onciul 20 жил өмнө
parent
commit
31d248f4a0
2 өөрчлөгдсөн 14 нэмэгдсэн , 4 устгасан
  1. 1 1
      Makefile.defs
  2. 13 3
      modules/tm/timer.c

+ 1 - 1
Makefile.defs

@@ -59,7 +59,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 9
 SUBLEVEL = 5
-EXTRAVERSION = -pre3
+EXTRAVERSION = -pre4
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 13 - 3
modules/tm/timer.c

@@ -640,7 +640,12 @@ static void remove_timer_unsafe(  struct timer_link* tl )
 	}
 }
 
+/* undefine TIMER_ORDERED for a little bit more performance at the expense of
+ * the variable fr_inv_timers */
+#define TIMER_ORDERED
+/*#define TIMER_SKIP_DELETED */
 
+#ifdef TIMER_ORDERED /* can be very slow if coupled with TIMER_SKIP_DELETED */
 /* put a new cell into a list nr. list_id */
 static void insert_timer_unsafe( struct timer *timer_list, struct timer_link *tl,
 	unsigned int time_out )
@@ -653,7 +658,11 @@ static void insert_timer_unsafe( struct timer *timer_list, struct timer_link *tl
 	for(ptr = timer_list->last_tl.prev_tl; 
 	    ptr != &timer_list->first_tl; 
 	    ptr = ptr->prev_tl) {
-		if ((ptr->time_out != TIMER_DELETED) && (ptr->time_out <= time_out)) break;
+		if (
+#ifdef TIMER_SKIP_DELETED
+				(ptr->time_out != TIMER_DELETED) && 
+#endif
+				(ptr->time_out <= time_out)) break;
 	}
 
 	tl->prev_tl = ptr;
@@ -664,9 +673,8 @@ static void insert_timer_unsafe( struct timer *timer_list, struct timer_link *tl
 	DBG("DEBUG: add_to_tail_of_timer[%d]: %p\n",timer_list->id,tl);
 }
 
+#else
 
-
-#if 0  /* not used anymore */
 /* put a new cell into a list nr. list_id */
 static void add_timer_unsafe( struct timer *timer_list, struct timer_link *tl,
 	unsigned int time_out )
@@ -693,6 +701,8 @@ static void add_timer_unsafe( struct timer *timer_list, struct timer_link *tl,
 #endif
 	DBG("DEBUG: add_timer_unsafe[%d]: %p\n",timer_list->id,tl);
 }
+
+#define insert_timer_unsafe(tlist, tl, to) add_timer_unsafe((tlist),(tl),(to))
 #endif