Skip to content

Conversation

@georgeee
Copy link
Member

Implement multi-key file storage.

Idea was first tested in benchmarks in PR #18117. Idea is to store heavy parts of a block (witnesses, which are part of scan state) in the new file storage, and be able to reference them from all over the codebase, including the ability to store references on disk (for which a Stable module is provided for tags).

Explain how you tested your changes:

  • Implemented both unit and property tests for the new code

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? None

It's a very simple way to store a set of related values in an efficient
manner.

Values are assumed to written all in one batch. Values can't be updated
or deleted individually (the only way possible is to overwrite the whole
file or remove the file).

Reading of the key reads only the bytes of file that are reuired for
the read.

It's an efficient way to store data that is semantically connected,
written and garbage-collected, but that needs to be accessed piecewise.
@georgeee georgeee requested a review from a team as a code owner November 17, 2025 20:23
@georgeee georgeee added the oom label Nov 17, 2025
Allows to serialize tags without overhead and fragility of storing
filenames, using semantically-meaningful representation instead.
@georgeee georgeee force-pushed the georgeee/multi-key-file-storage branch from a5132e8 to 17c0197 Compare November 17, 2025 22:10
@georgeee
Copy link
Member Author

!ci-build-me

@georgeee
Copy link
Member Author

!ci-bypass-changelog

Copy link
Member

@martyall martyall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty clever.

To be honest I didn't really understand how write_values_exn was working until I read the tests because I wasn't registering the importance of universal quantification in write_value.

If I has one suggestion for readability in my case, it would be to use a different type variable in the type definition of write_value and write_values, like use a in write_value and as in write_values

@martyall
Copy link
Member

!ci-build-me

@martyall martyall merged commit 2b03d5b into compatible Nov 24, 2025
54 checks passed
@martyall martyall deleted the georgeee/multi-key-file-storage branch November 24, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants