Speed up finding dependency cycles am: 9793b0a5e0 am: 010f5bbd8d

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1689305

Change-Id: I65385bbe06dc0877fb4d8d01cb8e636804722ce2
This commit is contained in:
Colin Cross 2021-04-29 03:00:25 +00:00 committed by Automerger Merge Worker
commit 92f64550cd

View file

@ -2081,6 +2081,11 @@ func parallelVisit(modules []*moduleInfo, order visitOrderer, limit int,
// modules to the modules that would have been unblocked when that module finished, i.e
// the reverse of the visitOrderer.
// In order to reduce duplicated work, once a module has been checked and determined
// not to be part of a cycle add it and everything that depends on it to the checked
// map.
checked := make(map[*moduleInfo]struct{})
var check func(module, end *moduleInfo) []*moduleInfo
check = func(module, end *moduleInfo) []*moduleInfo {
if module.waitingCount == -1 {
@ -2092,6 +2097,10 @@ func parallelVisit(modules []*moduleInfo, order visitOrderer, limit int,
return []*moduleInfo{module}
}
if _, alreadyChecked := checked[module]; alreadyChecked {
return nil
}
for _, dep := range order.propagate(module) {
cycle := check(dep, end)
if cycle != nil {
@ -2105,6 +2114,7 @@ func parallelVisit(modules []*moduleInfo, order visitOrderer, limit int,
}
}
checked[module] = struct{}{}
return nil
}