Skip to content

charly's unfiltered podman images enumeration degrades every bed on a large store #475

Closed

Description

@atrawog

Symptom

Bed steps that shell out to podman images become unboundedly slow on a long-lived host, with no
error naming the cause. charly check box and charly remove both appear to hang: the run
directory stays empty, no log line is written, and the only visible child process is

podman images --format json

Measured on this workstation: a single check-image step sat for 25+ minutes in that call. It
did eventually complete — so this is degradation, not deadlock, which is what makes it hard to
recognise. My own first diagnosis was "blocked on the container-storage lock", and that was wrong.

Root cause

The image store had 10,865 images, of which 10,607 were untagged (97.6%), occupying 334 GB.

$ podman ps                → instant (13 containers)
$ podman images            → times out
$ podman system locks      → "No lock conflicts have been detected."

Not contention — podman images is O(n) over the image set, and charly calls it inside steps that
are otherwise sub-second.

Where they come from: disposable beds do not reap the intermediate images their builds create.
Age-bucketing the untagged set on a host running two concurrent agents:

    <6h: 4773
  6-24h: 1979
   1-7d: 3808

≈800 untagged images per hour of bed activity, retained indefinitely. disposable: true
removes the container and the tagged image; the intermediates survive.

Why it is worth fixing rather than papering over

  • The failure is silent and misattributed. There is no message, so the natural reading is "the
    bed is hung" or "the host is contended", and the actual cause is invisible without going to
    overlay-images/images.json directly.
  • It degrades every bed on the host, not just the one that filled the store, so it presents as
    flakiness in unrelated work.
  • The obvious operator response — podman image prune -f — destroys charly's layer cache, so
    the cure slows every subsequent build. A prune filtered to until=24h keeps the warm cache, but
    an operator has to know that.
  • The prune itself must enumerate the same set first, so once the store is large enough the
    remedy is as slow as the symptom.

Suggested directions (not a prescription)

  1. Reap on teardown. A disposable: true bed knows exactly which intermediates it created;
    removing them at cleanup is bounded work at the point of creation rather than unbounded work
    later.
  2. Bound the call. Where charly needs a specific image, podman images --filter reference=…
    is O(matches), not O(store). The unfiltered --format json enumeration looks avoidable at
    several call sites.
  3. Fail loudly on a degraded store. If the call exceeds a threshold, say so — "the image store
    holds N images; this step is enumerating all of them" turns a 25-minute mystery into a
    one-line diagnosis.

Environment

charly dev build; podman overlay driver, transient=true; two concurrent agents running beds.


Assisted-by: Claude Code claude-opus-5[1m] (analysed on a live system)

