-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[internal] Make GIL usage explicit for
session_poll_workunits
(#13609)
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` return `Vec<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 the `py.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: ``` ❯ hyperfine -w 1 -r 10 './pants -ldebug --no-pantsd list ::' Time (mean ± σ): 4.611 s ± 0.206 s [User: 2.940 s, System: 0.474 s] Range (min … max): 4.419 s … 5.153 s 10 runs ``` After: ``` ❯ hyperfine -w 1 -r 10 './pants -ldebug --no-pantsd list ::' Time (mean ± σ): 4.655 s ± 0.113 s [User: 2.975 s, System: 0.509 s] Range (min … max): 4.430 s … 4.827 s 10 runs ``` ### Pantsd Before: ``` ❯ hyperfine -w 1 -r 10 './pants -ldebug --concurrent --pantsd list ::' Time (mean ± σ): 2.641 s ± 0.021 s [User: 2.026 s, System: 0.323 s] Range (min … max): 2.602 s … 2.670 s 10 runs ``` After: ``` ❯ hyperfine -w 1 -r 10 './pants -ldebug --concurrent --pantsd list ::' Time (mean ± σ): 2.651 s ± 0.023 s [User: 2.036 s, System: 0.334 s] Range (min … max): 2.611 s … 2.693 s 10 runs ``` [ci skip-build-wheels]
- Loading branch information
1 parent
66673f0
commit 996ff41
Showing
3 changed files
with
84 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters