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

[Execution Node] Reduce memory used for ledger.Payload by replacing decoded Key with encoded key buffer #2569

Closed
fxamacker opened this issue Jun 7, 2022 · 2 comments · Fixed by #2930
Assignees
Labels
Execution Cadence Execution Team Performance

Comments

@fxamacker
Copy link
Member

fxamacker commented Jun 7, 2022

Problem

ledger.Payload can use less memory. Payload.Key requires 4 allocations for any key with 3 parts.

We don't use Payload.Key except in migration and reports so it's expensive to needlessly keep it in memory.

Also, Payload.Key is needlessly decoded while rebuilding mtrie during EN restart as well as checkpointing.

Updates #1744 #2585

The Proposed Solution

Replace decoded Payload.Key with encoded key buffer to reduce number of allocations and avoid needlessly decoding it during EN restarts and checkpointing.

@fxamacker fxamacker added Performance Execution Cadence Execution Team labels Jun 7, 2022
@fxamacker fxamacker self-assigned this Jun 7, 2022
@fxamacker
Copy link
Member Author

Data held in RAM can be reduced by 25GB and allocations can be reduced by 803+ millions by keeping encoded Payload.Key in RAM instead of as decoded Ledger.Key:

  • total decoded size (as ledger.Key): ~35GB
  • total encoded size (as []byte): ~10GB

This is from mainnet17 checkpoint file (June 3).

@fxamacker
Copy link
Member Author

PR #2585 further reduces memory by removing legacy controller from Ledger.Key. It reduces encoded key size by having less data to encode in Key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Execution Cadence Execution Team Performance
Projects
None yet
3 participants
@fxamacker and others