ID:               32220
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kameshj at fastmail dot fm
-Status:           Assigned
+Status:           Feedback
 Bug Type:         Apache2 related
 Operating System: *
 PHP Version:      5CVS, 4CVS (2005-03-25)
 Assigned To:      dmitry
 New Comment:

The patch is no longer available..?


Previous Comments:
------------------------------------------------------------------------

[2005-12-05 09:03:14] kameshj at fastmail dot fm

Yes you are correct that only IIS sapi is making use of ts_free_thread.
But If you look at my patch you can see that I am registering this
ts_free_thread function to pthread_push_cleanup to make sure the pthread
subsystem to do the cleanup for us as soon as the thread is getting
killed not to wait for the main thread to free the full
thread_resources.

------------------------------------------------------------------------

[2005-12-01 15:51:41] [EMAIL PROTECTED]

I confirm that PHP doesn't call ts_free_thread() if Web Server (except
IIS) kills some thread. As a result all thread resources are not freed
before server shutdown.

The proposed patch is invalid and even cannot be compiled on Linux.

------------------------------------------------------------------------

[2005-11-10 18:36:39] [EMAIL PROTECTED]

Yes, but did you check out the patch..?


------------------------------------------------------------------------

[2005-11-08 09:50:11] [EMAIL PROTECTED]

I am not able to reproduce this. Seems like a mess in report. Apache2
worker MPM doesn't support StartThreads and MaxThreads directives.

------------------------------------------------------------------------

[2005-03-07 15:06:48] kameshj at fastmail dot fm

Description:
------------
Run apache2 in a worker thread model with the following settings
StartThreads 3
MaxSpareThreads 4
MaxThreads 10
Loadtests on a very simple php scripts like the one that calls
phpinfo() at regular intervals of 5 minutes causes a memory leak(Not
really a leak but huge unused memory that gets freed at tsrm_shutdown)

This causes the memory consumed by the apache2 procsss to shoot up.

---Investigation
Apache2 to handle the concurrent requests increases the number of child
threads to max of MaxThreads when no more request to server it kills the
threads till the number of threads comes to MaxSpareThreads.

In the case of setting given above after the load test of 10
simultaneous requests,
Apache kills 6 threads (As MaxThreads-MaxSpareThreads = 10-4 = 6).
The thread_resources momory associated with these 6 threads still not
freed as soon as the corresponding thread is killed.
These kind of spurt loads at regular intervals causes lots of such
thread_resources memory to get accumulated not being used for any real
purpose.

Only when the sapi module comes down it calls tsrm_shutdown then these
thread_resources are getting freed.

Attaching the patch to fix the issue is available at
http://puggy.symonds.net/~kameshj/TSRM.c.patch

This patch has a few clean up to existing ts_free_thread.
This patch registers ts_free_thread as thread cleanup routine.

Reproduce code:
---------------
Run apache2 in a worker thread model with the following settings
StartThreads 3
MaxSpareThreads 4
MaxThreads 10

write a simple test.php
<?php
phpinfo();
?>
Run a load test with ab 
ab -n 40 -c 10
Wait for 5 minutes
ab -n 40 -c 10
Wait for 5 minutes
ab -n 40 -c 10
Wait for 5 minutes
ab -n 40 -c 10


Expected result:
----------------
In the case of setting given above after the load test of 10
simultaneous requests,
Apache kills 6 threads (As MaxThreads-MaxSpareThreads = 10-4 = 6).
The thread_resources momory associated with these 6 threads still not
freed as soon as the corresponding thread is killed.
These kind of spurt loads at regular intervals causes lots of such
thread_resources memory to get accumulated not being used for any real
purpose.

Only when the sapi module comes down it calls tsrm_shutdown then these
thread_resources are getting freed.


Actual result:
--------------
thread_resources of a thread that gets killed should get freed as soon
as it dies rather than waiting till the tsrm_shutdown


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32220&edit=1

Reply via email to