-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement chunk iterators that drop the GIL #106
Conversation
42d05eb
to
5997114
Compare
I think it's better to provide a default limited chunk size rather than using None as default--doesn't seem like a default behaviour. |
Iter_chunk still seems significantly slower, although the chunk size is pretty large (25000). |
That's because it's doing 4x more work for less than 4x time |
backwards: bool, | ||
py: Python, | ||
) -> PyResult<Vec<(PyObject, PyObject)>> { | ||
let raw_items = py.allow_threads(|| -> PyResult<Vec<(Box<[u8]>, Box<[u8]>)>> { |
Check warning
Code scanning / clippy
very complex type used. Consider factoring parts into type definitions Warning
This is now done.
@Congyuwang iter chunk is faster. It's probably more helpful to look at the |
I'm comparing iter vs. iter_chunk. Not multithreaded vs. single threaded. Seems that based on the previous benchmark, multithreaded iter chunk is slower than multithreaded iter where GIL is not released. |
Looks like we have some kind of deadlock. |
This allows callers to get chunks at a time from the iterator and in such scenarios, it makes sense to drop the GIL.
Dropping the GIL is not only useful for scenarios when there are multiple iterators but when code may be calling other GIL-dropping code.