Bug #54728 Unnecessary overhead in the 64-bit "dulint" struct type
Submitted: 23 Jun 2010 9:50 Modified: 24 Aug 2010 18:50
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:3.23, 4.0, 4.1, 5.0, 5.1, 5.5 OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any
Tags: dulint 64-bit
Triage: Triaged: D3 (Medium) / R2 (Low) / E3 (Medium)

[23 Jun 2010 9:50] Marko Mäkelä
Description:
When InnoDB was originally developed in the 1990s, 64-bit processors were not common and not all compilers for 32-bit processors supported a 64-bit integer data type. This may have been a good solution back then.

typedef	struct dulint_struct	dulint;
struct dulint_struct{
	ulint	high;
	ulint	low;
};

Unfortunately, on 64-bit processors, this will take twice the space (2*64 bits) and the arithmetic operations will be slow too. The dulint type also makes code harder to read and maintain, even on 32-bit systems.

How to repeat:
Run some benchmarks on 64-bit systems. Replace dulint with a native 64-bit data type, and you should see some improvement in both memory usage and execution speed.

Suggested fix:
Replace dulint with a typedef based on ib_uint64_t.
[23 Jun 2010 11:08] 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/111884
[23 Jun 2010 11:08] 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/111885
[23 Jun 2010 14:23] Jimmy Yang
Ok to push. A couple of comments sent to Marko.
[24 Jun 2010 6:12] Marko Mäkelä
Pushed to mysql-trunk-innodb. This will not be fixed in MySQL versions before 5.5.
[4 Aug 2010 7:52] Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100624104620-pklunowaigv7quu9) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:02] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100624104620-pklunowaigv7quu9) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:18] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100624104620-pklunowaigv7quu9) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 9:01] Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:marko.makela@oracle.com-20100624104620-pklunowaigv7quu9) (pib:20)
[24 Aug 2010 18:50] Paul Dubois
Noted in 5.5.6, 5.6.0 changelogs.

Implementation of the 64-bit dulint structure in InnoDB was not
optimized for 64-bit processors, resulting in excessive storage and
reduced performance.