On Thu, Feb 20, 2020 at 1:59 PM Eric Covener <cove...@gmail.com> wrote: > > > Index: server/mpm/event/event.c > > =================================================================== > > --- server/mpm/event/event.c (revision 1874247) > > +++ server/mpm/event/event.c (working copy) > > @@ -1218,7 +1218,7 @@ > > * timeout today. With a normal client, the socket will be > > readable in > > * a few milliseconds anyway. > > */ > > - cs->queue_timestamp = apr_time_now(); > > + cs->queue_timestamp = apr_time_now() + TIMEOUT_FUDGE_FACTOR; > > notify_suspend(cs); > > > > /* Add work to pollset. */ > > This has the unfortunate property that under low load you see the > extra 100ms every time. In the same env today you see it pretty much > exact. > Maybe Yann has something better.
Something like the attached patch maybe? i.e. limiting wakeups when updating queues_next_expiry, yet using the current/real time when processing/cleaning the queues (once woken up already).
Index: server/mpm/event/event.c =================================================================== --- server/mpm/event/event.c (revision 1874061) +++ server/mpm/event/event.c (working copy) @@ -1734,7 +1734,7 @@ static void process_timeout_queue(struct timeout_q */ apr_time_t q_expiry = cs->queue_timestamp + qp->timeout; apr_time_t next_expiry = queues_next_expiry; - if (!next_expiry || next_expiry > q_expiry) { + if (!next_expiry || next_expiry > q_expiry + TIMEOUT_FUDGE_FACTOR) { queues_next_expiry = q_expiry; } break; @@ -2163,8 +2163,6 @@ static void * APR_THREAD_FUNC listener_thread(apr_ * with and without wake-ability. */ if (timeout_time && timeout_time < (now = apr_time_now())) { - timeout_time = now + TIMEOUT_FUDGE_FACTOR; - /* handle timed out sockets */ apr_thread_mutex_lock(timeout_mutex); @@ -2176,16 +2174,16 @@ static void * APR_THREAD_FUNC listener_thread(apr_ process_keepalive_queue(0); /* kill'em all \m/ */ } else { - process_keepalive_queue(timeout_time); + process_keepalive_queue(now); } /* Step 2: write completion timeouts */ - process_timeout_queue(write_completion_q, timeout_time, + process_timeout_queue(write_completion_q, now, start_lingering_close_nonblocking); /* Step 3: (normal) lingering close completion timeouts */ - process_timeout_queue(linger_q, timeout_time, + process_timeout_queue(linger_q, now, stop_lingering_close); /* Step 4: (short) lingering close completion timeouts */ - process_timeout_queue(short_linger_q, timeout_time, + process_timeout_queue(short_linger_q, now, stop_lingering_close); apr_thread_mutex_unlock(timeout_mutex);