Skip to content

fix(spruce): Prevent OOM during ROM cache population - #263

Merged
BrandonKowalski merged 1 commit into
rommapp:mainfrom
boburning:bugfix/stream-cache-pages
Aug 16, 2026
Merged

fix(spruce): Prevent OOM during ROM cache population#263
BrandonKowalski merged 1 commit into
rommapp:mainfrom
boburning:bugfix/stream-cache-pages

Conversation

@boburning

Copy link
Copy Markdown
Contributor

What changed

  • reduce ROM cache API pages from 1,000 items to 250
  • persist each page before fetching the next instead of retaining every ROM for a platform
  • add a regression test proving that each page is committed before the next request

Why

fetchPlatformGames previously preallocated a slice for a platform's complete ROM count and appended every API page before writing to SQLite. Responses include nested file and metadata payloads, so large libraries can exhaust 128 MB handhelds during the initial background cache sync.

On a Miyoo Mini Plus running spruceOS, the official ARM32 build exited after 23 seconds while fetching a 1,314-ROM FinalBurn Neo platform. Grout reached about 65 MB RSS immediately before disappearing; the device has about 100 MB usable RAM and no swap.

Page-sized transactions bound the retained response and database batching working set while preserving full and incremental update behavior. SavePlatformGames already replaces rows per game, so committing individual pages is compatible with both paths.

Device validation

Built the patched ARMv7 binary with the repository's docker/32.Dockerfile and tested it on the same Miyoo Mini Plus with swap disabled.

  • completed a full cache population for 23 mapped platforms
  • handled 1,457 NES, 1,314 FinalBurn Neo, 1,289 SNES, 1,181 GBA, 1,087 PlayStation, and 1,006 Genesis ROMs
  • completed collection and 3,042 collection-mapping writes
  • emitted Cache population completed and BackgroundSync: Sync completed
  • completed a subsequent incremental refresh using the recorded refresh timestamps

Checks

  • go test ./cache
  • gofmt on changed Go files
  • git diff --check
  • ARMv7 Docker build using docker/32.Dockerfile

@boburning boburning changed the title Prevent OOM during ROM cache population fix(spruce): Prevent OOM during ROM cache population Aug 15, 2026
@boburning
boburning marked this pull request as ready for review August 15, 2026 10:11
@BrandonKowalski
BrandonKowalski merged commit 4d53b9a into rommapp:main Aug 16, 2026
2 checks passed
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.

2 participants