-
Notifications
You must be signed in to change notification settings - Fork 223
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
Merge big subdags in pick virtual parents #1574
Conversation
Codecov Report
@@ Coverage Diff @@
## v0.9.0-dev #1574 +/- ##
==============================================
- Coverage 61.67% 59.98% -1.70%
==============================================
Files 512 515 +3
Lines 19503 20319 +816
==============================================
+ Hits 12029 12188 +159
- Misses 5756 6200 +444
- Partials 1718 1931 +213
Continue to review full report at Codecov.
|
selectedVirtualParents.Add(candidate) | ||
mergeSetSize += mergeSetIncrease | ||
log.Tracef("Added block %s to the virtual parents set", candidate) | ||
// Remove all candidates in the future of newCandidate (https://github.com/golang/go/wiki/SliceTricks#filter-in-place) |
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.
It could be nice if this was a separate function
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'm implementing a HashSlice
type now, can be replaced later
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.
Please extract it nontheless. It detracts from the core logic of the current function.
@@ -154,58 +178,55 @@ func (csm *consensusStateManager) selectVirtualSelectedParent( | |||
} | |||
|
|||
func (csm *consensusStateManager) mergeSetIncrease( |
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.
Please add a comment explaining the newCandidate thing
@@ -154,58 +178,55 @@ func (csm *consensusStateManager) selectVirtualSelectedParent( | |||
} | |||
|
|||
func (csm *consensusStateManager) mergeSetIncrease( | |||
candidate *externalapi.DomainHash, selectedVirtualParents hashset.HashSet) (uint64, error) { | |||
candidate *externalapi.DomainHash, selectedVirtualParents []*externalapi.DomainHash, mergeSetSize uint64) (canBeParent bool, newCandidate *externalapi.DomainHash, mergeSetIncrease uint64, err error) { |
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.
Please break down line
@@ -46,7 +45,12 @@ func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainH | |||
end-- | |||
} | |||
} | |||
// Limit to 30 candidates, that way we don't go over thousands of tips when the network isn't healthy. | |||
if len(candidates) > int(csm.maxBlockParents)*3 { |
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.
Please extract maxBlockParent*3 to a constant (in constants.go) and add a comment over it explaining why that number was chosen.
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.
Well there's no reason it was chosen other than my whims
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.
Even more so.
selectedVirtualParents.Add(candidate) | ||
mergeSetSize += mergeSetIncrease | ||
log.Tracef("Added block %s to the virtual parents set", candidate) | ||
// Remove all candidates in the future of newCandidate (https://github.com/golang/go/wiki/SliceTricks#filter-in-place) |
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.
Please extract it nontheless. It detracts from the core logic of the current function.
80080e0
to
c198a38
Compare
c198a38
to
74c121d
Compare
@@ -46,7 +45,12 @@ func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainH | |||
end-- | |||
} | |||
} | |||
// Limit to 30 candidates, that way we don't go over thousands of tips when the network isn't healthy. | |||
if len(candidates) > int(csm.maxBlockParents)*3 { |
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.
Even more so.
return nil, err | ||
} | ||
candidates = append(candidates, newCandidate) | ||
log.Debugf("Cannot add block %s, instead added new candidate: %s", candidate, newCandidate) |
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'd more specific in the log, a.k.a. "block %s increases merge set too much, instead adding it's ancestor %s"
} | ||
} | ||
} | ||
log.Tracef("The virtual parents resolved to be: %s", selectedVirtualParents) |
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'd put this in Debugf
onEnd := logger.LogAndMeasureExecutionTime(log, "mergeSetIncrease") | ||
defer onEnd() | ||
|
||
visited := hashset.New() | ||
queue := csm.dagTraversalManager.NewDownHeap() | ||
err := queue.Push(candidate) | ||
// Start with the parents in the queue as we already know the candidate isn't an ancestor of the parents. |
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.
You use "parents" for two different things
I'd revise to "Start with candidate's parents ... we already know the candidate isn't an ancestor of selectedVirtualParents"
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.
ops
This should: