basix icon indicating copy to clipboard operation
basix copied to clipboard

Valgrind CI check

Open schnellerhase opened this issue 10 months ago • 1 comments

Adds a valgrind check to the CI.

First step to resolve https://github.com/FEniCS/dolfinx/issues/1355

There are two main options to execute valgrind in a Python context

  1. use a standard Python executable and overwrite PYTHONMALLOC=malloc to allow for valgrind to properly track allocations (the approach used in the pybind11 PR linked by the issue), or
  2. configure (and build) Python with flag --with-valgrind.

Option 1 is very easy to setup (no custom Python install necessary) however the runtime gets out of hand and does not allow to reasonably check all test cases. Option 2 is the one chosen here and allows to execute all tests in a reasonable execution time.

Performance is still far from great, possibly a large speed up can be gained if the test cases are further split up into batches. In the current setup the whole pytest test/ run is a single valgrind call - this collects overhead during execution.

Note: Python is configured without -enable-optimizations --with-lto as recommended - while setting the optimization flags reduces the test execution runtime drastically the additional compile time of Python is not worth the gain here.

Note: Leak kind choice of definite,indirect is not driven by any observation, can be configured further as seen fit.

schnellerhase avatar Mar 21 '25 15:03 schnellerhase

Are we happy to see this merged @mscroggs @garth-wells ?

chrisrichardson avatar Jul 11 '25 08:07 chrisrichardson