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

Reduce number of reads from AccountState inside TxPool::SubmitTx #4820

Merged
merged 3 commits into from
Nov 11, 2022

Conversation

deffrian
Copy link
Contributor

Fixes | Closes | Resolves #

Changes:

  • First filter that reads SenderAccount from state will save a copy of this data inside new struct: TxFilteringState. If any other filter needs account data it will read it from TxFilteringState. So we read account data only once.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • [ x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • [ x ] Yes
  • No

In case you checked yes, did you write tests??

  • Yes
  • [ x ] No

@deffrian deffrian linked an issue Oct 26, 2022 that may be closed by this pull request
Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

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

Overall looks good, worth to compare performance with current master

src/Nethermind/Nethermind.TxPool/TxPool.cs Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.TxPool/TxPool.cs Show resolved Hide resolved
Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

I like the idea with some caveat, lets make this TxFilteringState be responsible for this account management like:

public struct TxFilteringState
{
    public Account SenderAccount { get { return _account ?? (_account = _accounts.GetAccount(_senderAddress)); } }
}

So now we can have this as lazy initialized while dropping this logic from filters.

@deffrian deffrian marked this pull request as ready for review November 1, 2022 07:57
@deffrian deffrian merged commit b945b5f into master Nov 11, 2022
@deffrian deffrian deleted the 4793-txpool-further-improvements branch November 11, 2022 10:59
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.

TxPool further improvements
3 participants