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

Make chain tip updates and access more efficient #2695

Merged
merged 2 commits into from
Aug 30, 2021
Merged

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Aug 30, 2021

Motivation

These changes make ChainTipReceiver a bit more efficient, since we're going to be using it in a few different places.

They are part of ticket #2639, but they don't close that ticket.

Solution

  • Store precalculated transactions in an Arc
  • Remove the unused Block from ChainTipBlock

Review

@oxarbitrage can review this PR.
It's not urgent, but it would be good to get it done early this week.

Reviewer Checklist

  • Code makes sense
  • Exsisting tests pass

Follow Up Work

Do the reset parts of #2639

Transaction `Hash`es are 32 bytes,
and the minimun transparent transaction size is 54 bytes.
So a full 2MB block can create 1.1MB of transaction hashes.

We use an `Arc` to avoid repeatedly cloning that much data.
This drops the block as soon as it isn't needed any more.

Previously, it would stick around until every `ChainTipReceiver`
dropped their `ChainTipBlock`, even if they didn't use the `Block`
at all.
@teor2345 teor2345 added A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement C-cleanup Category: This is a cleanup P-Medium labels Aug 30, 2021
@teor2345 teor2345 requested a review from oxarbitrage August 30, 2021 09:27
@teor2345 teor2345 self-assigned this Aug 30, 2021
Copy link
Contributor

@oxarbitrage oxarbitrage left a comment

Choose a reason for hiding this comment

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

This looks all very good to me.

@oxarbitrage oxarbitrage merged commit a66ecbc into main Aug 30, 2021
@oxarbitrage oxarbitrage deleted the chain-tip-efficient branch August 30, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants