Rate This Document
Findability
Accuracy
Completeness
Readability

Database Kernel Tuning

Purpose

Tune the database kernel to improve database performance.

Procedure

  1. Analyzing database kernel bottlenecks
    • Use the perf top tool to capture hotspot functions.
    • Use the Kunpeng DevKit to perform analysis.
    • Use the performance analysis tool provided by the database, for example, Performance Schema of MySQL.
  2. Analyzing the kernel source code for optimization methods
    • Lock size reduction: Use fine-grained locks to reduce lock contention.
    • Cache line alignment: Use cache line alignment to eliminate false sharing.
    • SIMD instruction acceleration: Use the SVE or NEON instruction to accelerate computing.
    • Inline function: For small functions that are frequently called, the time overhead caused by calling can be much higher than that by the function running. Therefore, the "inline" keyword can be added before the function definition to define the function as an inline function, reducing the time overhead caused by frequent calling and improving performance.
Kernel optimization cases:
  • MySQL CRC32 instruction optimization: In the Kunpeng processor, the MySQL CRC32 instruction optimization feature uses Kunpeng CRC32 hardware instructions to replace the CRC32 software algorithm, lowering the CRC32 calculation overhead.
  • MySQL fine-grained lock optimization: In the OLTP scenario, a large number of DML statements (INSERT, UPDATE, DELETE) are concurrently executed on the key data structure protected by the lock_sys->mutex global lock. As a result, the lock contention is severe and the performance deteriorates. To solve this problem, the Kunpeng BoostKit provides an optimization feature that uses fine-grained hash bucket locks to replace global locks, reducing lock conflicts and improving concurrency.