Skip to content

Optimize automatic cache persistence - #1

Merged
Arbousier1 merged 2 commits into
feature/new-branchfrom
codex/optimize-auto-save
Aug 1, 2026
Merged

Optimize automatic cache persistence#1
Arbousier1 merged 2 commits into
feature/new-branchfrom
codex/optimize-auto-save

Conversation

@TypeThe0ry

@TypeThe0ry TypeThe0ry commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Track cache modification and saved revisions so unchanged caches skip automatic persistence without losing changes made during an in-flight save.
  • Mark use-times, revenue, history, favourites, and persistent placeholder mutations dirty.
  • Feed dirty caches into one identity-deduplicated queue and drain it with a single cancelable async dispatcher instead of creating one delayed scheduler task per cache.
  • Allow only one automatic save per cache at a time while preserving newer dirty revisions for a later cycle.
  • Serialize saves per cache and only acknowledge a revision after every persistence step succeeds.
  • Stop accepting new database work before shutdown waiting begins, so the wait is a real submission barrier.
  • Bound database shutdown waiting to 30 seconds and dump named database worker stacks on timeout.
  • Use Folia's async scheduler for delayed async work and align the auto-save.period-tick fallback with the configured 6000-tick default.

Root cause

Automatic saving queued a full rewrite for the global cache and every online player at once, even when nothing had changed. YAML serialization and disk I/O then competed for CPU and storage in one burst, causing periodic MSPT spikes. A per-cache delayed-task approach would also leave many tasks to track and could race with shutdown.

Impact

Most save cycles now avoid untouched players entirely. Dirty players are deduplicated and spread over time by one dispatcher, overlapping automatic saves are coalesced, and shutdown cannot accept new asynchronous database work after its drain phase begins.

Validation

@Arbousier1
Arbousier1 marked this pull request as ready for review August 1, 2026 04:17
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Arbousier1
Arbousier1 merged commit e44b647 into feature/new-branch Aug 1, 2026
1 check 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