Skip to content

Port upstream 0.55.0: optimize OpenCodex pricing - #380

Open
Finesssee wants to merge 1 commit into
mainfrom
port/055-opencodex-price-once
Open

Port upstream 0.55.0: optimize OpenCodex pricing#380
Finesssee wants to merge 1 commit into
mainfrom
port/055-opencodex-price-once

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Upstream evidence

Validation

  • cargo test -p codexbar opencodex --no-fail-fast -> 6 passed
  • focused rustfmt on touched Rust files
  • git diff --check -> pass

Scope

Isolated OpenCodex spend performance port. No provider-auth, UI, or version bump changes.

@Finesssee

Finesssee commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Thermo-nuclear review

Finding (structural/performance blocker): pricing_snapshot() deep-clones the entire models.dev catalog. ModelsDevCache::load() already returns an Arc<ModelsDevCacheArtifact>, but the new snapshot immediately does artifact.catalog.clone(), copying the full provider/model HashMap tree once per aggregate. That replaces repeated metadata checks with a potentially large ownership copy.

The code-judo version is to let ModelsDevPricingSnapshot retain shared immutable ownership, e.g. an Arc<ModelsDevCacheArtifact> or Arc<ModelsDevCatalog>, and perform lookups through it. That keeps the bulk-pricing context genuinely cheap and avoids widening a central pricing boundary around copied state.

Verdict: NOT APPROVED.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant