Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45955 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28162 invoked from network); 5 Nov 2009 19:00:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Nov 2009 19:00:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=christopher.jones@oracle.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=christopher.jones@oracle.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain oracle.com from 141.146.126.234 cause and error) X-PHP-List-Original-Sender: christopher.jones@oracle.com X-Host-Fingerprint: 141.146.126.234 acsinet12.oracle.com Received: from [141.146.126.234] ([141.146.126.234:63390] helo=acsinet12.oracle.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/63-08268-6C023FA4 for ; Thu, 05 Nov 2009 14:00:24 -0500 Received: from rgminet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by acsinet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nA5J00R4015121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 5 Nov 2009 19:00:01 GMT Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by rgminet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nA5J0r2n032325; Thu, 5 Nov 2009 19:00:53 GMT Received: from abhmt014.oracle.com by acsmt358.oracle.com with ESMTP id 113226931257447534; Thu, 05 Nov 2009 12:58:54 -0600 Received: from [130.35.70.34] (/130.35.70.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 05 Nov 2009 10:58:54 -0800 Message-ID: <4AF3206D.8050606@oracle.com> Date: Thu, 05 Nov 2009 10:58:53 -0800 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Arvind Srinivasan CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090206.4AF320BD.0187:SCFMA4539814,ss=1,fgs=0 Subject: Re: [PHP-DEV] Feedback requested on using #defines to improve the performance of the TSRMG macro From: christopher.jones@oracle.com (Christopher Jones) Hi Arvind, Does the GLOBALS_ID_BASE idea work? In "ts_allocate_reserved_id(GLOBALS_ID_BASE+1...)" each extension would anyway need to reserve an increment to avoid clashes. Also, why is GLOBALS_ID_BASE 30 when the largest reserved value is 18? Maybe I'm missing something. Would there be significant memory space or locality issues if one ID per extension in the PHP source bundle was reserved upfront, even if those extensions were never enabled? Chris 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 > -- Blog: http://blogs.oracle.com/opal Twitter: http://twitter.com/ghrd