Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Early Discussion: New save format to reduce save size and number of files #5771

Open
randombk opened this issue Nov 28, 2024 · 3 comments
Open

Comments

@randombk
Copy link

Is your feature request related to a problem? Please describe.

Context and Motivation

CBN currently stores saves as loose uncompressed JSON files. Each map chunk is a separate file. Each player-chunk tuple is another file.

With very little exploration, CBN saves balloon to over a GB spread out over many hundred thousand individual files. This slows down saving/loading and makes filesystem operations on saves particularly slow (i.e. backups, syncing across machines, etc).

Describe the solution you'd like

Proposal

Migrate to a new save format where map tiles are stored as compressed JSON blobs in a SQLite3 database.

  • This would consolidate the multiple loose files, reduce storage sizes, all while minimizing the incremental complexity and dependencies introduced.
  • Very minimal changes to the codebase are needed - no JSON schemas are changed, only the filesystem read/write layer.
  • Migration to SQLite (and ACID transactions) would also help reduce save corruption.
  • This format would also be easy to manually manipulate if/when necessary.
  • Maintain backwards compatibility and incremental migration for existing saves.
  • Improved efficiency of save format would also potentially open the door to saving more detailed information about the world in the future.

Proposed Migration Path

  1. Backend cleanup of the world save/load codebase to make it easier to support multiple save formats. Keep the format unchanged at this stage.
  2. Implement the new format under an experimental feature flag/option. There should be a migration path for old saves.
  3. Roll the format out as the default format. Keep backwards compatibilty for a long/indefinite period of time.
  4. (Optional) deprecate the old format, and keep around a script to upgrade from the old format

Additional context

No response

@Coolthulhu
Copy link
Member

The reason for multiple save files is that we're semi-often modifying the files separately.
One benefit to current implementation is that the results are human-readable. Would the SQLite variant allow easy access to the data itself?

@thedyze
Copy link
Contributor

thedyze commented Nov 28, 2024

How about simple zip files? Would allow any user to have easy access.

@Zireael07
Copy link
Contributor

@thedyze Performance penalty for packing/unpacking and very tiny benefit (slightly beter organization)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants