AIO 学习摘记
天空cabin吧
全部回复
仅看楼主
level 6
一楼气质度姐
2012年07月12日 05点07分 1
level 6
异步IO ,asynchronous I/O (or nonblocking I/O)
在异步IO之前,进程都以串行的方式发布IO请求。每一个IO请求在被完成之前,都会将IO请求发起的进程置于 sleep 休眠状态。异步IO使进程在发起IO请求后,无需顺序等待IO完成。
The implementation of Asynchronous I/O on Red Hat Advanced Server allows Oracle processes to issue multiple I/O requests to disk with a single system call, rather than a large number of single I/O requests.

2012年07月12日 05点07分 2
level 6
也正如上文所述,如果数据库和操作系统层面未开启异步io,ORACLE 比较推荐使用 DBWR_IO_SLAVES 参数,使DBWR进程可以控制多个 SERVER PROCESS,进行 AIO 的模拟。
2012年07月12日 05点07分 3
level 6
如何确认 LINUX 下是否开启了 AIO:
The slabinfo maintains statistics about objects in memory. Some of the structs used by Asynchronous I/O are threated as objects in the virtual memory, so we can look for those structs on slabinfo. The ones related to AIO are named kio*.
$ cat /proc/slabinfo | grep kio
If Async I/O is enabled:
$ cat /proc/slabinfo | grep kio
kioctx 270 270 128 9 9 1 : 252 126
kiocb 66080 66080 96 1652 1652 1 : 252 126
kiobuf 236 236 64 4 4 1 : 252 126
and if Async I/O is disabled:
$ cat /proc/slabinfo | grep kio
kioctx 0 0 128 0 0 1 : 252 126
kiocb 0 0 96 0 0 1 : 252 126
kiobuf 0 0 64 0 0 1 : 252 126
In the SLAB allocator there are three different caches involved. The kioctx and kiocb are Async I/O data structures that are defined in aio.h header file. If it shows a non zero value that means async io is enabled.

2012年07月12日 05点07分 4
level 6
Example strace of dbw0 process with AIO enabled (init.ora parameter filesystemio_options = asynch) shows:
...
io_submit(3071864832, 1, {{0xb7302e34, 0, 1, 0, 21}}) = 1
gettimeofday({1176916625, 58882}, NULL) = 0
io_getevents(-1223102464, 1, 1024, {{0xb7302e34, 0xb7302e34, 8192, 0}}, {600, 0}) = 1
...
Example strace of dbw0 process with AIO disabled (filesystemio_options = none):
...
pwrite64(21, "\6\242\0\0004\21\300\0\220B\243\0\0\0\1\6\207\357\0\0\1"..., 8192, 36077568) = 8192
times(NULL) = 1775653082
times(NULL) = 1775653082
pwrite64(21, "\6\242\0\0<\21\300\0\220B\243\0\0\0\1\6\254\0\0\0\2\0*"..., 8192, 36143104) = 8192
...
2012年07月12日 06点07分 5
level 6
找到相关 dbwr0 的 pid,
strace -frT -o /tmp/dbwr.trc -p 24004
cat dbwr.trc|grep io_submit
24004 0.000031 io_submit(
18292627865
6, 1, {{0x2a973ecef8, 0, 1, 0, 21}}) = 1 <0.000024>24004 0.000037 io_submit(
18292627865
6, 1, {{0x2a973ecef8, 0, 1, 0, 21}}) = 1 <0.000024>24004 0.000031 io_submit(
18292627865
6, 1, {{0x2a973ecef8, 0, 1, 0, 21}}) = 1 <0.000025>24004 0.000031 io_submit(
18292627865
6, 1, {{0x2a973ecef8, 0, 1, 0, 21}}) = 1 <0.000024>24004 0.000031 io_submit(
18292627865
6, 1, {{0x2a973ecef8, 0, 1, 0, 21}}) = 1 <0.000024>

