CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Cache cost usage date parsers

Open ProspectOre opened this issue 5 months ago โ€ข 4 comments

Summary

  • cache CostUsageDateParser ISO8601DateFormatter and DateFormatter instances per thread
  • preserve current time zone behavior by including the current time zone identifier in DateFormatter cache keys
  • add coverage for selecting the newest monthly cost row across supported month formats

Why

Cost usage selection can parse many date strings while building current-day, current-session, and most-recent-month snapshots. The previous path rebuilt multiple Foundation formatters for each parse attempt, which is expensive in hot refresh paths.

Proof

Local validation, June 16, 2026 PT:

  • .build/lint-tools/bin/swiftformat Sources Tests --lint
    • 0/1139 files require formatting
  • .build/lint-tools/bin/swiftlint --strict
    • Found 0 violations, 0 serious in 1138 files
  • swift test --filter CostUsageDecodingTests
    • 17 tests in 1 suite passed after 0.009 seconds
  • swift build --build-tests
    • Build complete! (1.29 sec)
  • git diff --check
    • passed with no output

Benchmark harness was temporary and is not committed. Both runs used the same guard-based benchmark test and swift test --skip-build --filter CostUsageDateParserBenchmarkTests for the timed pass.

Metric Before After Change
parse 80k date strings 15.027595s 3.796186s 4.0x faster
parseMonth 60k month strings 4.345667s 1.334223s 3.3x faster
test body wall 19.373s 5.131s 3.8x faster
command real time 20.70s 8.41s 2.5x faster
max RSS 107,757,568 bytes 99,926,016 bytes 7.3% lower
peak memory footprint 29,098,704 bytes 27,919,056 bytes 4.1% lower
checksum date 162000000 / month 720000 date 162000000 / month 720000 unchanged

Risk

Low. The change keeps the same parse order and supported formats, with thread-local formatter reuse to avoid sharing mutable Foundation formatters across threads. The time zone identifier stays part of the DateFormatter cache key so a runtime time zone change can create a fresh cached formatter.

ProspectOre avatar Jun 16 '26 07:06 ProspectOre

@clawsweeper re-review

ProspectOre avatar Jun 16 '26 09:06 ProspectOre

๐Ÿฆž๐Ÿงน ClawSweeper re-review requested.

I asked ClawSweeper to review this item again. Action: item re-review queued (workflow sweep.yml, event repository_dispatch). Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

  • State: Complete
  • Detail: The targeted re-review finished, the durable review comment was updated, and the synced verdict was routed.
  • Run: https://github.com/openclaw/clawsweeper/actions/runs/27635548285
  • Updated: 2026-06-16T17:44:27.806Z

clawsweeper[bot] avatar Jun 16 '26 09:06 clawsweeper[bot]

@clawsweeper re-review

ProspectOre avatar Jun 16 '26 17:06 ProspectOre

ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 18, 2026, 7:32 PM ET / 23:32 UTC.

Summary Review failed before ClawSweeper could summarize the requested change.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness Not assessed. Failure reason: timeout.

This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Keep any merge decision on the normal maintainer review path until ClawSweeper can complete a fresh review.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against f2f9d8bc50bf.

Label changes

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove status: ๐Ÿ‘€ ready for maintainer look: Current PR status no longer selects a status label.
  • remove P3: Current review triage priority is none.
  • remove rating: ๐Ÿš platinum hermit: Current review failed before PR readiness was assessed, so no rating label should remain.
Evidence reviewed

What I checked:

  • failure reason: timeout.
  • codex failure detail: Codex review failed for this PR: Codex process timed out after 1199999ms.
  • codex stderr: No stderr captured.
  • codex stdout: ot start repair, autofix, rebase, CI repair, or automerge.\n- Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.\n- Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.\n\n
\n\n","createdAt":"2026-06-10T14:48:21Z","includesCreatedEdit":true,"isMinimized":false,"minimizedReason":"","reactionGroups":[],"url":"https://github.com/steipete/CodexBar/issues/1392#issuecomment-4671490901","viewerDidAuthor":true},{"id":"IC_kwDOQW2AGs8AAAABFnZx8Q","author":{"login":"TheAngryPit"},"authorAssociation":"NONE","body":"Thanks, this is helpful. I re-checked this against current upstream/main (a6bb6772) and agree my original proposal was too broad: the scann.
  • process error code: ETIMEDOUT.
  • Likely related people:

    • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    clawsweeper[bot] avatar Jun 16 '26 17:06 clawsweeper[bot]

    Landed as 518764ead945d2aa3c899bd89ed038766afe9d4f.

    Exact-head proof for c29f4e5b0da93f3a0d7a973320e0fdcb4bea8ac0:

    • 19 cost-usage decoding tests and 13 cookie-deadline tests passed locally.
    • 32 concurrent workers completed 56,000 mixed-format parses; direct benchmark improved from 2.42s uncached to 0.59s cached.
    • Exact CI shard 3/4 passed all 120 groups locally.
    • make check and full-branch autoreview passed.
    • GitHub CI passed four macOS shards, lint/aggregate, Linux x64/arm64, and security.

    steipete avatar Jun 19 '26 00:06 steipete