-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add CI/wheel builder for the free-threaded build #190
Add CI/wheel builder for the free-threaded build #190
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #190 +/- ##
==========================================
+ Coverage 79.81% 81.46% +1.64%
==========================================
Files 24 24
Lines 1635 1737 +102
Branches 241 239 -2
==========================================
+ Hits 1305 1415 +110
+ Misses 184 178 -6
+ Partials 146 144 -2 |
The Windows failure is related to pypa/setuptools#4662 and should be fixed in the next setuptools release. |
Thanks. Do you plan to add the global lock as part of this PR ? |
Whatever you prefer @MatthieuDartiailh. I was thinking of adding the global lock as part of another PR so that one is not blocked by the other. Does that work? Although, if we decide to open a new PR for the global lock, this one should probably be merged without Windows support so there's some kind of CI coverage. |
I think I would prefer to have everything in that PR because I won't publish wheels without it I think. |
Alright, I'll push everything here then. |
@MatthieuDartiailh I just completed doing the implementation of the global lock, where locking happens every time we switch from the Python bindings into C++ land. This does not solve all possible threading issues, cause there's still a few of them in the Python binding implementation (eg switching pointers around in shared I actually also did a somewhat deeper dive into the code and I think that the following would work nicely:
What do you think? |
Thanks @lysnikolaou !
I am not sure what you refer to here. Could you point me to an example ? Also do you have an idea how this could be addressed ?
We do not use an atomic reference counted pointer for performance (the C++ implementation is document as not being thread safe because of it). I had hoped we could enforce enough control on the binding to preserve this property of the C++ code. I think having a global lock on creation and destruction of reference counted C++ resource should be sufficient to guarantee the safety of the code (I am conscious doing it right may not be so easy, but do you agree on the principle ?)
The C++ code does not have any global state as far as I remember (and I will try to check again).
If the current solution is safe, I will likely merge as is to unblock the situation. In a second time I will try to look at benchmarks using std::shared_ptr to see how much performance penalty we would hit because of it, to see if it worth moving away from a global library lock. |
I'm referring to the fact that some objects are not immutable. For example, users can change variable contexts in place with PyObject*
Variable_setContext( Variable* self, PyObject* value )
{
if( value != self->context )
{
Py_XSETREF(self->context, cppy::incref( value ));
}
Py_RETURN_NONE;
} This is not thread-safe if
I agree with that in principle, yes, but I'm still not clear on whether more localized locks +
I'll check whether there's any more instances of thread-unsafe stuff happening on the Python side and let you know today, so that we can merge this. Thanks a lot for the help! |
@MatthieuDartiailh I could find any more thread unsafe stuff in the Python bindings (other than the one already mentioned above). I just pushed two commits:
With these, I think we're good to go! |
64a147d
to
01763db
Compare
Looks like you have some include issues. |
a1b1005
to
1123323
Compare
I will merge as is to be able to test the release workflow but I will wait for the setuptools fix to cut a new release. |
No description provided.