Sure. The plan is to use __thread when possible ;-)

Victor

On Thu, Feb 25, 2021 at 4:58 AM 谢俊逸 via Python-Dev
<python-dev@python.org> wrote:
>
> On MacOS & iOS, __thread variable is 35% faster than using 
> pthread_getspecific.
>
> getSpecific cost: 0.000649
> getTLS cost: 0.000423
>
>
> - (void)test { double t1 = CFAbsoluteTimeGetCurrent(); for (int i = 0; i < 
> 100000; i++) { [self getSpecific]; } double t2 = CFAbsoluteTimeGetCurrent(); 
> printf("getSpecific cost: %f\n", t2 - t1); double t3 = 
> CFAbsoluteTimeGetCurrent(); for (int i = 0; i < 100000; i++) { [self getTLS]; 
> } double t4 = CFAbsoluteTimeGetCurrent(); printf("getTLS cost: %f\n", t4 - 
> t3); } - (int)getSpecific { int * value = pthread_getspecific(tlsKey); return 
> *value; } - (int)getTLS { return *tlv_v5; }
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-dev@python.org/message/KTHAKNENSBKURE7I2SRVXEPJ6NDNCACI/
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/23MHKR44CZTGW7K3NCZADBRWDRA2BHIN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to