[GH-ISSUE #5110] Game checkpoints duplicate every captured snapshot blob forever — no retention cap, O(n²) shard rewrites #2827

Closed
opened 2026-10-21 05:56:21 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5110

Originally assigned to: @kolacheee on GitHub.

The problem

Game checkpoints store full immutable copies of what they capture — snapshotData (the tracker snapshot), spatialSnapshotData (the World Map snapshot), and now engineStateData (the turn-game/Experience state blobs, added by the #5102 checkpoint-restore fix). Nothing bounds how many checkpoints a chat accumulates: auto-checkpoints fire at session start, session end, and on every combat start and end, and only manual deletion removes one.

Because game_checkpoints is chat-sharded and the file store keeps tables in memory, a long campaign multiplies every captured blob into permanent heap and makes each new checkpoint re-serialize the chat's whole checkpoint shard — an O(n²) write pattern. With a game-surface Experience whose world save approaches its 256 KB cap, tens of sessions of auto-checkpoints add up to tens of megabytes duplicated per chat. This matters most on Android, where the whole app fights a ~1 GB heap (#4730 has the background).

listForChat also materializes every stored blob just to strip the fields before returning the list.

Try it yourself

Create a Game Mode chat, enter and leave combat a dozen times, and inspect the chat's game_checkpoints shard under data/storage/tables/ — every row carries full copies of all captured snapshots, even when nothing changed between checkpoints.

Suggested direction

Any of these would help, roughly in order of value:

  • A per-chat retention cap for auto-checkpoints (keep the newest N per trigger type; manual checkpoints exempt).
  • Content-address the captured blobs: store each unique blob once in a side table keyed by hash, and have checkpoint rows reference it — consecutive checkpoints of an unchanged world then share one copy.
  • Skip re-capturing a blob identical to the previous checkpoint's.

Found during the adversarial review of PR #5106 (the fix there was correctness of what is captured; this issue is about how much of it accumulates).

Originally created by @kolacheee on GitHub (Aug 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5110 Originally assigned to: @kolacheee on GitHub. ### The problem Game checkpoints store full immutable copies of what they capture — `snapshotData` (the tracker snapshot), `spatialSnapshotData` (the World Map snapshot), and now `engineStateData` (the turn-game/Experience state blobs, added by the #5102 checkpoint-restore fix). Nothing bounds how many checkpoints a chat accumulates: auto-checkpoints fire at session start, session end, and on every combat start and end, and only manual deletion removes one. Because `game_checkpoints` is chat-sharded and the file store keeps tables in memory, a long campaign multiplies every captured blob into permanent heap and makes each new checkpoint re-serialize the chat's whole checkpoint shard — an O(n²) write pattern. With a game-surface Experience whose world save approaches its 256 KB cap, tens of sessions of auto-checkpoints add up to tens of megabytes duplicated per chat. This matters most on Android, where the whole app fights a ~1 GB heap (#4730 has the background). `listForChat` also materializes every stored blob just to strip the fields before returning the list. ### Try it yourself Create a Game Mode chat, enter and leave combat a dozen times, and inspect the chat's `game_checkpoints` shard under `data/storage/tables/` — every row carries full copies of all captured snapshots, even when nothing changed between checkpoints. ### Suggested direction Any of these would help, roughly in order of value: - A per-chat retention cap for auto-checkpoints (keep the newest N per trigger type; manual checkpoints exempt). - Content-address the captured blobs: store each unique blob once in a side table keyed by hash, and have checkpoint rows reference it — consecutive checkpoints of an unchanged world then share one copy. - Skip re-capturing a blob identical to the previous checkpoint's. Found during the adversarial review of PR #5106 (the fix there was correctness of what is captured; this issue is about how much of it accumulates).
bsakaguchi 2026-10-21 05:56:21 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2827
No description provided.