]> granicus.if.org Git - apache/commitdiff
Turn the worker MPM's queue into a LIFO. This may
authorRyan Bloom <rbb@apache.org>
Tue, 18 Sep 2001 23:09:12 +0000 (23:09 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 18 Sep 2001 23:09:12 +0000 (23:09 +0000)
improve cache-hit performance under some conditions.

Submitted by:   Aaron Bannert <aaron@clove.org>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91077 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/mpm/worker/fdqueue.c
server/mpm/worker/fdqueue.h

diff --git a/CHANGES b/CHANGES
index e8e94c84ea5cd9d7003b5c74ac9c82c5de985794..f81f646ecdc7126a6f24ce9c41d8af78eeb14df8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.26-dev
 
+  *) Turn the worker MPM's queue into a LIFO.  This may
+     improve cache-hit performance under some conditions.
+     [Aaron Bannert <aaron@clove.org>]
+
   *) Switch back to SIGUSR1 for graceful restarts on all platforms that
      support it.  [Justin Erenkrantz]
 
index 8ffc148afc7dc7c235a3cc762823b8b7c726f137..753e6ed1ecb63bd131063f76b7cdb40d1fd0e621 100644 (file)
@@ -73,7 +73,6 @@ static int ap_queue_full(fd_queue_t *queue)
  */
 static int ap_queue_empty(fd_queue_t *queue)
 {
-    /*return (queue->head == queue->tail);*/
     return (queue->blanks >= queue->bounds - 1);
 }
 
@@ -108,7 +107,7 @@ int ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a)
         return FD_QUEUE_FAILURE;
 
     bounds = queue_capacity + 1;
-    queue->head = queue->tail = 0;
+    queue->tail = 0;
     queue->data = apr_palloc(a, bounds * sizeof(fd_queue_elem_t));
     queue->bounds = bounds;
     queue->blanks = queue_capacity;
@@ -144,7 +143,7 @@ int ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p)
 
     queue->data[queue->tail].sd = sd;
     queue->data[queue->tail].p = p;
-    queue->tail = (queue->tail + 1) % queue->bounds;
+    queue->tail++;
     queue->blanks--;
 
     pthread_cond_signal(&queue->not_empty);
@@ -164,6 +163,8 @@ int ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p)
  */
 apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p) 
 {
+    fd_queue_elem_t *elem;
+
     if (pthread_mutex_lock(&queue->one_big_mutex) != 0) {
         return FD_QUEUE_FAILURE;
     }
@@ -180,13 +181,12 @@ apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p)
         }
     } 
     
-    *sd = queue->data[queue->head].sd;
-    *p = queue->data[queue->head].p;
-    queue->data[queue->head].sd = NULL;
-    queue->data[queue->head].p = NULL;
-    if (sd != NULL) {
-        queue->head = (queue->head + 1) % queue->bounds;
-    }
+    queue->tail--;
+    elem = &queue->data[queue->tail];
+    *sd = elem->sd;
+    *p = elem->p;
+    elem->sd = NULL;
+    elem->p = NULL;
     queue->blanks++;
 
     if (pthread_mutex_unlock(&queue->one_big_mutex) != 0) {
index a0efaa003f31b06202150ba09f933d44e333e6d1..7ac951258b2da2aa0d4f32c4e651bbd337ac516e 100644 (file)
@@ -81,7 +81,6 @@ struct fd_queue_elem_t {
 typedef struct fd_queue_elem_t fd_queue_elem_t;
 
 struct fd_queue_t {
-    int                head;
     int                tail;
     fd_queue_elem_t   *data;
     int                bounds;