-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Optimize Codex cost refresh policy for large history windows #1392
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Context
While investigating local CodexBar menu/CPU lag, I found a narrower cost-history refresh problem that may be contributing to the broader menu performance reports in #1321, #1360, and #1371.
Local setup/signal:
~/.codex/sessionsaggregate shape: ~13 GB across ~403 JSONL filessamplecaptured during a high-CPU spike pointed at the background cost path, not the main menu drawing path:UsageStore.refreshTokenUsageCostUsageFetcher.loadTokenSnapshotCostUsageScanner.loadCodexDailyCostUsageScanner.scanCodexFileCostUsageJsonl.scanThis is related to #1016, but I think the shape is different enough to ask separately. #1016 was about raw JSONL scanner throughput / possible Swift vs Rust/SIMD optimization, and was closed as not worth pursuing without a real bottleneck. This issue is not proposing a scanner rewrite. It is about refresh policy for large history windows.
Proposal
For large windows such as 365 days, make the steady-state refresh cheaper by separating:
Possible behavior:
This would keep 365-day history useful without making every normal refresh scale like a large history rebuild.
Questions
Intended PR scope if accepted
The goal would be a conservative performance fix that preserves correctness and is easy to review.
Suggested labels, if maintainers agree:
enhancement,priority:medium,area:performance,area:usage-accuracy,provider:codex,needs-design.