Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45966 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31768 invoked from network); 6 Nov 2009 06:16:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Nov 2009 06:16:58 -0000 Authentication-Results: pb1.pair.com header.from=basant.kukreja@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=basant.kukreja@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.211.183 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: basant.kukreja@gmail.com X-Host-Fingerprint: 209.85.211.183 mail-yw0-f183.google.com Received: from [209.85.211.183] ([209.85.211.183:41000] helo=mail-yw0-f183.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/C2-11366-95FB3FA4 for ; Fri, 06 Nov 2009 01:16:57 -0500 Received: by ywh13 with SMTP id 13so784784ywh.29 for ; Thu, 05 Nov 2009 22:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=Vls2MNfd0VmLSUXSZ6DUf58vnkP8eRB2+tgDwr29b68=; b=o81prTNCZlOWv+g0GQr/KcKTHcqlPYklQQdhJQxLpmQdtmxkGjPXpCkjziMw/0b79t 0XbIA9hbkOYM1jSMmp+qfG6htOwWOwq/Ej+5Z1j4CfxCWmeHFAXyJbdMSs8qyrMSnMpv cj/CcMxKxbYa0w3Cxpr04jP74y6v3UnfJmbyk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=G2I9yjL9d6LXboG/jfTICsoAyQJdBukkVBlbEw/OxUw1kN822mx9LSZijr8M1Fs15E n4ap9Zdzk7VwUk/nzS77p1TZg+Z5s9FKOzoi6aQhcfMUzhGilnEOvtU3s41CikOLq6nH 6EtLKI/FT6klhoovdP6/pgyxAO7LL1g0ilk7g= Received: by 10.150.168.9 with SMTP id q9mr5906473ybe.320.1257488215296; Thu, 05 Nov 2009 22:16:55 -0800 (PST) Received: from basantk-mac-linux.red.iplanet.com (sca-ea-fw-1.Sun.COM [192.18.43.225]) by mx.google.com with ESMTPS id 14sm697037gxk.2.2009.11.05.22.16.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 05 Nov 2009 22:16:53 -0800 (PST) Date: Thu, 5 Nov 2009 22:18:51 -0800 To: Arvind Srinivasan Cc: internals@lists.php.net Message-ID: <20091106061851.GA27215@basantk-mac-linux.red.iplanet.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) Subject: Re: [PHP-DEV] Feedback requested on using #defines to improve the performance of the TSRMG macro From: basant.kukreja@gmail.com (Basant Kukreja) +1 Regards, Basant. On Thu, Nov 05, 2009 at 05:22:34PM +0530, Arvind Srinivasan wrote: > When compiled for multi-threaded (#ifdef ZTS ) operation, the various > subsystems in PHP use dynamically allocated (ts_allocate_id) > identifiers to index into the thread-local storage for each subsystem. > These dynamically allocated ids are used by macros such as CG, EG, PG, > AG. > > The TSRMG macro is defined as: > #define TSRMG(id, type, element) (((type) (*((void ***) > tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element) > > The PG macro is defined as: > # define PG(v) TSRMG(core_globals_id, php_core_globals *, v) > > where core_globals_id is > extern PHPAPI int core_globals_id; > > cc -E of > PG(connection_status) = PHP_CONNECTION_ABORTED; > translates to: > (((php_core_globals *) (*((void ***) > tsrm_ls))[((core_globals_id)-1)])->connection_status) = 1; > > and cc -S of the same code results in: > .loc 1 108 0 > movl %ebx, %eax > subl core_globals_id, %eax > movl (%esi), %edx > sall $2, %eax > negl %eax > movl (%edx,%eax), %eax > movw $1, 144(%eax) > > I used fixed IDs instead of dynamically allocated ones and noticed a > decent improvement in performance (few percentage points) when > running a web-based ecommerce-site workload on SPARC CMT hardware. > > With my changes the PG macro is defined as: > # define PG(v) TSRMG(CORE_GLOBALS_ID, php_core_globals *, v) > > #define CORE_GLOBALS_ID 10 > > and core_globals_id is > extern PHPAPI const ts_rsrc_id core_globals_id; > > cc -E of the same line of code translates to: > (((php_core_globals *) (*((void ***) > tsrm_ls))[((10)-1)])->connection_status) = 1; > > cc -S (my version): > .loc 1 108 0 > movl (%eax), %eax > movl 36(%eax), %eax > movw $1, 144(%eax) > > The patch is fairly long, so rather than attach it to this email, i'll > point to it. > > It'd be great if someone could give me feedback on my changes - > http://bitbucket.org/arvi/arviq/src/tip/arvi-16-ts_allocate_reserved_id > - for using reserved/fixed IDs for accessing thread-local storage of > frequently used/known/core subsystems. I think the changes only affect > the #ifdef ZTS codepaths. > > Thanks, > Arvi > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >