Repository navigation
fix(sizer): on a price tie prefer the smallest type that fits (#610) - #611
Merged
Merged
Conversation
Size() ranked by price and then tie-broke on the instance-type NAME, which is lexicographic and therefore semantically arbitrary. On hpc7g — where every size costs the same because you rent the socket rather than the cores — 'hpc7g.16xlarge' sorts before 'hpc7g.4xlarge' because '1' < '4', so a 16-vCPU request was sized to a 64-vCPU instance. Note this was NOT a bias toward the largest: on a 2x/4x/8xlarge family the same comparison picks the smallest and looks correct, which is why it survived. Tie-break is now vCPUs, then memory, then name (name retained last purely for determinism). Every candidate already satisfies the request, so the smallest is what the spec asked for and it minimises blast radius; on a family with genuinely equal-priced sizes the old behaviour over-provisioned at cost. Also documents resources.instance_type in 'task run --help': it has pinned an exact type since #413 (short-circuiting candidate search and pricing) but was described only in internal design docs, so the reporter concluded there was no way to sweep three equal-spec hpc7g sizes. The regression test uses hpc7g deliberately — a 2x/4x/8xlarge fixture would pass under the old code too, making such a test vacuous — and was verified to fail against the previous comparator before the fix landed. Fixes #610
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Fixes #610: a TaskSpec asking for 16 vCPUs in the
hpc7gfamily was sized tohpc7g.16xlarge(64 vCPUs). Two changes — the tie-break, and documenting the escape hatch that already existed.Root cause — not "prefers the largest", but lexicographic
taskproto.Sizeranked by on-demand price and then tie-broke on the instance-type name:hpc7g.16xlargewon because'1' < '4'. Onhpc7gevery size is the same price (you rent the socket, not the cores), so the tie was reached legitimately and then resolved by a string comparison that has nothing to do with size.Crucially this was not a bias toward the largest: on a family sized
2x/4x/8xlarge, the same comparison picks the smallest and looks entirely correct. That's why it survived — and it's why the regression test has to use a1-prefixed double-digit size or it proves nothing.The fix
Tie-break on vCPUs, then memory, then name (name kept last purely for determinism). Every candidate already satisfies the request, so on an equal rate the smallest is what the spec asked for and it minimises blast radius. On
hpc7gthe bill was unchanged, but the same tie-break would over-provision at cost on any family with genuinely equal-priced sizes.resources.instance_typealready existed — the real gap was documentationThe issue's second ask ("allow a spec to pin an exact instance type") has been implemented since #413:
Size()honoursresources.instance_typeas its first action, short-circuiting candidate search and pricing entirely. But it was documented only indocs/pooled-task-execution-design.mdanddocs/workflow-adapter-protocol-rfc.md— nothing user-facing, notdocs-gen/task.md, not--help. The reporter needed exactly this (sweeping three equal-spechpc7gsizes, whichcpu/memory_gibcannot distinguish) and reasonably concluded it didn't exist.task run --helpnow documents the pin, the price-tie rule, and howresources.familiesdiffers from pinning. A capability described only in an internal design note is, in practice, missing.Tests
TestSize_PriceTiePrefersSmallest— thehpc7gcase; verified to fail against the previous comparator (tie went to "hpc7g.16xlarge"/VCPUs = 64, want 16) and pass after. It also asserts its own fixture still contains a1-prefixed double-digit size, so it can't silently become vacuous.TestSize_PriceTiePrefersLessMemoryWhenVCPUsEqual— the second rung.TestSize_PriceTieFallsBackToNameWhenSameSize— equal price and size stays deterministic across repeated runs.gofmt/go vet ./.../go build ./...clean;make gen-docsrun anddocs-gen/task.mdcommitted.Expected release sizing: PATCH (behaviour fix + docs; no API change).
Fixes #610