2012年07月12日 06点07分 6
level 6
ORACLE 中的参数:
disk_asynch_io boolean TRUE
filesystemio_options string SETALL
2012年07月12日 06点07分 7
level 6
将 FILESYSTEMIO_OPTIONS 设为 NONE 后,相关的trace中的信息为:
13940 0.000031 pwrite(25, "&\242\0\0a\0\300\1\352\357\227\213\305\10\1\4\r|\0\0\0"..., 8192, 794624) = 8192 <0.005858>13940 0.000031 pwrite(25, "&\242\0\0i\0\300\1\361\357\227\213\305\10\1\4\263\'\0\0"..., 8192, 860160) = 8192 <0.012533>13940 0.000030 pwrite(25, "&\242\0\0y\0\300\1\16\360\227\213\305\10\1\4Z \0\0\0\0"..., 8192, 991232) = 8192 <0.007788>13940 0.000031 pwrite(25, "&\242\0\0\211\0\300\1\7\360\227\213\305\10\1\4\305{\0\0"..., 8192, 1122304) = 8192 <0.012604>13940 0.000030 pwrite(25, "\2\242\0\0] \300\1\24\357\227\213\305\10\1\4\242\333\0"..., 49152, 67870720) = 49152 <0.015225>13940 0.000030 pwrite(25, "\2\242\0\0\342 \300\1\5\357\227\213\305\10\32\4\n\253\0"..., 49152, 68960256) = 49152 <0.013079>13940 0.000030 pwrite(25, "\2\242\0\0w!\300\1\365\356\227\213\305\10%\4]\333\0\0\16"..., 32768, 70180864) = 32768 <0.013545>13940 0.000030 pwrite(25, "\2\242\0\0\316!\300\1\253\341\227\213\305\10\1\4\203x\0"..., 32768, 70893568) = 32768 <0.008763>13940 0.000031 pwrite(25, "\2\242\0\0)\"\300\1:\340\227\213\305\10\1\4@\217\0\0\1"..., 786432, 71639040) = 786432 <0.034560>13940 0.000030 pwrite(25, "\2\242\0\0\236)\300\1\375\356\227\213\305\10\21\4A\366"..., 49152, 87277568) = 49152 <0.013402>13940 0.000030 pwrite(25, "\2\242\0\0{W\300\1_\340\227\213\305\10\3\4_W\0\0\f\0\27"..., 57344, 183459840) = 57344 <0.015379>13940 0.000030 pwrite(25, "\2\242\0\0\tX\300\1\27\343\227\213\305\10\3\4\26\372\0"..., 1048576, 184623104) = 1048576 <0.049100>13940 0.000031 pwrite(25, "\2\242\0\0\32Y\300\1_\340\227\213\305\10\3\4\306\303\0"..., 49152, 186859520) = 49152 <0.011413>13940 0.000030 pwrite(25, "\2\242\0\0)]\300\1\351\356\227\213\305\0102\4n\254\0\0"..., 40960, 195371008) = 40960 <0.011221>13940 0.000030 pwrite(25, "\2\242\0\0Qf\300\1@\357\227\213\305\10\32\4\343\321\0\0"..., 65536, 214573056) = 65536 <0.007721>13940 0.000031 pwrite(25, "\2\242\0\0\tk\300\1\251\346\227\213\305\10\3\4\303\330"..., 1048576, 224468992) = 1048576 <0.044899>13940 0.000031 pwrite(25, "\2\242\0\0\211v\300\1F\352\227\213\305\10\3\4Bn\0\0\1\0"..., 1048576, 248586240) = 1048576 <0.046927>13940 0.000033 pwrite(25, "\2\242\0\0\211|\300\1\335\355\227\213\305\10\3\4\211f\0"..., 352256, 261169152) = 352256 <0.013564>
2012年07月12日 06点07分 8
level 6
通过查看内核中的异步 IO 进程信息,我们可以看到,LINUX操作系统层面的异步io已经打开了。
[root@selene tmp]# cat /proc/slabinfo | grep kiokioctx 60 120 384 10 1 : tunables 54 27 8 : slabdata 12 12 0kiocb 8 15 256 15 1 : tunables 120 60 8 : slabdata 1 1 0
2012年07月12日 06点07分 9
1