Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18541 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49836 invoked by uid 1010); 30 Aug 2005 00:26:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 49821 invoked from network); 30 Aug 2005 00:26:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Aug 2005 00:26:13 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:34939] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 7C/C3-15098-4A7A3134 for ; Mon, 29 Aug 2005 20:26:12 -0400 Received: (qmail 31444 invoked from network); 30 Aug 2005 00:26:07 -0000 Received: from localhost (HELO zeev-notebook.zend.com) (127.0.0.1) by localhost with SMTP; 30 Aug 2005 00:26:07 -0000 Message-ID: <5.1.0.14.2.20050830031409.045fe2e0@localhost> X-Sender: zeev@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 30 Aug 2005 03:26:04 +0300 To: "Sara Golemon" Cc: In-Reply-To: <011d01c5ace6$de33a7f0$5c8be5a9@ohr.berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] ZTS leak From: zeev@zend.com (Zeev Suraski) References: <011d01c5ace6$de33a7f0$5c8be5a9@ohr.berkeley.edu> At 01:13 30/08/2005, Sara Golemon wrote: >In looking into a series of leaks regarding tsrm interpreter contexts with >George and Wez, we came across a problem with how EG(zend_constants) is >created and destroyed. > >Specifically it's only destroyed once, from zend_shutdown(). However it's >created by executor_globals_ctor(). In non-ZTS this isn't a problem since >egctor is only called the one time during startup, however when ZTS is >enabled egctor gets called repeatedly (including once for every request >startup) and the allocated EG(zend_constants) is leaked over and over again. As far as I can tell it's a bug. By the way, we're not talking about a leak that happens too often - unless you're spawning and killing threads very often (in which case TSRM is very inefficient regardless of anything). The leak would happen per-terminated thread. >Of lesser criticality (but no less important) rsrc_plist is also leaked by >this unbalanced positioning. Ditto. >I temporarily plugged the constants leak (90k+ per request) by using the >patch below (though it's inefficient for obvious reasons), but rsrc_plist >will take a slightly different approach (heading out the door now so no time >to think it through). 90K+ per request sounds wrong. I guess that you're either measuring right after the server startup, when the threads are not yet initialized - and then every request initiates a new thread; Or you're using a very odd web server that spawns a thread for each incoming request (bad idea!). If it's the former, then that leak is actually not nearly as bad as you thought, if it's the latter... Fixing that leak should be the least of your worries :) >There's also a 200 byte leak in the thread key, but that's once per engine >and not a per-request issue so I'm even less concerned about that one. > >-Sara > >Index: Zend/zend.c >=================================================================== >RCS file: /repository/ZendEngine2/zend.c,v >retrieving revision 1.308 >diff -u -r1.308 zend.c >--- Zend/zend.c 3 Aug 2005 13:30:45 -0000 1.308 >+++ Zend/zend.c 29 Aug 2005 21:40:13 -0000 >@@ -486,6 +486,7 @@ > static void executor_globals_dtor(zend_executor_globals *executor_globals >TSRMLS_DC) > { > zend_ini_shutdown(TSRMLS_C); >+ zend_shutdown_constants(TSRMLS_C); > } > > >@@ -706,7 +707,6 @@ > zend_shutdown_extensions(TSRMLS_C); > free(zend_version_info); > >- zend_shutdown_constants(TSRMLS_C); > free(GLOBAL_FUNCTION_TABLE); > free(GLOBAL_CLASS_TABLE); > #ifdef ZTS Are you sure it's not leaking the global constants table with the zend_shutdown_constants() removed from zend_shutdown()? Zeev