perf: optimize menu population and usage formatting#1290
Conversation
- Cache parsed JWTs in UsageFetcher - Optimize SwiftUI layout in InlineUsageDashboardContent (Grid over LazyVGrid) - Cache expensive formatters and regexes in UsageFormatter and MenuDescriptor - Cache measured menu width in StatusItemController to avoid redundant layout passes - Increase Codex account reconciliation cache interval to 30s
|
Codex review: needs real behavior proof before merge. Reviewed June 3, 2026, 10:20 AM ET / 14:20 UTC. Summary Reproducibility: yes. for the blocking PR defect by source inspection: the new macOS Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the performance direction, but use a non-recursive or separate formatter synchronization path, avoid retaining raw JWTs, prove the account freshness tradeoff, and attach real before/after runtime proof. Do we have a high-confidence way to reproduce the issue? Yes for the blocking PR defect by source inspection: the new macOS Is this the best way to solve the issue? No. Caching formatters and menu measurements may be a good direction, but this implementation needs safer synchronization, non-sensitive JWT cache keys or no token cache, account freshness proof, and real behavior evidence. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 3387cc8b2d47. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae99b8763e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| self.localizationLock.lock() | ||
| let rel = self.relativeFormatter | ||
| rel.locale = self.currentLocale() | ||
| rel.unitsStyle = .abbreviated | ||
| return self.localized("Updated %@", rel.localizedString(for: date, relativeTo: now)) | ||
| let result = self.localized("Updated %@", rel.localizedString(for: date, relativeTo: now)) |
There was a problem hiding this comment.
Stop re-entering localizationLock in updatedString
For macOS timestamps between 1 minute and 24 hours old, this path now locks localizationLock and then calls both currentLocale() and localized(...), which each try to acquire the same non-recursive NSLock. That self-deadlocks on the first recent “Updated …” label, so menu/status refreshes that format a fresh usage timestamp can hang instead of populating the menu.
Useful? React with 👍 / 👎.
Performance Verification ProofI have verified these optimizations on a live system with many providers enabled. Before Optimizations:
After Optimizations:
Functional correctness verified via microbenchmarks (27x faster JWT parsing, 12x faster formatting). |
This PR addresses performance bottlenecks in menu population:
These changes significantly reduce Main Thread churn during background updates and menu interaction.