Skip to content

Reduce refresh CPU and memory use - #33

Merged
thrr87 merged 6 commits into
mainfrom
codex/reduce-refresh-cost
Jul 30, 2026
Merged

Reduce refresh CPU and memory use#33
thrr87 merged 6 commits into
mainfrom
codex/reduce-refresh-cost

Conversation

@thrr87

@thrr87 thrr87 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Tail rollout and fact files in bounded chunks. An idle refresh reads no old bytes, and a small append only handles the new records.
  • Reuse stable local aggregates and indexes. Release old fact buffers after durable storage, and load receipt detail only when the user opens one task tree.
  • Run usage evaluation away from MainActor. Publish only the newest result, including restored state at launch.
  • Bound Codex RPC lines and large local reads. Handle timeout races, invalid dates, and integer overflow without terminating the app.
  • Cap chart work and reduce needless sync writes without changing analytics meaning or history retention.

Validation

  • Swift tests: 495 passed
  • Codex client tests with Thread Sanitizer: 43 passed
  • Release build: passed
  • Full-screen QA: launch, Graphs, Facts, Insights, and repeated manual refresh passed

Representative local measurements:

  • persisted restore: 20,019 facts, at most 423 ms per bounded refresh, about 18 MB resident growth
  • 1,000 idle refreshes: 82.8 ms total, 0 bytes and 0 records reread, 0 resident growth
  • one-record append: 0.287 ms
  • stable evaluation over 100,000 facts: 0.182 ms
  • 50,000 timestamp parses: 48.8 ms

On the same large local profile, memory grew on each refresh before the retained-buffer fix: 355.4 MB → 480.3 MB → 614.0 MB. After the fix, it settled at 296.8 MB → 472.6 MB → 462.6 MB. A final fresh-build QA run also fell from 641.5 MB to 592.3 MB after another refresh instead of growing again.

Notes

  • Large local histories can still raise the process high-water mark while open. Repeated refreshes no longer retain another full fact buffer.
  • Controlled source gaps lower coverage or return a clear error. They do not delete analytics history or change its meaning.

Closes #35

thrr87 and others added 2 commits July 29, 2026 16:17
thrr87 added 3 commits July 29, 2026 18:11
…imits into codex/reduce-refresh-cost

# Conflicts:
#	Sources/CodexLimits/LocalActivityCollector.swift
#	Tests/CodexLimitsTests/LocalActivityPerformanceTests.swift
* perf: load local analytics on demand

* Use App Server account data for the lightweight core (#42)

* perf: use account data for lightweight analytics core

* chore: prepare v0.2.4

---------

Co-authored-by: thrr87 <193831865+thrr87@users.noreply.github.com>

---------

Co-authored-by: thrr87 <193831865+thrr87@users.noreply.github.com>
@thrr87
thrr87 merged commit e6e7d7a into main Jul 30, 2026
4 checks passed
@thrr87
thrr87 deleted the codex/reduce-refresh-cost branch July 30, 2026 20:09
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.

Bound refresh memory and prevent data-driven crashes

1 participant