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

NewBlockHeaders performance improvement #230

Merged
merged 3 commits into from
Dec 1, 2019

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Nov 29, 2019

When sending out new block headers to the websocket subscribers we
serialized the block once per each subscriber. This had some crypto
calls for each serialization and was CPU bound with redundant
calculations.

We can memoize the result and only serialize it once per block.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>

Changelog

n/a

When sending out new block headers to the websocket subscribers we
serialized the block once per each subscriber.  This had some crypto
calls for each serialization and was CPU bound with redundant
calculations.

We can memoize the result and only serialize it once per block.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

Clever use of memoize so we can entirely skip creation if it's not used. LGTM.

@shemnon
Copy link
Contributor Author

shemnon commented Nov 29, 2019

Unit tests actually had a mock to enforce that we only create blocks when we need them. I'll update this monday or so to have the tests verify no-more-than-once as well.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
@shemnon shemnon merged commit 8fc82b6 into hyperledger:master Dec 1, 2019
@shemnon shemnon deleted the websockets branch December 1, 2019 01:53
edwardmack pushed a commit to ChainSafe/besu that referenced this pull request Feb 4, 2020
* NewBlockHeaders performance improvement

When sending out new block headers to the websocket subscribers we
serialized the block once per each subscriber.  This had some crypto
calls for each serialization and was CPU bound with redundant
calculations.

We can memoize the result and only serialize it once per block.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
edwardmack pushed a commit to ChainSafe/besu that referenced this pull request Feb 4, 2020
* NewBlockHeaders performance improvement

When sending out new block headers to the websocket subscribers we
serialized the block once per each subscriber.  This had some crypto
calls for each serialization and was CPU bound with redundant
calculations.

We can memoize the result and only serialize it once per block.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Signed-off-by: edwardmack <ed@edwardmack.com>
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.

2 participants