[MDEV-10813] Clean-up InnoDB atomics, memory barriers and mutexes Created: 2016-09-15 Updated: 2020-06-10 Resolved: 2016-10-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Fix Version/s: | 10.2.3 |
| Type: | Task | Priority: | Critical |
| Reporter: | Sergey Vojtovich | Assignee: | Sergey Vojtovich |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Sprint: | 10.2.3-1, 10.2.3-2 | ||||||||||||||||||||||||||||
| Description |
|
InnoDB atomics implementation is getting worse: 5.7 implementation is not maintainable. We should remove it and use atomics provided by server instead. InnoDB is now full of meaningless memory barriers, these should be removed along with memory barriers implementation. We should restore fixes for InnoDB rwlocks. Mutexes should be cleaned up so that their code is readable. Also we should ensure that mutexes issue proper memory barriers. NOTE: there're 4 mutex implementations in InnoDB: futex base, spin lock (never used), pthread/critical_section based, event based (default). We should consider removing 3 implementations and leaving only pthread/critical_section based solution. |
| Comments |
| Comment by Sergey Vojtovich [ 2016-09-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
serg, please review patches in bb-10.2-mdev10813. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2016-09-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Apparently the only failure detected by buildbot is the windows one. Failures on fulltest occur in 10.2 as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2016-09-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Apparently, Windows failure is not exactly a sign of health . IT is a crash in in bootstrap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2016-09-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
wlad, it definitely is. I was going to ask you if you will be willing to help me to solve this. The problem should be fairly simple: it's startup, so no heavy concurrency should be involved. I guess either I used wrong atomic operation (different type) or something is missing to make my_atomic.h to emit the right code. I'm mostly curious about dump of rwlock structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2016-09-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
But first the crash - it is an assertion lock->lock_word = 0x00000000f0000000 volatile __int64 ulint which is the datatype of lock->lock_word, in Innodb is not synonymous to datatype "long". It is unsigned integer of the size of a pointer. The best standard approximation for that is size_t datatype. Now, long is 32 bit on all Windows, pointer is of course 64 bit on Win64. Thus my_atomic_caslong, my_atomic_addlong are wrong inside the sync0rw.ic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2016-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Wish: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2016-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
jplindst, InnoDB 5.7 comes with this idea for futex and spin-lock implementation. I fixed event based too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2016-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just pushed a patch that attempts to fix WIn64 build failure. I don't completely like it: I'd better change to types with deterministic size, but it can be fairly intrusive. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2016-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Or, we can have my_atomic_cas_ssize_t and my_atomic_add_ssize_t . Absolutely everything is better than "long" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2016-09-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
pushed a fix for Win64 compilation (missing casts) to bb-10.2-mdev10813 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2016-09-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This failed on OSX, too http://buildbot.askmonty.org/buildbot/builders/labrador/builds/8036/steps/compile/logs/stdio /private/var/lib/buildslave/maria-slave/labrador/build/storage/innobase/include/sync0rw.ic:341: error: invalid conversion from '_opaque_pthread_t*' to 'int64' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2016-10-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I suppose bb-10.2-mdev10813 branch (at commit d2a4536be9) is good for review now. Looking at the diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Axel Schwenke [ 2016-10-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I did a round of sysbench OLTP. On our 16 core / 32 thread benchmark machine the latest changes in bb-10.2-mdev10813 make nearly no difference. Here are numbers (queries per second - bigger is better)
On the 64 core / 128 thread machine it looks a bit different. Benchmark is still running, I'll add numbers when they arrive. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Axel Schwenke [ 2016-10-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here the numbers (again queries per second) from the 64 core / 128 thread machine. Read-only is a bit faster for the head of the tree. All in all performance on this hardware is rather poor, probably caused by contention in the server layers above InnoDB.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2016-10-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
According to the above there seem to be no performance/scalability regression introduced by relevant patches. |