[codex] Debounce usage API cache writes#503
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 353e347d23
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the Codex review feedback in the latest push:
Verified locally with:
|
|
Follow-up after another pass over the debounce change:
Verified locally:
@codex review |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
robinebers
left a comment
There was a problem hiding this comment.
Hey! 👋 This is Rob's AI reviewer. Thanks for the PR!
The concurrency design here is solid — the "one worker thread + write serializer lock + dirty/flushed generation counter" handoff is correct, the exit hook covers both ExitRequested and Exit, and the failed-write retry logic (keeping flushed_generation un-bumped) is the right call. Tests are well-scoped and use #[serial]. One thing to fix before merge:
-
The retry loop has no backoff or log throttling. If a write fails permanently (disk full,
app_data_dirremoved mid-run, permissions broken), the worker will spin every 500ms forever and emit alog::warn!on every iteration — that's ~120 warn lines per minute, indefinitely. Worth either:- exponential backoff on consecutive failures (e.g. 500ms → 1s → 2s → cap at 30s), and/or
- log only on transitions (first failure, then every Nth, then on recovery)
Even something simple like a consecutive-failure counter that throttles the log would be enough.
Everything else (the exit-flush wiring, the generation counter semantics, test coverage including the failed-write retry test) looks good.
|
Addressed the requested retry-loop fix in the latest push:
Verified locally with:
Note: full cargo fmt --check still reports pre-existing formatting drift in unrelated files: config.rs, local_http_api/server.rs, webkit_config.rs. I only checked the touched Rust file to avoid unrelated churn. |
|
Follow-up: updated the branch with current origin/main using a normal merge commit, no force-push. Re-verified after the merge:
The Vite Node 22.0.0 warning is still present, but the build exits successfully. |
robinebers
left a comment
There was a problem hiding this comment.
Backoff + log throttling addressed cleanly. Tests cover the helpers and the retry path. LGTM.
Summary
Part of #487.
This PR coalesces
usage-api-cache.jsonpersistence so a burst of successful probe results does not rewrite the full cache file once per provider result.Changes:
ExitRequested/Exit);This is based on current
main. It is independent from #498/#499/#500/#501/#502 and can merge separately after review.Verification
cargo test local_http_api::cache::testscargo test --lib -- --skip ccusage_timeout_kills_descendant_and_closes_pipesbun run buildgit diff --checkNote: the skipped Rust test is the existing unrelated flaky
ccusage_timeout_kills_descendant_and_closes_pipes, handled separately in #501.Part of #487.