Skip to content

Commit

Permalink
feat: optimize depth limit func (#1102)
Browse files Browse the repository at this point in the history
* feat: optimize depth limit func (#1099)

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Feb 28, 2022
1 parent 892f9a3 commit caa59e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions scheduler/resource/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ func (p *Peer) ReplaceParent(parent *Peer) {

// Depth represents depth of tree
func (p *Peer) Depth() int {
p.mu.RLock()
defer p.mu.RUnlock()

node := p
var depth int
for node != nil {
Expand Down
5 changes: 3 additions & 2 deletions scheduler/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ func (s *scheduler) filterParents(peer *resource.Peer, blocklist set.SafeSet) []
return true
}

if parent.Depth() > defaultDepthLimit {
peer.Log.Infof("exceeds the %d depth limit of the tree", defaultDepthLimit)
depth := parent.Depth()
if depth > defaultDepthLimit {
peer.Log.Infof("%d exceeds the %d depth limit of the tree", depth, defaultDepthLimit)
return true
}

Expand Down

0 comments on commit caa59e4

Please sign in to comment.