innodb_lru_scan_depth是5.6新增加的参数,根据 官方文档 描述,它会影响page cleaner线程每次刷脏页的数量,

这是一个每1秒  loop一次的线程。在Innodb内部,这个参数对应变量为srv_LRU_scan_depth,grep了一把,有几个地方会涉及到这个参数

page cleaner 线程  刷脏页的长度,从尾部开始刷 srv_LRU_scan_depth 

LRU 连表由 NEW 与 OLD 区构成

1.buf/buf0lru.cc

buf_LRU_free_from_unzip_LRU_list

从unzip_LRU_list取得空闲块

在扫描bp->unzip_LRU时保证扫描深度不超过srv_LRU_scan_depth,以从其中释放一个压缩块的非压缩页。

在5.5中,则有一个计算公式

distance = 100 + (n_iterations

* UT_LIST_GET_LEN(buf_pool->unzip_LRU)) / 5;

n_iterations越大,表示扫描了多次(或者说一次请求空闲块进入这个函数的次数),值不超过5.

buf_LRU_free_from_common_LRU_list

从通用LRU链上取空闲块 

与上述情况类似,但扫描的是bp->LRU。

这两个函数主要用于从LRU获取空闲块(例如free list已空),均有一个参数scan_all,当为true时,表示扫描全部LRU链表,这时候srv_LRU_scan_depth就不起作用了。

