commit 8991039aaa07832e6e3eb6b875852a5e2d5527b8 Author: zhongbei.yk Date: Sat Sep 2 16:59:14 2023 +0800 BUG#112137 parallel read is slow when innodb_use_native_aio = off When innodb_use_native_aio = off and innodb_parallel_read_threads is greater than innodb_read_io_threads, parallel read is slow. Reason: prarllel read add a new fetch mode called page_fetch::SCAN. In a parallel read work thread, the page is read by this mode. When mode is page_fetch::SCAN, work thread will do async IO. However, after AIO is submitted, the work thread is still waits fot the aio to complete(buf_wait_for_read). When there are more parallel work threads than io threads, the work thread will wait io thread to finish IO, and the performance loss is even worse under simulated AIO. How to fix: The parallel work thread does not need to submit the read operation to the io thread, which consumes the io thread resources and causes performance problems. The parallel worker thread can fully undertake the IO read. diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index b3e498f7f51..9fcca11b49f 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -4019,7 +4019,14 @@ dberr_t Buf_fetch::check_state(buf_block_t *&block) { template void Buf_fetch::read_page() { bool success{}; - auto sync = m_mode != Page_fetch::SCAN; + + /* In the original read_page function, async read is performed only when fetch + mode is scan. The scan mode is used only for parallel read. A parallel read + worker thread does not have to hand over io operations to the io thread, which + can take up io thread resources and cause performance problems when + innodb_use_native_aio = off. The parallel worker thread can fully undertake + the IO read. */ + bool sync = true; if (sync) { success = buf_read_page(m_page_id, m_page_size);