You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2015/12/23 02:16:42 UTC

svn commit: r1721479 - in /tcl/rivet/trunk: ChangeLog Makefile.in src/mod_rivet/rivet_lazy_mpm.c

Author: mxmanghi
Date: Wed Dec 23 01:16:42 2015
New Revision: 1721479

URL: http://svn.apache.org/viewvc?rev=1721479&view=rev
Log:
    * src/mod_rivet/rivet_lazy_mpm.c: taking a snapshot of the current development
    as this code proved to be quite robust when stressed using 'ab'


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/Makefile.in
    tcl/rivet/trunk/src/mod_rivet/rivet_lazy_mpm.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1721479&r1=1721478&r2=1721479&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Wed Dec 23 01:16:42 2015
@@ -1,3 +1,7 @@
+2015-12-22 Massimo Manghi <mx...@apache.org>
+    * src/mod_rivet/rivet_lazy_mpm.c: taking a snapshot of the current development
+    as this code proved to be quite robust when stressed using 'ab'
+
 2015-12-20 Massimo Manghi <mx...@apache.org>
     * src/mod_rivet/rivet_lazy_mpm.c: first prototype of a threaded bridge with
     reduced start up time and thread number optimization

Modified: tcl/rivet/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/Makefile.in?rev=1721479&r1=1721478&r2=1721479&view=diff
==============================================================================
--- tcl/rivet/trunk/Makefile.in (original)
+++ tcl/rivet/trunk/Makefile.in Wed Dec 23 01:16:42 2015
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -24,17 +24,7 @@
 #             before invoking pkg_mkIndex.
 # 2013/01/20: removing libtool created .la files
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
 am__make_running_with_option = \
   case $${target_option-} in \
       ?) ;; \
@@ -98,6 +88,18 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = .
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/configure $(am__configure_deps) \
+	$(srcdir)/config.h.in $(top_srcdir)/rivet/init.tcl.in \
+	ChangeLog tclconfig/ChangeLog INSTALL README TODO \
+	tclconfig/compile tclconfig/config.guess tclconfig/config.sub \
+	tclconfig/depcomp tclconfig/install-sh tclconfig/missing \
+	tclconfig/ltmain.sh $(top_srcdir)/tclconfig/compile \
+	$(top_srcdir)/tclconfig/config.guess \
+	$(top_srcdir)/tclconfig/config.sub \
+	$(top_srcdir)/tclconfig/install-sh \
+	$(top_srcdir)/tclconfig/ltmain.sh \
+	$(top_srcdir)/tclconfig/missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
 	$(top_srcdir)/m4/ax_split_version.m4 \
@@ -107,8 +109,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/a
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
-	$(am__configure_deps) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
@@ -172,17 +172,6 @@ ETAGS = etags
 CTAGS = ctags
 CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(top_srcdir)/rivet/init.tcl.in \
-	$(top_srcdir)/tclconfig/compile \
-	$(top_srcdir)/tclconfig/config.guess \
-	$(top_srcdir)/tclconfig/config.sub \
-	$(top_srcdir)/tclconfig/install-sh \
-	$(top_srcdir)/tclconfig/ltmain.sh \
-	$(top_srcdir)/tclconfig/missing ChangeLog INSTALL README TODO \
-	tclconfig/ChangeLog tclconfig/compile tclconfig/config.guess \
-	tclconfig/config.sub tclconfig/depcomp tclconfig/install-sh \
-	tclconfig/ltmain.sh tclconfig/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -410,7 +399,6 @@ psdir = @psdir@
 rivet_channel = @rivet_channel@
 rivet_commands = @rivet_commands@
 rivet_core = @rivet_core@
-runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -450,6 +438,7 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefi
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -682,15 +671,15 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
@@ -726,17 +715,17 @@ distcheck: dist
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
+	mkdir $(distdir)/_build $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build/sub \
-	  && ../../configure \
+	  && $(am__cd) $(distdir)/_build \
+	  && ../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=../.. --prefix="$$dc_install_base" \
+	    --srcdir=.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -914,8 +903,6 @@ uninstall-am: uninstall-local
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am uninstall-local
 
-.PRECIOUS: Makefile
-
 
 libtool: $(LIBTOOL_DEPS)
 	$(SHELL) ./config.status --recheck

