Release GIL in blocking AIO bindings - #8196
Conversation
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bab900afc3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
|
@tohtana thanks for this PR.
|
|
@tohtana on further thoughts, I think my perf concerns are invalid because the changes swap GIL for per-handle mutex, and so it should actually improve perf. Do you agree? |
|
@tohtana do you think similar GIL concerns also apply to the GDS variant: |
|
Hi @sfc-gh-truwase,
Yes, basically it won't hurt performance. We have much smaller critical sections now. When I briefly ran the benchmark, read showed a stable performance (10.066 → 10.029 GB/s). But the write showed a lot of fluctuation in my env and I currently don't have reliable numbers.
I think the concern is valid, and the exact same approach as this PR is not sufficient. We would need additional work to protect resources specific to GDS. It should be a follow-up PR. |
The blocking parallel AIO bindings can call the handle's internal
wait()while retaining the Python GIL. An AIO worker may need that GIL while completing PyTorch tensor cleanup. This causes a deadlock: the Python caller waits for the worker, while the worker waits for the GIL held by the caller.This PR releases the GIL at the
pread,pwrite,sync_pread, andsync_pwritepybind entrypoints to avoid the deadlock.