Re: APC's performance improvement patch for single process multithreaded php
| From: | Basant Kukreja | Date: | Fri, 09 Oct 2009 18:57:53 +0000 |
| Subject: | Re: APC's performance improvement patch for single process multithreaded php | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-6683@lists.php.net to get a copy of this message | ||
Hi,
I gave a thought about the multiprocess setup and thought about changing
single_proc to use_process_mem but later concluded that this option won't work
if multiple copies of cache existed. Here is a case :
Suppose apc.stat is set to 30 seconds and assume "one.php" is served by 2
processes and suppose they create cache for one.php at different interval
time. Now suppose one.php is changed, different process will update the cache
at different time so same one.php request will be served differently (one from
old version and one from new version) at the same time which of course is
incorrect.
I have refreshed the patch as trunk was changed. Please provide your comments.
Regards,
Basant.
=================================================
Documentation of apc.single_proc:
--------------------------------
By default single_proc is set to 0 and APC creates mmap/shared memory
to save cached php file and data. This can be set to 1 only if running inside
single multithreaded server process e.g "ServerLimit 1" for Apache worker mpm
or "MaxProcs 1" for Sun Web Server. When set to 1, instead of mmap/shared
memory, APC creates cache in process memory. This option have no effect on
single threaded multi process php e.g fastcgi.
On Wed, Oct 7, 2009 at 8:17 AM, Brian Moon <brian@moonspot.net> wrote:
>> On Unix platforms, APC can be compiled with mmap or shared memory.
>> This
>> performs good for multiprocess php. However when we run inside single
>> process
>> multi-threaded Web Servers e.g Sun Web Server or Apache worker mpm with
>> single
>> process, mmap is simply overkill. Reading APC's compiled cache from
>> in-process
>> memory is much efficient than from mmap.
>>
>> To achieve the above, I introduced a configurable variable apc.single_proc
>> which
>> is set to 0 by default. When apc.single_proc is set to 1, cache is created
>> inside process memory. Also mutex which is used to synchronize the cache
>> can
>> also be created as PTHREAD_PROCESS_PRIVATE. apc.single_proc can only be
>> set to 1
>> when ZTS is enabled.
>
> Most set ups with Apache worker use multi-threaded, multi-process. I guess
> for opcode caching it is ok, but not for data caching. You don't want that
> store once per process. That should probably be documented clearly someway.
> I would probably run with this flag on even in a multi/multi set up if it
> gave me better performance. Memory is cheap.
>
> Brian.
>