Modified: tcl/rivet/trunk/src/mod_rivet/rivet_lazy_mpm.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/mod_rivet/rivet_lazy_mpm.c?rev=1721479&r1=1721478&r2=1721479&view=diff
==============================================================================
--- tcl/rivet/trunk/src/mod_rivet/rivet_lazy_mpm.c (original)
+++ tcl/rivet/trunk/src/mod_rivet/rivet_lazy_mpm.c Wed Dec 23 01:16:42 2015
@@ -67,7 +67,9 @@ typedef struct lazy_tcl_worker {
 
 typedef struct vhost_iface {
     apr_uint32_t*       idle_threads_cnt;       /* */
-    apr_queue_t*        queue;                  /* available threads  */
+    //apr_queue_t*        queue;                  /* available threads  */
+    apr_thread_mutex_t* mutex;
+    apr_array_header_t* array;                   /* available threads  */
 } vhost;
 
 typedef struct mpm_bridge_status {
@@ -94,15 +96,15 @@ static void* APR_THREAD_FUNC request_pro
         char* page;
 
         apr_thread_mutex_lock(w->mutex1);
-        apr_queue_push(module_globals->mpm->vhosts[w->idx].queue,w);
+        //apr_queue_push(module_globals->mpm->vhosts[w->idx].queue,w);
         apr_atomic_inc32(module_globals->mpm->vhosts[w->idx].idle_threads_cnt);
-        do {
+        while (w->status != init) {
             apr_thread_cond_wait(w->condition1,w->mutex1);
-        } while (w->status != init);
+        } 
 
-        apr_atomic_dec32(module_globals->mpm->vhosts[w->idx].idle_threads_cnt);
         w->status = processing;
         apr_thread_mutex_unlock(w->mutex1);
+        apr_atomic_dec32(module_globals->mpm->vhosts[w->idx].idle_threads_cnt);
 
         /* Content generation */
 
@@ -123,10 +125,16 @@ static void* APR_THREAD_FUNC request_pro
         apr_thread_mutex_unlock(w->mutex2);
 
         apr_thread_mutex_lock(w->mutex1);
-        do {
+        while (w->status == done) {
             apr_thread_cond_wait(w->condition1,w->mutex1);
-        } while (w->status == done);
+        } 
         apr_thread_mutex_unlock(w->mutex1);
+ 
+        // rescheduling itself in the array of idle threads
+       
+        apr_thread_mutex_lock(module_globals->mpm->vhosts[w->idx].mutex);
+        *(lazy_tcl_worker **) apr_array_push(module_globals->mpm->vhosts[w->idx].array) = w;
+        apr_thread_mutex_unlock(module_globals->mpm->vhosts[w->idx].mutex);
 
     } while (1);
 
@@ -155,9 +163,10 @@ void Lazy_MPM_ChildInit (apr_pool_t* poo
     apr_status_t    rv;
     int             vh;
 
-    apr_atomic_init(pool);
     module_globals->mpm = apr_pcalloc(pool,sizeof(mpm_bridge_status));
 
+    //module_globals->mpm->vhosts = (vhost *) apr_pcalloc(pool,sizeof(vhost) * module_globals->vhosts_count);
+
     rv = apr_thread_mutex_create(&module_globals->mpm->mutex,APR_THREAD_MUTEX_UNNESTED,pool);
     ap_assert(rv == APR_SUCCESS);
     rv = apr_thread_cond_create(&module_globals->mpm->condition, pool); 
@@ -168,32 +177,56 @@ void Lazy_MPM_ChildInit (apr_pool_t* poo
     */
 
     module_globals->mpm->vhosts = (vhost *) apr_pcalloc(pool,module_globals->vhosts_count * sizeof(vhost));
+    ap_assert(module_globals->mpm->vhosts != NULL);
 
     for (vh = 0; vh < module_globals->vhosts_count; vh++)
     {
-        module_globals->mpm->vhosts[vh].idle_threads_cnt = 
-                (apr_uint32_t *) apr_pcalloc(pool,sizeof(apr_uint32_t));
+        apr_array_header_t* array;
+
+        ap_assert(apr_thread_mutex_create(&module_globals->mpm->vhosts[vh].mutex,APR_THREAD_MUTEX_UNNESTED,pool) == APR_SUCCESS);
+        array = apr_array_make(pool,0,sizeof(void*));
+        ap_assert(array != NULL);
+        module_globals->mpm->vhosts[vh].array = array;
 
+        //ap_assert(apr_queue_create(&module_globals->mpm->vhosts[vh].queue,MOD_RIVET_QUEUE_SIZE,pool) == APR_SUCCESS);
+        module_globals->mpm->vhosts[vh].idle_threads_cnt = (apr_uint32_t *) apr_pcalloc(pool,sizeof(apr_uint32_t));
         apr_atomic_set32(module_globals->mpm->vhosts[vh].idle_threads_cnt,0);
-        ap_assert (apr_queue_create(&module_globals->mpm->vhosts[vh].queue,
-                    MOD_RIVET_QUEUE_SIZE,module_globals->pool) == APR_SUCCESS);
         
-        create_worker(pool,vh);
-        create_worker(pool,vh);
+        //create_worker(pool,vh);
+        //create_worker(pool,vh);
     }
 }
 
 int Lazy_MPM_Request (request_rec* r,rivet_req_ctype ctype)
 {
+    //void*               v;
+    //apr_status_t        rv;
     lazy_tcl_worker*    w;
-    apr_status_t        rv;
     int                 ap_sts;
     rivet_server_conf*  conf = RIVET_SERVER_CONF(r->server->module_config);
+    apr_array_header_t* array;
+    apr_thread_mutex_t* mutex;
 
-    do {
-        rv = apr_queue_pop(module_globals->mpm->vhosts[conf->idx].queue, (void *)&w);
-    } while (rv == APR_EINTR);
-
+    //do {
+    //     rv = apr_queue_pop(module_globals->mpm->vhosts[conf->idx].queue, &v);
+    //} while (rv == APR_EINTR);
+    //w = (lazy_tcl_worker*) v;
+
+    /* If the array is empty we create a new worker thread */
+
+    mutex = module_globals->mpm->vhosts[conf->idx].mutex;
+    array = module_globals->mpm->vhosts[conf->idx].array;
+    apr_thread_mutex_lock(mutex);
+    if (apr_is_empty_array(array))
+    {
+        w = create_worker(module_globals->pool,conf->idx);
+    }
+    else
+    {
+        w = *(lazy_tcl_worker**) apr_array_pop(array);
+    }
+    apr_thread_mutex_unlock(mutex);
+    
     apr_thread_mutex_lock(w->mutex1);
     w->r        = r;
     w->ctype    = ctype;
@@ -203,10 +236,9 @@ int Lazy_MPM_Request (request_rec* r,riv
     apr_thread_mutex_unlock(w->mutex1);
 
     apr_thread_mutex_lock(w->mutex2);
-    do {
+    while (w->status != done) {
         apr_thread_cond_wait(w->condition2,w->mutex2);
-    } while (w->status != done);
-
+    } 
     ap_sts = w->ap_sts;
     apr_thread_mutex_unlock(w->mutex2);
 



---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org