Skip to content

Rotated free-slip: reassigning an expression each step leaks ~14 MB per solve at np 2 through the prolongation rebuild #1007

Open

Description

@lmoresi

A rotated free-slip Stokes solve whose expression is reassigned each step leaks about 14 MB per step at np 2 (about 7 MB per rank), because each reassignment rebuilds the rotated workspace and the custom prolongation, which leaks.

Measured on development 15f13d0, np 2: an annulus with walls slid 1e-5, both walls rotated free slip, custom FMG, tol 1e-9. The figure is ru_maxrss summed over the two ranks.

each step rotated workspace reused peak RSS over 6 solves
s.bodyforce = ... reassigned, sign flipped False every solve 805, 819, 832, 847, 860, 874 MB
a uw.expression amplitude's .sym flipped True after the first 803, 810, 811, 811, 811, 811 MB

The same growth appears on #964's branch with the body force changed each solve.

Why

  • From the comment at utilities/rotated_bc.py ~L2128 (bcaef15, 2026-09-17): _build_rotated_custom_Pl leaks the velocity submatrix and the rotated fine prolongation on every call. Nothing owns them, and _destroy_rotated_linear_cache only dereferences custom_Pl, since its coarse Mats belong to the hierarchy.
  • The trigger is _rotated_geometry_signature, which includes dm.handle. A reassigned expression re-JITs and rebuilds the solver DM, so the whole workspace rebuilds, prolongation included, and leaks again.
  • Changing a uw.expression's value, or a field's data, keeps the DM and doesn't leak.

Likely fix (hypothesis, not tried)

Have the custom_Pl record keep the objects it creates, and the cache destroy them. Optionally, key the geometry tier on something narrower than dm.handle.

Probe: runs/2026-11-06/rev906/leak/leak.py on hyperion, with modes rhs and expr.

Underworld development team with AI support from Claude Code

Activity

  1. added
    fixed-in-PR
    on Nov 8, 2026
  2. lmoresi commented on Nov 8, 2026

    @lmoresi
    MemberAuthor

    Fixed in #1013 (bugfix/rotated-prolongation-leak-1007). The rebuild path now ends with the collective garbage cleanup. Hyperion measured leak.py at np 2 flat from the third solve, where development keeps rising. test_1144 counts petsc4py's deferred-destroy list: it fails on development in every order tried and passes on the branch.

    Underworld development team with AI support from Claude Code

  3. added a commit that references this issue on Nov 8, 2026
  4. added
    fixed-in-development
    and removed
    fixed-in-PR
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed-in-development

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions