-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for no-gil/freethreaded work #4265
Comments
As a tiny piece of this and to try to learn the library better, I'm working on adding wrappers for the new |
Just to update the current state of things: pyo3 builds against the free-threaded build if you do:
If you use pyenv, you'll also need to locally delete or modify the This very quicky crashes inside of mimalloc internals, ultimately inside of
Just to make sure all of this is reproducible and we have some feedback on CI, I think I'm going to add a free-threaded CI job marked with |
That sounds great to me, thanks! |
* Update dict.get_item binding to use PyDict_GetItemRef Refs #4265 * test: add test for dict.get_item error path * test: add test for dict.get_item error path * test: add test for dict.get_item error path * fix: fix logic error in dict.get_item bindings * update: apply david's review suggestions for dict.get_item bindings * update: create ffi::compat to store compatibility shims * update: move PyDict_GetItemRef bindings to spot in order from dictobject.h * build: fix build warning with --no-default-features * doc: expand release note fragments * fix: fix clippy warnings * respond to review comments * Apply suggestion from @mejrs * refactor so cfg is applied to functions * properly set cfgs * fix clippy lints * Apply @davidhewitt's suggestion * deal with upstream deprecation of new_bound
I added a new checkbox for " Adopt new owned-reference-friendly C APIs". If we have a list of all the ones we need, I can make those sub-checkboxes. |
I think I also had a chat with @davidhewitt today and in addition to Our first idea is to make GILProtected a no-op on In addition we need to use I looked at adding a failing CI job, but that won't work right now because of if you run the tests on a free-threaded build with |
Ok, updated the tracking list.
|
I'm still learning the library and it shows... I think David meant |
My guess is it's a reference to |
My mistake, yes we removed the |
See #4421 which updates the FFI bindings for the free-threaded build. That's enough to get the tests to pass without deadlocking, so I added a CI config as well. |
Added a checkbox for |
Defaulting to frozen, and then requiring users to pick a strategy for mutability seems good to me. In my experience, a lot of types don't have particularly useful concurrent semantics, and while a lock can make them safe, it can't make it sensible. FWIW my concern is much less that locks have overhead, it's that rw-locks are full of performance cliffs and priority inversion issues (https://blog.nelhage.com/post/rwlock-contention/). |
* Update dict.get_item binding to use PyDict_GetItemRef Refs #4265 * test: add test for dict.get_item error path * test: add test for dict.get_item error path * test: add test for dict.get_item error path * fix: fix logic error in dict.get_item bindings * update: apply david's review suggestions for dict.get_item bindings * update: create ffi::compat to store compatibility shims * update: move PyDict_GetItemRef bindings to spot in order from dictobject.h * build: fix build warning with --no-default-features * doc: expand release note fragments * fix: fix clippy warnings * respond to review comments * Apply suggestion from @mejrs * refactor so cfg is applied to functions * properly set cfgs * fix clippy lints * Apply @davidhewitt's suggestion * deal with upstream deprecation of new_bound
As I commented in #4265, I want to suggest that a realistic goal here for the 0.23 release is to transition from "unusable and unsound" to "unusable but sound for testing". Given that we have breaking changes already landing in 0.23, I think much better to delay the breaking changes needed above in #4265 (comment) to 0.23 (this is primarily immutable by default with the opt-in). Thus for 0.23 I'd like to merge the PRs which make PyO3 sound under free threading but don't change existing semantics, even if those semantics are unhelpful under free threading. This is (as far as I'm aware)
I think that would be good enough to unblock the downstream ecosystem to start testing their own projects under free threading. The focus of the 0.24 release can then be the breaking changes needed to make the semantics of PyO3 actually sensible under free threading. |
That makes sense to me, given that this is clearly documented of course. How are other libraries like Boost and Pybind11 handling this? (If they are even handling nogil at all...) |
I've been experimenting with
(here I'm using a slightly modified version of cargo-stress to get better error reporting, see danhhz/cargo-stress#6). I don't understand how we could be getting a UTF-8 decode error while defining a class. This could be a sign of some thread-safety issue in |
Hmm, we just had the same issue in https://github.com/PyO3/pyo3/actions/runs/11054116502/job/30710180455#step:9:5074 |
Ohhh, I get it, it's because |
Good point, I will try to fix that PR up next time I type a line of code! |
Ah, just realised #4584 - I've added a checkbox for |
really looking forward to this! |
#4298 might imply |
As per python/cpython#125243 (comment) I've added a bullet to the top for datetime bindings. |
Are we good for |
Yes, we should be. The concern about thread safety in the |
God help us, we're close. Has anyone here done a top to bottom perusal of pyo3 for other potential concerns? |
Not me. I did just grep the codebase for I'm also hoping that finishing up #4566 will elucidate any remaining issues in tests and docs. My plan is to help finish that up next week. |
I've got a long train ride tomorrow, so I may take another top to bottom
pass
…On Fri, Oct 25, 2024 at 5:43 PM Nathan Goldbaum ***@***.***> wrote:
Has anyone here done a top to bottom perusal of pyo3 for other potential
concerns?
Not me. I did just grep the codebase for Cell and UnsafeCell uses, and I
think all the remaining ones are safe? The fact that PyAny uses an
UnsafeCell to wrap a PyObject * pointer is OK, right?
I'm also hoping that finishing up #4566
<#4566> will elucidate any remaining
issues in tests and docs. My plan is to help finish that up next week.
—
Reply to this email directly, view it on GitHub
<#4265 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBCEJZGM4BM25NZIEULZ5K3QFAVCNFSM6AAAAABJTCDPMSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZYHEZDCNZUGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
My orm Dependency pydantic。 |
See #4651 . We will be releasing initial support very soon, some challenges at home have delayed the work. Thank you for your patience. |
We didn't have a dedicated issue for this, so now there's one.
TODO:
cfg
for no-gil, but only allowed behind an experimental featureffi-check
passing with a no-GIL buildPyDict_GetItemRef
PyList_GetItemRef
PyDict_Next
PyWeakref_GetRef
PyImport_AddModuleRef
Python<'_>
indicates only a single thread is executing:pyo3::sync::GILOnceCell
PyClassBorrowChecker
GILProtected
PyErrState::normalize
Py_mod_gil
slot should be setdatetime
bindings are not thread safe (?)The text was updated successfully, but these errors were encountered: