[MDEV-14529] InnoDB rw-locks: optimize memory barriers Created: 2017-11-29 Updated: 2018-01-20 Resolved: 2017-12-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.3.2 |
| Fix Version/s: | 10.3.3 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Sandeep sethia | Assignee: | Sergey Vojtovich |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 16.02 on Arm 64 bit platform |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Epic Link: | arm64 optimization | ||||||||
| Description |
|
Hi, I see __atomic_compare_exchange_n function is being called with different memory order while but in rw_lock_lock_word_decr function i see __ATOMIC_SEQ_CST being hard coded in the cmpxchng. I feel we can use consistenly use ACQUIRE AND RELAX memory order for all the mutex implemenation in all the platform. |
| Comments |
| Comment by Sergey Vojtovich [ 2017-11-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Agree. Previously SEQ_CST was needed here as a workaround. Now with https://github.com/MariaDB/server/commit/fb7caad72b5c37e96c69aad63f9589f8b56855d6 this dependency is gone. If we find that nothing else depends on SEQ_CST, we can certainly change it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-11-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
grep -r my_atomic storage/innobase/|grep -v explicit shows that there're still plenty of SEQ_CST's issued. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sandeep sethia [ 2017-11-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I will do sysbench and mysqlslap benchmark and propose a patch for this . I am not sure if for add and subtract function we can remove SEQ_CST ? Any thoughts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-11-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm pretty sure that we can remove SEQ_CST everywhere. But there can be silly code relying on it. We can analyse it if you feel it is important. Personally I'm all for getting rid of SEQ_CST. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sandeep sethia [ 2017-11-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Attached is the patch which I have developed for removing SEQ_CST in few atomic operations. For load and store I cannot remove SEQ_CST as the __ATOMIC_ACQ_REL is invalid memory_order.patch Also for add functions I have given __ATOMIC_ACQ_REL memory order as only option can be given . Let me know your comments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sandeep sethia [ 2017-11-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I see 3-5% gain in mysqlslap benchmark for doing complex queries and 1-2% benefit in sysbench oltp workloads. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-11-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm afraid memory_order.patch is not acceptable. Because, according to C11, non-explicit versions of atomic functions are supposed to issue SEQ_CST. We need to fix things case by case by changing to explicit version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I retarget this task to fix InnoDB rw-locks specifically, other memory barrier issues to be fixed separately. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sandeep sethia [ 2017-12-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You want me to modify the patch and send it once again . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ssethia, I already started working on it. It is a bit complicated by different issues, so what I plan to do is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
marko, could you review 5 patches on top of https://github.com/MariaDB/server/commits/bb-10.3-MDEV-14529 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There're 7 patches now, top 2 are not of interested, the rest 5 are to be reviewed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
marko, sorry now there're even more revisions. Please look at those that have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-12-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
svoj, the patches look generally OK. I posted some minor comments. OK to push after addressing those. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Pushed
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2017-12-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ssethia, rw-locks are now fixed in 10.3. If you still see performance improvement from your patch, then we should analyse other places where SEQ_CST is being issued. |