Bug #112137 | parallel read is slow when innodb_use_native_aio = off | ||
---|---|---|---|
Submitted: | 22 Aug 2023 13:48 | Modified: | 14 Mar 21:47 |
Reporter: | Ke Yu (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S5 (Performance) |
Version: | 8.0.33, 8.0.34 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Contribution |
[22 Aug 2023 13:48]
Ke Yu
[24 Aug 2023 9:05]
MySQL Verification Team
Hello Ke Yu, Thank you for the report and feedback. I'm in the middle of verifying this and get back to you if anything further needed. Thank you. regards, Umesh
[24 Aug 2023 10:30]
MySQL Verification Team
Hello Ke Yu, Thank you for the report and feedback. Verified as described. regards, Umesh
[24 Aug 2023 10:32]
MySQL Verification Team
8.0.34 test results
Attachment: 112137.results (application/octet-stream, text), 4.60 KiB.
[2 Sep 2023 9:05]
Ke Yu
Contributed patch (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: bug112137.diff (application/octet-stream, text), 1.97 KiB.
[8 Nov 2023 16:15]
Marcin Babij
Posted by developer: Hello Ke Yu, Thank you for the report. `--innodb-read-io-threads=1` This is not a fair comparison. If you use `--innodb-read-io-threads=16` then it seems it could behave similarly. 6.4s * 16 = 1m42s, which is more than reported 1m20s, so there seems to not be much room for disadvantage. 1. Could you check if the problem persists with `--innodb-read-io-threads=16` please? 2. Is there any reason you'd not set it higher if you don't use Native AIO? If it is set low, the performance will be degraded vs Native AIO in many more cases. 3. Could you share information why you are not using Native AIO? It is highly discouraged, unless it is not possible to be used otherwise.
[9 Nov 2023 2:09]
Ke Yu
Hello Marcin Babij, 1. If we use '--innodb-read-io-threads=16', the time cost of Native AIO and simulated AIO 6.4s, 10.16s respectively. use '--innodb-read-io-threads=4', the time cost of Native AIO and simulated AIO 6.4s, 21.73s respectively. 2. In my application, there are machines with relatively small cpu cores, so the io thread count is low. 3. History reasons. By the way, the main point I want to make is that "but we can compensate for this by changing the read operations in parallel read worker thread from asynchronous to synchronous."
[9 Nov 2023 12:06]
Marcin Babij
Posted by developer: 1. Thank you for testing it! Is 10s quite OK for you as workaround? 2. Small CPU core count is not a problem. You can use even higher numbers if this helps your performance. These threads should be sleeping if not used, and they post a blocking IO fast and sleep on it if used. Kernel scheduler should be able to fit them all on a single core just fine. You may want to test if 32 threads will help and how they influence the CPU usage, for example when the server is idle. 3. OK. This seem interesting, may be an input to some future work in this area, please share some reasons why it is used or was used in the first place, if you don't mind. > "but we can compensate for this by changing the read operations in parallel read worker thread from asynchronous to synchronous." Yes, I understand, we are evaluating this change too, it would revert some of the work done in WL#12978 InnoDB:Fix imbalance during parallel scan https://dev.mysql.com/worklog/task/?id=12978 . It was not a crucial part of this WL, more like an addition. It seems it already caused performance problems that were fixed in 8.0.23 with: A 20µs sleep in the buf_wait_for_read() function introduced with parallel read functionality in MySQL 8.0.17 took 1ms on Windows, causing an unexpected timeout when running certain tests. Also, AIO threads were found to have uneven amounts of waiting operating system IO requests. (Bug #31095274)
[10 Nov 2023 3:17]
Ke Yu
Hello Marcin Babij, 1. It is ok! 2. Yes, I understand. However, due to cpu limitations, some instances set this value lower. The native aio will post a blocking IO fast and sleep on, but the simulated AIO wil do the io itself. This consumes cpu resources 3. We will gradually use native aio in the future.
[27 Nov 2023 7:54]
MySQL Verification Team
Checked against Marcin's patched build
Attachment: 112137_8.3.0.results (application/octet-stream, text), 5.05 KiB.
[14 Mar 21:47]
Philip Olson
Posted by developer: Fixed as of the upcoming MySQL Server 8.0.37 and 8.4.0 releases, and here's the proposed changelog entry from the documentation team: With innodb_use_native_aio=off and innodb_read_io_threads=1, queries performing parallel scans, such as SELECT COUNT(*), were slow. Thank you for the bug report.
[15 Apr 18:53]
Philip Olson
Posted by developer: Updated release note: With innodb_parallel_read_threads set to a value greater than 1, InnoDB would unnecessarily request asynchronous reads which required more synchronization during I/O completion and created a bottleneck due to the limited number of available threads (innodb_read_io_threads) for handling I/O operations. Now this performs synchronous instead of asynchronous reads.