Bug #49491 | Much overhead for MD5() and SHA1() on short strings | ||
---|---|---|---|
Submitted: | 6 Dec 2009 23:14 | Modified: | 12 Mar 2010 16:35 |
Reporter: | Jan Steemann (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: General | Severity: | S5 (Performance) |
Version: | 5.1.38 and above | OS: | Any |
Assigned to: | Davi Arnaut | CPU Architecture: | Any |
Tags: | Contribution, md5, performance, sha1 |
[6 Dec 2009 23:14]
Jan Steemann
[6 Dec 2009 23:15]
Jan Steemann
Patch for sql/item_strfunc.cc for MySQL 5.1.38
Attachment: md5_sha1_speedup.diff (application/octet-stream, text), 2.08 KiB.
[7 Dec 2009 20:19]
Lenz Grimmer
Hi Jan, thank you very much for your contribution! We appreciate it. In order for us to be able to accept and incorporate your contribution, I have to ask you for one additional favor, which you only have to perform once for all future contributions (including any other Sun-governed Open Source project). Can you please fill out and send us a copy of the Sun Contributor Agreement (SCA), as outlined on the following Wiki page? http://forge.mysql.com/wiki/Contributing_Code Thanks in advance! Please let us know, if you have any questions or concerns about this.
[10 Dec 2009 18:09]
Jan Steemann
I have filled out the SCA and sent it to Sun via fax on Dec 8, 2009. Now waiting to be listed in the SCA signatories list.
[25 Dec 2009 7:57]
Sveta Smirnova
Thank you for the report. Verified with following results. Linux 64 bit 5.1 without patch: md5 - 4 sec sha1 - 8 sec Linux 64 bit 5.1 with patch: md5 - 3 sec sha1 - 7 sec MacOS 32-bit without patch: md5 - 10 sec sha1 - 20 sec MacOS 32-bit with patch: md5 - 7 sec sha1 - 13 sec
[26 Jan 2010 14:54]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/98208 3334 Davi Arnaut 2010-01-26 Bug#49491: Much overhead for MD5() and SHA1() on short strings MySQL's hash functions MD5 and SHA relied on the somewhat slow sprintf function to convert the digests to hex representations. This patch replaces the sprintf with a specific and inline hex conversion function. Patch contributed by Jan Steemann. @ sql/item_strfunc.cc Add a hex conversion function.
[26 Jan 2010 17:05]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/98225 3334 Davi Arnaut 2010-01-26 Bug#49491: Much overhead for MD5() and SHA1() on short strings MySQL's hash functions MD5 and SHA relied on the somewhat slow sprintf function to convert the digests to hex representations. This patch replaces the sprintf with a specific and inline hex conversion function. Patch contributed by Jan Steemann. @ sql/item_strfunc.cc Add a hex conversion function.
[26 Jan 2010 17:08]
Davi Arnaut
Queued to 5.1-bugteam
[4 Feb 2010 10:19]
Bugs System
Pushed into 5.1.44 (revid:joro@sun.com-20100204101444-2j32mhqroo0iiio6) (version source revid:davi.arnaut@sun.com-20100126170519-bgtcp6eg8rp3tgst) (merge vers: 5.1.43) (pib:16)
[5 Feb 2010 11:48]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100204063540-9czpdmpixi3iw2yb) (version source revid:alik@sun.com-20100130212638-ai8t5v3u6647p6d2) (pib:16)
[5 Feb 2010 11:54]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100205113942-oqovjy0eoqbarn7i) (version source revid:alik@sun.com-20100204064210-ljwanqvrjs83s1gq) (merge vers: 6.0.14-alpha) (pib:16)
[5 Feb 2010 12:00]
Bugs System
Pushed into 5.5.2-m2 (revid:alik@sun.com-20100203172258-1n5dsotny40yufxw) (version source revid:alik@sun.com-20100130191336-i53i9wx67n81ridm) (merge vers: 5.5.2-m2) (pib:16)
[10 Feb 2010 19:23]
Paul DuBois
Noted in 5.1.44, 5.5.2, 6.0.14 changelogs. The MD5() and SHA1() functions had excessive overhead for short strings. Setting report to Need Merge pending push to Celosia.
[12 Mar 2010 14:14]
Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:30]
Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:46]
Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[12 Mar 2010 16:35]
Paul DuBois
Fixed in earlier 5.1.x, 5.5.x.
[29 Jan 2011 6:46]
Linhai Song
Description: There is a similar code fragment in sql/table.cc /* calculate md5 of query SYNOPSIS TABLE_LIST::calc_md5() buffer buffer for md5 writing */ void TABLE_LIST::calc_md5(char *buffer) { uchar digest[16]; MY_MD5_HASH(digest, (uchar *) select_stmt.str, select_stmt.length); sprintf((char *) buffer, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]); } I think this code fragment has similar problem. Should it also be patched? thanks a lot
[11 Jun 2012 16:34]
Paul DuBois
Noted in 5.6.6 changelog.