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
31
context.go
31
context.go
|
@ -4144,8 +4144,20 @@ func (c *Context) VerifyProvidersWereUnchanged() []error {
|
||||||
if !c.buildActionsReady {
|
if !c.buildActionsReady {
|
||||||
return []error{ErrBuildActionsNotReady}
|
return []error{ErrBuildActionsNotReady}
|
||||||
}
|
}
|
||||||
var errors []error
|
toProcess := make(chan *moduleInfo)
|
||||||
|
errorCh := make(chan []error)
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
go func() {
|
||||||
for _, m := range c.modulesSorted {
|
for _, m := range c.modulesSorted {
|
||||||
|
toProcess <- m
|
||||||
|
}
|
||||||
|
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 {
|
for i, provider := range m.providers {
|
||||||
if provider != nil {
|
if provider != nil {
|
||||||
hash, err := proptools.HashProvider(provider)
|
hash, err := proptools.HashProvider(provider)
|
||||||
|
@ -4153,7 +4165,7 @@ func (c *Context) VerifyProvidersWereUnchanged() []error {
|
||||||
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()))
|
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
|
continue
|
||||||
}
|
}
|
||||||
if provider != nil && m.providerInitialValueHashes[i] != hash {
|
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()))
|
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 {
|
} else if m.providerInitialValueHashes[i] != 0 {
|
||||||
|
@ -4162,6 +4174,21 @@ func (c *Context) VerifyProvidersWereUnchanged() []error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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