Merge "Parallelize VerifyProvidersWereUnchanged" into main am: 177fd07327
am: 0e7baaa021
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3102364 Change-Id: I2802de3f9cdd3aaca2929193262960d7c862d4ff Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
46abec2ab1
1 changed files with 43 additions and 16 deletions
59
context.go
59
context.go
|
@ -4144,23 +4144,50 @@ func (c *Context) VerifyProvidersWereUnchanged() []error {
|
||||||
if !c.buildActionsReady {
|
if !c.buildActionsReady {
|
||||||
return []error{ErrBuildActionsNotReady}
|
return []error{ErrBuildActionsNotReady}
|
||||||
}
|
}
|
||||||
var errors []error
|
toProcess := make(chan *moduleInfo)
|
||||||
for _, m := range c.modulesSorted {
|
errorCh := make(chan []error)
|
||||||
for i, provider := range m.providers {
|
var wg sync.WaitGroup
|
||||||
if provider != nil {
|
go func() {
|
||||||
hash, err := proptools.HashProvider(provider)
|
for _, m := range c.modulesSorted {
|
||||||
if err != nil {
|
toProcess <- m
|
||||||
errors = append(errors, fmt.Errorf("provider %q on module %q was modified after being set, and no longer hashable afterwards: %s", providerRegistry[i].typ, m.Name(), err.Error()))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if provider != nil && m.providerInitialValueHashes[i] != hash {
|
|
||||||
errors = append(errors, fmt.Errorf("provider %q on module %q was modified after being set", providerRegistry[i].typ, m.Name()))
|
|
||||||
}
|
|
||||||
} else if m.providerInitialValueHashes[i] != 0 {
|
|
||||||
// This should be unreachable, because in setProvider we check if the provider has already been set.
|
|
||||||
errors = append(errors, fmt.Errorf("provider %q on module %q was unset somehow, this is an internal error", providerRegistry[i].typ, m.Name()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
close(toProcess)
|
||||||
|
}()
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
var errors []error
|
||||||
|
for m := range toProcess {
|
||||||
|
for i, provider := range m.providers {
|
||||||
|
if provider != nil {
|
||||||
|
hash, err := proptools.HashProvider(provider)
|
||||||
|
if err != nil {
|
||||||
|
errors = append(errors, fmt.Errorf("provider %q on module %q was modified after being set, and no longer hashable afterwards: %s", providerRegistry[i].typ, m.Name(), err.Error()))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if m.providerInitialValueHashes[i] != hash {
|
||||||
|
errors = append(errors, fmt.Errorf("provider %q on module %q was modified after being set", providerRegistry[i].typ, m.Name()))
|
||||||
|
}
|
||||||
|
} else if m.providerInitialValueHashes[i] != 0 {
|
||||||
|
// This should be unreachable, because in setProvider we check if the provider has already been set.
|
||||||
|
errors = append(errors, fmt.Errorf("provider %q on module %q was unset somehow, this is an internal error", providerRegistry[i].typ, m.Name()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors != nil {
|
||||||
|
errorCh <- errors
|
||||||
|
}
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
wg.Wait()
|
||||||
|
close(errorCh)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var errors []error
|
||||||
|
for newErrors := range errorCh {
|
||||||
|
errors = append(errors, newErrors...)
|
||||||
}
|
}
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue