Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46255 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63789 invoked from network); 30 Nov 2009 20:03:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2009 20:03:51 -0000 X-Host-Fingerprint: 95.31.13.88 xdmitri2.static.corbina.ru Received: from [95.31.13.88] ([95.31.13.88:13817] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/46-43487-525241B4 for ; Mon, 30 Nov 2009 15:03:51 -0500 Message-ID: To: internals@lists.php.net References: Date: Mon, 30 Nov 2009 23:03:45 +0300 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Posted-By: 95.31.13.88 Subject: Re: [PHP-DEV] [PATCH] - Improving multi-threaded performance by propagating TSRMLS_C From: dmda@yandex.ru ("jvlad") > Hi Pierre, > > >> slow (as you noticed). However it can't be done in 5.3 as it will >> break the ABI. >> > > I noticed that a recent fix (http://bugs.php.net/bug.php?id=49936) > added TSRMLS_DC to an API in 5.3. > http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/main/streams/php_stream_context.h?r1=290796&r2=290795&pathrev=290796 > > Wouldn't that need to be reverted as it breaks the ABI? > How about the idea below: you can introduce new functions/macros with TSRMLSx propagated in, in v5.3 without changing existing API exposed to extensions, and make core using new API. Old functions/macros can be marked as deprecated. This will preseve ABI in v5.3 :) As of v6, you don't have to preserve ABI, so you can do replace the functions with new ones at once (introduce new, remove old, get all parts using new). Hmm and the diff will be big... BTW, did you try to avoid pthread_get_specific() calls now and forever? Something like just one pointer in static TLS would do. http://people.redhat.com/drepper/tls.pdf http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html Since static TLS storage is quite a limited resource under some OSes, I think it will be wise to use only one thread-specific pointer in TLS and this pointer will point to the thread-specific array of pointers (not in TLS but in regular heap) and these pointers will point to all thread-globals like CG(), EG(), etc. The index of the array will be well-known id returned by ts_allocate_id. These arrays should be big enough to allow new globals to be added in run-time without re-allocating all the arrays in all currently running threads (see how ts_allocate_id() extends the arrays with pointers one by one, locking all threads). Structure and dereferencing will be exactly the same as currently implemented in TSRM.h, only storage will be declared global with __thread prefix and all related calls like TlsAlloc(), pthread_key_create would be removed. -jv