Valgrind CI check
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
- use a standard Python executable and overwrite
PYTHONMALLOC=mallocto allow forvalgrindto properly track allocations (the approach used in the pybind11 PR linked by the issue), or - 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.
Are we happy to see this merged @mscroggs @garth-wells ?