Skip to content

Adjust -fsanitize=address,undefined test optimisation level and fix warnings#2109

Merged
jkbonfield merged 4 commits into
samtools:developfrom
daviesrob:optimisation-tweak
Sep 9, 2024
Merged

Adjust -fsanitize=address,undefined test optimisation level and fix warnings#2109
jkbonfield merged 4 commits into
samtools:developfrom
daviesrob:optimisation-tweak

Conversation

@daviesrob

Copy link
Copy Markdown
Member

Enabling sanitizers leads to long compilation times at high optimisation levels. Testing shows that with the sanitizers, changing from -O3 to -Og makes almost no difference to the make test time, but gives a significantly faster build.

On a local machine, the total times for make -j 3 && make test were:

Setting Time
-O3 6m13.677s
-O2 5m11.763s
-Os 4m11.703s
-Og 3m24.097s

In all cases make test took around 2m10s +/- 2s.

Using this lower optimisation level triggers a couple of "may be used uninitialized" warnings, where the compiler isn't able to work out that they are actually always set before use. These are silenced by making it more obvious that they are set.

Enabling sanitizers leads to long compilation times at high
optimisation levels.  Testing shows that with the sanitizers,
changing from "-O3" to "-Og" makes almost no difference to
the "make test" time, but gives a significantly faster build.

On a local machine, the total times for "make -j 3 && make test"
were:

| Setting | Time      |
| ------: | --------: |
|     -O3 | 6m13.677s |
|     -O2 | 5m11.763s |
|     -Os | 4m11.703s |
|     -Og | 3m24.097s |

In all cases "make test" took around 2m10s +/- 2s.
These turn up at low optimisation levels, where the compiler
isn't so good at working out that the variables do get
set before use.  Silence by making this more obvious.
@daviesrob

Copy link
Copy Markdown
Member Author

.. and add UBSAN_OPTIONS, so undefined behaviour sanitizer stops with a stack trace if it finds anything.

@jkbonfield jkbonfield merged commit b817714 into samtools:develop Sep 9, 2024
@daviesrob daviesrob deleted the optimisation-tweak branch September 9, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants