Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46257 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94632 invoked from network); 1 Dec 2009 12:06:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2009 12:06:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 83.243.58.134 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 83.243.58.134 mailout2.netbeat.de Linux 2.6 Received: from [83.243.58.134] ([83.243.58.134:58811] helo=mailout2.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/60-24347-0C6051B4 for ; Tue, 01 Dec 2009 07:06:26 -0500 Received: (qmail 11000 invoked by uid 89); 1 Dec 2009 12:11:03 -0000 Received: from unknown (HELO ?192.168.1.21?) (postmaster%schlueters.de@93.104.57.91) by mailout2.netbeat.de with ESMTPA; 1 Dec 2009 12:11:03 -0000 X-Originator: 9e51b244e0a38413ab6a9876e36ba9df To: Arvind Srinivasan Cc: internals@lists.php.net In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Tue, 01 Dec 2009 13:05:42 +0100 Message-ID: <1259669142.2291.9.camel@guybrush> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PATCH] - Improving multi-threaded performance by propagating TSRMLS_C From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Mon, 2009-11-30 at 19:02 +0530, Arvind Srinivasan wrote: > (1) If the number of occurrences of the API to be modified are > relatively small, then make the change directly. > e.g. > -int fcgi_accept_request(fcgi_request *req); > -int fcgi_finish_request(fcgi_request *req, int force_close); > +int fcgi_accept_request(fcgi_request *req TSRMLS_DC); > +int fcgi_finish_request(fcgi_request *req, int force_close TSRMLS_DC); right > (2) If the number of occurrences is large, then rename the function > (prefix with _) and add a macro that passes TSRMLS_C > e.g. > -ZEND_API void zend_hash_destroy(HashTable *ht); > +ZEND_API void _zend_hash_destroy(HashTable *ht TSRMLS_DC); > +#define zend_hash_destroy(ht) _zend_hash_destroy((ht) TSRMLS_CC) I'm not too happy about hiding the TSRM macro with another macro as it makes reading the code harder. When writing code I want to spot easily whether my function needs TSRM or not. When adding such a macro that should be done for making the code better readable, not worse. > (3) For functions that have varargs, pass TSRMLS_C as the last but one parameter > e.g. > -ZEND_API int zend_get_parameters(int ht, int param_count, ...); > +ZEND_API int zend_get_parameters(int ht TSRMLS_DC, int param_count, ...); right. > (4) For single argument functions that have varags, pass TSRMLS_C as > the first parameter > e.g. > -ZEND_API int zend_get_parameters_ex(int param_count, ...) /* {{{ */ > +ZEND_API int zend_get_parameters_ex(TSRMLS_DC1 int param_count, ...) /* {{{ */ > > where > +#define TSRMLS_DC1 TSRMLS_D, > +#define TSRMLS_CC1 TSRMLS_C, Are there more cases of this? - If zend_get_parameters is the only case I'd keep the TSRMLS_FETCH in it. zend_get_parameters is deprecated and shouldn't be used anymore. But adding a new macro makes it harder for new people to get started with the code. johannes