-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
* 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
There was a problem hiding this 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.
👍 |
|
||
@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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.