On 13Nov2019 1954, Larry Hastings wrote:
On 11/13/19 5:52 AM, Victor Stinner wrote:
Le mer. 13 nov. 2019 à 14:28, Larry Hastings<la...@hastings.org> a écrit :
I did exactly that in the Gilectomy prototype. Pulling it out of TLS was too
slow,
What do you mean? Getting tstate from a TLS was a performance
bottleneck by itself? Reading a TLS variable seems to be quite
efficient.
I'm pretty sure you understand the sentence "Pulling it out of TLS was
too slow". At the time CPython used the POSIX APIs for accessing thread
local storage, and I didn't know about and therefore did not try this
"__thread" GCC extension. I do remember trying some other API that was
purported to be faster--maybe a GCC library function for faster TLS
access?--but I didn't get that to work either before I gave up on it out
of frustration.
Also, I dimly recall that I moved several things from globals into the
ThreadState structure, and probably added one or two of my own. So
nearly every function call was referencing ThreadState at one point or
another. Passing it as a parameter was a definite win over calling the
POSIX TLS APIs.
Passing it as a parameter is also a huge win for embedders, as it gets
very complicated to merge locking/threading models when the host
application has its own requirements.
Overall, I'm very supportive of passing context through parameters
rather than implicitly through TLS.
(Though we've got a long way to go before it'll be possible for
embedders to not be held hostage by CPython's threading model... one
step at a time! :) )
Cheers,
Steve
_______________________________________________
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/TLMDK7JZQIUWQUUKFHOPNEFQCJKFL5JM/
Code of Conduct: http://python.org/psf/codeofconduct/