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
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).
Benchmarking shows that for smaller thresholds the multi-threading performance tends to be worse, or at least not much better.
@@ -0,0 +1 @@ | |||
Drop the GIL during large ``bytes.join`` operations. |
This comment has been minimized.
This comment has been minimized.
methane
Jan 28, 2020
Member
Add your name in ACKS (see https://devguide.python.org/pullrequest/#crediting),
and add "Patch by ...." here.
This comment has been minimized.
This comment has been minimized.
bmerry
Jan 29, 2020
Author
Contributor
I've already added myself to ACKS, but have now added "Patch by ...".
This comment has been minimized.
This comment has been minimized.
methane
Jan 29, 2020
Member
I can not find "Bruce Merry" in ACKS.
https://github.com/python/cpython/blob/master/Misc/ACKS
This comment has been minimized.
This comment has been minimized.
bmerry
Jan 29, 2020
Author
Contributor
That's the master version of ACKS. I'm adding myself in this pull request: https://github.com/bmerry/cpython/blob/bpo-36051/Misc/ACKS#L1109
d07d9f4
into
python:master
This comment has been minimized.
This comment has been minimized.
bedevere-bot
commented
Jan 29, 2020
|
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.
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