perf(azure compute): add vCPU + MemoryGB to ComputeDetails and wire batched SKU catalogue · Issue #148 · LeanerCloud/cloud-commitments-cli · GitHub
Skip to content

perf(azure compute): add vCPU + MemoryGB to ComputeDetails and wire batched SKU catalogue #148

Closed

Description

@cristim

Summary

Follow-up to PR #81 (perf(azure): batched SKU catalogue lookup eliminates N+1 in recommendation converters), which closed #49 for cache / cosmosdb / database but explicitly scoped back compute.

The two enrichments the SKU catalogue would supply for compute are vCPU and MemoryGB, sourced from armcompute.ResourceSKUsClient.ListByLocation(region) → ResourceSKU.Capabilities. Neither has a field on common.ComputeDetails (pkg/common/types.go) to write into — the struct currently exposes only InstanceType, Platform, Tenancy, Scope. Adding new fields touches every cloud provider (AWS, Azure, GCP) + every consumer (frontend rendering, common matchers, snapshot/golden tests), which is well outside the scope of an Azure perf change.

Current behaviour

providers/azure/services/compute/client.go::convertAzureVMRecommendation (line ~703) builds common.ComputeDetails{InstanceType: f.ResourceType} only. The function godoc (post-#81) explicitly explains the scope decision and points back here.

Expected behaviour

Full ComputeDetails population: vCPU, MemoryGB, plus the existing InstanceType / Platform / Tenancy / Scope. UI tables render the actual instance shape instead of just the SKU name.

Proposed fix

Three-step refactor, ideally as separate atomic commits in a single PR:

  1. Extend common.ComputeDetails: add VCPU int + MemoryGB float64. JSON tags consistent with existing fields. Update Go-side consumers (matchers, frontend type bindings via pkg/common → frontend types.ts).
  2. Update AWS + GCP converters: populate the new fields where the SDK already exposes them (AWS DescribeInstanceTypes, GCP MachineType).
  3. Wire Azure: port the same lazy cachedSKULookup pattern from cache/cosmos/database into compute/client.go, hitting armcompute.ResourceSKUsClient.NewListPager(region) once per client lifetime, mapping ResourceSKU.Name → {VCPU, MemoryGB}. Converter reads from the cache and falls back to zero on miss.

Test plan

  • Per-converter unit tests for AWS/Azure/GCP: SKU catalogue / instance-type cache returns known {vCPU, memoryGB} → assert Details.VCPU and Details.MemoryGB are populated. Catalogue fetch error → fields stay 0, conversion succeeds.
  • Pin the perf invariant in Azure: _CachedSKULookup_FetchedOnce analogue, multiple converter calls hit the catalogue once.
  • Snapshot/golden-test updates for any frontend rendering that exposes the new fields.

References

Severity

Medium — UI degrades to "unknown" for vCPU/memory on Azure compute recs (and presumably AWS/GCP if they also leave the field empty pending the type extension).

Effort

Medium — type extension is mechanical but cross-cutting (3 providers, frontend, matchers, snapshot tests). Wiring the Azure SKU cache itself is ~30 LOC mirroring cache/cosmos/database.

Activity

  1. cristim commented on Apr 28, 2026

    @cristim
    MemberAuthor

    P2: cross-cutting type extension required before Azure (and potentially AWS/GCP) compute recommendations can show vCPU/MemoryGB in the UI. Touches 3 providers + frontend types + snapshot tests — M effort. The Azure SKU catalogue pattern is already established by PR #81 for cache/cosmos/database; compute wiring mirrors that pattern. (triage agent wave1-C)

  2. cristim commented on Apr 30, 2026

    @cristim
    MemberAuthor

    Verification (post-merge of #81)

    Confirming this issue is partially addressed — recommend keep open as scoped follow-up.

    What I checked on feat/multicloud-web-frontend

    Step 1 — Extend common.ComputeDetails: DONE.
    pkg/common/types.go now has both fields:

    type ComputeDetails struct {
        InstanceType string  `json:"instance_type"`
        Platform     string  `json:"platform"`
        Tenancy      string  `json:"tenancy"`
        Scope        string  `json:"scope"`
        VCPU         int     `json:"vcpu,omitempty"`      // 0 = unknown
        MemoryGB     float64 `json:"memory_gb,omitempty"` // 0 = unknown
    }

    GetDetailDescription already renders the size suffix when both fields are populated.

    Step 3 — Wire Azure batched SKU catalogue: NOT DONE.
    providers/azure/services/compute/client.go::convertAzureVMRecommendation (line ~707) still builds:

    Details: common.ComputeDetails{
        InstanceType: f.ResourceType,
    },

    No cachedSKULookup from armcompute.ResourceSKUsClient. The N+1-eliminator pattern from cache/cosmos/database has not been mirrored into compute.

    Step 2 — AWS/GCP populate the new fields: not separately verified in this pass.

    Verdict

    Type extension landed; the Azure wiring (the perf payoff) and the test plan (_PopulatesVCPUMemoryFromSKUCache, _CachedSKULookup_FetchedOnce for compute) remain. Recommend keep open with the title narrowed to "wire batched SKU catalogue + populate VCPU/MemoryGB on Azure compute" since the type-extension half is done.

  3. added a commit that references this issue on May 3, 2026
    c05c0d1
  4. cristim commented on May 13, 2026

    @cristim
    MemberAuthor

    Verified resolved by PR #229.

    Recommending closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions