bug: map import fails on 16384 px at tile size 64 #83
Notifications
Due Date
No due date set.
Blocks
#77 M4: real-phone playtest gate (Note 10, 60 fps)
SirStone/FFF_vtt_frozen
Reference: SirStone/FFF_vtt_frozen#83
Reference in New Issue
Block a user
Part of #63
Owner ran, with the server stopped:
It ran ~5 min at 100% CPU, RSS climbed 4.2 -> 4.8 GB, wrote 0 usable tiles, then failed and cleaned up through
failImport(server/importer.nim:251). The owner saw no progress output, so it looked hung. This is a regression of #79's "16384 px memory-sane" claim.Diagnosis (reproduced)
server/importer.nim:245-251runs ONE crop:ImageMagick materialises all 65,536 cropped images in one image list before/while writing. Each live image has its own pixel cache (fd + mapping), and
-limit memory/-limit mapare per image, not global: the Q16-HDRI source cache alone is 16384^2 x 16 B = 4.29 GB and stays resident (observed RSS 8.3 GB once tiles were in flight). Reproduction withulimit -n 1024on a copy of the owner file:UnableToOpenFile '/tmp/magick-...': Too many open files @ error/cache.c/ReadPixelCachePixels/4860->No IDATs written into file .../tile_13334.png-> exit 1Fix requirements
rows 37/256, tiles 9472/65536) and a clear failure message including the underlying magick stderr.Closes the #77 blocker.
Fixed in
c8b5289on main (fix: stream map import so 16384 px at 64 px is memory- and fd-bounded).Cause confirmed:
-limit memory/-limit mapare per image, and the one-shot-crop ... +adjoinheld 65,536 tile images plus the 4.29 GB Q16-HDRI source cache. Reproduced on a copy of the owner file withulimit -n 1024: 771 fds at 20 s (RSS 2.1 GB, 0 tiles), 1023 fds at 300 s (RSS 8.3 GB, 59,312 tiles), thenToo many open files @ cache.c/ReadPixelCachePixels-> exit 1.Design: one
magickdecode to raw samples (disk-backed pixel cache under-limit memory 32MiB -limit map 32MiB), the CLI reads the source one tile row at a time into a scratch band file, and a pool of 8magickchildren (no pipes,poParentStreams) cuts each band into tiles. Live pixel caches and fds are bounded by the worker count, never by the tile count. Progress on stderr (rows 37/256, tiles 9472/65536); failures quote the image, the row band and magick's own message. Atomicity, lock and exit codes unchanged; a tile row too large to stream falls back to the one-shot crop (then small by construction).Measured, 16 cores:
run/map16384.png(copy) at 64 px: 19 s, 391 MiB peak RSS, 10 fds/process, 65,536 tilesTests:
tools/import.test.mjskeeps the fast fixtures and adds the pixel-identity proof and a truncated-source failure case; newdevbox run import-scaleruns 16384/64 underulimit -n 256and leavesresults/import-scale.log(devbox run testskips it, ~25 s). README import section documents the progress output and the ~20 s/400 MB expectation.Gates:
devbox run test(167 pass, 1 skipped),client-test(183),e2e(29) all green.