Suboptimal debug code in mem_init_buf() and mem_erase_buf()

Reported by Laurynas Biveinis on 2013-03-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server
Status tracked in 5.6
5.1
Low
Unassigned
5.5
Low
Unassigned
5.6
Low
Unassigned
Percona XtraBackup
Undecided
Laurynas Biveinis
2.0
Undecided
Laurynas Biveinis
2.1
Undecided
Laurynas Biveinis

Bug Description

Callgrind simulated profiling of compact_compressed testcase on 5.6 debug configuration shows it spending ~56% of its cycles in ut_rnd_gen_ibool(), which is only called from UNIV_MEM_DEBUG-enabled mem_init_buf() / mem_erase_buf(), with a significant numbers of calls coming from UNIV_ZIP_DEBUG page_zip_validate().

Both mem_init_buf() and mem_erase_buf() fill the buffer with one of the two possible values, chosen randomly for each individual byte:

for each byte
       if (ut_rnd_gen_ibool()) {
                       *ptr = value1;
               } else {
                       *ptr = value2;
       }

This is very inefficient (reported upstream as http://bugs.mysql.com/bug.php?id=68725), and easy to replace with memset(), which would lose the randomness but would be much faster. Adding such memsets() to innodb56.patch shows compact_compressed testcase cycles to be cut 3x. There are similar results on 5.5 debug configuration as well.

Thus let's add this to XtraBackup InnoDB patches for improved testcase runtime.

A highly unscientific wall time measurement showed the testcase runtime to be reduced from ~1h on compact_compressed testcase to 7min + 8mins for the split compact_compressed_8kb and _16kb.

Reverting Fix Released and the milestone for 2.0 until innodb56.patch is fixed there too.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.