Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45953 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32016 invoked from network); 5 Nov 2009 11:52:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Nov 2009 11:52:39 -0000 Authentication-Results: pb1.pair.com header.from=yoarvi@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=yoarvi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.44 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: yoarvi@gmail.com X-Host-Fingerprint: 209.85.160.44 mail-pw0-f44.google.com Received: from [209.85.160.44] ([209.85.160.44:34806] helo=mail-pw0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/A1-23484-58CB2FA4 for ; Thu, 05 Nov 2009 06:52:37 -0500 Received: by pwj15 with SMTP id 15so850366pwj.23 for ; Thu, 05 Nov 2009 03:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=ehq9iUDLPZtyk7vhcRf9JNUccFpV/ZUvdUaArqVfbKU=; b=kJofPP5yIxUlHxTHUHbx2kwBwGVMGgLJhS5C+6LltPfWb42B18pLdM67RHrUN+P37a 8dRhxz5RHjq1jq8yy10/dPP27Z0LrIJEaLbpkwKnE5iDukO1ZzUcw3KvCsyotj5M76YG HLr4GkCJSeEewtYM0unSwcLQO9irShutLDDbc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=SLkr0+3K1m+bpA2AGsl2Y/8/kETJUHPXRAu7J5CzNC3tVWSuKEL6hR3IgU3r0qZDpf G/yhsI49qXs9o7518lMnyxN1ub5JX39YcBFAvYikwlpKj22aepSyYbNO7N4wXgq33KfO /N0yagEs8lWctEVNcIOprCZ9DFUGkoPbwLp6U= MIME-Version: 1.0 Received: by 10.143.20.41 with SMTP id x41mr294573wfi.148.1257421954603; Thu, 05 Nov 2009 03:52:34 -0800 (PST) Date: Thu, 5 Nov 2009 17:22:34 +0530 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Feedback requested on using #defines to improve the performance of the TSRMG macro From: yoarvi@gmail.com (Arvind Srinivasan) 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