Skip to content

Commit

Permalink
Reduce parallelism to 1/1 in all cases (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko authored Jan 5, 2022
1 parent 70a0c0e commit 07a4962
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions internal/terraform/module/module_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package module
import (
"context"
"log"
"runtime"
"sync/atomic"
"time"

Expand All @@ -30,13 +29,12 @@ type moduleLoader struct {
}

func newModuleLoader(fs filesystem.Filesystem, modStore *state.ModuleStore, schemaStore *state.ProviderSchemaStore) *moduleLoader {
p := loaderParallelism(runtime.NumCPU())
plc, lc := int64(0), int64(0)
ml := &moduleLoader{
queue: newModuleOpsQueue(fs),
logger: defaultLogger,
nonPrioParallelism: p.NonPriority,
prioParallelism: p.Priority,
nonPrioParallelism: 1,
prioParallelism: 1,
opsToDispatch: make(chan ModuleOperation, 1),
loadingCount: &lc,
prioLoadingCount: &plc,
Expand All @@ -48,31 +46,6 @@ func newModuleLoader(fs filesystem.Filesystem, modStore *state.ModuleStore, sche
return ml
}

type parallelism struct {
NonPriority, Priority int64
}

func loaderParallelism(cpu int) parallelism {
// Cap utilization for powerful machines
if cpu >= 4 {
return parallelism{
NonPriority: int64(3),
Priority: int64(1),
}
}
if cpu == 3 {
return parallelism{
NonPriority: int64(2),
Priority: int64(1),
}
}

return parallelism{
NonPriority: 1,
Priority: 1,
}
}

func (ml *moduleLoader) SetLogger(logger *log.Logger) {
ml.logger = logger
}
Expand Down

0 comments on commit 07a4962

Please sign in to comment.