You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2014/12/28 23:41:41 UTC

[Bug 57399] New: Many unnecessary CPU wakeups per second

https://issues.apache.org/bugzilla/show_bug.cgi?id=57399

            Bug ID: 57399
           Summary: Many unnecessary CPU wakeups per second
           Product: Apache httpd-2
           Version: 2.4.10
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mpm_event
          Assignee: bugs@httpd.apache.org
          Reporter: andersk@mit.edu

PowerTOP shows httpd waking up 20 times per second on a completely idle server.
 This is wasteful of CPU time and power, especially on a laptop or a virtual
machine.  The biggest culprit appears to be the following code in
server/mpm/event/event.c:

        apr_thread_mutex_lock(g_timer_skiplist_mtx);
        te = apr_skiplist_peek(timer_skiplist);
        if (te) {
            if (te->when > now) {
                timeout_interval = te->when - now;
            }
            else {
                timeout_interval = 1;
            }
        }
        else {
            timeout_interval = apr_time_from_msec(100);
        }
        apr_thread_mutex_unlock(g_timer_skiplist_mtx);

        rc = apr_pollset_poll(event_pollset, timeout_interval, &num, &out_pfd);

which says if there’s no reason to wake up, wake up every 100 ms anyway. 
apr_time_from_msec(100) should be replaced with -1.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 57399] Many unnecessary CPU wakeups per second

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57399

--- Comment #2 from Anders Kaseorg <an...@mit.edu> ---
Looking at that code, if replacing 100 ms with -1 would cause the server to
miss timers registered when no timers are in progress, then it must already be
the case that the server will miss timers registered when a longer timer is in
progress.  I assumed that, for correctness, anything that registers an earlier
timer must also arrange for the listener thread to break out of its current
apr_pollset_poll (either via an FD event or via a signal) so that it can be
restarted with a lower timeout.  If that isn’t already the case, it should be
fixed either way.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 57399] Many unnecessary CPU wakeups per second

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57399

--- Comment #1 from Eric Covener <co...@gmail.com> ---
> which says if there’s no reason to wake up, wake up every 100 ms anyway. 
> apr_time_from_msec(100) should be replaced with -1.

Wouldn't the server then miss timer events registered and fired while there is
no poll activity in the server?  Maybe we could document the limited features
that use timers and expose the 100ms number as configuration.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org