bpo-36051: drop GIL during large b''.join operations by bmerry · Pull Request #17757 · python/cpython
Improve multi-threaded performance by dropping the GIL in the fast path of bytes.join. To avoid increasing overhead for small joins, it is only done if the output size exceeds a threshold.
The existing stress test is increased in size to exceed GIL_THRESHOLD, and a new stress test is added with an empty separator (since that is a separate code path).
The GIL is now also dropped in the code path with non-empty separator, but it is *not* dropped if any of the items is not a `bytes` object (see discussion in bpo-36051 for reasoning).
shihai1991 pushed a commit to shihai1991/cpython that referenced this pull request
Jan 31, 2020This was referenced
Mar 6, 2026copybara-service bot pushed a commit to grpc/grpc that referenced this pull request
Mar 23, 2026Remove one of the GIL contention from the grpc python wrapper. The python [releases the GIL](python/cpython#17757) while doing b"".join. This was one of the major GIL contention in the python wrapper. Fixing this significantly reduces the GIL contention. Closes #41812 COPYBARA_INTEGRATE_REVIEW=#41812 from googlyrahman:samplefix df4796a PiperOrigin-RevId: 888241985
asheshvidyut pushed a commit to asheshvidyut/grpc that referenced this pull request
Mar 26, 2026) Remove one of the GIL contention from the grpc python wrapper. The python [releases the GIL](python/cpython#17757) while doing b"".join. This was one of the major GIL contention in the python wrapper. Fixing this significantly reduces the GIL contention. Closes grpc#41812 COPYBARA_INTEGRATE_REVIEW=grpc#41812 from googlyrahman:samplefix df4796a PiperOrigin-RevId: 888241985
asheshvidyut pushed a commit to asheshvidyut/grpc that referenced this pull request
Apr 8, 2026) Remove one of the GIL contention from the grpc python wrapper. The python [releases the GIL](python/cpython#17757) while doing b"".join. This was one of the major GIL contention in the python wrapper. Fixing this significantly reduces the GIL contention. Closes grpc#41812 COPYBARA_INTEGRATE_REVIEW=grpc#41812 from googlyrahman:samplefix df4796a PiperOrigin-RevId: 888241985
This file contains hidden or 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