LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Nicolas Chaillan Date: Sun Aug 17 06:55:19 2008 Subject: Re: [PATCH] ZTS as fast as non-ZTS
Very, very nice work. Congrats. Works fine there too. -- Cordialement. -- Nicolas Chaillan | GROUPAKT.fr | UIN : 16549830 nicos@php.net | info@groupakt.fr | http://www.groupakt.fr http://www.fmsakt.fr | http://www.prospecttel.com discussion : 200808170419.11153.arnaud.lb@gmail.com... > Hi, > > Currently the way globals work forces to pass a thread-local-storage > pointer > across function calls, which involves some overhead. Also, not all > functions > get the pointer as argument and need to use TSRMLS_FETCH(), which is slow. > For > instance emalloc() involves a TSRMLS_FETCH(). An other overhead is > accessing > globals, using multiple pointers in different locations. > > The following patch caches each global address in a native TLS variable so > that accessing a global is as simple as global_name->member. This removes > the > requirement of passing the tls pointer across function calls, so that the > two > major overheads of ZTS builds are avoided. > > Globals can optionally be declared statically, which speeds up things a > bit. > > Results in bench.php: > non-ZTS: 3.7s > ZTS unpatched: 5.2s > ZTS patched: 4.0s > ZTS patched and static globals: 3.8s > > The patch introduces two new macros: TSRMG_D() (declare) and TSRMG_DH() > (declare, for headers) to declare globals, instead of the current > "ts_rsrc_id > foo_global_id". These macros declare the global id, plus the __thread > pointer > to the global storage. > > ts_allocate_id now takes one more callback function as argument to bind > the > global pointer to its storage. This callback is declared in TSRMG_D[H](). > > As all TSRMLS_* macros now does nothing, it is needed to call > ts_resource(0) > explicitly at least one time in each thread to initialize its storage. A > new > TSRMLS_INIT() macro as been added for this purpose. > > All this is disabled by default. --with-tsrm-__thread-tls enables the > features > of the patch, and --with-tsrm-full-__thread-tls enables static declaration > of > globals. > > It as been tested on Linux compiled with --disable-all in CLI and a bit in > Apache2 with the worker MPM. Known issues: > - Declaring globals statically (--with-tsrm-full-__thread-tls) causes > troubles > to dlopen(), actually Apache wont load the module at runtime (it works > with > just --with-tsrm-__thread-tls). > - The patch assumes that all resources are ts_allocate_id()'ed before any > other thread calls ts_allocate_id or ts_resource_ex(), which is possibly > not > the case. > > The patch needs some tweaks and does not pretend to be included in any > branch, > but I would like to have some comments on it. > > The patch: http://arnaud.lb.s3.amazonaws.com/__thread-tls.patch > > Regards, > > Arnaud >
| Navigate in group php.internals at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by Zareef Ahmed
Powered By PHP Consultants |