Activity

  1. atrawog commented on Aug 30, 2026

    @atrawog
    ContributorAuthor

    Correction — my "unreaped garbage" premise was wrong

    I filed this with the framing that ~97.6% of the store was garbage the beds failed to reap. That
    part is not supported, and I am retracting it.

    The test that disproved it was the fix itself:

    $ podman image prune -f --filter until=24h
    EXIT=0   removed=137
    $ store after: total=10848  untagged=10588
    

    I had predicted ~3,808 removals from age-bucketing created in overlay-images/images.json.
    Podman removed 137. Podman's "dangling" means untagged and unreferenced, so the untagged
    bulk is not reclaimable — those entries are the layer graph backing the 256 tagged images, i.e.
    charly's build cache, not litter. My age-bucketing also read a created field that evidently
    is not what podman filters on; I did not verify it before drawing a conclusion from it.

    So "disposable beds leak ~800 images/hour" should be read as unverified. Beds may well be
    reaping correctly and the store may simply be the honest cost of a warm cache across many boxes.

    What survives, still measured

    podman ps              → instant (13 containers)
    podman images          → times out
    podman system locks    → "No lock conflicts have been detected."
    store                  → 10,848 images / 256 tagged / 334 GB
    

    A check-image step sat 25+ minutes in podman images --format json and then completed. That is
    real, and it is not lock contention.

    What that changes about the fix

    Suggestion 1 (reap on teardown) rests on the retracted premise — disregard it unless someone
    confirms the leak independently.

    Suggestion 2 is now the whole point, and is stronger for it: if the untagged bulk is legitimate
    cache, then it is supposed to grow, and the only durable answer is for charly not to enumerate
    the whole store. podman images --filter reference=… is O(matches); the unfiltered
    --format json call is O(store) and appears avoidable at the call sites that want one known image.

    Suggestion 3 (say so when the call is slow) also stands, and this episode is the argument for it:
    the absent diagnostic cost me two wrong root causes in a row — first "storage-lock contention",
    then "unreaped garbage" — before the prune's own result contradicted me.

    Operator note for anyone hitting this meanwhile: prune --filter until=24h will not reclaim
    much, because the store is mostly referenced. Reclaiming it means removing tagged images you no
    longer want and letting their ancestry go with them — which is a cache decision, not a cleanup.


    Assisted-by: Claude Code claude-opus-5[1m] (analysed on a live system)

  2. changed the title [-]Beds do not reap intermediate images; charly's own `podman images` calls then degrade silently[/-] [+]charly's unfiltered `podman images` enumeration degrades every bed on a large store[/+] on Aug 30, 2026
  3. atrawog commented on Aug 30, 2026

    @atrawog
    ContributorAuthor

    Correcting the root cause in this issue — it is mine, and the measurements disprove it. Fix in opencharly/spec#76.

    I set out to implement what this issue proposes (avoid the unfiltered enumeration, filter dangling) and measured first. Both halves collapse:

    $ podman images --all --format '{{.Id}}' | wc -l                     ->  12585
    $ podman images --filter dangling=true --format '{{.Id}}' | wc -l    ->    402   (3.2%, not 97.6%)
    
    $ time podman images --format json                          ->   9003 ms, 17408384 bytes
    $ time podman images --filter dangling=false --format json  ->  13569 ms, 15776571 bytes
    

    Filtering dangling images is 50% slower — the filter costs more than the 402 rows it removes. The "10,607 untagged (97.6%)" figure does not describe this store.

    Where the cost actually is: 1,170 image IDs carrying 12,585 tag names across 177 repositories.

       1141  ghcr.io/opencharly/arch
        611  ghcr.io/opencharly/arch-builder
        464  ghcr.io/opencharly/cachyos
        423  ghcr.io/opencharly/fedora-nonfree
        414  ghcr.io/opencharly/fedora
    

    I also tested the next plausible cause — that retention is blind to them, since charlyImageTags skips images without ai.opencharly.box:

    image IDs with ai.opencharly.box label: 876
    image IDs WITHOUT it:                   294
    tag names on labelled images:          5565
    tag names on UNLABELLED images:          17   <- retention is NOT blind to them
    

    So the store is not full of junk retention cannot see. It is full of accumulated CalVer tags retention has not pruned — an operational matter, not an enumeration bug.

    What #76 therefore fixes is the symptom this issue actually reported: a slow store presenting as a silent stall. The call is bounded (process group killed on expiry) and names the cause instead of sitting for 25 minutes with no log line, and a completed-but-slow listing now reports its own cost. It deliberately does not claim to make a large store fast — the enumeration is inherently O(store), and the 5-minute cache above it is what keeps repeat calls cheap.

    Leaving this open until #76 merges; the remaining question after that is retention policy for the tag accumulation, which is a separate matter from enumeration.

  4. atrawog commented on Aug 30, 2026

    @atrawog
    ContributorAuthor

    Closing — the reported symptom is fixed in opencharly/spec#76 (merged, on main).

    To recap what actually turned out to be true, since this issue's original root cause was mine and wrong:

    • Not dangling images. 402 of 12,585, i.e. 3.2% — not the 97.6% this issue claimed. Filtering them out is slower (13.5s vs 9.0s), because the filter costs more than the rows it removes.
    • Not retention blindness. 5,565 of 5,582 tag names sit on images carrying ai.opencharly.box, so charlyImageTags can see essentially all of them.
    • It is simply a large store: 1,170 image IDs carrying 12,585 tag names across 177 repositories, ~9s and ~17MB of JSON per enumeration on every cache miss.

    So there was no enumeration bug to fix. What there was, and what #76 fixes, is that an O(store) call with no bound and no log line is indistinguishable from a hang — the 25-minute observation that prompted this issue. It is now bounded, kills the process group on expiry, and names the cause:

    listing local images via podman: timed out after 4m0s — the local image store is large
    or contended; prune it (charly clean) or retry when builds are idle
    

    and a completed-but-slow listing reports its own cost, so a growing store is visible before it becomes a mystery.

    The tag accumulation is not a defect. charly clean with defaults.keep_images is the mechanism, and it is an explicit operator command by design — pruning images is destructive and should not happen behind someone's back. On this workstation it simply had not been run.

    Nothing left open here that is a bug. If unbounded growth between charly clean runs turns out to be worth changing, that is a retention-policy decision rather than an enumeration fix, and deserves its own issue stating the policy it wants.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions