You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Ames <am...@yahoo.com> on 2007/07/20 18:24:02 UTC

Re: one word syncronize once more

please see rev. 558039.  requests_this_child does not need to be 100% accurate.  the cure below is worse than the disease.

Greg

----- Original Message ----
From: Dmytro Fedonin <Dm...@Sun.COM>
To: dev@httpd.apache.org
Sent: Thursday, June 14, 2007 11:49:42 AM
Subject: one word syncronize once more

Hi all,

I've got some response which shows that I was not clear enough in my previous 
post. Fullproof solution would be:

Index: server/mpm/worker/worker.c
===================================================================
--- server/mpm/worker/worker.c  (revision 545597)
+++ server/mpm/worker/worker.c  (working copy)
@@ -892,7 +887,7 @@
          bucket_alloc = apr_bucket_alloc_create(ptrans);
          process_socket(ptrans, csd, process_slot, thread_slot, bucket_alloc);
          worker_sockets[thread_slot] = NULL;
-        requests_this_child--; /* FIXME: should be synchronized - aaron */
+        apr_atomic_dec32(&requests_this_child); /* much slower than important */
          apr_pool_clear(ptrans);
          last_ptrans = ptrans;
      }
Because we don't care about if (requests_this_child <= 0) it would be enough. But 
it is too way slow and is not so important.






       
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

Re: one word syncronize once more

Posted by Darryl Miles <da...@netbauds.net>.
Greg Ames wrote:
> please see rev. 558039.  requests_this_child does not need to be 100% accurate.  the cure below is worse than the disease.
> 
> Greg
> 
> -        requests_this_child--; /* FIXME: should be synchronized - aaron */
> +        apr_atomic_dec32(&requests_this_child); /* much slower than important */


Maybe someone could reconfirm to the list what exactly the disease is ?


If this counter is not accurate (meaning it may loose 
increments/decrements) does the end the world cave in ?  Maybe someone 
could explain how and where this particular variable 
"requests_this_child" is used.

For example if its just to provide guideline information to allow 
termination after 10000 requests then thats less of a problem than if 
someone configured it to terminate after 2 requests.  Being 0.0001% out 
is less of a problem than 100% out.

For example if the counter is used in some way to allow apache to 
restart/logrotate and if it does not come back to zero reliabily then 
apache will remain hung trying to shutdown (as it often the case in my 
real world experience) then the disease would be a hung webserver during 
shutdown and taking.  This is much more fatal.

I'm not suggesting this particular counter "requests_this_child" has a 
direct cause with hung apache instances but I'm asking those that 
understand the disease(s) if they could explain exactly what they are.




I'm not familiar with the apr_atomic_dec32() API, is this correctly 
optimized to a single asm instruction "lock decl 0xaddr32" on Intel IA32 
?  How many clock cycles do you think that operations takes, what 
technical understanding makes you think such a "cure" should be utilized 
with caution ?

My understanding of the cure is that its very very light weight so light 
weight I'd challenge you to prove the mythical performance issue in the 
situation its being used in apache.


To give this some weight, I'm was recently involved in an multi-threaded 
ethernet packet processing application dealing with 100's of mbit and 
each packet that came updated multiple counters using the IA32 "LOCK" 
prefix but there was zero noticeable contention.  Indeed this is the 
purpose of the assembly primitive to implement something in hardware 
that is most efficiently done there.


Darryl


Re: one word syncronize once more

Posted by Jim Jagielski <ji...@jaguNET.com>.
Agreed... There are lots of places where we really don't need
true synchronization, since 100% accuracy in the "real"
values aren't crucial.

On Jul 20, 2007, at 12:24 PM, Greg Ames wrote:

> please see rev. 558039.  requests_this_child does not need to be  
> 100% accurate.  the cure below is worse than the disease.
>
> Greg
>
> ----- Original Message ----
> From: Dmytro Fedonin <Dm...@Sun.COM>
> To: dev@httpd.apache.org
> Sent: Thursday, June 14, 2007 11:49:42 AM
> Subject: one word syncronize once more
>
> Hi all,
>
> I've got some response which shows that I was not clear enough in  
> my previous
> post. Fullproof solution would be:
>
> Index: server/mpm/worker/worker.c
> ===================================================================
> --- server/mpm/worker/worker.c  (revision 545597)
> +++ server/mpm/worker/worker.c  (working copy)
> @@ -892,7 +887,7 @@
>           bucket_alloc = apr_bucket_alloc_create(ptrans);
>           process_socket(ptrans, csd, process_slot, thread_slot,  
> bucket_alloc);
>           worker_sockets[thread_slot] = NULL;
> -        requests_this_child--; /* FIXME: should be synchronized -  
> aaron */
> +        apr_atomic_dec32(&requests_this_child); /* much slower  
> than important */
>           apr_pool_clear(ptrans);
>           last_ptrans = ptrans;
>       }
> Because we don't care about if (requests_this_child <= 0) it would  
> be enough. But
> it is too way slow and is not so important.
>
>
>
>
>
>
>
> ______________________________________________________________________ 
> ______________
> Get the free Yahoo! toolbar and rest assured with the added  
> security of spyware protection.
> http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
>