Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Brief introduction of oracle Asynchronous IO

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In synchronous IO, a thread enters a waiting state after initiating an IO request, and does not stop waiting until the end of the IO and processes other requests instead. After the asynchronous IO sends the IO request to the kernel, it doesn't have to wait for the IO operation to complete and deal with something else. Asynchronous IO can improve performance. However, it is obvious that there are higher requirements for disk processing IO ability, otherwise more processing requests are submitted, the processing capacity can not keep up, and the requirement of improving performance cannot be achieved at all. Asynchronous IO requires that the Linux kernel is version 2.6.

Check that the operating system enables asynchronous IO:

Cat / proc/slabinfo | grep kio

Kioctx 29 40 384 10 1: tunables 54 27 8: slabdata 4 40

Kiocb 0 0 256 15 1: tunables 120 60 8: slabdata 0 0 0

The first two values of kiocb are 0, indicating that asynchronous IO is not enabled.

To enable asynchronous IO, two parameters are required:

Alter system set filesystemio_options=setall scope=spfile

Alter system set disk_asynch_io = true scope=spfile;-- enabled by default

After disk_asynch_io is enabled, you also need to enable filesystemio_options, otherwise it will not be enabled, similar to double switch. This defaults to the db file async Iramp O submit wait event.

The filesystemio_options parameter has four values:

ASYNCH: enable asynchronous Icano on file system files, and there is no timing requirement for data transfer.

DIRECTIO: enable direct I DIRECTIO O on the file system file, bypassing buffer cache.

SETALL: enable async and direct iUniverse O on file system files.

NONE: disables async and direct Imax O on file system files.

If disk_asynch_io=false, you can also set the parameter dbwr_io_slaves to a value greater than 0 to mimic asynchronous io.

Among the kernel parameters, the fs.aio-max-nr parameter refers to the number of asynchronous IO requests that can be owned simultaneously. Oracle recommends greater than or equal to 1048576.

Root@bd-dev-mingshuo-183:/home/oracle#more / etc/sysctl.conf | grep aio

Fs.aio-max-nr = 1048576

SQL > sho parameter disk_asynch_io

NAME TYPE VALUE

-

Disk_asynch_io boolean TRUE

SQL > sho parameter filesystem

NAME TYPE VALUE

-

Filesystemio_options string none

Root@bd-dev-mingshuo-183:/home/oracle#ps-ef | grep dbw

Root 5068 4412 0 16:56 pts/5 00:00:00 grep dbw

Oracle 10201 10 Jul11? 00:02:41 ora_dbw0_mingdb

Root@bd-dev-mingshuo-183:strace-p 10201-o / home/oracle/dbwn.trc

Write some data:

SQL > create table test_io as select * from user_objects

SQL > update test_io set object_id=11; SQL > select file_no,filetype_name,asynch_io from v$iostat_file

FILE_NO FILETYPE_NAME ASYNCH_IO

0 Other ASYNC_OFF

0 Control File ASYNC_OFF

0 Log File ASYNC_OFF

0 Archive Log ASYNC_OFF

0 Data File Backup ASYNC_OFF

0 Data File Incremental Backup ASYNC_OFF

0 Archive Log Backup ASYNC_OFF

0 Data File Copy ASYNC_OFF

0 Flashback Log ASYNC_OFF

0 Data Pump Dump File ASYNC_OFF

0 External Table ASYNC_OFF

FILE_NO FILETYPE_NAME ASYNCH_IO

1 Data File ASYNC_OFF

1 Temp File ASYNC_OFF

2 Data File ASYNC_OFF

2 Temp File ASYNC_OFF

3 Data File ASYNC_OFF

3 Temp File ASYNC_OFF

4 Data File ASYNC_OFF

5 Data File ASYNC_OFF

6 Data File ASYNC_OFF

7 Data File ASYNC_OFF

8 Data File ASYNC_OFF

FILE_NO FILETYPE_NAME ASYNCH_IO

9 Data File ASYNC_OFF

10 Data File ASYNC_OFF

11 Data File ASYNC_OFF

14 Data File ASYNC_OFF

15 Data File ASYNC_OFF

27 rows selected.

Modify parameters and restart

Alter system set filesystemio_options=setall scope=spfile

Startup force-testing environment, a little bit violent.

Write some data root@bd-dev-mingshuo-183:/home/oracle#ps-ef after reboot | grep dbw

Oracle 5137 1 0 16:59? 00:00:00 ora_dbw0_mingdb

Root 5374 4412 0 16:59 pts/5 00:00:00 grep dbw

Strace-p 5137-o / home/oracle/dbwn_aio.trc

Compare trace files in two cases:

Synchronous IO:

Root@bd-dev-mingshuo-183:/home/oracle#more dbwn.trc | grep pwrite

