This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inconsistent size for GIL release in hashlib
Type: Stage: resolved
Components: Documentation Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jcea Nosy List: berker.peksag, docs@python, jcea, python-dev
Priority: normal Keywords: easy

Created on 2013-10-04 01:36 by jcea, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg198930 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2013-10-04 01:36
In http://docs.python.org/3.3/library/hashlib.html there is a contradiction:

"""
For better multithreading performance, the Python GIL is released for strings of more than 2047 bytes at object creation or on update.

[...]

Changed in version 3.1: The Python GIL is released to allow other threads to run while hash updates on data larger than 2048 bytes is taking place when using hash algorithms supplied by OpenSSL.
"""

So is it 2047 or 2048? :)
msg198931 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2013-10-04 01:57
It looks like it is 2048: http://hg.python.org/cpython/rev/f9f5d9047a05/

See also issue 4751.
msg198932 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2013-10-04 02:12
For extra safety, I just checked the source of 3.4:

"""
#define HASHLIB_GIL_MINSIZE 2048

[...]

if (self->lock == NULL && view.len >= HASHLIB_GIL_MINSIZE) {

[...]

if (view.len >= HASHLIB_GIL_MINSIZE) {

[...]

if (len >= HASHLIB_GIL_MINSIZE) {
"""

So, yes, the GIL is released if len >= 2048 bytes.

BTW, in Python 3.x hashes can't be calculated on strings, but bytes.

I take care of this. Commit in 5 minutes.
msg198933 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-04 02:16
New changeset 310c26df3234 by Jesus Cea in branch '3.3':
Close #19160: Inconsistent size for GIL release in hashlib
http://hg.python.org/cpython/rev/310c26df3234

New changeset 9503097ce1b7 by Jesus Cea in branch 'default':
MERGE: Close #19160: Inconsistent size for GIL release in hashlib
http://hg.python.org/cpython/rev/9503097ce1b7
msg198934 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-04 02:21
New changeset bfebfadfc4aa by Jesus Cea in branch '3.3':
Close #19160: Inconsistent size for GIL release in hashlib
http://hg.python.org/cpython/rev/bfebfadfc4aa

New changeset 989ea05b2500 by Jesus Cea in branch 'default':
MERGE: Close #19160: Inconsistent size for GIL release in hashlib
http://hg.python.org/cpython/rev/989ea05b2500
History
Date User Action Args
2022-04-11 14:57:51adminsetgithub: 63359
2013-10-04 02:21:22python-devsetmessages: + msg198934
2013-10-04 02:16:06python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg198933

resolution: fixed
stage: resolved
2013-10-04 02:12:49jceasetassignee: docs@python -> jcea
messages: + msg198932
2013-10-04 01:57:46berker.peksagsetnosy: + berker.peksag
messages: + msg198931
2013-10-04 01:36:13jceacreate