Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-36051: drop GIL during large b''.join operations #17757
+45
−19
Conversation
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.
This comment has been minimized.
This comment has been minimized.
For now I've only made the change for the b''.join fast-path, but if there is agreement I could also add it to the general case (non-empty separator). I think the code is safe against another thread mutating the sequence while the GIL is dropped (because the setup code takes it own refs to all the items), but it would be good if someone could double-check it. |
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).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
bmerry commentedDec 30, 2019
•
edited by bedevere-bot
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.
https://bugs.python.org/issue36051