httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1407533 [1/3] - in /httpd/httpd/trunk/server/mpm: ./ eventopt/
Date Fri, 09 Nov 2012 16:41:13 GMT
Author: jim
Date: Fri Nov  9 16:41:12 2012
New Revision: 1407533

URL: http://svn.apache.org/viewvc?rev=1407533&view=rev
Log:
Pull the event optimization MPM back into trunk. This
provides more eyes and allows work to continue on
it...

Added:
    httpd/httpd/trunk/server/mpm/eventopt/
    httpd/httpd/trunk/server/mpm/eventopt/Makefile.in   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/config.m4   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/config3.m4   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/equeue.c   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/equeue.h   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/eventopt.c   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/fdqueue.c   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/fdqueue.h   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/mpm_default.h   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/pod.c   (with props)
    httpd/httpd/trunk/server/mpm/eventopt/pod.h   (with props)
Modified:
    httpd/httpd/trunk/server/mpm/config2.m4

Modified: httpd/httpd/trunk/server/mpm/config2.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/config2.m4?rev=1407533&r1=1407532&r2=1407533&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/config2.m4 (original)
+++ httpd/httpd/trunk/server/mpm/config2.m4 Fri Nov  9 16:41:12 2012
@@ -1,7 +1,7 @@
 AC_MSG_CHECKING(which MPM to use by default)
 AC_ARG_WITH(mpm,
 APACHE_HELP_STRING(--with-mpm=MPM,Choose the process model for Apache to use by default.
-                          MPM={simple|event|worker|prefork|winnt}
+                          MPM={simple|eventopt|event|worker|prefork|winnt}
                           This will be statically linked as the only available MPM unless
                           --enable-mpms-shared is also specified.
 ),[

Added: httpd/httpd/trunk/server/mpm/eventopt/Makefile.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/Makefile.in?rev=1407533&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/Makefile.in (added)
+++ httpd/httpd/trunk/server/mpm/eventopt/Makefile.in Fri Nov  9 16:41:12 2012
@@ -0,0 +1 @@
+include $(top_srcdir)/build/special.mk

Propchange: httpd/httpd/trunk/server/mpm/eventopt/Makefile.in
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/trunk/server/mpm/eventopt/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/config.m4?rev=1407533&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/config.m4 (added)
+++ httpd/httpd/trunk/server/mpm/eventopt/config.m4 Fri Nov  9 16:41:12 2012
@@ -0,0 +1,11 @@
+AC_MSG_CHECKING(if eventopt MPM supports this platform)
+if test $forking_mpms_supported != yes; then
+    AC_MSG_RESULT(no - This is not a forking platform)
+elif test $ac_cv_define_APR_HAS_THREADS != yes; then
+    AC_MSG_RESULT(no - APR does not support threads)
+elif test $have_threaded_sig_graceful != yes; then
+    AC_MSG_RESULT(no - SIG_GRACEFUL cannot be used with a threaded MPM)
+else
+    AC_MSG_RESULT(yes)
+    APACHE_MPM_SUPPORTED(eventopt, yes, yes)
+fi

Propchange: httpd/httpd/trunk/server/mpm/eventopt/config.m4
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/trunk/server/mpm/eventopt/config3.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/config3.m4?rev=1407533&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/config3.m4 (added)
+++ httpd/httpd/trunk/server/mpm/eventopt/config3.m4 Fri Nov  9 16:41:12 2012
@@ -0,0 +1,11 @@
+dnl ## XXX - Need a more thorough check of the proper flags to use
+
+APACHE_CHECK_SERF
+if test "$ac_cv_serf" = yes ; then
+    APR_ADDTO(MOD_MPM_EVENTOPT_LDADD,[\$(SERF_LIBS)])
+fi
+APACHE_SUBST(MOD_MPM_EVENTOPT_LDADD)
+
+APACHE_MPM_MODULE(eventopt, $enable_mpm_eventopt, eventopt.lo fdqueue.lo equeue.lo pod.lo,[
+    AC_CHECK_FUNCS(pthread_kill)
+], , [\$(MOD_MPM_EVENTOPT_LDADD)])

Propchange: httpd/httpd/trunk/server/mpm/eventopt/config3.m4
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/trunk/server/mpm/eventopt/equeue.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/equeue.c?rev=1407533&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/equeue.c (added)
+++ httpd/httpd/trunk/server/mpm/eventopt/equeue.c Fri Nov  9 16:41:12 2012
@@ -0,0 +1,125 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "equeue.h"
+
+#include <apr_atomic.h>
+#include <sched.h>
+
+struct ap_equeue_t {
+    apr_uint32_t nelem;
+    apr_size_t elem_size;
+    uint8_t *bytes;
+    volatile apr_uint32_t writeCount;
+    volatile apr_uint32_t readCount;
+};
+
+
+static APR_INLINE apr_uint32_t count_to_index(ap_equeue_t *eq, apr_uint32_t count)
+{
+    return (count & (eq->nelem - 1));
+}
+
+static APR_INLINE void* index_to_bytes(ap_equeue_t *eq, apr_uint32_t idx)
+{
+    apr_size_t offset = idx * eq->elem_size;
+    return (void*)&eq->bytes[offset];
+}
+
+static APR_INLINE apr_uint32_t nearest_power(apr_uint32_t num)
+{
+    apr_uint32_t n = 1;
+    while (n < num) {
+        n <<= 1;
+    }
+
+    return n;
+}
+
+#if 0
+static void dump_queue(ap_equeue_t *eq)
+{
+    apr_uint32_t i;
+
+    fprintf(stderr, "dumping %p\n", eq);
+    fprintf(stderr, "  nelem:   %u\n", eq->nelem);
+    fprintf(stderr, "  esize:   %"APR_SIZE_T_FMT"\n", eq->elem_size);
+    fprintf(stderr, "  wcnt:    %u\n", eq->writeCount);
+    fprintf(stderr, "  rcnt:    %u\n", eq->writeCount);
+    fprintf(stderr, "  bytes:   %p\n", eq->bytes);
+    for (i = 0; i < eq->nelem; i++) {
+        fprintf(stderr, "    [%u] = %p\n", i, index_to_bytes(eq, i));
+    }
+
+    fprintf(stderr, "\n");
+    fflush(stderr);
+}
+#endif
+
+apr_status_t
+ap_equeue_create(apr_pool_t *p, apr_uint32_t nelem, apr_size_t elem_size, ap_equeue_t **eqout)
+{
+    ap_equeue_t *eq;
+
+    *eqout = NULL;
+
+    eq = apr_palloc(p, sizeof(ap_equeue_t));
+    eq->nelem = nearest_power(nelem);
+    eq->bytes = apr_palloc(p, eq->nelem * elem_size);
+    eq->elem_size = elem_size;
+    eq->writeCount = 0;
+    eq->readCount = 0;
+    *eqout = eq;
+
+    return APR_SUCCESS;
+}
+
+void *
+ap_equeue_reader_next(ap_equeue_t *eq)
+{
+    if (apr_atomic_read32(&eq->writeCount) == eq->readCount) {
+        return NULL;
+    }
+    else {
+        apr_uint32_t idx = count_to_index(eq, apr_atomic_inc32(&eq->readCount));
+        return index_to_bytes(eq, idx);
+    }
+}
+
+void *
+ap_equeue_writer_value(ap_equeue_t *eq)
+{
+    apr_uint32_t idx;
+
+    while (1) {
+        apr_uint32_t readCount = apr_atomic_read32(&eq->readCount);
+
+        if (count_to_index(eq, eq->writeCount + 1) != count_to_index(eq, readCount)) {
+            break;
+        }
+        /* TODO: research if sched_yield is even worth doing  */
+        sched_yield();
+    }
+
+    idx = count_to_index(eq, eq->writeCount);
+    return index_to_bytes(eq, idx);
+}
+
+
+void ap_equeue_writer_onward(ap_equeue_t *eq)
+{
+    apr_atomic_inc32(&eq->writeCount);
+}

Propchange: httpd/httpd/trunk/server/mpm/eventopt/equeue.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: httpd/httpd/trunk/server/mpm/eventopt/equeue.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/eventopt/equeue.h?rev=1407533&view=auto
==============================================================================
--- httpd/httpd/trunk/server/mpm/eventopt/equeue.h (added)
+++ httpd/httpd/trunk/server/mpm/eventopt/equeue.h Fri Nov  9 16:41:12 2012
@@ -0,0 +1,50 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _eventopt_mpm_equeue_h_
+#define _eventopt_mpm_equeue_h_
+
+#include "httpd.h"
+
+typedef struct ap_equeue_t ap_equeue_t;
+
+apr_status_t
+ap_equeue_create(apr_pool_t *p,
+                 unsigned int nelem,
+                 apr_size_t elem_size,
+                 ap_equeue_t **eqout);
+
+
+/**
+ * Current value of the reader, returns NULL if the reader is caught up
+ * with the writer
+ */
+void* ap_equeue_reader_next(ap_equeue_t *eq);
+
+/**
+ * Returns pointer to next available write slot.  May block
+ * in a spin lock if none are available.
+ */
+void* ap_equeue_writer_value(ap_equeue_t *eq);
+
+/**
+ * Move the write position up one, making the previously 
+ * editted value available to the reader.
+ */
+void ap_equeue_writer_onward(ap_equeue_t *eq);
+
+
+#endif

Propchange: httpd/httpd/trunk/server/mpm/eventopt/equeue.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message