Chinaunix首页 | 论坛 | 博客
  • 博客访问: 132473
  • 博文数量: 46
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 335
  • 用 户 组: 普通用户
  • 注册时间: 2014-07-19 19:13
文章分类

全部博文(46)

文章存档

2015年(1)

2014年(45)

我的朋友

分类: Mysql/postgreSQL

2014-08-24 14:59:29

1、  InnoDB存储引擎体系架构


 

(1).后台线程

默认,InnoDB后台线程有7个,4IO thread, 1master thread, 1个锁(lock)监控线程,1个错误监控线程

4IO threadinsert buffer threadlog threadread threadwrite thread

 

(2)内存

        

         缓冲池(buffer pool)、重做日志缓冲池(redo log buffer)、额外内存池(additional memory pool)

    InnoDB把数据库文件按页(每页16k)读取到缓冲池,按最近最少使用算法保留缓冲池中缓存数据,数据库文件修改,首先修改缓冲池中页(胀页),按一定得频率刷新到文件


(3)master thread 源码分析

         Void master_thread(){

                   Goto  loop;

        Loop:

        For(int i=0;i<10;i++)

{

         Thread_sleep(1);

        Do log buffer flush to disk

        If(last_one_second_ios<5)

                   Do merge at most 5 insert buffer

         If(buf_get_modified_ratio_pct > innodb_max_dirty_pages_pct)

                   Do buffer pool flush 100 dirty page

         If(no user activity)

                   Goto background loop

                   }

                   If(last_ten_second_ios < 200)

                            do buffer pool flush 100 dirty page

                   do merge at most 5 insert buffer

                   do log buffer flush to disk

                do full purge

                   if(buf_get_modified_ratio_pct > 70%)

                            do buffer pool flush 100 dirty page

                   else

                            buffer pool flush 10 dirty page

                   do fuzzy checkpoint

             goto loop

                   background loop:

                   do full purge

                   do merge 20 insert buffer

                   if not idle:

                   goto loop:

                   else:

                            goto flush loop

                   flush loop:

                   do buffer pool flush 100 dirty page

                   if(buf_get_modified_ratio_pct > innodb_max_dirty_pages_pct)

                            goto flush loop

                   goto suspend loop

                   suspend loop:

                   suspend_thread()

                   waiting event

                   goto loop;

         }

 

(4)关键特性

         插入缓冲

         两次写

         自适应哈希索引


阅读(704) | 评论(0) | 转发(0) |
0

上一篇:jdbc事务处理

下一篇:innodb存储引擎-文件

给主人留下些什么吧!~~