Pwrite (267, "\ 2\ 242\ 0\ 0FW\ 202\ 1\ 326\ 351;\ 0\ 0\ 0\ 10\ 4J\ 257\ 0\ 0\ 207\ 0\ 35\ 0\ 211\ 0\ 0\ 0\ 0\ f"..., 8192, 1256767488) = 8192

Pwrite (267g, 8192, 1291714560) = 8192

Pwrite (267, "\ 2\ 242\ 0\ 0\ 303\ 177\ 202\ 1\ 276\ 351;\ 0\ 0\ 2\ 4\ 351\ 367\ 0\ 254\ 0\ 31\ 0\ 212\ 0\ 0\ 00011", 8192, 1341677568) = 8192

Pwrite (267,\ 2\ 242\ 0\ 0\ 213\ 202\ 1\ 270\ 351;\ 0\ 0\ 0\ 4\ 263 _ 0\ 0 &\ 1\ 31\ 0006\ 0\ 0\ 21\ 0 & "..., 8192, 1366687744) = 8192

Asynchronous IO:

More / home/oracle/dbwn_aio.trc | grep io_

Io_submit (140219848069120,1, {data:0x7f8775482ed0, pwrite, filedes:262, str: "\ 6\ 242\ 0\ 0\ 3Y\ 0\ 1\ 246z =\ 0\ 0\ 1\ 6\ 246\ 310\ 0\ 2\ 0\ 0\ 322\"\ 0\ 0\ 245z =\ 0 "..., nbytes:8192, offset:186671104}}) = 1

Io_getevents (140219848069120,1,128, {{0x7f8775482ed0, 0x7f8775482ed0, 8192,0}}, {600,0}) = 1

Io_submit (140219848069120,1, {data:0x7f8775482ed0, pwrite, filedes:262, str: "\ 6\ 242\ 0\ 0\ 360j\ 0\ 1\ 246z =\ 0\ 0\ 0\ 6\ 257\ 337\ 0\ 1\ 36 @\ 0\ 323\"\ 0\ 0\ 245z =\ 0 "..., nbytes:8192, offset:224264192}}) = 1

Io_getevents (140219848069120,1,128, {{0x7f8775482ed0, 0x7f8775482ed0, 8192,0}}, {600,0}) = 1

Io_submit (140219848069120,1, {data:0x7f8775482ed0, pwrite, filedes:262, str: "\ 6\ 242\ 0\ 0\ 177D\ 0\ 1\ 246z =\ 0\ 0\ 0\ 6\ 305\ 207\ 0\ 2\ 0\ 0\ 324\"\ 0\ 0\ 245z =\ 0 "..., nbytes:8192, offset:143646720}}) = 1

Io_getevents (140219848069120,1,128, {{0x7f8775482ed0, 0x7f8775482ed0, 8192,0}}, {600,0}) = 1

Pwrite stands for synchronous IO.

Io_submit/io_getevents stands for asynchronous IO. Io_submit represents an asynchronous IO request, and io_getevents gets the result of IO processing. The purpose of obtaining the result is to write the result to io_event, and there are many steps between io_submit and io_getevents. It is not the request seen here that is still waiting. It seems to run counter to asynchronous IO, but there is no such step.

After enabling asynchronous IO:

SQL > select file_no,filetype_name,asynch_io from v$iostat_file

FILE_NO FILETYPE_NAME ASYNCH_IO

0 Other ASYNC_OFF

0 Control File ASYNC_OFF

0 Log File ASYNC_OFF

0 Archive Log ASYNC_OFF

0 Data File Backup ASYNC_OFF

0 Data File Incremental Backup ASYNC_OFF

0 Archive Log Backup ASYNC_OFF

0 Data File Copy ASYNC_OFF

0 Flashback Log ASYNC_OFF

0 Data Pump Dump File ASYNC_OFF

0 External Table ASYNC_OFF

FILE_NO FILETYPE_NAME ASYNCH_IO

1 Data File ASYNC_ON

1 Temp File ASYNC_ON

2 Data File ASYNC_ON

2 Temp File ASYNC_ON

3 Data File ASYNC_ON

3 Temp File ASYNC_ON

4 Data File ASYNC_ON

5 Data File ASYNC_ON

6 Data File ASYNC_ON

7 Data File ASYNC_ON

8 Data File ASYNC_ON

FILE_NO FILETYPE_NAME ASYNCH_IO

9 Data File ASYNC_ON

10 Data File ASYNC_ON

11 Data File ASYNC_ON

14 Data File ASYNC_ON

15 Data File ASYNC_ON

27 rows selected.

Both data files and temporary files are asynchronous, but some files are still synchronized, probably because data cannot be lost. For example, if asynchronous IO is enabled for log files, it is likely to result in data loss.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report