Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Use streams and avoid iterating child nodes multiple times #1380

Merged
merged 4 commits into from
May 1, 2019

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented May 1, 2019

PR description

One of the hot spots in a world state download is calculating the child requests in TrieNodeDataRequest. Previously it iterated over the nodes twice filtering on an inverse condition - we can replace that with a single loop through the nodes and an if/else. Also switches to returning a Stream instead of a List to avoid needing to collect the children into a list only to then iterate it again.

There's still a significant cost in calculating the children because the nodes wind up being serialised to RLP (https://pegasys1.atlassian.net/browse/PAN-2599 logged for that) but the profiler at least suggests this is an improvement.

Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

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

LGTM

@ajsutton ajsutton merged commit 827a220 into PegaSysEng:master May 1, 2019
@ajsutton ajsutton deleted the stream-child-requests branch May 1, 2019 22:01
notlesh pushed a commit to notlesh/pantheon that referenced this pull request May 4, 2019
notlesh pushed a commit to notlesh/pantheon that referenced this pull request May 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants