Skip to content

Skip redundant HDF5 detection during model CMake configure - #3220

Open
dweindl wants to merge 1 commit into
AMICI-dev:mainfrom
dweindl:speedup-model-config-hdf5
Open

Skip redundant HDF5 detection during model CMake configure#3220
dweindl wants to merge 1 commit into
AMICI-dev:mainfrom
dweindl:speedup-model-config-hdf5

Conversation

@dweindl

@dweindl dweindl commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • AmiciConfig.cmake currently calls find_dependency(HDF5 COMPONENTS C HL CXX REQUIRED), which re-runs FindHDF5.cmake's compiler-wrapper interrogation (spawning h5cc/h5c++ subprocesses) on every single model configure, even though the result never changes for a given AMICI installation.
  • On non-Config-mode HDF5 packaging (e.g. Debian/Ubuntu system HDF5), this consistently costs several hundred ms per model configure, on top of unavoidable CMake ABI/toolchain detection.
  • This resolves the HDF5 library paths once, when AMICI core itself is built, and bakes them into AmiciConfig.cmake as plain imported targets (hdf5::hdf5, hdf5::hdf5_cpp, hdf5::hdf5_hl, hdf5::hdf5_hl_cpp) instead of re-deriving them for every model. Falls back to the full find_dependency() search if the cached paths no longer exist on disk (e.g. HDF5 was moved/reinstalled since AMICI was built).
  • Goal: speed up importing/building many models in one go (test suite, benchmark collections, PEtab batch imports), where this per-model overhead adds up across dozens of independently-configured build directories — including under pytest-xdist, where models can't share a single build directory across parallel workers.

Test plan

  • Rebuilt AMICI core from source (pip install -e python/sdist --no-build-isolation) and confirmed the regenerated AmiciConfig.cmake has the baked-in HDF5 paths substituted correctly
  • Measured 3 back-to-back CMake configures of fresh, never-before-seen model directories: ~1.0s each, down from ~3.4s cold before this change
  • Full model build → install → simulate with the rebuilt core: correct simulation results
  • Ran a subset of python/tests/test_sbml_import.py (model-import/build tests) against the rebuilt core: all pass

🤖 Generated with Claude Code

find_dependency(HDF5 COMPONENTS C HL CXX REQUIRED) in AmiciConfig.cmake
re-runs FindHDF5.cmake's compiler-wrapper interrogation (spawning
h5cc/h5c++ subprocesses) on every single model configure. That result
never changes for a given AMICI installation, and on non-Config-mode
HDF5 packaging (e.g. Debian/Ubuntu system HDF5) this consistently
costs several hundred ms per model, on top of the ABI/toolchain
detection every fresh CMake build tree pays anyway.

The goal is to speed up importing/building many models in one go,
e.g. our own test suite, benchmark collections, or PEtab batch
imports, where this per-model overhead otherwise adds up across
dozens of independent, freshly-configured build directories -
including under pytest-xdist, where models can't share a build
directory across parallel workers.

Capture the resolved hdf5/hdf5_cpp/hdf5_hl/hdf5_hl_cpp library paths
once, when AMICI core itself is built, and bake them into
AmiciConfig.cmake as plain imported targets instead of re-deriving
them for every model. Falls back to the full find_dependency() search
if the cached paths no longer exist on disk.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.94%. Comparing base (607bc50) to head (8e6d5e9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3220      +/-   ##
==========================================
- Coverage   78.59%   77.94%   -0.66%     
==========================================
  Files         318      318              
  Lines       21090    21090              
  Branches     1487     1487              
==========================================
- Hits        16576    16438     -138     
- Misses       4506     4644     +138     
  Partials        8        8              
Flag Coverage Δ
cpp 71.96% <ø> (-0.05%) ⬇️
cpp_python 36.59% <ø> (ø)
petab 48.27% <ø> (ø)
petab_sciml 16.22% <ø> (ø)
petab_sciml_benchmarks 14.78% <ø> (ø)
python 70.33% <ø> (-0.04%) ⬇️
sbmlsuite-jax ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dweindl
dweindl marked this pull request as ready for review August 5, 2026 13:18
@dweindl
dweindl requested a review from a team as a code owner August 5, 2026 13:18

@FFroehlich FFroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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