Performance: my_hash_sort_bin is called too often

Description

According to various profiler reports, my_hash_sort_bin() is among heaviest functions for simple SELECT queries.

Firstly my_hash_sort_bin() is called too often:
1. twice while acquiring MDL lock (same key)
2. once while acquiring table from table cache (almost same key)
3. once while releasing MDL lock (same key)

For all the above cases it is sufficient to calculate value only once. Though table cache may need a bit more complex solution.

Secondly my_hash_sort_bin() seem to do a lot memory accesses, more details here: http://bazaar.launchpad.net/~mysql/mysql-server/5.7/revision/5107.1.537

perf report for non-patched version:

perf report for patched version:

perf report for patched version + reuse hash value in table cache:

According to simple SELECT tests QPS went up from 14593 to 14843 (over 1.5%):

Environment

None

Assignee

Sergey Vojtovich

Reporter

Sergey Vojtovich

Labels

None

Fix versions

Affects versions

Priority

Major
Configure