Hi Nikita,

On 2/13/19 12:02 PM, Nikita Popov wrote:
> On Wed, Feb 13, 2019 at 9:26 AM Dmitry Stogov <dmi...@zend.com 
> <mailto:dmi...@zend.com>> wrote:
> 
>     Hi,
> 
> 
>     After JIT+ZTS related discussion with Joe and Bob, and some related
>     analyzes.
> 
>     I came to more or less formed design idea and described it at
>     https://wiki.php.net/zts-improvement
> 
>     This is not an RFC and I'm not sure, if I like to implement TSRM
>     changes myself now.
> 
> 
>     Comments are welcome.
> 
> 
> Hi Dmitry,
> 
> Thanks for looking into this issue. As a possible alternative I would 
> like to suggest the use of ZEND_TLS (__thread) for the EG/CG/BG etc 
> globals on Linux (on Windows this is not possible due to DLL linkage 
> restrictions).

I played with __thread long time ago (may be 10 years), and that time it 
didn't work as expected. I can't remember the exact problems. May be it 
made troubles when used in DSO PHP build with DSO extensions, may be the 
size of "__thread" segment was limited, may be both.

> __thread generates very good code (single load over %fs 
> segment with constant address) if the global is defined and used in an 
> executable.

I suppose 2 loads:

        movq    executor_globals@gottpoff(%rip), %rax
        movq    %fs:field_offset(%rax), %rax

> I'm not sure what kind of code it generates when TLS is 
> declared in an executable and used in a shared object, but as direct 
> access from extensions to the engine globals shouldn't be common, it's 
> probably okay even if it uses __tls_get_addr.

The main problem with "__thread" might be portability.
I especially thought about keeping TSRM layer with the same API, to 
avoid portability issues, but if "__thread" works fine, we definitely 
should use it.

On the other hand, I'm not sure, who uses ZTS build today and if they 
need performance.

Thanks. Dmitry.


> 
> Nikita

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

Reply via email to