[internal] Make GIL usage explicit for session_poll_workunits
#13609
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prework for #13526. We were reacquiring the GIL directly inside
py.allow_threads(||)
. Rust-cpython allows that, but PyO3 does not. (PyO3 has the benefit of instilling much stronger confidence in reasoning when the GIL is held or not.)We can easily work around this by having
WorkunitStore.with_latest_workunits
returnVec<Workunit>
instead of&[Workunit]
. No new clones are happening! We already were making this Vec. Only now we move the value out, rather than referencing it via a closure passed in as a callback.That change allows for operating on the
Vec<Workunit>
safely outside of thepy.allow_threads(||)
to convert it into the FFI boundary.Benchmark
These benchmarks use the Toolchain BuildSense plugin + anonymous telemetrics streaming workunit handlers.
No pantsd
Before:
After:
Pantsd
Before:
After:
[ci skip-build-wheels]