我们知道获取空闲块的入口函数是buf_LRU_get_free_block,之前也做过5.5关于这个函数的分析(见 http://mysqllover.com/?p=387

buf_LRU_get_free_block  取空闲块 函数

在5.6中,如果free list为空,则

>如果有flush在发生,等待完成并重试

>如果buf_pool->try_LRU_scan为true,则扫描srv_LRU_scan_depth深度的LRU,成功则返回空闲快

>如果上一步失败,iteration=1,扫描整个LRU链表

>如果上一步失败,iteration>1,依然扫描整个LRU链表,但sleep 100000us

2.buf/buf0flu.cc:

这里主要是page cleaner线程调用

page cleaner线程

buf_flush_page_cleaner_thread  //page cleaner线程入口

|—>buf_flush_LRU_tail

|–>扫描LRU,调用srv_LRU_scan_depth/PAGE_CLEANER_LRU_BATCH_CHUNK_SIZE()

次buf_flush_LRU函数,每次尝试去处理100个block.

划分成chunk的目的是防止用户线程在请求空闲块时等待时间太长

          srv_LRU_scan_depth/PAGE_CLEANER_LRU_BATCH_CHUNK_SIZE()

          buf_flush_LRU   LRU刷新函数

buf_flush_LRU-> buf_do_LRU_batch

buf_free_from_unzip_LRU_list_batch

从buf_pool->unzip_LRU上把非压缩frame移到bp->free上,如果bp->free的长度大于等于srv_LRU_scan_depth会跳出

 

buf_flush_LRU_list_batch

和上面的类似,但是从bp->LRU上扫描

可见srv_LRU_scan_depth会控制从LRU上清理block并将其放到free list上的扫描深度,不光影响page cleaner线程,也会影响用户线程;

从其作用可以看出,当系统的IO比较空闲的时候,可以适当将这个参数设大,当IO吃紧时,需要适当减小

related bug:

http://bugs.mysql.com/bug.php?id=68481

http://bugs.mysql.com/bug.php?id=68497

related blog:

http://mysqlha.blogspot.com/2013/02/mysql-56-io-bound-update-only-workloads.html


/*******************************************************************//**
Flush and move pages from LRU or unzip_LRU list to the free list.
Whether LRU or unzip_LRU is used depends on the state of the system.
@return number of blocks for which either the write request was queued
or in case of unzip_LRU the number of blocks actually moved to the
free list */
static
ulint
buf_do_LRU_batch(
/*=============*/
buf_pool_t* buf_pool, /*!< in: buffer pool instance */
ulint max ) /*!< in: desired number of blocks in the free_list */
{
ulint count = ; if (buf_LRU_evict_from_unzip_LRU(buf_pool)) {
count += buf_free_from_unzip_LRU_list_batch(buf_pool, max);
} if (max > count) {
count += buf_flush_LRU_list_batch(buf_pool, max - count);
} return(count);
}

innodb_lru_scan_depth的更多相关文章

  1. innodb_io_capacity >=innodb_lru_scan_depth*inoodb_buffer_pool_instances。与 checkpoint

    innodb_lru_scan_depth:每个缓冲池刷脏页的能力 innodb_io_capacity:  iops inoodb_buffer_pool_instances=8 :缓冲池的个数 . ...

  2. ORCLE INNODB 博客与 innodb_lru_scan_depth

    https://blogs.oracle.com/mysqlinnodb/ http://mysqllover.com/?p=485 •MySQL. MySQL 5.6.10 http://www.m ...

  3. InnoDB体系结构学习笔记

    后台线程 Master Thread 核心的后台线程,主要负责将缓冲池的数据异步刷新到磁盘,保证数据的一致性,包括(脏页的刷新).合并插入缓冲.(UNDO页的回收)等 IO Thread 4个writ ...

  4. 【msql】关于redo 和 undo log

    InnoDB 有两块非常重要的日志,一个是undo log,另外一个是redo log,前者用来保证事务的原子性以及InnoDB的MVCC,后者用来保证事务的持久性.和大多数关系型数据库一样,Inno ...

  5. [MySQL Reference Manual]14 InnoDB存储引擎

    14 InnoDB存储引擎 14 InnoDB存储引擎 14.1 InnoDB说明 14.1.1 InnoDB作为默认存储引擎 14.1.1.1 存储引擎的趋势 14.1.1.2 InnoDB变成默认 ...

  6. [MySQL Reference Manual] 8 优化

    8.优化 8.优化 8.1 优化概述 8.2 优化SQL语句 8.2.1 优化SELECT语句 8.2.1.1 SELECT语句的速度 8.2.1.2 WHERE子句优化 8.2.1.3 Range优 ...

  7. innodb buffer pool小解

    INNODB维护了一个缓存数据和索引信息到内存的存储区叫做buffer pool,他会将最近访问的数据缓存到缓冲区.通过配置各个buffer pool的参数,我们可以显著提高MySQL的性能. INN ...

  8. 9.5.8 Optimizing InnoDB Disk I/O

    如果你数据库设计以及sq操作都是最佳实践,但是你数据库仍然被较重的io活动拖累的较慢,那么试一试看看top或者windows的任务管理器,cpu使用率和工作量低于70%,那么或许是您的硬盘较慢. 1 ...

  9. ORACLE存储过程创建失败,如何查看其原因

    工作中用SQL Server比较多,Oracle可以说是小白,最近想用存储过程来完成单据复制的功能,结果遇到各种问题,其实都是非常简单的问题,但是对我来说还是花了很多时间来解决,浪费这些时间非常不值得 ...

随机推荐

  1. CodeForces 622 A.Infinite Sequence

    A.Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. 《Java数据结构与算法》笔记-CH5-链表-4用链表实现堆栈

    //用链表实现堆栈 /** * 节点类 */ class LinkS { private long data; public LinkS next; public LinkS(long d) { th ...

  3. 第三百三十六天 how can I 坚持

    家里断网了,忘交网费了,连的手机网络,也挺好,吃完饭就可以睡觉了. 不知道怎的,昨天和家人聊天,一提对象的事就很容易着急生气,然后就会后悔..哎,这脾气得改. 确实不知道自己的另一半是啥样,想象不出来 ...

  4. Servlet 2.4 规范之第一篇:概览

          写在前面的话: 本系列是对<Java Servlet Specification Version 2.4>的完全翻译,力争但不保证完美表达出英文原文的思想内涵.如有疏漏之处,还 ...

  5. Leetcode226:Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a ...

  6. Dell商用台式机、笔记本、服务器800电话

    戴尔Optiplex商用台式机 售后服务电话 800-858-0950 选1选2选2 戴尔Latitude商用笔记本 售后服务电话 800-858-0950 选1选3选2 戴尔服务器PowerEdge ...

  7. IntegrityError错误

    Python插入数据库提交失败,一直走IntegrityError错误,没打印错误信息(一定注意编码规范,记住打印错误信息),以为插不进去,弄了好久,最后打印了错误信息 (sqlite3.Integr ...

  8. 用DependanceProperty做Dynamic换Icon

    1:做Icon用Canvas还是DrawingBrush? Canvas的例子:

  9. 《高性能MySQL》

    <高性能MySQL>(第3版)讲解MySQL如何工作,为什么如此工作? MySQL系统架构.设计应用技巧.SQL语句优化.服务器性能调优.系统配置管理和安全设置.监控分析,以及复制.扩展和 ...

  10. 如何加入自定义WebControl

    http://www.screencast.com/users/Dennis.Garavsky/folders/Default/media/c75b4ec6-1641-4f82-936e-39360d ...