[MDEV-19734] investigate the performance effects of -O2 vs -O3 , possibly -O1 for gcc Created: 2019-06-11  Updated: 2022-11-21

Status: Open
Project: MariaDB Server
Component/s: Compiling
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Vladislav Vaintroub Assignee: Axel Schwenke
Resolution: Unresolved Votes: 1
Labels: None

Issue Links:
Relates
relates to MDEV-14900 Upstream 10.4 debian patches Closed
relates to MDEV-19709 Bitmap<128>::merge etc may crash on o... Closed

 Description   

To avoid gcc bugs in the production software (such as MDEV-19709), it could be better to
compile with less aggressive optimization.

Some people state that -O2 is faster than -O3, due to more compact code (less inlining or loop unrolling) and as result less cache misses . See https://stackoverflow.com/a/19985801/547065 for example.

The task is about benchmarking, and giving recommendations. From the quality standpoint, we can assume that -O2 would have less bug, and it is better tested, since it is the optimization used most often for production software.
From performance standpoint, the right -O level needs to be measured.



 Comments   
Comment by Otto Kekäläinen [ 2020-06-14 ]

In Debian we have been carrying the patch https://salsa.debian.org/mariadb-team/mariadb-10.4/-/blob/master/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch for some while. Should it be upstreamed or deleted?

Comment by Otto Kekäläinen [ 2020-10-06 ]

We still have this patch in Debian with mariadb-10.5. Could you axel give some opinion on this? Or marko or danblack?

See https://salsa.debian.org/mariadb-team/mariadb-10.5/-/tree/master/debian/patches

Comment by Daniel Black [ 2020-10-07 ]

Why is Debian carrying them if it doesn't know the effect of them?

Comment by Otto Kekäläinen [ 2020-10-13 ]

Because Ondrej Sury who participated in packaging some years back did
various things that 90% were good and 10% were bad. I would not throw
away stuff unless I know for sure that it was a bad part, therefore
this issue and question. We need at least one C/C++ expert to say if
this optimization is good or bad. At least it works and has been used
for many years now.

Comment by Daniel Black [ 2022-11-21 ]

otto, the packaging should match what is most tested. At the moment, what's in the codebase is the most tested. The only buildbot -O2 forcing is with asan/msan builds. So I'd drop the patch on the basis that O3 is more tested.

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