-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-11039 - Add new scheduling algorithm for reducing tail latencies (for 10.2) #248
Conversation
….2-vats Sync upstream and rebase.
….2-vats Rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look correct and fine. There is small differences on used style and normal InnoDB style because InnoDB style uses tab for indention not spaces. Could you please fix the indention before I will merge this. Currently on 10.2 there is no xtradb.
@@ -1410,7 +1410,7 @@ handle_rpl_parallel_thread(void *arg) | |||
mysql_mutex_unlock(&rpt->LOCK_rpl_thread); | |||
|
|||
my_thread_end(); | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary.
@@ -1096,6 +1096,8 @@ struct trx_t { | |||
|
|||
time_t start_time; /*!< time the state last time became | |||
TRX_STATE_ACTIVE */ | |||
clock_t start_time_micro; /*!< start time of the transaction | |||
in microseconds. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention does not look correct in all places, InnoDB uses tabs not spaces.
if (trx_is_high_priority(lock1->trx)) { | ||
return true; | ||
} | ||
if (trx_is_high_priority(lock2->trx)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention does not look correct here.
ulint space; | ||
ulint page_no; | ||
ulint rec_fold; | ||
hash_table_t* hash; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention in this function does not look correct, use tab-characters not spaces.
@@ -4823,7 +5197,7 @@ lock_release( | |||
ut_d(lock_check_dict_lock(lock)); | |||
|
|||
if (lock_get_type_low(lock) == LOCK_REC) { | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unnecessary.
@@ -52,12 +53,16 @@ Created 5/7/1996 Heikki Tuuri | |||
#include "row0mysql.h" | |||
#include "pars0pars.h" | |||
|
|||
#include <inttypes.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where you use this ?
@janlindstrom Hi, Jan. I've replaced all space indention with tab indention in my code. I also undid all changes to XtraDB. Could you kindly take a look? |
Hi Jiamin, Thanks for your contribution. These changes were originally proposed for 10.1 in PR#245, Normally there's no need to create separate pull request for 10.2, because it will be merged from 10.1 anyway. But I guess target version of this PR is not decided currently, so I keep both PR's open. Thanks, |
@svoj Hi, Sergey. I created a separate pull request for 10.2 because the locking system has undergone some significant code refactor in it, so the pull request for 10.1 would not be compatible with 10.2. Also from our information it would be easier for you to accept new features in version 10.2. This patch contains several fixes that hasn't been adopted in the previous patch yet. Do you want me to update that patch as well? |
Actually, I did accept this also for 10.1. So if there is some fixed needed could you create new pull request for them and make VATS as default. |
@sensssz, you're right. It perfectly makes sense if code is too different between versions. Please follow up with Jan regarding additional patches. |
@janlindstrom Sure I will create a pull request for 10.1. For that version should I also implement it in XtraDB or should I undo all the changes to XtraDB? |
Why not keep the XtraDB changes (for 10.1)? |
@janlindstrom I don't think this should go into 10.1 at all, 10.1 is GA for quite a while, no new features. |
No undo for XtraDB and for 10.1 for now. |
@sensssz Hi Jiamin, I see that you also contributed this to MySQL, and it was introduced there under WL#10793, MySQL Bug#84266, mysql/mysql-server#115, mysql/mysql-server@fb056f4 In MySQL 8.0, I found the following bug fixes related to this: It looks like MySQL 8.0 employs a threshold based on I would appreciate it if you could comment how the implementations of the algorithm differ between MariaDB 10.2 and MySQL 8.0. |
Hi, Marko, The algorithms we merged into MariaDB is actually different from what we merged into MySQL 8.0. They are based on two of our papers (VATS, CATS). VATS grants locks to transactions according to their age, while CATS does so according to each transaction's dependency set size (the number of transactions being blocked on it). Therefore, CATS's implementation is much more complicated because it also needs to maintain each transaction's dependency set size. For VATS, the idea is very simple: it inserts transactions to the queue according to their ages so that they are granted in this order. An additional thing I did was to keep the granted locks at the front of the queue. Is there a specific test case that I can use to reproduce the problem? I will look into this problem as well. |
Hi, @sensssz, sorry that you didn't get a reply earlier. MDEV-16664 is still not closed. May be you'd like to check the issue itself, it's https://jira.mariadb.org/browse/MDEV-16664 There are few ways to reproduce the problem, in issue comments. Either with an RQG (random query generator, https://github.com/MariaDB/randgen) or simply by running one of the mysql-test cases on repeat. |
One additional problem with VATS is the fact that it is not compatible with Galera replication where if lock request is done by brute force thread (BF) no other lock request may granted before it as BF transactions may not wait for locks (if there is already granted lock request its holder thread is selected as victim and killed). This fact naturally can be fixed with, if wsrep_thd_is_BF(trx->mysql_thd) we set transaction age so high that no other transaction lock request can be granted before it. |
@sensssz, I posted in MDEV-16664 some information from an |
@sensssz Due to lack of response, I am going to deprecate the configuration parameter |
This branch introduces a new scheduling algorithm (Variance-Aware-Transaction-Scheduling, VATS) for the record lock manager of InnoDB based on MariaDB 10.2. Instead of using First-Come-First-Served (FCFS), the newly introduced algorithm prefers the eldest transaction. A configuration parameter (innodb_lock_schedule_algorithm) is introduced for users to choose between VATS and FCFS (the default one). We've extensively tested this algorithm in many workloads. The algorithm is very simple, and the changes are very local, but it significantly improves performance (in terms of average latency and throughput) and predictability (in terms of reduction of tail and quantile latencies) For more details, please refer to this paper http://arxiv.org/abs/1602.01871