]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] reduce the number of calls to task_wakeup()
authorWilly Tarreau <w@1wt.eu>
Fri, 29 Aug 2008 13:26:14 +0000 (15:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Nov 2008 09:19:07 +0000 (10:19 +0100)
A test has shown that more than 16% of the calls to task_wakeup()
could be avoided because the task is already woken up. So make it
inline and move the test to the inline part.

include/proto/task.h
src/task.c

index 10f6b42f6aa09ce7655035bf924b05a4d192c158..fbb9ee891ab7ee90e8ba55eeb0557b2dfbb0ab79 100644 (file)
@@ -41,7 +41,13 @@ extern struct task *last_timer;   /* optimization: last queued timer */
 int init_task();
 
 /* puts the task <t> in run queue <q>, and returns <t> */
-struct task *task_wakeup(struct task *t);
+struct task *__task_wakeup(struct task *t);
+static inline struct task *task_wakeup(struct task *t)
+{
+       if (t->state == TASK_RUNNING)
+               return t;
+       return __task_wakeup(t);
+}
 
 /* removes the task <t> from the run queue if it was in it.
  * returns <t>.
index 15539c234b78f90440e5ea6d5a3eef88a894e879..5182b8170c0b48d654710a89fd26b767794f4bda 100644 (file)
@@ -131,11 +131,8 @@ int init_task()
  * size. A nice value of -1024 sets the task to -run_queue*32, while a nice
  * value of 1024 sets the task to run_queue*32.
  */
-struct task *task_wakeup(struct task *t)
+struct task *__task_wakeup(struct task *t)
 {
-       if (t->state == TASK_RUNNING)
-               return t;
-
        task_dequeue(t);
 
        run_queue++;
@@ -231,7 +228,7 @@ void wake_expired_tasks(int *next)
 
                        /* detach the task from the queue and add the task to the run queue */
                        eb = eb32_next(eb);
-                       task_wakeup(task);
+                       __task_wakeup(task);
                }
                tree = (tree + 1) & TIMER_TREE_MASK;
        } while (((tree - now_tree) & TIMER_TREE_MASK) < TIMER_TREES/2);