+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
> 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to