#50436 [NEW]: [PATCH] - Improving multi-threaded performance by propagating TSRMLS_C
From: yoarvi at gmail dot com
Operating system: Solaris 5.10 (SPARC)
PHP version: 6SVN-2009-12-10 (SVN)
PHP Bug Type: Performance problem
Bug description: [PATCH] - Improving multi-threaded performance by propagating TSRMLS_C
Description:
------------
When running a benchmarking workload on PHP that was configured with
multi-threading support (--enable-maintainer-zts) I noticed that
pthread_get_specific is invoked many times during the processing of a
request. PHP code invokes TSRMLS_FETCH() (which ends up invoking
ts_resource_ex) in a number of places.
Caller/callee data from Sun Studio's collector/analyzer showed the
following:
Attr. Excl. Incl. Name
User CPU User CPU User CPU
sec. sec. sec.
178.105 185.460 363.564 _emalloc
96.568 114.320 210.888 _efree
27.960 89.232 343.901 _zval_ptr_dtor
19.544 6.685 26.228 php_body_write_wrapper
6.925 36.806 224.617 _zval_dtor_func
4.263 2.902 7.165 safe_free_zval_ptr_rel
4.163 11.898 16.061 zend_get_parameters_ex
4.013 14.690 174.682 my_copy_zval
3.963 6.775 10.738 _erealloc
3.502 12.399 978.444 apc_copy_function_for_execution
2.732 4.143 9.647 do_inherit_method_check
2.592 21.565 225.137 _zval_copy_ctor_func
0.881 22.095 106.535 virtual_file_ex
0.600 1.961 6.855 list_entry_destructor
0.470 1.301 24.397 zend_file_handle_dtor
0.410 1.781 2.712 zend_function_dtor
0.270 0.350 0.620 convert_to_array
0.220 0.991 15.831 apc_search_paths
0.150 0.490 3.362 zend_register_resource
0.140 1.581 10.137 zend_alter_ini_entry
0.130 4.833 9023.272 php5_execute
0.110 0.500 3.502 zend_ini_long
0.070 0.530 0.600 _zend_bailout
0.050 0.320 4.513 zend_error
0.040 0.690 3.913 php_error_cb
0.040 0.560 2.852 zend_alter_ini_entry_ex
0. 3.202 584.369 php_request_shutdown
274.252 274.252 357.910 *ts_resource_ex
83.659 84.749 84.749 pthread_getspecific
Propagating the value of TSRMLS_CC will avoid the overhead of having
to invoke tsrm_tls_get/pthread_get_specific. The following patch
(against trunk) does this:
http://bitbucket.org/arvi/arviq/src/tip/svn-TSRM-patch.txt
Reproduce code:
---------------
http://marc.info/?l=php-internals&m=125958800305102&w=2
is the relevant
email thread on the internals mailing list.
Expected result:
----------------
Improved multi-threaded performance.
--
Edit bug report at http://bugs.php.net/?id=50436&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50436&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50436&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50436&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50436&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50436&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50436&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50436&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50436&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50436&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50436&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50436&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50436&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50436&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50436&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50436&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50436&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50436&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50436&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50436&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50436&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50436&r=mysqlcfg
Thread (2 messages)
- yoarvi at gmail dot com