Skip to content

Commit

Permalink
perf: Remove Available() call inside of filterInstanceTypesByRequir…
Browse files Browse the repository at this point in the history
…ements (#1947)
  • Loading branch information
jonathan-innis authored Jan 31, 2025
1 parent 1e21a7d commit af994ba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/controllers/provisioning/scheduling/nodeclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,16 @@ func filterInstanceTypesByRequirements(instanceTypes []*cloudprovider.InstanceTy
// about why scheduling failed
itCompat := compatible(it, requirements)
itFits := fits(it, requests)
itHasOffering := it.Offerings.Available().HasCompatible(requirements)

// By using this iterative approach vs. the Available() function it prevents allocations
// which have to be garbage collected and slow down Karpenter's scheduling algorithm
itHasOffering := false
for _, of := range it.Offerings {
if of.Available && requirements.IsCompatible(of.Requirements, scheduling.AllowUndefinedWellKnownLabels) {
itHasOffering = true
break
}
}

// track if any single instance type met a single criteria
results.requirementsMet = results.requirementsMet || itCompat
Expand Down

0 comments on commit af994ba

Please sign in to comment.