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

Cleanup, refactor, and improve GetMissingNodes #1979

Closed
wants to merge 3 commits into from

Conversation

JoelKatz
Copy link
Collaborator

@JoelKatz JoelKatz commented Jan 24, 2017

Split SHAMap::getMissingNodes into three functions, cleanup and improve comments. Algorithmic improvements include avoiding the need to restart from the root.

In my quick benchmarks:
Time to coldstart with no database and get to full sync: 7% faster
Time to resynch to network ledger after synch is lost: 15% faster
Fetch speed of historical ledgers: 166% faster

The first patch (Make ledger fetch tuning saner) uses the configured fetch limit in one case where we had a limit hard coded in. It also bumps the limits a bit for the larger node sizes.

The second patch fixes a bug that could cause a non-validator to crash in rare cases were it opted to bow out the middle of consensus. The code attempted to send a proposal unconditionally which will fail if we're not a validator because we don't have a valid signing key.

@HowardHinnant HowardHinnant self-requested a review January 24, 2017 23:14
@HowardHinnant HowardHinnant self-assigned this Jan 24, 2017
* Clean up and refactor
* Resume parents of nodes read asynchronously
* Resume at tip of new stack if exhausted prior stack
* No need to restart at root
Copy link
Contributor

@HowardHinnant HowardHinnant left a comment

Choose a reason for hiding this comment

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

Really nice job. I especially appreciated the explicit deleting of the special copy members of MissingNodes. Explicitly deleting of the default constructor there isn't required (it is inhibited by default), but is fine to make that explicit.

This refactor makes getMissingNodes much easier to read/follow.

One could make the new gmn_* functions const, but I don't feel strongly enough about that to hold up approval.

In gmn_ProcessDeferredReads I would've done a local using namespace std::chrono rather than type out all the std::chrono individually. But that is purely stylistic. I'm fine with the way you have it.

Everything passes on macOS.

@HowardHinnant
Copy link
Contributor

👍


@param maxNodes The maximum number of found nodes to return
@param filter The filter to use when retrieving nodes
@param return The nodes known to be missing
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be @return, not @param return.

getMissingNodes (
std::size_t max,
SHAMapSyncFilter *filter);
getMissingNodes (int maxNodes, SHAMapSyncFilter *filter);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is maxNodes an int as opposed to an unsigned value? Does passing in a negative value ever make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think earlier versions of getMissingNodes could return a few more nodes than requested. Passing in the limit as a signed value prevented it from underflowing if it was decremented past zero in cases like that.

@nbougalis nbougalis self-assigned this Feb 3, 2017
@nbougalis nbougalis added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Mar 2, 2017
@scottschurr scottschurr mentioned this pull request Mar 21, 2017
@scottschurr
Copy link
Collaborator

Merged to develop as 6fac038, aebcc21, and 09a1d1a

@JoelKatz JoelKatz deleted the gmn_fix branch October 8, 2018 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants