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

Limit Accepted Block Cache + Store BlockID Index On-Disk #558

Merged
merged 5 commits into from
Oct 15, 2023

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Oct 14, 2023

Resolves: #475

We purposely store blocks separately from block metadata to make block shuffling on-disk less onerous (should be properly fixed with #553).

This should make implementing archival-required features much easier.

@patrick-ogrady
Copy link
Contributor Author

Memory usage:
profile001

@patrick-ogrady
Copy link
Contributor Author

alloc space:
profile002

@patrick-ogrady
Copy link
Contributor Author

This reduced memory usage by ~50% (compared to what was seen on devnet):
image

@patrick-ogrady patrick-ogrady changed the title Limit Accepted Block Cache Limit Accepted Block Cache + Store BlockID Index On-Disk Oct 15, 2023
return err
}
if err := batch.Put(PrefixBlockHeightKey(blk.Height()), blk.Bytes()); err != nil {
if err := batch.Put(PrefixBlockIDHeightKey(blk.ID()), bigEndianHeight); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to store this on-disk now so that we can service historical Get requests. We make this tradeoff so that we can avoid db compaction (from storing blocks all over disk).

return err
}
blkID := blk.ID()
if err := batch.Put(PrefixBlockHeightIDKey(blk.Height()), blkID[:]); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We store a height lookup to avoid pulling entire blocks from disk to service historical queries.

@patrick-ogrady patrick-ogrady merged commit d487de4 into main Oct 15, 2023
15 of 16 checks passed
@patrick-ogrady patrick-ogrady deleted the rewrite-block-storage branch October 15, 2023 00:42
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.

[chain] Only store last X blocks in memory
1 participant