Skip to content

Save optimization - #2152

Draft
Cvolton wants to merge 6 commits into
mainfrom
save-optimization
Draft

Save optimization#2152
Cvolton wants to merge 6 commits into
mainfrom
save-optimization

Conversation

@Cvolton

@Cvolton Cvolton commented Aug 6, 2026

Copy link
Copy Markdown
Member

Draft for now, since I see some space for improvements, but already creating the PR to get a second pair of eyes on this so I can see if this approach is worth pursuing.

This PR supersedes #1952. It adds "dirty" and "taken" flag tracking to saved and settings jsons and avoids saving them. As mentioned before, the motivation is primarily Android saving performance, though this leads to measurable improvements on Windows as well.

The idea is simple - do not resave settings and saved jsons if they haven't changed. To achieve this it essentially tracks 3 states - clean, dirty, taken. Clean is simple - do not save. Dirty means that it should be saved the next time the game saves but it doesn't need to be saved again afterwards. Taken means that a ref to the container may be stored somewhere, so it should be resaved every time until game exit. This logic is applied to both settings and saved values. Dirty flag is also set if the mod contains settings the user does not have or if the settings file is corrupted (didn't successfully load) for some reason.

In addition to this major change, the PR contains the following minor changes:

  • Mod settings are now saved when the user clicks "Apply" in the mod settings popup (to save time on game exit)
  • Saved values are now loaded even if settings fail to load

Stuff I'd like to figure out before marking this prod ready

  • Using RAII to track container borrow lifespans to not require a permanent taken flag (might not be doable without V6 though?)
  • probs just that, i also need to write doc comments and maybe reorder the members i added

thanks for reading my big yap

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