• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MySQL aio
 

MySQL aio

on

  • 2,249 views

 

Statistics

Views

Total Views
2,249
Views on SlideShare
2,233
Embed Views
16

Actions

Likes
6
Downloads
63
Comments
0

1 Embed 16

http://www.mysqlops.com 16

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MySQL aio MySQL aio Presentation Transcript

    • MySQL AIO
      丹臣/赵林
      2011/8/16
    • content
      aio参数,以及aio线程状态
      5个os_aio_array_struct结构体,以及初始化
      aio的消费者-IO线程的启动及运行流程
      aio的生产者
    • aio参数
      一些控制参数:
      innodb_thread_concurrency=16
      innodb_read_io_threads=8
      innodb_write_io_threads=8
    • 查看aio线程状态
      Show innodb statusG中FILE I/O部份
    • 5个aio arrays的定义
    • os_aio_array_struct
    • aio初始化,以及创建I/O线程
      os_aio_init(io_limit,
      srv_n_read_io_threads,
      srv_n_write_io_threads,
      SRV_MAX_N_PENDING_SYNC_IOS);
      /* Create i/o-handler threads: */
      for (i = 0; i < srv_n_file_io_threads; i++) {
      n[i] = i;
      os_thread_create(io_handler_thread, n + i, thread_ids + i);
      }
    • 这5个aio arrays数组初始化,请注意这个函数最上面的注解
    • os_aio_array_create
      • slots指向一个os_aio_slot_t结构体数组,数组大小为n
      • n_reserved是指这个array中正在使用的slot有多少个
      • os_aio_slot_struct结构体中的reserved为true时,n_reserved会++1
    • I/O线程运行主函数
    • fil_aio_wait函数
    • os_aio_simulated_handle函数
    • mutex为什么可以提前释放?
    • os_aio_write_array
      一个segment包含很多个slots,这里每个只画了2个,是一个示例.每个segment会有对应的一个IO线程来处理.
      Segment 2
      Segment 3
      几个io线程消费slots,以及连接线程将aio请求放入slots中,每个线程都要去获得os_aio_write_array->mutex,所以这里存在争用,各个线程需要减少持有mutex的时间
      Segment 4
      Segment 5
    • Mutex再次获得,修改slot状态
    • 好处与前提
      最耗时的os i/o操作,io thread不会持有mutex,减少了mutex争用
      read/write aio array里存在多个segments,提高了并发
      os_aio_read_array
      os_aio_write_array
      前提:一个io线程只能操作对应的一个segment,其它io线程无法访问这个segment
    • aio的生产者
      Fil_io
      /* Queue the aio request */
      ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,offset_low, offset_high, len, node, message);
    • aio的生产者
      fio_io调用os_aio函数
    • os_aio_simulated_wake_handler_thread
    • About me
      新浪微博:http://weibo.com/zhaolinjnu
      个人blog:http://zhaolinjnu.blog.sohu.com/
      Email: danchen@taobao.com