[MDEV-17441] InnoDB transition to C++11 atomics Created: 2018-10-13  Updated: 2022-05-25  Resolved: 2019-07-12

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

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Eugene Kosov (Inactive)
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Blocks
blocks MDEV-12535 Relax buf_pool::n_pend_unzip protecti... Closed
Problem/Incident
causes MDEV-28601 InnoDB history list length is reverte... Closed
Relates
relates to MDEV-15706 Remove information_schema.innodb_metr... Open
relates to MDEV-18677 clang 7 fails to compile innodb Closed

 Description   

Atomic operations using my_atomic produce pretty convoluted and error prone code. In 10.4 we have C++11 enabled and it provides much cleaner atomic operations API.



 Comments   
Comment by Sergey Vojtovich [ 2018-10-13 ]

marko, please review 10 top patches at https://github.com/MariaDB/server/commits/bb-10.4-MDEV-17441

Please also pay special attention to buf_tmp_buffer_t::reserved patch.

Comment by Marko Mäkelä [ 2018-10-23 ]

Looks generally OK. I posted a few comments to some of the commits.

I still see a few references to my_atomic in InnoDB after the commits that I reviewed. Could all of them be replaced?

I’d also like to have a few member functions in rw_lock_t, to reduce some typing. Ideally, the memory ordering would not be repeated on each operation, but it should be part of the object declaration. Could we somehow the memory ordering a template parameter, or otherwise make relaxed memory ordering the default, to reduce typing?

Comment by Sergey Vojtovich [ 2018-10-24 ]

Original head with 17 patches just for reference: https://github.com/MariaDB/server/commits/bf64d634b831052e8f603fb6cc43296051ae24a3
Second review round head with 21 patches: https://github.com/MariaDB/server/commits/b9f945a186255741319f621c94aeadf43d04c6f7

Comment by Sergey Vojtovich [ 2018-10-24 ]

We should eventually eliminate them all. Unfortunately trying to eliminate them at once may lead to project failure, since it is not that trivial.

I don't like idea of making relaxed default memory ordering for two reasons:
1. unfortunately implicit memory order in general makes people make unexpected assumptions of how memory ordering works, which leads to horribly broken code
2. sequentially consistent is c++11 defined default memory ordering; even though I agree relaxed is more appropriate, it'd be very confusing to have atomics implementation with different default

But I agree we could reduce some typing by having proper methods in rw_lock_t or alike.

Comment by Sergey Vojtovich [ 2018-10-24 ]

marko, I implemented most of your suggestions and pushed to https://github.com/MariaDB/server/commits/bb-10.4-MDEV-17441

Would you like to have another look?

Comment by Marko Mäkelä [ 2018-10-29 ]

Looks OK. I sent a few comments, requesting minor improvement for code clarity.

Comment by Marko Mäkelä [ 2019-02-03 ]

I see that os0once.h and srv0mon.h still have not been converted to use C++11 atomics. Shall we leave those for a later version?

Comment by Sergey Vojtovich [ 2019-02-03 ]

I have WiP patches for os0once.h, which I'm planning to complete soon hopefully.
srv0mon.h requires larger refactoring and we should probably postpone it.

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

The srv0mon.h would be refactored or removed by MDEV-15706 in a later release.

Comment by Sergey Vojtovich [ 2019-06-13 ]

kevg, could you complete this effort? Specifically get rid of os0once. I pushed 2 WiP patches to bb-10.4-svoj-MDEV-17441.

Comment by Marko Mäkelä [ 2019-06-25 ]

Looks good. I only had a minor request to replace a comment with a debug assertion.

Generated at Thu Feb 08 08:36:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.