Thursday, May 28, 2009

InnoDB checksum performance

Once again Domas is unhappy with some aspect of Innodb performance and doing crazy things with gdb to tune it. I made it faster by changing the checksum code to process one 32-bit word at a time rather than one byte at a time. This will be in a future Google patch and is enabled with the parameter innodb_fast_checksum. This is not compatible with the old checksum so you must dump and reload the database to use it.

I measured the benefit using the insert benchmark from Tokutek on a server that can do a lot of IO. CPU overheads are measured using oprofile. The data below lists the percentage of time for the top 4 functions in mysqld. The checksum is computed in buf_calc_page_new_checksum. By using the fast checksum, the checksum overhead drops from 33.6% to 22.1% for gcc -O2 and from 31.6% to 17.3% for gcc -O3.

Overhead for gcc -O2

Using the original checksum code:
  • 33.6% - buf_calc_page_new_checksum
  • 10.4% - memcpy
  • 4.4% - os_aio_simulated_handle
  • 4.3% - rec_get_offsets_func
Using the fast checksum code:
  • 22.1% - buf_calc_page_new_checksum
  • 12.1% - memcpy
  • 5.1% - rec_get_offsets_func
  • 4.9% - os_aio_simulated_handle
Overhead for gcc -O3

Using the original checksum code:
  • 31.6% - buf_calc_page_new_checksum
  • 12.6% - memcpy
  • 5.8% - rec_get_offsets_func
  • 2.6 - os_aio_simulated_handle
Using the fast checksum code:
  • 17.3% - buf_calc_page_new_checksum
  • 13.6% - memcpy
  • 6.8% - rec_get_offsets_func
  • 2.0% - os_aio_simulated_handle

2 comments:

  1. as you give up backward compatibility, why bother with 32 bit words for checksum calculation? you can use 64 bit words -should go even faster.

    ReplyDelete
  2. It probably would, but then you need to replace the checksum function with one that works for 64-bit integers.

    ReplyDelete

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.