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

Optimization: More memory-efficient scan state and staged ledger hashing #14524

Conversation

tizoc
Copy link
Member

@tizoc tizoc commented Nov 7, 2023

Explain your changes:

  • Hashing of the scan state and staged ledger performs a lot of unnecessary intermediary allocations by appending strings together before feeding them to the hashing context. This version avoids such concatenation and instead feeds strings directly to the hashing context while retaining the same ordering. Avoiding such unnecessary allocations relieves the garbage collector from all that pressure and also solves some >1GB allocation spikes.

Explain how you tested your changes:

  • Patched nodes were launched in a mixed environment (patched and unpatched nodes) in a private cluster. Also a bunch of randomly generated scan states were hashed with both new and old versions to ensure that the result is the same.

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? List them

This version avoids the construction of intermediary strings
through concatenation and instead feeds every chunk directly
to the hashing context to considerably reduce the amount of
allocations performed during hashing.
@tizoc tizoc requested a review from a team as a code owner November 7, 2023 00:16
Copy link
Member

@bkase bkase left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@deepthiskumar
Copy link
Member

!ci-build-me

@deepthiskumar
Copy link
Member

!approved-for-mainnet

@deepthiskumar
Copy link
Member

The version linter is failing due to the PR branch not being in this repo. We are working to create another pipeline. The PR doesn't update any types and the hashes before and after were tested.

@deepthiskumar deepthiskumar merged commit 55d2040 into MinaProtocol:rampup Nov 8, 2023
33 of 35 checks passed
@tizoc tizoc deleted the optimization/staged-ledger-hash-memory branch February 2, 2024 23:32
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.

None yet

3 participants