Optimize per fleet offers #3316
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #3303
This PR optimizes getting offers for multiple/all fleets when selecting optimal fleet for the run in
get_run_plan()and during provisioning. It changescompute.get_offers()signature and implementations to returnIteratorinstead oflist. This allows callers to take offers with a limit. A low limit (100) is used when selecting the optimal fleet. For configured backends with ~11k cached offers (aws+gcp) and 10 fleets, this reduces peak memory from 1.3GB to 0.5GB, and time of getting offers from 15-20s to 1.5-2s, essentially eliminating linear growth with the number of fleets.The offers returned are the same. The only downside is that the optimal offers may not be in the first 100 offers in case many offers are not available, and a different fleet will be chosen as optimal.