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

Projects
None yet
4 participants
@JoelKatz
Copy link
Member

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 Jan 24, 2017

@HowardHinnant HowardHinnant self-assigned this Jan 24, 2017

Improve getMissingNodes:
* 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

@JoelKatz JoelKatz force-pushed the JoelKatz:gmn_fix branch from 57f4e7c to 32efbf1 Jan 25, 2017

@HowardHinnant
Copy link
Contributor

HowardHinnant left a comment

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

This comment has been minimized.

Copy link
Contributor

HowardHinnant commented Jan 26, 2017

👍

@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

This comment has been minimized.

Copy link
@nbougalis

nbougalis Feb 3, 2017

Member

This should be @return, not @param return.

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

This comment has been minimized.

Copy link
@nbougalis

nbougalis Feb 3, 2017

Member

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

This comment has been minimized.

Copy link
@JoelKatz

JoelKatz Feb 23, 2017

Author Member

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 label Mar 2, 2017

@scottschurr scottschurr referenced this pull request Mar 21, 2017

Merged

Develop next #2059

@scottschurr

This comment has been minimized.

Copy link
Contributor

scottschurr commented Mar 21, 2017

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

@JoelKatz JoelKatz deleted the JoelKatz:gmn_fix branch Oct 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.