InnoDB小知识:双写缓冲区浪费了32个页面(512 KiB)

In my ongoing quest to completely understand InnoDB’s data storage, I came across a quite small and inconsequential waste, which is nevertheless fun to write about. I noticed the following block of pages which were allocated very early in the ibdata1 system tablespace but apparently unused (unnecessary lines removed from output):

在我持续不断地努力完全理解InnoDB的数据存储的过程中,我发现了一个非常小而无关紧要的浪费,但是写起来还是很有趣。我注意到在ibdata1系统表空间中非常早就分配的以下页面块,但显然没有使用(从输出中删除了不必要的行):

$ innodb_space -f ibdata1 space-page-type-regions start end count type 13 44 32 ALLOCATED

$ innodb_space -f ibdata1 space-page-type-regions start end count type 13 44 32 ALLOCATED

Background on the doublewrite buffer

关于双写缓冲区的背景

Most people using InnoDB have heard of the “doublewrite buffer”—part of InnoDB’s page flushing strategy. The doublewrite buffer is used as a “scratch area” to write (by default) 128 pages contiguously before flushing them out to their final destinations (which may be up to 128 different writes). The MySQL manual says, in “InnoDB Disk I/O”:

大多数使用InnoDB的人都听说过“双写缓冲区”——这是InnoDB的页面刷新策略的一部分。双写缓冲区被用作“临时区域”,在将它们刷新到最终目的地之前(最多可以是128个不同的写入),默认情况下连续写入128个页面。MySQL手册中在InnoDB磁盘I/O中说:

InnoDB uses a novel file flush technique involving a structure called the doublewrite buffer. It adds safety to recovery following an operating system crash or a power outage, and improves performance on most varieties of Unix by reducing the need for fsync() operations.

InnoDB 使用一种称为双写缓冲区的结构来实现一种新颖的文件刷新技术。它增加了在操作系统崩溃或停电后进行恢复的安全性,并通过减少对大多数 Unix 变体的 fsync() 操作的需求来提高性能。

Before writing pages to a data file, InnoDB first writes them to a contiguous tablespace area called the doublewrite buffer. Only after the write and the flush to the doublewrite buffer has completed does InnoDB write the pages to their proper positions in the data file. If the operating system crashes in the middle of a page write, InnoDB can later find a good copy of the page from the doublewrite buffer during recovery.

在将页面写入数据文件之前,InnoDB首先将它们写入一个称为双写缓冲区的连续表空间区域。只有在写入和刷新到双写缓冲区完成后,InnoDB才会将页面写入数据文件的正确位置。如果操作系统在页面写入过程中崩溃,Inn...

开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.3. UTC+08:00, 2024-11-28 20:33
浙ICP备14020137号-1 $bản đồ khách truy cập$