Skip to content

fix: refuse atlases whose decoded volume cannot fit the memory cap - #4

Closed
tabedzki wants to merge 1 commit into
mainfrom
fix/atlas-size-gate
Closed

tabedzki wants to merge 1 commit into
mainfrom
fix/atlas-size-gate

Conversation

@tabedzki

@tabedzki tabedzki commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

🤖 Human guided, AI assisted PR (using this skill). AI text below. 🤖

Problem. A 10 µm mouse atlas is a 4.6 GB array; under a 3 GB cap it can never decode, so the server OOM-loops via the restart policy.

Change. check_fits compares the manifest's shape × 4 with the cap (PIXELMAP_MAX_ATLAS_MB, else cgroup limit − 512 MB, else unlimited) and raises AtlasTooLarge before any fetch — in ensure_downloaded (worker thread) and canonical_annotation (atlases already on disk). GUI shows both sizes and keeps the button usable. Not gated at dropdown time because the registry has no shapes.

_memory.py is identical to #2's. Follow-up: #2's cache could evict before decoding using this size.

Assisted-by: Claude-Code:Opus-5

@tabedzki

tabedzki commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner Author

🤖 Human guided, AI assisted comment (using this skill). AI text below. 🤖

Findings

Decoded sizes (shape × uint32): 50 µm 38 MB, 25 µm 308 MB, rat 1,074 MB, any 10 µm mouse 4,592 MB. Session build only touches 25 µm metadata, so a restarted container is healthy until the first compute on a too-large atlas — the "fine until I connect" symptom.

The registry cache holds only versions, so sizing an un-downloaded atlas needs its manifest (network). The download worker fetches it anyway, hence the gate lives there and in canonical_annotation.

Limit = cgroup − 512 MB baseline → 2,560 MB on a 3 GB container: rat allowed, 10 µm refused. Exact once #3 lands; on main's dask path the real need is ~2× the array, so PIXELMAP_MAX_ATLAS_MB covers the gap until then.

Assisted-by: Claude-Code:Opus-5

@tabedzki
tabedzki marked this pull request as draft September 18, 2026 15:46
An annotation volume is one dense uint32 array: allen_mouse_25um is
308 MB, whs_sd_rat_39um 1.07 GB, and any of the 10 um mouse atlases
4.6 GB. On a container capped at 3 GB the last of those can never be
decoded -- the process is OOM-killed, Docker's restart policy brings it
back, and the next user to pick the same atlas kills it again. Nothing
in the app distinguished "large" from "impossible".

The manifest publishes `shape`, so the decoded size is known before a
single chunk is fetched. `check_fits` compares it with the cap --
PIXELMAP_MAX_ATLAS_MB, or the cgroup limit minus a 512 MB process
baseline, or unlimited outside a container -- and raises AtlasTooLarge.
It runs in `ensure_downloaded` (the download worker, which fetches the
manifest anyway) and in `canonical_annotation`, so an oversized atlas
whose chunks are already on disk is refused at compute time too. The
GUI turns either into an error notification that names both sizes and
leaves the button usable.

Test doubles without a `shape` are treated as "no opinion", never as
"fits".

Assisted-by: Claude-Code:Opus-5
@tabedzki tabedzki closed this Sep 21, 2026
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.

1 participant