[MDEV-31095] Create separate tpool thread for async aio Created: 2023-04-20 Updated: 2023-10-05 Resolved: 2023-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | None |
| Fix Version/s: | 10.6.16, 10.10.7, 10.11.6, 11.0.4, 11.1.3, 11.2.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Michael Widenius | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | performance | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Linux mutex does not ensure that mutex are given in a FIFO order, but instead allows 'fast threads' to steal the mutex, which causes other threads to starve. This is a problem with tpool as if there is burst of aio_reads, it will create 'nproc*2' threads to handle the request even if one thread could do the job (if the block is on a very fast device or on a memory device). If the file is on a hard disk things may be even worse. This can be seen by just starting the server on a data directory with a large 'ib_buffer_pool' file. In addition the current code does not honor the variables srv_n_read_io_threads or srv_n_write_io_threads. The suggested fix is to use a separate tpool for just async io and use a limited number of threads for this. Here is some suggested code to use as a base:
|
| Comments |
| Comment by Marko Mäkelä [ 2023-05-29 ] |
|
wlad created a branch with 3 commits related to this. Curiously, this change to make preloading the buffer pool use a single thread would seem to conceptually revert monty, can you please test these changes, one by one? Based on recent experience from |
| Comment by Vladislav Vaintroub [ 2023-05-29 ] |
|
Apparently, the performance did not suffer after using single thread, and was actually slightly improved on 10GB preload I tried. I did perform a performance test, so the claim that it would be better, is founded |
| Comment by Marko Mäkelä [ 2023-05-29 ] |
|
wlad, right, there would be 2 threads involved. Related to this, perhaps you could comment on MDEV-11378. An idea is that for reading pages for applying logs or warming up the buffer pool, it might be better to allocate N contiguous page frame addresses from the buffer pool, and then submit a smaller number of normal or scatter-gather read requests for multiple pages at once. |
| Comment by Marko Mäkelä [ 2023-09-21 ] |
|
In my limited test, comparing the latest 10.6 with a merge of the branch, I did not observe any noticeable performance impact. I did not test the loading of a buffer pool. |
| Comment by Vladislav Vaintroub [ 2023-10-04 ] |
|
I'm assigning that to me,as tpool is something I'm maintaining.
|
| Comment by Vladislav Vaintroub [ 2023-10-04 ] |
|
Fixed "too many threads" by making tpool less eager to create additional threads during Innodb batches of asynchronous work during startup. Loading 10GB buffer pool would now require 6-7 threads overall in tpool, down from previous ncpus*2=32(on my machine). Innodb is currently stress-testing tpool during startup and recovery, with load that otherwise would not happen. It did not happen previously either, when recovery or buffer pool load were less multithreaded. |