Bug #99097 Suboptimal impl of integer load/store InnoDB functions for big-endian arch

Submitted: 27 Mar 2020 10:41 Modified: 27 Mar 2020 14:00
Reporter: Dmitry Shulga Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[27 Mar 2020 10:41] Dmitry Shulga
Description:
InnoDB has its own inline functions to load/store integer values from/to
memory. These functions make conversion between a host byte order and the
big-endian representation because the InnoDB on-disk format is big-endian.
Unfortunately, implementation of these functions could be translated by
compiler to not optimal assembler code. The following Godbolt link
https://godbolt.org/z/Bvm4hx shows how optimized and not-optimized functions
look like after compiler generated assembler code.

The following commit
https://github.com/mysql/mysql-server/commit/f717e0567457e8a0d513ac17ff63d62e3dc0670d
and its follow-up
https://github.com/mysql/mysql-server/commit/7c24e9bd619304dd7655f4fee4ef52a238d25d13
provide functions to convert 2-bytes and 4-bytes integers to/from big-endian
format.

Unfortunately, similar functions are missed for 3-bytes, 5-bytes, 6-bytes,
7-bytes and 8-bytes integers. Moreover, mi_*() macros and inlined functions
located in the file include/myisampack.h use own implementation to load/store
integer in big-endian format. Additionally, implementation of functions
mach_read_from_*, mach_write_to_* use direct manipulation with bytes array
instead of calling the load*be()/store*be() functions to store/load integers
in big-endian representation. That leads to code duplication and code bloating
in the mysqld binary.

This bug report is to make optimization of source code for loading/storing
integers in big-endian format and to refactor source code for storing/loading
integers in big-endian format to avoid code duplication.

How to repeat:
Do code analysis and look to Godbolt output https://godbolt.org/z/Bvm4hx
[27 Mar 2020 14:00] MySQL Verification Team
Hello Mr. Shulga,

Thank you for your bug report. However, thank you even more for your contribution.

We are truly grateful.

Verified as reported.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.