gh-112535: Implement fallback implementation of _Py_ThreadId() by corona10 · Pull Request #113185 · python/cpython · GitHub
Skip to content

gh-112535: Implement fallback implementation of _Py_ThreadId() - #113185

Merged
corona10 merged 4 commits into
python:mainfrom
corona10:gh-112535-fallback
Dec 18, 2023
Merged

gh-112535: Implement fallback implementation of _Py_ThreadId()#113185
corona10 merged 4 commits into
python:mainfrom
corona10:gh-112535-fallback

Conversation

@corona10

@corona10 corona10 commented Dec 15, 2023

Copy link
Copy Markdown
Member

@corona10

Copy link
Copy Markdown
Member Author

@colesbury colesbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions on code comments below. I think we should put any detailed explanations of _Py_GetThreadLocal_Addr near the implementation (and not where it's called in _Py_ThreadId().

I don't think there's a lot we can say generally about the implementation of &_Py_tss_tstate -- it depends on the platform, but adding a constant offset is generally not expensive. There are two common costs:

  1. Calling _Py_GetThreadLocal_Addr(), which mostly can't be inlined.
  2. Depending on the implementation of TLS, computing the address may or may not require another function call.

Comment thread Include/object.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should just be an #else. We're not using thread_local or depending on GNU specific features here in object.h.

Comment thread Python/pystate.c Outdated
Comment thread Python/pystate.c
Comment thread Include/object.h Outdated
corona10 and others added 2 commits December 19, 2023 01:27
Co-authored-by: Sam Gross <colesbury@gmail.com>
@corona10
corona10 enabled auto-merge (squash) December 18, 2023 16:32
@corona10
corona10 merged commit d00dbf5 into python:main Dec 18, 2023
@corona10
corona10 deleted the gh-112535-fallback branch December 18, 2023 16:55
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants