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

perf: ⚡️ concourse worker cpu is spiking too high #645

Merged
merged 1 commit into from
Oct 18, 2024
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
8 changes: 5 additions & 3 deletions pkg/environment/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (a *Apply) applyNamespaceDirs(chunkFolder []string) error {

chunkStream := util.Generator(done, chunkFolder...)

routineResults := a.parallelApplyNamespace(done, chunkStream)
routineResults := a.parallelApplyNamespace(done, chunkStream, 6) // goroutines are very lightweight and can number in millions, but the tasks we are doing are very heavy so we need to limit this as much as possible

results := util.FanIn(done, routineResults...)

Expand All @@ -206,8 +206,10 @@ func (a *Apply) applyNamespaceDirs(chunkFolder []string) error {
return nil
}

func (a *Apply) parallelApplyNamespace(done <-chan bool, dirStream <-chan string) []<-chan string {
numRoutines := runtime.NumCPU()
func (a *Apply) parallelApplyNamespace(done <-chan bool, dirStream <-chan string, numRoutines int) []<-chan string {
if a.Options.IsApplyPipeline {
runtime.GOMAXPROCS(3) // this is based on https://github.com/ministryofjustice/cloud-platform-infrastructure/blob/ebafd84ba45a18deeb113d1b57f565141368c187/terraform/aws-accounts/cloud-platform-aws/vpc/eks/cluster.tf#L46C1-L46C58 current max cpu is 4 (for workloads running in concourse)
}

routineResults := make([]<-chan string, numRoutines)

Expand Down
Loading