Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module loader: Reduce parallelism to 1/1 in all cases #752

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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