Skip to content

fix(heatconduction): keep the FEniCS JIT cache on the host - #278

Merged
mkeeler43 merged 1 commit into
mainfrom
fix/heatconduction-fenics-jit-cache
Sep 7, 2026
Merged

mkeeler43 merged 1 commit into
mainfrom
fix/heatconduction-fenics-jit-cache

Conversation

@mkeeler43

@mkeeler43 mkeeler43 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #273.

Every simulate and optimize of the heat conduction problems starts a new container. FEniCS compiles its forms on first use and caches the result, but the cache is inside the container, so it is lost when the call ends and the next call compiles everything again. In the sweep behind #273 that was about 18 compilations per call, against 0.35 s of actual solver time.

Fix: mount a host directory into the container and point DIJITSO_CACHE_DIR at it. The directory is $SCRATCH/.cache/engibench/dijitso if SCRATCH is set, otherwise ~/.cache/engibench/dijitso. Delete it to reset the cache.

Both heat problems go through run_container_script, and the mount and environment variable go through the existing mounts= / env= arguments of container.run, so this is the same for Docker, Podman and Apptainer.

Verified

Docker (macOS): a script that assembles one form takes 7.4 s cold and 1.1 s warm. Three containers started at once on an empty cache all succeed and leave exactly one copy of each compiled module. dijitso is written for this: it compiles to a temp file and moves it into the cache with an atomic rename.

Apptainer (Euler): three back-to-back simulate calls take 19 s, 5 s, 5 s. A 50-design package went from ~57 min to ~12 min with the same results.

DIJITSO_CACHE_DIR is the only variable dijitso reads; INSTANT_CACHE_DIR from the issue's workaround is ignored by this FEniCS version.

Not in this PR

run_container_script names every container dolfin, so two heat conduction jobs on one Docker or Podman host fail with a name conflict. Apptainer ignores the name. That is an existing bug, not touched here.

Every simulate/optimize starts a new container, so the compiled forms were
lost with it and each call recompiled them. Mount a host directory as the
dijitso cache instead.

Fixes #273.
@mkeeler43
mkeeler43 force-pushed the fix/heatconduction-fenics-jit-cache branch from 4a47a73 to 8ff675a Compare September 3, 2026 17:09
@mkeeler43 mkeeler43 changed the title fix(heatconduction): keep the FEniCS JIT cache on the host across container runs fix(heatconduction): keep the FEniCS JIT cache on the host Sep 3, 2026

@g-braeunlich g-braeunlich left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@mkeeler43
mkeeler43 merged commit 1621122 into main Sep 7, 2026
20 of 21 checks passed
@mkeeler43
mkeeler43 deleted the fix/heatconduction-fenics-jit-cache branch September 7, 2026 11:11
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.

Containerised problems recompile their FEniCS forms on every call (heatconduction2d ~5x slower than it needs to be)

2 participants