Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16264

Implement a common work queue for InnoDB background tasks

Details

    Description

      InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

      We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

      All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:

      • io_handler_thread
      • buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
      • recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
      • fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
      • buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
      • srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
      • trx_rollback_all_recovered (any work is submitted at InnoDB startup)
      • log_scrub_thread (can probably be removed in MDEV-14425)
      • dict_stats_thread (work submitted by dict_stats_update_if_needed() and for defragmentation, btr_page_split_and_insert())
      • btr_defragment_thread (work submitted by btr_defragment_add_index() in OPTIMIZE TABLE)
      • buf_resize_thread (work initiated by SET GLOBAL innodb_buffer_pool_size)
      • fts_optimize_thread (work initiated by fts_optimize_add_table() on DDL or when loading table definition)
      • fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

      Some of the following might still need dedicated threads:

      • srv_master_thread
      • lock_wait_timeout_thread
      • srv_error_monitor_thread
      • srv_monitor_thread

      I/O cleanup

      We should implement native asynchronous I/O on BSD systems using kevent(), and remove the support for simulated asynchronous I/O threads.

      Pending read requests can be directly waited for by buf_page_get_gen(). If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

      High level overview of what was done so far

      A library tpool that encapsulated the threadpool implementation.

      Threadpool is capable of

      • submitting tasks (task is void function with void * parameter).
      • submitting asynchronous io on files and executing callbacks on io completion
      • timers (execute callback in the future)

      Changes in server

      • create_background_thd() to create a true background THD which is not counted, neither can be seen in SHOW PROCESSLIS, nor they would make server hang in close_connections() when they are not freed. These background THDs are to be used to purge tasks.
      • a "preshutdown" method in handler, to be calledafter connections are gone, but before plugins are shut down.
        This is used by Innodb for things that were done in thd_destructor_thread previously (stop purge and FTS optimize)

      Changes in Innodb

      The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

      IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
      However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
      IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

      Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

      Purge preallocates/caches background THDs, and purge task attach these THDs when they start, and detach when they are finished.

      Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

      Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.

      Attachments

        Issue Links

          Activity

            marko Marko Mäkelä created issue -
            marko Marko Mäkelä made changes -
            Field Original Value New Value
            marko Marko Mäkelä made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work.

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread
            * fil_crypt_thread
            * buf_dump_thread
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260)
            * trx_rollback_all_recovered
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread
            * btr_defragment_thread
            * buf_resize_thread
            * fts_optimize_thread
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work.

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work.

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work. A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work. A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read request when handling the I/O completion.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            GeoffMontee Geoff Montee (Inactive) made changes -
            marko Marko Mäkelä made changes -
            NRE Projects RM_105_CANDIDATE
            ralf.gebhardt Ralf Gebhardt made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            marko Marko Mäkelä made changes -
            wlad Vladislav Vaintroub made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            wlad Vladislav Vaintroub made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            thiru Thirunarayanan Balathandayuthapani made changes -
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sitzng IO control block caches
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sitzng IO control block caches
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

            Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

            Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

            Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

            Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

            Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

            Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            h2. Changes in server
            * create_background_thd() to create a *true* background THD which is not counted, neither can be seen in SHOW PROCESSLIS, nor they would make server hang in close_connections() when they are not freed. These background THDs are to be used to purge tasks.
            * a "preshutdown" method in handler, to be calledafter connections are gone, but before plugins are shut down.
            This is used by Innodb for things that were done in thd_destructor_thread previously (stop purge and FTS optimize)

            h2. Changes in Innodb
            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

            Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

            Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

            Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.
            wlad Vladislav Vaintroub made changes -
            Description InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            h2. Changes in server
            * create_background_thd() to create a *true* background THD which is not counted, neither can be seen in SHOW PROCESSLIS, nor they would make server hang in close_connections() when they are not freed. These background THDs are to be used to purge tasks.
            * a "preshutdown" method in handler, to be calledafter connections are gone, but before plugins are shut down.
            This is used by Innodb for things that were done in thd_destructor_thread previously (stop purge and FTS optimize)

            h2. Changes in Innodb
            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

            Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

            Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

            Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.
            InnoDB creates a large number of threads that are specializing on a single task. This makes debugging hard, because core dumps contain stack traces for a large number of threads. It also causes unnecessary thread stack allocation and increases the complexity of scheduling threads. Many of the threads are waking up periodically, polling for work(for those, we can introduce a timer task , for example OS timers would submit work to common pool). A lot of CPU and context switching is nowadays spent on "coordinator" threads(purge, page-cleaner).

            We should make InnoDB use a pool of threads, and scale the size of this pool based on the workload. There should be a common work queue for all the threads.

            All of the following background threads would be replaced by the common thread pool, listed in roughly descending order of impact/difficulty ratio:
            * io_handler_thread
            * buf_flush_page_cleaner_worker,buf_flush_page_cleaner_coordinator (only one after MDEV-15058)
            * recv_writer_thread (a special "page cleaner" during redo log apply; triggered by buffer pool LRU)
            * fil_crypt_thread (needs to be rewritten to use a queue of tablespaces that need key rotation)
            * buf_dump_thread (triggered by SET GLOBAL innodb_buffer_pool_(dump|load)_(abort|now))
            * srv_purge_coordinator_thread, srv_worker_thread (see also MDEV-16260; work added by transaction commit)
            * trx_rollback_all_recovered (any work is submitted at InnoDB startup)
            * log_scrub_thread (can probably be removed in MDEV-14425)
            * dict_stats_thread (work submitted by {{dict_stats_update_if_needed()}} and for defragmentation, {{btr_page_split_and_insert()}})
            * btr_defragment_thread (work submitted by {{btr_defragment_add_index()}} in {{OPTIMIZE TABLE}})
            * buf_resize_thread (work initiated by {{SET GLOBAL innodb_buffer_pool_size}})
            * fts_optimize_thread (work initiated by {{fts_optimize_add_table()}} on DDL or when loading table definition)
            * fts_parallel_tokenization, fts_parallel_merge (should be generalized to allow parallel execution of multiple ADD INDEX for any ALTER TABLE; work added by ALTER TABLE)

            Some of the following might still need dedicated threads:
            * srv_master_thread
            * lock_wait_timeout_thread
            * srv_error_monitor_thread
            * srv_monitor_thread

            h2. I/O cleanup
            We should implement native asynchronous I/O on BSD systems using {{kevent()}}, and remove the support for simulated asynchronous I/O threads.

            Pending read requests can be directly waited for by {{buf_page_get_gen()}}. If read-ahead is desired, that can be implemented by adding a read completion request when handling the I/O completion.

            h1. High level overview of what was done so far
            h2. A library tpool that encapsulated the threadpool implementation.
            Threadpool is capable of
            * submitting tasks (task is void function with void * parameter).
            * submitting asynchronous io on files and executing callbacks on io completion
            * timers (execute callback in the future)

            h2. Changes in server
            * create_background_thd() to create a *true* background THD which is not counted, neither can be seen in SHOW PROCESSLIS, nor they would make server hang in close_connections() when they are not freed. These background THDs are to be used to purge tasks.
            * a "preshutdown" method in handler, to be calledafter connections are gone, but before plugins are shut down.
            This is used by Innodb for things that were done in thd_destructor_thread previously (stop purge and FTS optimize)

            h2. Changes in Innodb
            The "ticker" (srv_master_thread, lock_wait_timeout_thread, srv_error_monitor_thread,srv_monitor_thread) threads are mapped to periodic timers.

            IO handler threads are gone, substituted with thread_pool::submit_io() and passing the callback on completion.
            However., innodb_io_read_threads and innodb_io_write_threads parameters are still used, to limit concurrency of
            IO inside the threadpool. In addition, these parameters are used to calculate io_setup() parameter on Linux , and for sizing IO control block caches

            Al others threads with exception of buf_flush_page_cleaner_coordinator, recv_writer_thread, fil_crypt_thread, log_scrub_thread are gone and replaced by either tasks, timers or, as in case of purge threads, with combination of tasks and timers . The purge coordinator has idle state, where it sleeps a little and rechecks if work is still there, and for that timer was used.

            Purge preallocates/caches background THDs, and purge task attach these THDs when they start, and detach when they are finished.

            Sometimes there were threads that did fork/join type of work (fts_parallel..., purge), where one tasks waits for others to complete, for that special "waitable" tasks were used.

            Except AIO, there were no big changes in existing logic . Some things can be improved and simplified later. The limits for different kind of tasks are still in place, i.e innodb_purge_threads are still there, only that they limit concurrency of a specific task.
            marko Marko Mäkelä made changes -

            I pushed some suggested cleanups to bb-10.5-wlad. OK to push to 10.5.

            I spotted some future cleanup opportunity, which I will note in other tasks:

            • SRV_MAX_N_IO_THREADS and any related code and variables should probably be removed (MDEV-16526)
            • srv_sys or at least srv_sys.tasks should be removed (MDEV-16260)
            • srv_max_n_threads should be removed (MDEV-14462)
            marko Marko Mäkelä added a comment - I pushed some suggested cleanups to bb-10.5-wlad. OK to push to 10.5. I spotted some future cleanup opportunity, which I will note in other tasks: SRV_MAX_N_IO_THREADS and any related code and variables should probably be removed ( MDEV-16526 ) srv_sys or at least srv_sys.tasks should be removed ( MDEV-16260 ) srv_max_n_threads should be removed ( MDEV-14462 )
            wlad Vladislav Vaintroub made changes -
            issue.field.resolutiondate 2019-11-15 17:41:30.0 2019-11-15 17:41:30.555
            wlad Vladislav Vaintroub made changes -
            Fix Version/s 10.5.0 [ 23709 ]
            Fix Version/s 10.5 [ 23123 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            svoj Sergey Vojtovich made changes -
            svoj Sergey Vojtovich made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            svoj Sergey Vojtovich made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            julien.fritsch Julien Fritsch made changes -
            marko Marko Mäkelä made changes -
            wlad Vladislav Vaintroub made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            Labels performance thread threadpool ServiceNow performance thread threadpool
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            Labels ServiceNow performance thread threadpool 76qDvLB8Gju6Hs7nk3VY3EX42G795W5z performance thread threadpool
            serg Sergei Golubchik made changes -
            Labels 76qDvLB8Gju6Hs7nk3VY3EX42G795W5z performance thread threadpool performance thread threadpool
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 87410 ] MariaDB v4 [ 133551 ]
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -

            SRV_MAX_N_IO_THREADS was removed in MDEV-24685.

            marko Marko Mäkelä added a comment - SRV_MAX_N_IO_THREADS was removed in MDEV-24685 .
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            rob.schwyzer@mariadb.com Rob Schwyzer (Inactive) made changes -
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 201658
            Zendesk active tickets 201658
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -

            People

              wlad Vladislav Vaintroub
              marko Marko Mäkelä
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.