Repository navigation
fix(task): size with one region-wide price table, not a Price List call per candidate - #1236
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ll per candidate (#1181) Sizing priced each of the ~1325 matching types with its own GetProducts request (149-256 s before RunInstances in E1). Fetch the region's On-Demand table once via a new pkg/pricelist (ceil(types/100) pages, independent of the spec), fall back to the static table by exact match with a labelled note, and report the timing breakdown under -v. Fixes #1181
scttfrdmn
force-pushed
the
fix/1181-sizing-pricing-calls
branch
from
October 20, 2026 18:40
8205c55 to
9510471
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1181
What was slow
truffleFinder.FindCandidates(cmd/task.go) calledtruffleaws.Client.OnDemandPriceonce for every match, serially. Each call is one Price ListGetProductsrequest filtered byinstanceType. Acpu: 2spec matches 1325 types in us-east-1, so that was 1325 requests, each retried up to 8 times when throttled (truffle#175). E1 measured 149-256 s before RunInstances; the instance search itself is a few paginated DescribeInstanceTypes calls (the pinned case took 4-5 s in total).Fix
pkg/pricelist:RegionOnDemandPricesruns one paginatedGetProductsquery per region. It uses truffle'sonDemandFiltersminusinstanceType, withMaxResults=100, a 40-page cap, and the same 8-attempt retryer and us-east-1 endpoint as truffle. That costs ceil(types in region / 100) requests, which does not depend on what the spec matched. It lives in pkg/ becauseTestNoNewAWSSDKImportsInCmdforbids new SDK imports in cmd/.fallbackPriceruses. If the live fetch fails, there is no per-candidate retry storm: one failed request, then static prices.PricesAsOfdate. Before, this was silent.-vprintssizing: instance search Xs (N candidates), pricing Ys (K Price List request(s)).The real home for this is truffle. I filed spore-host/truffle#262 with the measurements; once it lands, spawn should drop
pkg/pricelist.Gate
TestSizingMakesAConstantNumberOfPricingCallsrunsrenderTaskDryRunon acpu: 2spec, with 1325 synthetic candidates and a recordingGetProductsfake that counts every request and honours theregionCode/instanceTypefilters. It asserts:instanceType;TestSizingFallsBackToTheStaticTableAndSaysSoasserts one call when the Price List fails, exact static prices, and a labelled note.I watched both fail against two reverts that compile:
GetProductswith aninstanceTypefilter (the old design): 1325 per-type requests, 106 calls on the failure path.breakdropped): 18,550 requests, with 140 vs 18,550 for the two candidate counts.Checks
make check: all tests pass.check-build-tagsfails on /private/tmp paths, and it fails the same way on unmodified main.make lint: 0 issues.semgrep --config=auto --error: 0 findings.make check-docs: clean.Not verified
No AWS calls were made. I have not measured the real page count or latency of a region-only
GetProductsquery against the live Price List, nor checked that its rates equal the per-type rates. The filters are identical apart frominstanceType, so they should, but a single live dry run would confirm it.