Re: FW: Help needed in benchmarking memory patch
| From: | Michael Vergoz | Date: | Fri, 14 Jul 2006 11:37:58 +0000 |
| Subject: | Re: FW: Help needed in benchmarking memory patch | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-24376@lists.php.net to get a copy of this message | ||
Salut Dmitry,
Thank you for your confirmation.
I also have a remark about the last_error_message i don't understand why it should live between request ?
In fact it's possible that my patch wasn't very good but it's necesary to free the buffer in other place which will be executed at the end of the thread. Do you have an idea ? ts_free_thread() ?
Other question, did you used my code to confirm the disabled_functions leaks ?
I had found 4 other big leaks but i have to find the code which reproduce the leak
We keep in touch
And thanks again
Michael Vergoz
----- Original Message ----- From: "Dmitry Stogov" <dmitry@zend.com>
To: "'Michael Vergoz'" <mv-php@binarysec.com>; "'Andi Gutmans'" <andi@zend.com>
Sent: Friday, July 14, 2006 12:35 PM
Subject: RE: [PHP-DEV] FW: Help needed in benchmarking memory patch
Hi Michael, Sorry for delay. You catched real memory leaks (in ZTS mode), but your fix isn't. Seems "last_error_message" was designed to live between requests. (I'll ask authors at Monday). Also we have the same leak with "disabled_functions". I'll try prepare patch at Monday. Will you able to test it? Thanks. Dmitry.-----Original Message----- From: Michael Vergoz [mailto:mv-php@binarysec.com] Sent: Tuesday, July 11, 2006 10:33 PM To: Andi Gutmans; 'Dmitry Stogov'; 'PHPdev' Subject: Re: [PHP-DEV] FW: Help needed in benchmarking memory patch Here is a small patch allowing to correct the small leak. This one will have to be merge with that of Michael - (its patch is correct and does not contain any leak (I were not clear in my last mail) - thus +1) http://badcode.be/~descript/PHP/PHP_5_2-php-main.diff Michael Vergoz ----- Original Message ----- From: "Michael Vergoz" <mv-php@binarysec.com> To: "Andi Gutmans" <andi@zend.com>; "'Dmitry Stogov'" <dmitry@zend.com>; "'PHPdev'" <internals@lists.php.net> Sent: Tuesday, July 11, 2006 8:29 PM Subject: Re: [PHP-DEV] FW: Help needed in benchmarking memory patchSalut Andi & Dmitry, If you have errors in your script you have a leak in PG(last_error_message) & PG(last_error_file) because ofphp_error_cb()which allocates via strdup() these two variables. It shouldbe noted alsothat these variables are not given with NULL after their freed in php_error_cb() - main/main.c +679 and that both lastallowance will neverbe freed for each thread. They are freed with the stop of the process viaphp_module_shutdown().I propose to free these buffer in php_request_shutdown()?In fact theleak more are the small ones but they become repetitive in aThreaded program.There is also another condition to generate large mem leakfor exampleby re-using a thread to carry out several script with thecontinuation. Thereyou explodes all the records if you do not do ats_free_thread() justafter your php_request_shutdown(). It's for that which Ithink that itwould be very judicious to add a ts_free_thread() beforeeach the return()of the HttpExtensionProc() function of the ISAPI SAPI module. Michael Vergoz ----- Original Message ----- From: "Andi Gutmans" <andi@zend.com> To: "'Michael Vergoz'" <mv-php@binarysec.com>; "'Dmitry Stogov'" <dmitry@zend.com>; "'PHPdev'" <internals@lists.php.net> Sent: Tuesday, July 11, 2006 7:38 PM Subject: RE: [PHP-DEV] FW: Help needed in benchmarking memory patchrunning? OneAre you sure this isn't because the IIS thread is stillmemory patchthread handles multiple requests.-----Original Message----- From: Michael Vergoz [mailto:mv-php@binarysec.com] Sent: Tuesday, July 11, 2006 10:33 AM To: Dmitry Stogov; 'Andi Gutmans'; PHPdev Subject: Re: [PHP-DEV] FW: Help needed in benchmarkingISAPI shouldIn fact I had found some leaks it would seem that ts_free_thread() after php_request_shutdown() solves all the problem. I am checking if it's bad but if not the case the SAPImemory patchhave a small modification. mv- ----- Original Message ----- From: "Dmitry Stogov" <dmitry@zend.com> To: "'Michael Vergoz'" <mv-php@binarysec.com>; "'Andi Gutmans'" <andi@zend.com>; <internals@lists.php.net> Sent: Tuesday, July 11, 2006 1:54 PM Subject: RE: [PHP-DEV] FW: Help needed in benchmarkingHi Michael, The patch was tested in ZTS mode too. What SAPI you are talking about? (I would like to reproduceThanks. Dmitry.the problem).Linux becauseWe didn't find a material difference between malloc() and mmap() though, most probably because malloc() at these sizes-----Original Message----- From: Michael Vergoz [mailto:mv-php@binarysec.com] Sent: Tuesday, July 11, 2006 1:22 PM To: Andi Gutmans; internals@lists.php.net Subject: Re: [PHP-DEV] FW: Help needed in benchmarking memory patch Hi aAndymmap().actually callsYou can have good difference with the mremap() ofseparation isit directly changes the vector into memory without recopying these data. -- Before beginning a benchmark I would like to speak about a serious problem that I have with TSRM/MM. A S1 script carried out by thread T1 will use the same memory capacity as S2 script by T2 whereas theoreticallysapi_shutdown() andit. Then oneobligatory. In addition to the problem of safety, that cause also a problem of management of the load memory of the process father. We define a father process P=while(1); When a process father starts it must initialize tsrm_startup(), sapi_startup() and php_module_startup(). At this time all the additional functions and objects are loaded and usable by all script (what is normal). With the creation of a thread one associates a TSRMLS tocarries out php_request_startup(), php_execute_script() and php_request_shutdown() to entirely enclose PHP/Zend. With the execution of Sx script in Tx: the variables dynamics, static and constant of this one will be stored in AG(head). The problem comes from there. It is impossible to destroy a memory which a script has just used because the process father continues to turn and nor php_request_shutdown(), php_module_shutdown(),that I find atsrm_shutdown() will not be carried out AND THUS there will be a mem leak I am very annoyed by this problem, it is necessarymemory patchpossibility to destroy these buffer. Michael Vergoz ----- Original Message ----- From: "Andi Gutmans" <andi@zend.com> To: "'Michael Vergoz'" <mv-php@binarysec.com>; <internals@lists.php.net> Sent: Tuesday, July 11, 2006 8:26 AM Subject: RE: [PHP-DEV] FW: Help needed in benchmarkinglevel. ISorry I didn't make clear that only the malloc()/free()The mmap() and Win32 Allocation code is commented. We didn't find a material difference between malloc() andpart works.most probably because malloc() at these sizes actuallymmap() though,So really most important is for some ppl to run somecalls mmap().Thx. Andibenchmarks on this.memory patch-----Original Message----- From: Michael Vergoz [mailto:mv-php@binarysec.com] Sent: Monday, July 10, 2006 5:25 PM To: Andi Gutmans; internals@lists.php.net Subject: Re: [PHP-DEV] FW: Help needed in benchmarkingstudy. Already aHi Andi, I appreciated to see this code which I must stillportable itsmall remark it is that the system call mremap() is notmust alwaysis available only on Linux. Then the size of the segments"be paginated" - normally your code is good on thisuser-memory can bethink that a concept of kernel-memory andenvironmentsvery interesting to study, especially in threadsattachment. You canNo help??? Come on guys. I'm sure some of you can spare asleep (04:26- that I use. I would continue to look at your code but now I willmemory patchpm)! mv- ----- Original Message ----- From: "Andi Gutmans" <andi@zend.com> To: "'Andi Gutmans'" <andi@zend.com>; <internals@lists.php.net> Sent: Monday, July 10, 2006 5:57 PM Subject: RE: [PHP-DEV] FW: Help needed in benchmarking:)few idle cyclesmemory patch-----Original Message----- From: Andi Gutmans [mailto:andi@zend.com] Sent: Friday, July 07, 2006 8:38 PM To: internals@lists.php.net Subject: [PHP-DEV] FW: Help needed in benchmarkingSending 3rd time this time without theit to scalethe memoryget the diff at http://gutmans.org/alloc.zip -----Original Message----- From: Andi Gutmans [mailto:andi@zend.com] Sent: Thursday, July 06, 2006 11:06 PM To: 'internals@lists.php.net' Subject: Help needed in benchmarking memory patch Hi all, Attached is a patch we've been working on to improvereducing themanagement of PHP. This patch's main advantage ismemory footprint of PHP, and therefore allowingseems tobetter. Although at low concurrencies the changeconcurrencies we sawbe negligble, while testing at higherenvironmentthis patch andsignificant improvement with this patch, mainly due to lower memory usage. We would very much appreciate if people here testedothers aresend in their results. It would help us understand ifwhether theregetting consistent results with ours, and also seetree. There'sare any additional improvements we should make. This patch should apply cleanly to the PHP 5.2 CVScontrol the sizenot much tuning that needs to be done. It uses malloc() to allocate large memory blocks. You canof these blocks by setting the ZEND_MM_SEG_SIZE-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.phpor M to playvariable before starting Apache/PHP. You may use Karound with the block size. The default we are using is 256KB which seems to be a good balance. Any feedback would be appreciated! Andi -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php