[MDEV-11382] AliSQL: [Feature] Issue#9: PROVIDE ADAPTIVE ALGORITHM FOR INNODB CONCURRENCY TICKETS Created: 2016-11-29  Updated: 2021-03-09  Resolved: 2021-03-09

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Axel Schwenke
Resolution: Won't Fix Votes: 0
Labels: performance

Attachments: File MDEV-11382-10.2.patch    
Issue Links:
Relates
relates to MDEV-23379 Deprecate and ignore options for Inno... Closed
Epic Link: AliSQL patches

 Description   

Description:
------------
To avoide too many concurrency threads,InnoDB use
innodb_thread_concurrency to control the number of operating system
threads concurrently inside InnoDB. When a thread is permitted to
enter InnoDB, it is given a number of "free tickets" equal to the
value of innodb_concurrency_tickets, and the thread can enter and
leave InnoDB freely until it has used up its tickets.
 
innodb_concurrency_tickets is a fixed number, and it is hard to
choose a proper value fit for both small transactions and large
transactons. With a small innodb_concurrency_tickets value, large
transactons will acquire tickets many times, which extends the length
of time required to complete their task. With a large
innodb_concurrency_tickets value, small transactons may get starved
by too many concurrent large transactions.
 
This patch provides a method to adaptively adjust tickets assigned to
readonly SELECT SQL statement. For large SELECT query, it may acquire
tickets many times if the previous assigned tickets are exhausted.
To avoid starving smally quries, the tickets assiged to large query are
decreased exponentially according to the number of times it acquire
tickets, i.e. the more times large query acquire tickets, the smaller
tickets it will be assigned. To avoid it getting a too small value,
innodb_rds_min_concurrency_tickets is used as the lower bound of the
tickets number assigned.
 
Two global InnoDB variables are added,
1. innodb_rds_adaptive_tickets_algo: control whether adaptive algorithm
   is enabled.
2. innodb_rds_min_concurrency_tickets: the lower bound of tickets can
   be assiged under adaptive adjusting.

https://github.com/alibaba/AliSQL/commit/e6abc82cddaae0f8dc63ef976f7662a40443de8b



 Comments   
Comment by Marko Mäkelä [ 2017-11-17 ]

I think that the connection throttling would better be moved out from InnoDB, and it should apply to all storage engines. Maybe this should be part of the thread pool?

Comment by Marko Mäkelä [ 2017-11-17 ]

wlad, what is your opinion?

Comment by Vladislav Vaintroub [ 2017-11-17 ]

Limiting concurrency, while avoiding starvation is already part of the threadpool. in "generic" threadpool implementation, we try to have 1 thread active per thread-group (there is usually as many groups as CPUs, so 1 thread per CPU is actively executing)- However, there is also a timer thread that checks every now and then for long running queries, and if it detects starvation (no new queries executed for specific time period), new threads are started to execute queries, even if this would "overcommit" CPUs.

There is no black magic, no tickets, no "entering innodb mode" , "read-only selects" in the threadpool design.

Comment by Marko Mäkelä [ 2019-04-30 ]

I ported the AliSQL change to the latest MariaDB 10.2.

axel, can you please benchmark MDEV-11382-10.2.patch?

Comment by Axel Schwenke [ 2019-04-30 ]

plinux can you give me a hint, what kind of workloads this patch is adressing? I'm sure you did some internal tests to validate it. What did you use?

Comment by Marko Mäkelä [ 2021-03-09 ]

In MDEV-23379, we deprecate and ignore the settings to throttle InnoDB concurrency at the high level. The InnoDB storage engine in MariaDB should now scale to many concurrent threads (say, 1000 concurrent connections on a 50-core machine) while the throughput is not much less than the optimum that would be reached at fewer concurrent connections.

Generated at Thu Feb 08 07:49:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.