Databases 47 min read

In‑depth Analysis of MySQL InnoDB Buffer Pool Architecture and Performance Optimizations

This article provides a comprehensive technical walkthrough of MySQL‑8.0.22 InnoDB's buffer pool, detailing its physical and logical structures, page management algorithms, fast read/write optimizations, change buffer, adaptive hash index, and the complete page‑read call stack, complete with code excerpts and diagrams.

Tencent Database Technology
Tencent Database Technology
Tencent Database Technology
In‑depth Analysis of MySQL InnoDB Buffer Pool Architecture and Performance Optimizations

The buffer pool is InnoDB's in‑memory cache that stores data pages, lock information, change‑buffer entries, adaptive hash index structures, and more, enabling fast access and reducing disk I/O.

Physical structure : a buffer pool consists of multiple buf_pool_t instances, each divided into chunks and pages . Instances are created based on innodb_buffer_pool_size / innodb_buffer_pool_instances to avoid lock contention. Each page is represented by buf_block_t and buf_page_t , with a default size of 16 KB.

Logical structure : InnoDB uses several linked lists—free list, LRU list, unzip LRU list, CLOCK list, unzip CLOCK list, flush list, zip clean list, and withdraw list—to manage pages. The LRU list implements a modified LRU algorithm with a midpoint, young list, and old list to protect hot pages from eviction.

Fast read/write optimizations include buffer‑pool initialization, single‑node warm‑up (dump/load), master‑slave buffer‑pool synchronization, change‑buffer caching for secondary‑index modifications, and the adaptive hash index (AHI) that builds hash shortcuts for frequently accessed keys.

Page‑read process : the call stack starts with buf_page_get_gen , proceeds through Buf_fetch<T>::single_page , Buf_fetch_normal::get , lookup in the page hash, and, if missing, buf_read_page_low . Allocation may involve buf_LRU_get_free_block , which falls back to scanning the LRU list, flushing pages, or evicting from unzip LRU. The function buf_page_init_for_read prepares a temporary descriptor for compressed pages, allocates space from the buddy system, and finally inserts the page into the appropriate lists.

Throughout the process, InnoDB carefully balances memory usage, I/O patterns (random, linear, and scan pre‑reads), and concurrency control to maintain high throughput and low latency for database workloads.

Memory ManagementcachingInnoDBMySQLdatabase performanceBuffer Pool
Tencent Database Technology
Written by

Tencent Database Technology

Tencent's Database R&D team supports internal services such as WeChat Pay, WeChat Red Packets, Tencent Advertising, and Tencent Music, and provides external support on Tencent Cloud for TencentDB products like CynosDB, CDB, and TDSQL. This public account aims to promote and share professional database knowledge, growing together with database enthusiasts.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.